Skip to content

Commit 34cf851

Browse files
committed
Updates default stylesheet and demo app
1 parent 9bbc5e4 commit 34cf851

File tree

14 files changed

+188
-82
lines changed

14 files changed

+188
-82
lines changed

AdvancedDockingSystem/include/ads/ContainerWidget.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class InternalContentData;
2222

2323
/*!
2424
* ContainerWidget is the main container to provide the docking
25-
* functionality. It manages mulitple Sections and all possible areas.
25+
* functionality. It manages multiple sections with all possible areas.
2626
*/
2727
class ADS_EXPORT_API ContainerWidget : public QFrame
2828
{
@@ -130,7 +130,7 @@ private slots:
130130
/*!
131131
* Emits whenever the "isActiveTab" state of a SectionContent changes.
132132
* Whenever the users sets another tab as active, this signal gets invoked
133-
* for the old now inactive tab and the new active tab (the order is unspecified).
133+
* for the old tab and the new active tab (the order is unspecified).
134134
*/
135135
void activeTabChanged(const SectionContent::RefPtr& sc, bool active);
136136

AdvancedDockingSystem/res/ads.qrc

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<file>img/splitter-vertical.png</file>
1515
<file>stylesheets/default-windows.css</file>
1616
<file>stylesheets/vendor-partsolutions.css</file>
17+
<file>stylesheets/modern-windows.css</file>
1718
</qresource>
1819
</RCC>

AdvancedDockingSystem/res/stylesheets/default-windows.css

+50-9
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,69 @@
33
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
44
*/
55

6-
QSplitter::handle {
6+
ads--ContainerWidget,
7+
ContainerWidget
8+
{
79
background: palette(dark);
810
}
911

10-
ads--ContainerWidget, ContainerWidget {
12+
ads--ContainerWidget QSplitter::handle,
13+
ContainerWidget QSplitter::handle
14+
{
1115
background: palette(dark);
1216
}
1317

14-
ads--SectionWidget, SectionWidget {
18+
ads--SectionWidget,
19+
SectionWidget
20+
{
1521
background: palette(window);
22+
border: 1px solid palette(light);
1623
}
1724

18-
ads--SectionTitleWidget, SectionTitleWidget {
25+
ads--SectionTitleWidget,
26+
SectionTitleWidget
27+
{
1928
background: palette(window);
20-
border-right: 1px solid palette(light);
21-
padding: 9px;
29+
border-color: palette(light);
30+
border-style: solid;
31+
border-width: 0 1px 0 0;
32+
padding: 0 9px;
33+
}
34+
35+
ads--SectionTitleWidget[activeTab="true"],
36+
SectionTitleWidget[activeTab="true"]
37+
{
38+
/* background: palette(light);*/
39+
/* background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(255, 255, 255, 255), stop:1 rgba(240, 240, 240, 255));*/
40+
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
2241
}
2342

24-
ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
43+
ads--SectionContentWidget,
44+
SectionContentWidget
45+
{
2546
background: palette(light);
47+
border-color: palette(light);
48+
border-style: solid;
49+
border-width: 1px 0 0 0;
2650
}
2751

28-
ads--SectionContentWidget, SectionContentWidget {
29-
border: 1px solid palette(light);
52+
/* Special: QLabels inside SectionTitleWidget
53+
*/
54+
ads--SectionTitleWidget QLabel,
55+
SectionTitleWidget QLabel
56+
{
57+
color: palette(dark);
58+
}
59+
ads--SectionTitleWidget[activeTab="true"] QLabel,
60+
SectionTitleWidget[activeTab="true"] QLabel
61+
{
62+
color: palette(foreground);
63+
}
64+
65+
/* Special: QLabels inside SectionTitleWidget, which is floating
66+
*/
67+
ads--FloatingWidget ads--SectionTitleWidget QLabel,
68+
FloatingWidget SectionTitleWidget QLabel
69+
{
70+
color: palette(foreground);
3071
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
QSplitter::handle {
2+
background: palette(light);
3+
}
4+
5+
ads--ContainerWidget, ContainerWidget {
6+
background: palette(light);
7+
}
8+
9+
ads--SectionWidget, SectionWidget {
10+
background: palette(light);
11+
}
12+
13+
ads--SectionTitleWidget, SectionTitleWidget {
14+
background: #ffffff;
15+
}
16+
ads--SectionTitleWidget QLabel, SectionTitleWidget QLabel {
17+
color: #000000;
18+
}
19+
20+
ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
21+
background: #000000;
22+
border-right: 1px solid #000000;
23+
padding: 9px;
24+
}
25+
ads--SectionTitleWidget[activeTab="true"] QLabel, SectionTitleWidget[activeTab="true"] QLabel {
26+
color: #ffffff;
27+
}
28+
29+
ads--SectionContentWidget, SectionContentWidget {
30+
border: 1px solid #000000;
31+
}
32+
33+
QAbstractItemView {
34+
border: 0;
35+
}

AdvancedDockingSystemDemo/src/icontitlewidget.cpp

+31-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,41 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidge
1414
setLayout(l);
1515

1616
_iconLabel = new QLabel();
17-
if (!icon.isNull())
18-
_iconLabel->setPixmap(icon.pixmap(16, 16));
1917
l->addWidget(_iconLabel);
2018

2119
_titleLabel = new QLabel();
22-
_titleLabel->setText(title);
2320
l->addWidget(_titleLabel, 1);
21+
22+
setIcon(icon);
23+
setTitle(title);
24+
}
25+
26+
void IconTitleWidget::setIcon(const QIcon& icon)
27+
{
28+
if (icon.isNull())
29+
{
30+
_iconLabel->setPixmap(QPixmap());
31+
_iconLabel->setVisible(false);
32+
}
33+
else
34+
{
35+
_iconLabel->setPixmap(icon.pixmap(16, 16));
36+
_iconLabel->setVisible(true);
37+
}
38+
}
39+
40+
void IconTitleWidget::setTitle(const QString& title)
41+
{
42+
if (title.isEmpty())
43+
{
44+
_titleLabel->setText(QString());
45+
_titleLabel->setVisible(false);
46+
}
47+
else
48+
{
49+
_titleLabel->setText(title);
50+
_titleLabel->setVisible(true);
51+
}
2452
}
2553

2654
void IconTitleWidget::polishUpdate()

AdvancedDockingSystemDemo/src/icontitlewidget.h

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class IconTitleWidget : public QFrame
1212

1313
public:
1414
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);
15+
16+
public slots:
17+
void setIcon(const QIcon& icon);
18+
void setTitle(const QString& title);
1519
void polishUpdate();
1620

1721
public:

AdvancedDockingSystemDemo/src/main.cpp

+12-44
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,27 @@
44

55
#include "mainwindow.h"
66

7-
int main(int argc, char *argv[])
7+
static void initStyleSheet(QApplication& a)
88
{
9-
QApplication a(argc, argv);
10-
a.setQuitOnLastWindowClosed(true);
11-
12-
//Q_INIT_RESOURCE(ads);
13-
14-
// Load style sheet
15-
// QFile f(":/stylesheets/default-windows.css");
16-
QFile f(":/stylesheets/vendor-partsolutions.css");
9+
QFile f(":/stylesheets/default-windows.css");
10+
// QFile f(":/stylesheets/modern-windows.css");
11+
// QFile f(":/stylesheets/vendor-partsolutions.css");
1712
if (f.open(QFile::ReadOnly))
1813
{
1914
QByteArray ba = f.readAll();
2015
f.close();
2116
a.setStyleSheet(QString(ba));
2217
}
18+
}
19+
20+
int main(int argc, char *argv[])
21+
{
22+
QApplication a(argc, argv);
23+
//Q_INIT_RESOURCE(ads);
24+
a.setQuitOnLastWindowClosed(true);
25+
initStyleSheet(a);
2326

2427
MainWindow mw;
2528
mw.show();
2629
return a.exec();
2730
}
28-
29-
// a.setStyleSheet(""
30-
// " QSplitter::handle { border: 1px solid #000000; background: #000000; } "
31-
// " ads--ContainerWidget { border: 1px solid #ff0000; background: #FFE6E6; padding: 6px; } "
32-
// " ads--SectionWidget { border: 1px solid #00ff00; background: #E6FFE6; padding: 6px; } "
33-
// " ads--SectionTitleWidget { border: 1px solid #0000ff; background: #E6E6FF; padding: 6px; } "
34-
// " ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #0000ff; background: #9696FF; padding: 6px; } "
35-
// " ads--SectionContentWidget { border: 1px solid #FFFF00; background: #FFFFE6; padding: 6px; } "
36-
// );
37-
38-
//static void centerWidget(QWidget* widget)
39-
//{
40-
// if (widget)
41-
// {
42-
// QDesktopWidget deskWidget;
43-
// const int screenIndex = deskWidget.primaryScreen();
44-
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
45-
// const int x = (deskRect.width() - widget->rect().width()) / 2;
46-
// const int y = (deskRect.height() - widget->rect().height()) / 2;
47-
// widget->move(x, y);
48-
// }
49-
//}
50-
51-
//static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC)
52-
//{
53-
// if (widget && widthPC >= 0.0 && heightPC >= 0.0)
54-
// {
55-
// QDesktopWidget deskWidget;
56-
// const int screenIndex = deskWidget.primaryScreen();
57-
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
58-
// const int w = (deskRect.width() / 100) * widthPC;
59-
// const int h = (deskRect.height() / 100) * heightPC;
60-
// widget->resize(w, h);
61-
// }
62-
//}

AdvancedDockingSystemDemo/src/mainwindow.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget*
4747
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
4848
{
4949
QTreeView* w = new QTreeView();
50+
w->setFrameShape(QFrame::NoFrame);
5051
// QFileSystemModel* m = new QFileSystemModel(w);
5152
// m->setRootPath(QDir::currentPath());
5253
// w->setModel(m);
@@ -84,14 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
8485
ui(new Ui::MainWindow)
8586
{
8687
ui->setupUi(this);
87-
ui->mainToolBar->hide();
88-
ui->statusBar->hide();
89-
#if QT_VERSION >= 0x050000
90-
QObject::connect(ui->actionAddSectionContent, &QAction::triggered, this, &MainWindow::onActionAddSectionContentTriggered);
91-
#else
92-
QObject::connect(ui->actionAddSectionContent, SIGNAL(triggered(bool)), this, SLOT(onActionAddSectionContentTriggered()));
93-
#endif
9488

89+
// ADS - Create main container (ContainerWidget).
9590
_container = new ADS_NS::ContainerWidget();
9691
_container->setOrientation(Qt::Vertical);
9792
#if QT_VERSION >= 0x050000
@@ -101,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) :
10196
#endif
10297
setCentralWidget(_container);
10398

99+
// ADS - Adding some contents.
104100
// Test #1: Use high-level public API
105101
if (true)
106102
{
@@ -111,17 +107,17 @@ MainWindow::MainWindow(QWidget *parent) :
111107
sw = _container->addSectionContent(createCalendarSC(cw), sw, ADS_NS::RightDropArea);
112108
sw = _container->addSectionContent(createFileSystemTreeSC(cw), sw, ADS_NS::CenterDropArea);
113109

114-
// _container->addSectionContent(createCalendarSC(_container));
115-
// _container->addSectionContent(createLongTextLabelSC(_container));
116-
// _container->addSectionContent(createLongTextLabelSC(_container));
117-
// _container->addSectionContent(createLongTextLabelSC(_container));
110+
_container->addSectionContent(createCalendarSC(_container));
111+
_container->addSectionContent(createLongTextLabelSC(_container));
112+
_container->addSectionContent(createLongTextLabelSC(_container));
113+
_container->addSectionContent(createLongTextLabelSC(_container));
118114
}
119115

120116
// Default window geometry
121117
resize(800, 600);
122-
123-
// Restore window geometry and ContainerWidget state from last session
124118
restoreGeometry(loadDataHelper("MainWindow"));
119+
120+
// ADS - Restore geometries and states of contents.
125121
_container->restoreState(loadDataHelper("ContainerWidget"));
126122
}
127123

AdvancedDockingSystemDemo/src/mainwindow.ui

+42-9
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,6 @@
1414
<string>MainWindow</string>
1515
</property>
1616
<widget class="QWidget" name="centralWidget"/>
17-
<widget class="QToolBar" name="mainToolBar">
18-
<attribute name="toolBarArea">
19-
<enum>TopToolBarArea</enum>
20-
</attribute>
21-
<attribute name="toolBarBreak">
22-
<bool>false</bool>
23-
</attribute>
24-
<addaction name="actionAddSectionContent"/>
25-
</widget>
2617
<widget class="QStatusBar" name="statusBar"/>
2718
<widget class="QMenuBar" name="menuBar">
2819
<property name="geometry">
@@ -33,12 +24,54 @@
3324
<height>21</height>
3425
</rect>
3526
</property>
27+
<widget class="QMenu" name="menuFile">
28+
<property name="title">
29+
<string>File</string>
30+
</property>
31+
<addaction name="actionExit"/>
32+
</widget>
33+
<widget class="QMenu" name="menuView">
34+
<property name="title">
35+
<string>View</string>
36+
</property>
37+
<addaction name="actionDemo_1"/>
38+
<addaction name="actionDemo_2"/>
39+
<addaction name="actionDemo_3"/>
40+
</widget>
41+
<widget class="QMenu" name="menuAbout">
42+
<property name="title">
43+
<string>About</string>
44+
</property>
45+
</widget>
46+
<addaction name="menuFile"/>
47+
<addaction name="menuView"/>
48+
<addaction name="menuAbout"/>
3649
</widget>
3750
<action name="actionAddSectionContent">
3851
<property name="text">
3952
<string>Add SectionContent</string>
4053
</property>
4154
</action>
55+
<action name="actionDemo_1">
56+
<property name="text">
57+
<string>Demo 1</string>
58+
</property>
59+
</action>
60+
<action name="actionDemo_2">
61+
<property name="text">
62+
<string>Demo 2</string>
63+
</property>
64+
</action>
65+
<action name="actionDemo_3">
66+
<property name="text">
67+
<string>Demo 3</string>
68+
</property>
69+
</action>
70+
<action name="actionExit">
71+
<property name="text">
72+
<string>Exit</string>
73+
</property>
74+
</action>
4275
</widget>
4376
<layoutdefault spacing="6" margin="11"/>
4477
<resources/>

0 commit comments

Comments
 (0)