Skip to content

Commit f311bfc

Browse files
authored
Merge pull request FreeCAD#19649 from alfrix/taskpanel_improvements
refactor(Gui): improve the taskpanel
2 parents d15cec2 + 9abea00 commit f311bfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+790
-2063
lines changed

src/Gui/CMakeLists.txt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ set(Gui_RES_SRCS
449449
Icons/resource.qrc
450450
Language/translation.qrc
451451
${FreeCAD_TR_QRC}
452-
QSint/actionpanel/schemes.qrc
453452
)
454453

455454
qt_add_resources(Gui_QRC_SRCS ${Gui_RES_SRCS})
@@ -862,20 +861,10 @@ SET(qsintActionPanel_SRCS
862861
QSint/actionpanel/actionpanel.h
863862
QSint/actionpanel/actionpanelscheme.cpp
864863
QSint/actionpanel/actionpanelscheme.h
865-
QSint/actionpanel/androidpanelscheme.cpp
866-
QSint/actionpanel/androidpanelscheme.h
867-
QSint/actionpanel/macpanelscheme.cpp
868-
QSint/actionpanel/macpanelscheme.h
869864
QSint/actionpanel/taskgroup_p.cpp
870865
QSint/actionpanel/taskgroup_p.h
871866
QSint/actionpanel/taskheader_p.cpp
872867
QSint/actionpanel/taskheader_p.h
873-
QSint/actionpanel/winvistapanelscheme.cpp
874-
QSint/actionpanel/winvistapanelscheme.h
875-
QSint/actionpanel/winxppanelscheme.cpp
876-
QSint/actionpanel/winxppanelscheme.h
877-
QSint/actionpanel/freecadscheme.cpp
878-
QSint/actionpanel/freecadscheme.h
879868
)
880869
SOURCE_GROUP("Widget\\QSintActionPanel" FILES ${qsintActionPanel_SRCS})
881870
set(qsint_MOC_HDRS

src/Gui/QSint/actionpanel/actionbox.cpp

Lines changed: 32 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -9,94 +9,35 @@
99

1010
#include <QVariant>
1111

12-
1312
namespace QSint
1413
{
1514

16-
17-
const char* ActionBoxStyle =
18-
"QSint--ActionBox {"
19-
"background-color: white;"
20-
"border: 1px solid white;"
21-
"border-radius: 3px;"
22-
"text-align: left;"
23-
"}"
24-
25-
"QSint--ActionBox:hover {"
26-
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F9FDFF, stop: 1 #EAF7FF);"
27-
"border: 1px solid #DAF2FC;"
28-
"}"
29-
30-
31-
"QSint--ActionBox QSint--ActionLabel[class='header'] {"
32-
"text-align: left;"
33-
"font: 14px;"
34-
"color: #006600;"
35-
"background-color: transparent;"
36-
"border: none;"
37-
"}"
38-
39-
"QSint--ActionBox QSint--ActionLabel[class='header']:hover {"
40-
"color: #00cc00;"
41-
"text-decoration: underline;"
42-
"}"
43-
44-
45-
"QSint--ActionBox QSint--ActionLabel[class='action'] {"
46-
"background-color: transparent;"
47-
"border: none;"
48-
"color: #0033ff;"
49-
"text-align: left;"
50-
"font: 11px;"
51-
"}"
52-
53-
"QSint--ActionBox QSint--ActionLabel[class='action']:!enabled {"
54-
"color: #999999;"
55-
"}"
56-
57-
"QSint--ActionBox QSint--ActionLabel[class='action']:hover {"
58-
"color: #0099ff;"
59-
"text-decoration: underline;"
60-
"}"
61-
62-
"QSint--ActionBox QSint--ActionLabel[class='action']:on {"
63-
"background-color: #ddeeff;"
64-
"color: #006600;"
65-
"}"
66-
67-
;
68-
69-
70-
ActionBox::ActionBox(QWidget *parent) :
71-
QFrame(parent)
15+
ActionBox::ActionBox(QWidget *parent)
16+
: QFrame(parent)
7217
{
7318
init();
7419
}
7520

76-
ActionBox::ActionBox(const QString & headerText, QWidget *parent) :
77-
QFrame(parent)
21+
ActionBox::ActionBox(const QString & headerText, QWidget *parent)
22+
: QFrame(parent)
7823
{
79-
init();
80-
headerLabel->setText(headerText);
24+
init(headerText);
8125
}
8226

83-
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent) :
84-
QFrame(parent)
27+
ActionBox::ActionBox(const QPixmap & icon, const QString & headerText, QWidget *parent)
28+
: QFrame(parent)
8529
{
86-
init();
87-
headerLabel->setText(headerText);
30+
init(headerText);
8831
setIcon(icon);
8932
}
9033

91-
void ActionBox::init()
34+
void ActionBox::init(const QString &headerText)
9235
{
93-
setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Maximum);
94-
95-
setStyleSheet(QString(ActionBoxStyle));
36+
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
9637

97-
QHBoxLayout *mainLayout = new QHBoxLayout(this);
38+
auto *mainLayout = new QHBoxLayout(this);
9839

99-
QVBoxLayout *iconLayout = new QVBoxLayout();
40+
auto *iconLayout = new QVBoxLayout();
10041
mainLayout->addLayout(iconLayout);
10142

10243
iconLabel = new QLabel(this);
@@ -106,7 +47,7 @@ void ActionBox::init()
10647
dataLayout = new QVBoxLayout();
10748
mainLayout->addLayout(dataLayout);
10849

109-
headerLabel = createItem("");
50+
headerLabel = createItem(headerText);
11051
headerLabel->setProperty("class", "header");
11152
}
11253

