From c25baf11d08f9afb8af7c873b889b4e4e037dfc6 Mon Sep 17 00:00:00 2001
From: Benedikt Reinartz <filmor@gmail.com>
Date: Fri, 22 Dec 2017 08:26:25 +0100
Subject: [PATCH] Add native styling back.

---
 mscore/helpBrowser.cpp |   5 ++-
 mscore/miconengine.cpp |   6 ++-
 mscore/musescore.cpp   | 112 +++++++++++++++++++++++++------------------------
 mscore/preferences.cpp |   6 +++
 mscore/preferences.h   |   3 +-
 mscore/prefsdialog.ui  |   5 +++
 6 files changed, 78 insertions(+), 59 deletions(-)

diff --git a/mscore/helpBrowser.cpp b/mscore/helpBrowser.cpp
index 7b51e9bc4..5d6046a5e 100644
--- a/mscore/helpBrowser.cpp
+++ b/mscore/helpBrowser.cpp
@@ -150,8 +150,9 @@ HelpBrowser::HelpBrowser(QWidget* parent)
 
       bl->addStretch(10);
 
-      view->document()->setDefaultStyleSheet(
-            preferences.globalStyle == MuseScoreStyleType::DARK ? cssDark : css);
+      if (preferences.globalStyle != MuseScoreStyleType::NATIVE)
+          view->document()->setDefaultStyleSheet(
+                preferences.globalStyle == MuseScoreStyleType::DARK ? cssDark : css);
 
       toolbar->setLayout(bl);
       }
