Skip to content

Commit e4c45bd

Browse files
AlexandrKudryaiakov
authored andcommitted
fix: style.cpp depenties fixes
1 parent 5efc728 commit e4c45bd

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

qrgui/brandManager/styles.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* Copyright 2007-2015 QReal Research Group
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License. */
14+
15+
#include "styles.h"
16+
17+
#include <QApplication>
18+
#include <QSettings>
19+
#include <QPalette>
20+
#include <QColor>
21+
22+
using namespace qReal;
23+
24+
QPalette Styles::loadPalette(QString pathToPalette) const {
25+
QSettings settings(pathToPalette, QSettings::IniFormat);
26+
QPalette palette;
27+
28+
const QMap<QString, QPalette::ColorRole> colorRoles = {
29+
{"Window", QPalette::Window},
30+
{"WindowText", QPalette::WindowText},
31+
{"Base", QPalette::Base},
32+
{"AlternateBase", QPalette::AlternateBase},
33+
{"ToolTipBase", QPalette::ToolTipBase},
34+
{"ToolTipText", QPalette::ToolTipText},
35+
{"Text", QPalette::Text},
36+
{"Dark", QPalette::Dark},
37+
{"Shadow", QPalette::Shadow},
38+
{"Button", QPalette::Button},
39+
{"ButtonText", QPalette::ButtonText},
40+
{"BrightText", QPalette::BrightText},
41+
{"Link", QPalette::Link},
42+
{"Highlight", QPalette::Highlight},
43+
{"HighlightedText", QPalette::HighlightedText}
44+
};
45+
46+
for (const auto &group : {"PaletteActive", "PaletteDisabled"}) {
47+
QPalette::ColorGroup colorGroup = (QString(group) == "PaletteDisabled") ? QPalette::Disabled : QPalette::Active;
48+
49+
for (auto it = colorRoles.begin(); it != colorRoles.end(); ++it) {
50+
QStringList rgb = settings.value(QString(group) + "/" + it.key()).toStringList();
51+
if (!rgb.isEmpty()) {
52+
QColor color(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
53+
palette.setColor(colorGroup, it.value(), color);
54+
}
55+
}
56+
}
57+
58+
return palette;
59+
}

qrgui/brandManager/styles.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include <QtWidgets/QApplication>
18+
#include <QPalette>
1819

1920
#include <qrutils/inFile.h>
2021
#include "fonts.h"

0 commit comments

Comments
 (0)