Tue, 28 Jun 2022 12:29:38 +0300
Make settings editor scrollable
24 | 1 | /* |
2 | * LDForge: LDraw parts authoring CAD | |
3 | * Copyright (C) 2013 - 2020 Teemu Piippo | |
4 | * | |
5 | * This program is free software: you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation, either version 3 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
178 | 19 | #include <QStyleFactory> |
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
178
diff
changeset
|
20 | #include <QWidget> |
264
76a025db4948
Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
259
diff
changeset
|
21 | #include "src/uiutilities.h" |
16 | 22 | |
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
178
diff
changeset
|
23 | std::vector<QAction*> uiutilities::collectActions(QObject* subject) |
16 | 24 | { |
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
178
diff
changeset
|
25 | std::vector<QAction*> actions; |
16 | 26 | for (QAction* action : subject->findChildren<QAction*>()) |
27 | { | |
28 | if (not action->text().isEmpty() | |
29 | and action->data().isNull() | |
30 | and not action->objectName().isEmpty()) | |
31 | { | |
32 | actions.push_back(action); | |
33 | } | |
34 | } | |
35 | return actions; | |
36 | } | |
37 | ||
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
178
diff
changeset
|
38 | uiutilities::KeySequenceMap uiutilities::makeKeySequenceMap(const std::vector<QAction*>& actions) |
16 | 39 | { |
40 | KeySequenceMap result; | |
41 | for (QAction* action : actions) | |
42 | { | |
43 | result[action->objectName()] = action->shortcut(); | |
44 | } | |
45 | return result; | |
46 | } | |
178 | 47 | |
48 | void uiutilities::colorizeWidget(QWidget* widget, const QColor& color) | |
49 | { | |
50 | QPalette pal{color}; | |
51 | widget->setPalette(pal); | |
52 | widget->setAutoFillBackground(true); | |
53 | widget->setStyle(QStyleFactory::create("Fusion")); | |
54 | widget->update(); | |
259
c27612f0eac0
- Made it build under Qt6
Teemu Piippo <teemu.s.piippo@gmail.com>
parents:
178
diff
changeset
|
55 | } |