From 51dcfdf52b59c6e5adf2a4ff47df1b5e03929410 Mon Sep 17 00:00:00 2001 From: Doug Massay Date: Thu, 11 Apr 2024 14:44:56 -0400 Subject: [PATCH] Attach Widget Focus UI prefs to settings store [deploy] --- src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp | 9 ++++++++- src/Dialogs/PreferenceWidgets/AppearanceWidget.h | 3 ++- src/Misc/SettingsStore.cpp | 3 ++- src/main.cpp | 10 +++------- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp b/src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp index e2768e3aae..bbcc3b6e7f 100644 --- a/src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp +++ b/src/Dialogs/PreferenceWidgets/AppearanceWidget.cpp @@ -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 ** Copyright (C) 2012-2013 Grant Drake ** @@ -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()) { @@ -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; @@ -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(); diff --git a/src/Dialogs/PreferenceWidgets/AppearanceWidget.h b/src/Dialogs/PreferenceWidgets/AppearanceWidget.h index 0a185b2360..47b5e62d87 100644 --- a/src/Dialogs/PreferenceWidgets/AppearanceWidget.h +++ b/src/Dialogs/PreferenceWidgets/AppearanceWidget.h @@ -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 ** Copyright (C) 2012 Grant Drake ** @@ -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; diff --git a/src/Misc/SettingsStore.cpp b/src/Misc/SettingsStore.cpp index 38c9020cbb..c00d91d424 100644 --- a/src/Misc/SettingsStore.cpp +++ b/src/Misc/SettingsStore.cpp @@ -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 ** Copyright (C) 2012-2013 Dave Heiland ** @@ -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); ; } diff --git a/src/main.cpp b/src/main.cpp index 1f89d3e3c1..4bb5000933 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 ** ** This file is part of Sigil. @@ -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); }