Skip to content

Commit

Permalink
Attach Widget Focus UI prefs to settings store [deploy]
Browse files Browse the repository at this point in the history
  • Loading branch information
dougmassay committed Apr 11, 2024
1 parent 4efdc7a commit 51dcfdf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/************************************************************************
**
** Copyright (C) 2016-2021 Kevin B. Hendricks, Stratford, ON
** Copyright (C) 2016-2020 Doug Massay
** Copyright (C) 2016-2024 Doug Massay
** Copyright (C) 2011-2013 John Schember <[email protected]>
** Copyright (C) 2012-2013 Grant Drake
**
Expand Down Expand Up @@ -145,6 +145,7 @@ PreferencesWidget::ResultActions AppearanceWidget::saveSettings()
settings.setAppearancePrefsTabIndex(ui.tabAppearance->currentIndex());
settings.setShowFullPathOn(ui.ShowFullPath->isChecked() ? 1 : 0);
settings.setPreviewDark(ui.PreviewDarkInDM->isChecked() ? 1 : 0);
settings.setUIHighlightFocusWidget(ui.chkFocusDec->isChecked() ? 1 : 0);
// handle icon theme
QString icon_theme = "main";
if (ui.Fluent->isChecked()) {
Expand Down Expand Up @@ -262,6 +263,10 @@ PreferencesWidget::ResultActions AppearanceWidget::saveSettings()
if ((m_currentUIFont != m_initUIFont) || m_uiFontResetFlag) {
results = results | PreferencesWidget::ResultAction_RestartSigil;
}
// if show widget focus highlight pref changed, set need for restart
if (m_ShowWidgetFocus != (ui.chkFocusDec->isChecked() ? 1 : 0)) {
results = results | PreferencesWidget::ResultAction_RestartSigil;
}
m_uiFontResetFlag = false;
results = results & PreferencesWidget::ResultAction_Mask;
return results;
Expand All @@ -273,6 +278,8 @@ SettingsStore::CodeViewAppearance AppearanceWidget::readSettings()
ui.tabAppearance->setCurrentIndex(settings.appearancePrefsTabIndex());
m_ShowFullPathOn = settings.showFullPathOn();
ui.ShowFullPath->setChecked(settings.showFullPathOn());
m_ShowWidgetFocus = settings.uiHighlightFocusWidgetEnabled();
ui.chkFocusDec->setChecked(settings.uiHighlightFocusWidgetEnabled());

// Handle Icon Theme
QString icon_theme = settings.uiIconTheme();
Expand Down
3 changes: 2 additions & 1 deletion src/Dialogs/PreferenceWidgets/AppearanceWidget.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/************************************************************************
**
** Copyright (C) 2019-2021 Kevin B. Hendricks, Stratford, Ontario Canada
** Copyright (C) 2020 Doug Massay
** Copyright (C) 2016-2024 Doug Massay
** Copyright (C) 2012 John Schember <[email protected]>
** Copyright (C) 2012 Grant Drake
**
Expand Down Expand Up @@ -62,6 +62,7 @@ private slots:
int m_ShowFullPathOn;
int m_HighDPI;
int m_DragTweak;
bool m_ShowWidgetFocus;
int m_PreviewDark;
bool m_wasDark;
QString m_initUIFont;
Expand Down
3 changes: 2 additions & 1 deletion src/Misc/SettingsStore.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/************************************************************************
**
** Copyright (C) 2016-2024 Kevin B. Hendricks, Stratford, ON
** Copyright (C) 2016-2023 Doug Massay
** Copyright (C) 2016-2024 Doug Massay
** Copyright (C) 2011-2013 John Schember <[email protected]>
** Copyright (C) 2012-2013 Dave Heiland
**
Expand Down Expand Up @@ -946,6 +946,7 @@ void SettingsStore::clearAppearanceSettings()
remove(KEY_UI_ICON_THEME);
remove(KEY_DRAG_DISTANCE_TWEAK);
remove(KEY_PREVIEW_DARK_IN_DM);
remove(KEY_UI_HIGHLIGHT_FOCUS_WIDGET);
;
}

Expand Down
10 changes: 3 additions & 7 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/************************************************************************
**
** Copyright (C) 2018-2023 Kevin B. Hendricks, Stratford Ontario Canada
** Copyright (C) 2019-2022 Doug Massay
** Copyright (C) 2019-2024 Doug Massay
** Copyright (C) 2009-2011 Strahinja Markovic <[email protected]>
**
** This file is part of Sigil.
Expand Down Expand Up @@ -655,12 +655,8 @@ int main(int argc, char *argv[])
// End of UI font stuff

// allow user to highlight focus widget
QString focus_highlight = Utility::GetEnvironmentVar("SIGIL_HIGHLIGHT_FOCUS_WIDGET");
if (focus_highlight.isEmpty()) {
settings.setUIHighlightFocusWidget(false);
} else {
settings.setUIHighlightFocusWidget(true);
QString current_stylesheet = app.styleSheet();
if (settings.uiHighlightFocusWidgetEnabled()) {
QString current_stylesheet = app.styleSheet();
current_stylesheet.append(":focus { border: 1px solid red; } }");
app.setStyleSheet(current_stylesheet);
}
Expand Down

3 comments on commit 51dcfdf

@kevinhendricks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it on my mac, and it works like a charm! Thank you.

@dougmassay
Copy link
Contributor Author

@dougmassay dougmassay commented on 51dcfdf Apr 12, 2024 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kevinhendricks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They seem fine to me!

Please sign in to comment.