# HG changeset patch # User Farid Partonia # Date 1650531947 -16200 # Node ID 291994766c5531a300a5b45880a79c8a773eb346 # Parent 04601f6c47f4123448834f87c392ca341f9946fe add fusion dark style to gui * gui-preferences-global.h: added extra styles * main-window.cc (main_window): initiale new class variable with default style; (notice_settings): check desired style for extra fusion dark style and set style togehter with new palette accordingly; (getFusionDarkPalette): new function for creating the palette for new fusion dark style * main-window.h: new function getFusionDarkPalette, new class variable m_default_palette * settings-dialog.cc (settings_dialog): add new stayle to combo box with styles diff -r 04601f6c47f4 -r 291994766c55 libgui/src/gui-preferences-global.h --- a/libgui/src/gui-preferences-global.h Sat Apr 23 18:10:45 2022 +0200 +++ b/libgui/src/gui-preferences-global.h Thu Apr 21 13:35:47 2022 +0430 @@ -117,6 +117,15 @@ const gui_pref global_status_bar ("show_status_bar", QVariant (true)); + +enum +{ + EXTRA_STYLE_FUSION_DARK = 0 +} ; +const QStringList +global_extra_styles (QStringList () + << "Fusion-Dark"); + #if defined (Q_OS_MAC) // prevent native file dialogs on MAC by setting the default "false" and // setting the flag for ignoring the pref to "true" (3rd argument) diff -r 04601f6c47f4 -r 291994766c55 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Sat Apr 23 18:10:45 2022 +0200 +++ b/libgui/src/main-window.cc Thu Apr 21 13:35:47 2022 +0430 @@ -172,6 +172,7 @@ QApplication *qapp = m_octave_qobj.qapplication (); m_default_style = qapp->style ()->objectName (); + m_default_palette = qapp->palette (); gui_settings *settings = rmgr.get_settings (); @@ -911,12 +912,24 @@ if (preferred_style == global_style.def.toString ()) preferred_style = m_default_style; - QStyle *new_style = QStyleFactory::create (preferred_style); - if (new_style) + QApplication* qapp = m_octave_qobj.qapplication(); + + if (preferred_style == global_extra_styles.at (EXTRA_STYLE_FUSION_DARK)) { - QApplication *qapp = m_octave_qobj.qapplication (); - - qapp->setStyle (new_style); + QStyle *new_style = QStyleFactory::create (QStringLiteral("Fusion")); + if (new_style) + qapp->setStyle (new_style); + qapp->setPalette (getFusionDarkPalette()); + qapp->setStyleSheet ("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }"); + } + else + { + QStyle *new_style = QStyleFactory::create (preferred_style); + if (new_style) + { + qapp->setPalette (m_default_palette); + qapp->setStyle (new_style); + } } // the widget's icons (when floating) @@ -997,6 +1010,33 @@ } + QPalette main_window::getFusionDarkPalette() + { + QPalette darkPalette; + darkPalette.setColor(QPalette::Window, QColor(53, 53, 53)); + darkPalette.setColor(QPalette::WindowText, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, QColor(127, 127, 127)); + darkPalette.setColor(QPalette::Base, QColor(42, 42, 42)); + darkPalette.setColor(QPalette::AlternateBase, QColor(66, 66, 66)); + darkPalette.setColor(QPalette::ToolTipBase, Qt::white); + darkPalette.setColor(QPalette::ToolTipText, Qt::white); + darkPalette.setColor(QPalette::Text, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::Text, QColor(127, 127, 127)); + darkPalette.setColor(QPalette::Dark, QColor(35, 35, 35)); + darkPalette.setColor(QPalette::Shadow, QColor(20, 20, 20)); + darkPalette.setColor(QPalette::Button, QColor(53, 53, 53)); + darkPalette.setColor(QPalette::ButtonText, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::ButtonText, QColor(127, 127, 127)); + darkPalette.setColor(QPalette::BrightText, Qt::red); + darkPalette.setColor(QPalette::Link, QColor(42, 130, 218)); + darkPalette.setColor(QPalette::Highlight, QColor(42, 130, 218)); + darkPalette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80)); + darkPalette.setColor(QPalette::HighlightedText, Qt::white); + darkPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127)); + + return darkPalette; + } + void main_window::prepare_to_exit (void) { // Find files dialog is constructed dynamically, not at time of main_window diff -r 04601f6c47f4 -r 291994766c55 libgui/src/main-window.h --- a/libgui/src/main-window.h Sat Apr 23 18:10:45 2022 +0200 +++ b/libgui/src/main-window.h Thu Apr 21 13:35:47 2022 +0430 @@ -153,10 +153,10 @@ void open_donate_page (void); void process_settings_dialog_request (const QString& desired_tab = QString ()); - void show_about_octave (void); void notice_settings (const gui_settings *settings, bool update_by_worker = false); + QPalette getFusionDarkPalette(); void prepare_to_exit (void); void go_to_previous_widget (void); void reset_windows (void); @@ -309,6 +309,7 @@ QString m_default_encoding; QString m_default_style; + QPalette m_default_palette; //! Toolbar. diff -r 04601f6c47f4 -r 291994766c55 libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Sat Apr 23 18:10:45 2022 +0200 +++ b/libgui/src/settings-dialog.cc Thu Apr 21 13:35:47 2022 +0430 @@ -116,6 +116,7 @@ // Global style QStringList styles = QStyleFactory::keys(); + styles.append (global_extra_styles); combo_styles->addItems (styles); combo_styles->insertItem (0, global_style.def.toString ()); combo_styles->insertSeparator (1);