@@ -118,22 +59,14 @@ void ActionBox::setIcon(const QPixmap & icon)
11859

11960
QPixmap ActionBox::icon() const
12061
{
121-
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
12262
return iconLabel->pixmap(Qt::ReturnByValue);
123-
#else
124-
QPixmap p;
125-
const QPixmap* ptr = iconLabel->pixmap();
126-
if (ptr)
127-
p = *ptr;
128-
return p;
129-
#endif
13063
}
13164

13265
ActionLabel* ActionBox::createItem(QAction * action, QLayout * l)
13366
{
134-
if (!action)
67+
if (!action) {
13568
return nullptr;
136-
69+
}
13770
ActionLabel *act = createItem("", l);
13871
act->setDefaultAction(action);
13972
return act;
@@ -143,15 +76,15 @@ QList<ActionLabel*> ActionBox::createItems(QList<QAction*> actions)
14376
{
14477
QList<ActionLabel*> list;
14578

146-
if (actions.isEmpty())
79+
if (actions.isEmpty()) {
14780
return list;
148-
81+
}
14982
QLayout *l = createHBoxLayout();
15083

151-
Q_FOREACH (QAction *action, actions) {
152-
ActionLabel *act = createItem(action, l);
153-
if (act)
84+
for (QAction *action : actions) {
85+
if (auto *act = createItem(action, l)) {
15486
list.append(act);
87+
}
15588
}
15689

15790
return list;
@@ -162,10 +95,10 @@ ActionLabel* ActionBox::createItem(const QString & text, QLayout * l)
16295
ActionLabel *act = new ActionLabel(this);
16396
act->setText(text);
16497
act->setProperty("class", "action");
165-
act->setStyleSheet("");
16698

167-
if (l)
99+
if (l) {
168100
l->addWidget(act);
101+
}
169102
else {
170103
QHBoxLayout *hbl = new QHBoxLayout();
171104
hbl->addWidget(act);
@@ -187,11 +120,14 @@ QSpacerItem* ActionBox::createSpacer(QLayout * l)
187120
{
188121
QSpacerItem * spacer;
189122

190-
if (l) // add horizontal spacer
123+
if (l) {
124+
// add horizontal spacer
191125
l->addItem(spacer = new QSpacerItem(1,0,QSizePolicy::MinimumExpanding,QSizePolicy::Ignored));
192-
else // add vertical spacer
126+
}
127+
else {
128+
// add vertical spacer
193129
dataLayout->addItem(spacer = new QSpacerItem(0,1,QSizePolicy::Ignored,QSizePolicy::MinimumExpanding));
194-
130+
}
195131
return spacer;
196132
}
197133

@@ -215,13 +151,14 @@ void ActionBox::addLayout(QLayout * l)
215151

216152
void ActionBox::addWidget(QWidget * w, QLayout * l)
217153
{
218-
if (!w)
154+
if (!w) {
219155
return;
220-
156+
}
221157
w->setParent(this);
222158

223-
if (l)
159+
if (l) {
224160
l->addWidget(w);
161+
}
225162
else {
226163
QHBoxLayout *hbl = new QHBoxLayout();
227164
hbl->addWidget(w);
@@ -235,5 +172,4 @@ QSize ActionBox::minimumSizeHint() const
235172
return {150,65};
236173
}
237174

238-
239175
} // namespace

0 commit comments

Comments
 (0)