Mercurial > hg > svgui
comparison view/ViewManager.cpp @ 1580:a2ff9c01889e
Merge from branch background-mode
author | Chris Cannam |
---|---|
date | Fri, 24 Jan 2020 15:11:08 +0000 |
parents | 2c974337f306 |
children | 199dbb3547d4 |
comparison
equal
deleted
inserted
replaced
1572:5f6fdd525158 | 1580:a2ff9c01889e |
---|---|
20 #include "data/model/Model.h" | 20 #include "data/model/Model.h" |
21 #include "widgets/CommandHistory.h" | 21 #include "widgets/CommandHistory.h" |
22 #include "View.h" | 22 #include "View.h" |
23 #include "Overview.h" | 23 #include "Overview.h" |
24 | 24 |
25 #include "system/System.h" | |
26 | |
25 #include <QSettings> | 27 #include <QSettings> |
26 #include <QApplication> | 28 #include <QApplication> |
29 #include <QStyleFactory> | |
27 | 30 |
28 #include <iostream> | 31 #include <iostream> |
29 | 32 |
30 //#define DEBUG_VIEW_MANAGER 1 | 33 //#define DEBUG_VIEW_MANAGER 1 |
31 | 34 |
70 m_showCentreLine = | 73 m_showCentreLine = |
71 settings.value("show-centre-line", m_showCentreLine).toBool(); | 74 settings.value("show-centre-line", m_showCentreLine).toBool(); |
72 settings.endGroup(); | 75 settings.endGroup(); |
73 | 76 |
74 if (getGlobalDarkBackground()) { | 77 if (getGlobalDarkBackground()) { |
75 /* | 78 // i.e. widgets are already dark; create a light palette in |
76 cerr << "dark palette:" << endl; | 79 // case we are asked to switch to it, but don't create a dark |
77 cerr << "window = " << QApplication::palette().color(QPalette::Window).name() << endl; | 80 // one because it will be assigned from the actual application |
78 cerr << "windowtext = " << QApplication::palette().color(QPalette::WindowText).name() << endl; | 81 // palette if we switch |
79 cerr << "base = " << QApplication::palette().color(QPalette::Base).name() << endl; | 82 |
80 cerr << "alternatebase = " << QApplication::palette().color(QPalette::AlternateBase).name() << endl; | |
81 cerr << "text = " << QApplication::palette().color(QPalette::Text).name() << endl; | |
82 cerr << "button = " << QApplication::palette().color(QPalette::Button).name() << endl; | |
83 cerr << "buttontext = " << QApplication::palette().color(QPalette::ButtonText).name() << endl; | |
84 cerr << "brighttext = " << QApplication::palette().color(QPalette::BrightText).name() << endl; | |
85 cerr << "light = " << QApplication::palette().color(QPalette::Light).name() << endl; | |
86 cerr << "dark = " << QApplication::palette().color(QPalette::Dark).name() << endl; | |
87 cerr << "mid = " << QApplication::palette().color(QPalette::Mid).name() << endl; | |
88 */ | |
89 m_lightPalette = QPalette(QColor("#000000"), // WindowText | 83 m_lightPalette = QPalette(QColor("#000000"), // WindowText |
90 QColor("#dddfe4"), // Button | 84 QColor("#dddfe4"), // Button |
91 QColor("#ffffff"), // Light | 85 QColor("#ffffff"), // Light |
92 QColor("#555555"), // Dark | 86 QColor("#555555"), // Dark |
93 QColor("#c7c7c7"), // Mid | 87 QColor("#c7c7c7"), // Mid |
94 QColor("#000000"), // Text | 88 QColor("#000000"), // Text |
95 QColor("#ffffff"), // BrightText | 89 QColor("#ffffff"), // BrightText |
96 QColor("#ffffff"), // Base | 90 QColor("#ffffff"), // Base |
97 QColor("#efefef")); // Window | 91 QColor("#efefef")); // Window |
98 | 92 |
99 | 93 m_lightPalette.setColor(QPalette::Highlight, Qt::darkBlue); |
100 } else { | 94 if (!OSReportsDarkThemeActive()) { |
101 /* | 95 int r, g, b; |
102 cerr << "light palette:" << endl; | 96 if (OSQueryAccentColour(r, g, b)) { |
103 cerr << "window = " << QApplication::palette().color(QPalette::Window).name() << endl; | 97 m_lightPalette.setColor(QPalette::Highlight, QColor(r, g, b)); |
104 cerr << "windowtext = " << QApplication::palette().color(QPalette::WindowText).name() << endl; | 98 } |
105 cerr << "base = " << QApplication::palette().color(QPalette::Base).name() << endl; | 99 } |
106 cerr << "alternatebase = " << QApplication::palette().color(QPalette::AlternateBase).name() << endl; | 100 |
107 cerr << "text = " << QApplication::palette().color(QPalette::Text).name() << endl; | 101 } else { |
108 cerr << "button = " << QApplication::palette().color(QPalette::Button).name() << endl; | 102 // i.e. widgets are currently light; create a dark palette in |
109 cerr << "buttontext = " << QApplication::palette().color(QPalette::ButtonText).name() << endl; | 103 // case we are asked to switch to it, but don't create a light |
110 cerr << "brighttext = " << QApplication::palette().color(QPalette::BrightText).name() << endl; | 104 // one because it will be assigned from the actual application |
111 cerr << "light = " << QApplication::palette().color(QPalette::Light).name() << endl; | 105 // palette if we switch |
112 cerr << "dark = " << QApplication::palette().color(QPalette::Dark).name() << endl; | 106 |
113 cerr << "mid = " << QApplication::palette().color(QPalette::Mid).name() << endl; | 107 m_darkPalette = QPalette(QColor("#f0f0f0"), // WindowText |
114 */ | |
115 m_darkPalette = QPalette(QColor("#ffffff"), // WindowText | |
116 QColor("#3e3e3e"), // Button | 108 QColor("#3e3e3e"), // Button |
117 QColor("#808080"), // Light | 109 QColor("#808080"), // Light |
118 QColor("#1e1e1e"), // Dark | 110 QColor("#1e1e1e"), // Dark |
119 QColor("#404040"), // Mid | 111 QColor("#404040"), // Mid |
120 QColor("#ffffff"), // Text | 112 QColor("#f0f0f0"), // Text |
121 QColor("#ffffff"), // BrightText | 113 QColor("#ffffff"), // BrightText |
122 QColor("#000000"), // Base | 114 QColor("#000000"), // Base |
123 QColor("#202020")); // Window | 115 QColor("#202020")); // Window |
116 | |
117 m_darkPalette.setColor(QPalette::Highlight, QColor(25, 130, 220)); | |
118 if (OSReportsDarkThemeActive()) { | |
119 int r, g, b; | |
120 if (OSQueryAccentColour(r, g, b)) { | |
121 m_darkPalette.setColor(QPalette::Highlight, QColor(r, g, b)); | |
122 } | |
123 } | |
124 | |
125 m_darkPalette.setColor(QPalette::Link, QColor(50, 175, 255)); | |
126 m_darkPalette.setColor(QPalette::LinkVisited, QColor(50, 175, 255)); | |
127 | |
128 m_darkPalette.setColor(QPalette::Disabled, QPalette::WindowText, | |
129 QColor("#808080")); | |
130 m_darkPalette.setColor(QPalette::Disabled, QPalette::Text, | |
131 QColor("#808080")); | |
132 m_darkPalette.setColor(QPalette::Disabled, QPalette::Shadow, | |
133 QColor("#000000")); | |
124 } | 134 } |
125 } | 135 } |
126 | 136 |
127 ViewManager::~ViewManager() | 137 ViewManager::~ViewManager() |
128 { | 138 { |
790 m_darkPalette = QApplication::palette(); | 800 m_darkPalette = QApplication::palette(); |
791 } else { | 801 } else { |
792 m_lightPalette = QApplication::palette(); | 802 m_lightPalette = QApplication::palette(); |
793 } | 803 } |
794 | 804 |
795 #ifndef Q_OS_MAC | 805 #ifdef Q_OS_MAC |
806 return; | |
807 #endif | |
808 | |
796 if (dark) { | 809 if (dark) { |
810 | |
811 #ifdef Q_OS_WIN32 | |
812 // The Windows Vista style doesn't use the palette for many of | |
813 // its controls. They can be styled with stylesheets, but that | |
814 // takes a lot of fiddly and fragile custom bits. Easier and | |
815 // more reliable to switch to a non-Vista style which does use | |
816 // the palette. | |
817 | |
818 QStyle *plainWindowsStyle = QStyleFactory::create("windows"); | |
819 if (!plainWindowsStyle) { | |
820 SVCERR << "Failed to load plain Windows style" << endl; | |
821 } else { | |
822 qApp->setStyle(plainWindowsStyle); | |
823 } | |
824 #endif | |
825 | |
797 QApplication::setPalette(m_darkPalette); | 826 QApplication::setPalette(m_darkPalette); |
798 } else { | 827 |
828 } else { | |
829 | |
830 #ifdef Q_OS_WIN32 | |
831 // Switch back to Vista style | |
832 | |
833 QStyle *fancyWindowsStyle = QStyleFactory::create("windowsvista"); | |
834 if (!fancyWindowsStyle) { | |
835 SVCERR << "Failed to load fancy Windows style" << endl; | |
836 } else { | |
837 qApp->setStyle(fancyWindowsStyle); | |
838 } | |
839 #endif | |
840 | |
799 QApplication::setPalette(m_lightPalette); | 841 QApplication::setPalette(m_lightPalette); |
800 } | 842 } |
801 #endif | |
802 } | 843 } |
803 | 844 |
804 bool | 845 bool |
805 ViewManager::getGlobalDarkBackground() const | 846 ViewManager::getGlobalDarkBackground() const |
806 { | 847 { |