diff --git a/mscore/miconengine.cpp b/mscore/miconengine.cpp
index 09ad69cee..a20d4aca8 100644
--- a/mscore/miconengine.cpp
+++ b/mscore/miconengine.cpp
@@ -121,7 +121,8 @@ void MIconEnginePrivate::loadDataForModeAndState(QSvgRenderer* renderer, QIcon::
                   f.open(QIODevice::ReadOnly);
                   QByteArray ba = f.readAll();
                   if (mode == QIcon::Disabled) {
-                        if (Ms::preferences.globalStyle == Ms::MuseScoreStyleType::LIGHT) {
+                        if (Ms::preferences.globalStyle == Ms::MuseScoreStyleType::LIGHT ||
+                            Ms::preferences.globalStyle == Ms::MuseScoreStyleType::NATIVE) {
                               if (state == QIcon::On)
                                     ba.replace("fill:#3b3f45", "fill:#8daac7");
                               else
@@ -135,7 +136,8 @@ void MIconEnginePrivate::loadDataForModeAndState(QSvgRenderer* renderer, QIcon::
                               }
                         }
                   else {
-                        if (Ms::preferences.globalStyle == Ms::MuseScoreStyleType::LIGHT) {
+                        if (Ms::preferences.globalStyle == Ms::MuseScoreStyleType::LIGHT ||
+                            Ms::preferences.globalStyle == Ms::MuseScoreStyleType::NATIVE) {
                               if (state == QIcon::On)
                                     ba.replace("fill:#3b3f45", "fill:#4171a2");
                               }
diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp
index 0eccc8cbd..2c5ea1fa4 100644
--- a/mscore/musescore.cpp
+++ b/mscore/musescore.cpp
@@ -678,7 +678,8 @@ MuseScore::MuseScore()
 
       for (int i = 0; i < VOICES; ++i) {
             QToolButton* tb = new QToolButton(this);
-            if (preferences.globalStyle == MuseScoreStyleType::LIGHT)
+            if (preferences.globalStyle == MuseScoreStyleType::LIGHT ||
+                preferences.globalStyle == MuseScoreStyleType::NATIVE)
                   tb->setStyleSheet(vbsh);
             tb->setToolButtonStyle(Qt::ToolButtonTextOnly);
             QPalette p(tb->palette());
@@ -5345,60 +5346,63 @@ int main(int argc, char* av[])
                   const char* name;
                   const char* color;
                   };
-            MgStyleConfigData::animationsEnabled = preferences.animations;
-            MgStyle* st = new MgStyle;
-            QApplication::setStyle(st);
-            QPalette p(QApplication::palette());
-            QSettings s;
 
-            switch (preferences.globalStyle) {
-                  case MuseScoreStyleType::DARK: {
-                        static const PaletteItem pi[] = {
-                              { QPalette::Window,          "WindowColor",          "#525252" },
-                              { QPalette::WindowText,      "WindowTextColor",      "#FFFFFF" },
-                              { QPalette::Base,            "BaseColor",            "#424242" },
-                              { QPalette::AlternateBase,   "AlternateBaseColor",   "#626262" },
-                              { QPalette::Text,            "TextColor",            "#FFFFFF" },
-                              { QPalette::Button,          "ButtonColor",          "#525252" },
-                              { QPalette::ButtonText,      "ButtonTextColor",      "#FFFFFF" },
-                              { QPalette::BrightText,      "BrightTextColor",      "#000000" },
-
-//                            { QPalette::Light,           "LightColor",           "#00FF00" },
-//                            { QPalette::Midlight,        "MidlightTextColor",    "#00FF00" },
-//                            { QPalette::Dark,            "DarkTextColor",        "#00FF00" },
-//                            { QPalette::Mid,             "MidColor",             "#00FF00" },
-//                            { QPalette::Shadow,          "ShadowColor",          "#00FF00" },
-                              { QPalette::Highlight,       "HighlightColor",       "#88bff6" },
-//                            { QPalette::HighlightedText, "HighlightedTextColor", "#00FF00" },
-                              { QPalette::Link,            "HighlightedTextColor", "#00ffff" },
-                              { QPalette::LinkVisited,     "HighlightedTextColor", "#00ffff" },
-                              { QPalette::ToolTipBase,     "ToolTipBaseColor",     "#808080" },
-                              { QPalette::ToolTipText,     "ToolTipTextColor",     "#000000" },
-                              };
-                        for (auto i : pi)
-                              p.setColor(i.role, s.value(i.name, i.color).value<QColor>());
-                        break;
-                        }
-                  case MuseScoreStyleType::LIGHT:
-                        static const PaletteItem pi[] = {
-                              { QPalette::Window,        "WindowColor",        "#e3e3e3"  },
-                              { QPalette::WindowText,    "WindowTextColor",    "#333333"  },
-                              { QPalette::Base,          "BaseColor",          "#f9f9f9"  },
-                              { QPalette::AlternateBase, "AlternateBaseColor", "#eeeeee"  },
-                              { QPalette::Text,          "TextColor",          "#333333"  },
-                              { QPalette::Button,        "ButtonColor",        "#c9c9c9"  },
-                              { QPalette::ButtonText,    "ButtonTextColor",    "#333333"  },
-                              { QPalette::BrightText,    "BrightTextColor",    "#000000"  },
-                              { QPalette::ToolTipBase,   "ToolTipBaseColor",   "#fefac2"  },
-                              { QPalette::ToolTipText,   "ToolTipTextColor",   "#000000"  },
-                              { QPalette::Link,          "LinkColor",          "#3a80c6"  },
-                              { QPalette::LinkVisited,   "LinkVisitedColor",   "#3a80c6"  },
-                              };
-                        for (auto i : pi)
-                              p.setColor(i.role, s.value(i.name, i.color).value<QColor>());
-                        break;
-                  }
-            QApplication::setPalette(p);
+            if (preferences.globalStyle != MuseScoreStyleType::NATIVE) {
+                MgStyleConfigData::animationsEnabled = preferences.animations;
+                MgStyle* st = new MgStyle;
+                QApplication::setStyle(st);
+                QPalette p(QApplication::palette());
+                QSettings s;
+
+                switch (preferences.globalStyle) {
+                case MuseScoreStyleType::DARK: {
+                    static const PaletteItem pi[] = {
+                        { QPalette::Window,          "WindowColor",          "#525252" },
+                        { QPalette::WindowText,      "WindowTextColor",      "#FFFFFF" },
+                        { QPalette::Base,            "BaseColor",            "#424242" },
+                        { QPalette::AlternateBase,   "AlternateBaseColor",   "#626262" },
+                        { QPalette::Text,            "TextColor",            "#FFFFFF" },
+                        { QPalette::Button,          "ButtonColor",          "#525252" },
+                        { QPalette::ButtonText,      "ButtonTextColor",      "#FFFFFF" },
+                        { QPalette::BrightText,      "BrightTextColor",      "#000000" },
+
+                        //                            { QPalette::Light,           "LightColor",           "#00FF00" },
+                        //                            { QPalette::Midlight,        "MidlightTextColor",    "#00FF00" },
+                        //                            { QPalette::Dark,            "DarkTextColor",        "#00FF00" },
+                        //                            { QPalette::Mid,             "MidColor",             "#00FF00" },
+                        //                            { QPalette::Shadow,          "ShadowColor",          "#00FF00" },
+                        { QPalette::Highlight,       "HighlightColor",       "#88bff6" },
+                        //                            { QPalette::HighlightedText, "HighlightedTextColor", "#00FF00" },
+                        { QPalette::Link,            "HighlightedTextColor", "#00ffff" },
+                        { QPalette::LinkVisited,     "HighlightedTextColor", "#00ffff" },
+                        { QPalette::ToolTipBase,     "ToolTipBaseColor",     "#808080" },
+                        { QPalette::ToolTipText,     "ToolTipTextColor",     "#000000" },
+                    };
+                    for (auto i : pi)
+                        p.setColor(i.role, s.value(i.name, i.color).value<QColor>());
+                    break;
+                }
+                case MuseScoreStyleType::LIGHT:
+                    static const PaletteItem pi[] = {
+                        { QPalette::Window,        "WindowColor",        "#e3e3e3"  },
+                        { QPalette::WindowText,    "WindowTextColor",    "#333333"  },
+                        { QPalette::Base,          "BaseColor",          "#f9f9f9"  },
+                        { QPalette::AlternateBase, "AlternateBaseColor", "#eeeeee"  },
+                        { QPalette::Text,          "TextColor",          "#333333"  },
+                        { QPalette::Button,        "ButtonColor",        "#c9c9c9"  },
+                        { QPalette::ButtonText,    "ButtonTextColor",    "#333333"  },
+                        { QPalette::BrightText,    "BrightTextColor",    "#000000"  },
+                        { QPalette::ToolTipBase,   "ToolTipBaseColor",   "#fefac2"  },
+                        { QPalette::ToolTipText,   "ToolTipTextColor",   "#000000"  },
+                        { QPalette::Link,          "LinkColor",          "#3a80c6"  },
+                        { QPalette::LinkVisited,   "LinkVisitedColor",   "#3a80c6"  },
+                    };
+                    for (auto i : pi)
+                        p.setColor(i.role, s.value(i.name, i.color).value<QColor>());
+                    break;
+                }
+                QApplication::setPalette(p);
+            }
 
             qApp->setStyleSheet(
                   "*:disabled {\n"
diff --git a/mscore/preferences.cpp b/mscore/preferences.cpp
index 96f77425b..33f349823 100644
--- a/mscore/preferences.cpp
+++ b/mscore/preferences.cpp
@@ -470,6 +470,8 @@ void Preferences::read()
       styleName              = s.value("style", styleName).toString();
       if (styleName == "dark")
             globalStyle  = MuseScoreStyleType::DARK;
+      else if (styleName == "native")
+            globalStyle  = MuseScoreStyleType::NATIVE;
       else
             globalStyle  = MuseScoreStyleType::LIGHT;
 
@@ -1547,6 +1549,10 @@ void PreferenceDialog::apply()
             prefs.styleName = "dark";
             prefs.globalStyle = MuseScoreStyleType::DARK;
             }
+      else if (styleName->currentIndex() == int(MuseScoreStyleType::NATIVE)) {
+            prefs.styleName = "native";
+            prefs.globalStyle = MuseScoreStyleType::NATIVE;
+            }
       else {
             prefs.styleName = "light";
             prefs.globalStyle = MuseScoreStyleType::LIGHT;
diff --git a/mscore/preferences.h b/mscore/preferences.h
index 1ebf6b467..661a2dce7 100644
--- a/mscore/preferences.h
+++ b/mscore/preferences.h
@@ -58,7 +58,8 @@ enum {
 
 enum class MuseScoreStyleType : char {
       DARK,
-      LIGHT
+      LIGHT,
+      NATIVE
       };
 
 // MusicXML export break values
diff --git a/mscore/prefsdialog.ui b/mscore/prefsdialog.ui
index bc06fd096..60503156e 100644
--- a/mscore/prefsdialog.ui
+++ b/mscore/prefsdialog.ui
@@ -734,6 +734,11 @@
                 <string>Light</string>
                </property>
               </item>
+              <item>
+               <property name="text">
+                <string>Native</string>
+               </property>
+              </item>
              </widget>
             </item>
             <item>
-- 
2.13.6

