@@ -39,120 +39,30 @@ void StyleHelper::SetStyle(){
3939 f.open (QFile::ReadOnly | QFile::Text);
4040 QTextStream ts (&f);
4141 qApp->setStyleSheet (ts.readAll ());
42- if (style_sheet==" amoled" || style_sheet==" vsdark" ){
43- m_host->settings_dlg ->updateButtonStyle (true );
44- QPixmap pix (" :/icons/settings-white.svg" );
45- QIcon icon (pix);
46- QPixmap pix2 (" :/icons/queue-white.svg" );
47- QIcon icon2 (pix2);
48- QPixmap pix3 (" :/icons/menu-white.svg" );
49- QIcon icon3 (pix3);
50- m_host->ui ->set ->setIcon (icon);
51- m_host->ui ->cpreset ->setIcon (icon2);
52- m_host->ui ->toolButton ->setIcon (icon3);
53- }else {
54- m_host->settings_dlg ->updateButtonStyle (false );
55- QPixmap pix (" :/icons/settings.svg" );
56- QIcon icon (pix);
57- QPixmap pix2 (" :/icons/queue.svg" );
58- QIcon icon2 (pix2);
59- QPixmap pix3 (" :/icons/menu.svg" );
60- QIcon icon3 (pix3);
61- m_host->ui ->set ->setIcon (icon);
62- m_host->ui ->cpreset ->setIcon (icon2);
63- m_host->ui ->toolButton ->setIcon (icon3);
64- }
42+ loadIcons (style_sheet==" amoled" || style_sheet==" vsdark" );
6543 }
6644 }else {
67- loadIcons (false );
68- if (color_palette==" dark" ){
69- loadIcons (true );
70- QColor background = QColor (53 ,53 ,53 );
71- QColor foreground = Qt::white;
72- QColor base = QColor (25 ,25 ,25 );
73- QColor selection = QColor (42 , 130 , 218 );
74- setPalette (base,background,foreground,selection,Qt::black);
75- }else if (color_palette==" gray" ){
76- loadIcons (true );
77- QColor background = QColor (49 ,49 ,74 );
78- QColor foreground = Qt::white;
79- QColor base = QColor (83 ,83 ,125 );
80- QColor selection = QColor (85 ,85 ,127 );
81- setPalette (base,background,foreground,selection,Qt::black,QColor (144 ,144 ,179 ));
82- }else if (color_palette==" white" ){
83- QColor background = Qt::white;
84- QColor foreground = Qt::black;
85- QColor base = Qt::white;
86- QColor selection = QColor (56 ,161 ,227 );
87- setPalette (base,background,foreground,selection,Qt::black);
88- }
89- else if (color_palette==" blue" ){
90- loadIcons (true );
91- QColor background = QColor (0 ,0 ,50 );
92- QColor foreground = Qt::white;
93- QColor base = QColor (0 ,0 ,38 );
94- QColor selection = QColor (85 ,0 ,255 );
95- setPalette (base,background,foreground,selection,Qt::black);
96- }
97- else if (color_palette==" darkblue" ){
98- loadIcons (true );
99- QColor background = QColor (19 ,25 ,38 );
100- QColor foreground = Qt::white;
101- QColor base = QColor (14 ,19 ,29 );
102- QColor selection = QColor (70 ,79 ,89 );
103- setPalette (base,background,foreground,selection,Qt::black);
104- }
105- else if (color_palette==" honeycomb" ){
106- QColor background = QColor (212 ,215 ,208 );
107- QColor foreground = Qt::black;
108- QColor base = QColor (185 ,188 ,182 );
109- QColor selection = QColor (243 ,193 ,41 );
110- setPalette (base,background,foreground,selection,Qt::white);
111- }
112- else if (color_palette==" black" ){
113- loadIcons (true );
114- QColor background = QColor (16 ,16 ,16 );
115- QColor foreground = QColor (222 ,222 ,222 );
116- QColor base = Qt::black;
117- QColor selection = QColor (132 ,132 ,132 );
118- setPalette (base,background,foreground,selection,Qt::black);
119- }
120- else if (color_palette==" darkgreen" ){
121- loadIcons (true );
122- QColor background = QColor (27 ,34 ,36 );
123- QColor foreground = QColor (197 ,209 ,217 );
124- QColor base = QColor (30 ,30 ,30 );
125- QColor selection = QColor (21 ,67 ,58 );
126- setPalette (base,background,foreground,selection,Qt::black);
127- }
128- else if (color_palette==" green" ){
129- loadIcons (true );
130- QColor background = QColor (0 ,12 ,0 );
131- QColor foreground = Qt::white;
132- QColor base = QColor (6 ,29 ,12 );
133- QColor selection = QColor (86 ,191 ,121 );
134- setPalette (base,background,foreground,selection,Qt::black);
135- }
136- else if (color_palette==" stone" ){
137- loadIcons (true );
138- QColor background = QColor (34 ,45 ,50 );
139- QColor foreground = Qt::white;
140- QColor base = QColor (27 ,36 ,40 );
141- QColor selection = QColor (165 ,206 ,255 );
142- setPalette (base,background,foreground,selection,Qt::black);
143- }
144- else if (color_palette==" custom" ){
45+ auto palettes = ColorStyleProvider::TABLE ();
46+ if (color_palette==" custom" ){
14547 QColor base = QColor (loadColor (0 ,0 ),loadColor (0 ,1 ),loadColor (0 ,2 ));
14648 QColor background = QColor (loadColor (1 ,0 ),loadColor (1 ,1 ),loadColor (1 ,2 ));
14749 QColor foreground = QColor (loadColor (2 ,0 ),loadColor (2 ,1 ),loadColor (2 ,2 ));
14850 QColor selection = QColor (loadColor (3 ,0 ),loadColor (3 ,1 ),loadColor (3 ,2 ));
14951 QColor disabled = QColor (loadColor (4 ,0 ),loadColor (4 ,1 ),loadColor (4 ,2 ));
15052 QColor selectiontext = QColor (255 -loadColor (3 ,0 ),255 -loadColor (3 ,1 ),255 -loadColor (3 ,2 ));
53+ ColorStyle cs = ColorStyle (m_appconf->getWhiteIcons (),
54+ base,background,foreground,selection,selectiontext,disabled);
15155
152- setPalette (base,background,foreground,selection,selectiontext,disabled );
56+ setPalette (cs );
15357 loadIcons (m_appconf->getWhiteIcons ());
15458 }
59+ else if (palettes.contains (color_palette)){
60+ ColorStyle currentColorStyle = palettes[color_palette];
61+ setPalette (currentColorStyle);
62+ loadIcons (currentColorStyle.useWhiteIcons );
63+ }
15564 else {
65+ loadIcons (false );
15666 QApplication::setPalette (m_host->style ()->standardPalette ());
15767 QFile f (" :/default.qss" );
15868 if (!f.exists ())printf (" Unable to set stylesheet, file not found\n " );
@@ -167,24 +77,35 @@ void StyleHelper::SetStyle(){
16777 }
16878 emit styleChanged ();
16979}
170- void StyleHelper::setPalette (const QColor& base, const QColor& background, const QColor& foreground, const QColor& selection, const QColor& selectiontext, const QColor& disabled ){
80+ void StyleHelper::setPalette (const ColorStyle& s ){
17181 QPalette *palette = new QPalette ();
172- palette->setColor (QPalette::Window, background);
173- palette->setColor (QPalette::WindowText, foreground);
174- palette->setColor (QPalette::Base, base);
175- palette->setColor (QPalette::AlternateBase, background);
176- palette->setColor (QPalette::ToolTipBase, background);
177- palette->setColor (QPalette::ToolTipText, foreground);
178- palette->setColor (QPalette::Text, foreground);
179- palette->setColor (QPalette::Button, background);
180- palette->setColor (QPalette::ButtonText, foreground);
82+ palette->setColor (QPalette::Window, s. background );
83+ palette->setColor (QPalette::WindowText, s. foreground );
84+ palette->setColor (QPalette::Base, s. base );
85+ palette->setColor (QPalette::AlternateBase, s. background );
86+ palette->setColor (QPalette::ToolTipBase, s. background );
87+ palette->setColor (QPalette::ToolTipText, s. foreground );
88+ palette->setColor (QPalette::Text, s. foreground );
89+ palette->setColor (QPalette::Button, s. background );
90+ palette->setColor (QPalette::ButtonText, s. foreground );
18191 palette->setColor (QPalette::BrightText, Qt::red);
18292 palette->setColor (QPalette::Link, QColor (42 , 130 , 218 ));
183- palette->setColor (QPalette::Highlight, selection);
184- palette->setColor (QPalette::HighlightedText, selectiontext);
93+ palette->setColor (QPalette::Highlight, s. selection );
94+ palette->setColor (QPalette::HighlightedText, s. selectiontext );
18595 qApp->setPalette (*palette);
186- QString rgbdisabled = disabled.name ();
187- qApp->setStyleSheet (R"( QFrame[frameShape="4"], QFrame[frameShape="5"]{ color: gray; }*::disabled { color: )" + rgbdisabled +" ;}QToolButton::disabled { color: " + rgbdisabled +" ;}QComboBox::disabled { color: " + rgbdisabled +" ;}" );
96+ qApp->setStyleSheet (QString (R"( QFrame[frameShape="4"], QFrame[frameShape="5"]{
97+ color: gray;
98+ }
99+ *::disabled {
100+ color: %1;
101+ }
102+ QToolButton::disabled{
103+ color: %1;
104+
105+ }
106+ QComboBox::disabled{
107+ color: %1;
108+ })" ).arg (s.disabled .name ()));
188109}
189110void StyleHelper::loadIcons (bool white){
190111 MainWindow* m_host = qobject_cast<MainWindow*>(m_objhost);
@@ -230,11 +151,3 @@ int StyleHelper::loadColor(int index,int rgb_index){
230151 QStringList rgb = elements[index].split (' ,' );
231152 return rgb[rgb_index].toInt ();
232153}
233- void StyleHelper::switchPalette (const QPalette& palette)
234- {
235- MainWindow* m_host = qobject_cast<MainWindow*>(m_objhost);
236- qApp->setPalette (palette);
237- QList<QWidget*> widgets = m_host->findChildren <QWidget*>();
238- foreach (QWidget* w, widgets)
239- w->setPalette (palette);
240- }
0 commit comments