Skip to content

Commit

Permalink
Updates default stylesheet and demo app
Browse files Browse the repository at this point in the history
  • Loading branch information
mfreiholz committed Mar 8, 2016
1 parent 9bbc5e4 commit 34cf851
Show file tree
Hide file tree
Showing 14 changed files with 188 additions and 82 deletions.
4 changes: 2 additions & 2 deletions AdvancedDockingSystem/include/ads/ContainerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class InternalContentData;

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

Expand Down
1 change: 1 addition & 0 deletions AdvancedDockingSystem/res/ads.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
<file>img/splitter-vertical.png</file>
<file>stylesheets/default-windows.css</file>
<file>stylesheets/vendor-partsolutions.css</file>
<file>stylesheets/modern-windows.css</file>
</qresource>
</RCC>
59 changes: 50 additions & 9 deletions AdvancedDockingSystem/res/stylesheets/default-windows.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,69 @@
* Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5
*/

QSplitter::handle {
ads--ContainerWidget,
ContainerWidget
{
background: palette(dark);
}

ads--ContainerWidget, ContainerWidget {
ads--ContainerWidget QSplitter::handle,
ContainerWidget QSplitter::handle
{
background: palette(dark);
}

ads--SectionWidget, SectionWidget {
ads--SectionWidget,
SectionWidget
{
background: palette(window);
border: 1px solid palette(light);
}

ads--SectionTitleWidget, SectionTitleWidget {
ads--SectionTitleWidget,
SectionTitleWidget
{
background: palette(window);
border-right: 1px solid palette(light);
padding: 9px;
border-color: palette(light);
border-style: solid;
border-width: 0 1px 0 0;
padding: 0 9px;
}

ads--SectionTitleWidget[activeTab="true"],
SectionTitleWidget[activeTab="true"]
{
/* background: palette(light);*/
/* 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));*/
background: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:0.5, stop:0 palette(window), stop:1 palette(light));
}

ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
ads--SectionContentWidget,
SectionContentWidget
{
background: palette(light);
border-color: palette(light);
border-style: solid;
border-width: 1px 0 0 0;
}

ads--SectionContentWidget, SectionContentWidget {
border: 1px solid palette(light);
/* Special: QLabels inside SectionTitleWidget
*/
ads--SectionTitleWidget QLabel,
SectionTitleWidget QLabel
{
color: palette(dark);
}
ads--SectionTitleWidget[activeTab="true"] QLabel,
SectionTitleWidget[activeTab="true"] QLabel
{
color: palette(foreground);
}

/* Special: QLabels inside SectionTitleWidget, which is floating
*/
ads--FloatingWidget ads--SectionTitleWidget QLabel,
FloatingWidget SectionTitleWidget QLabel
{
color: palette(foreground);
}
35 changes: 35 additions & 0 deletions AdvancedDockingSystem/res/stylesheets/modern-windows.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
QSplitter::handle {
background: palette(light);
}

ads--ContainerWidget, ContainerWidget {
background: palette(light);
}

ads--SectionWidget, SectionWidget {
background: palette(light);
}

ads--SectionTitleWidget, SectionTitleWidget {
background: #ffffff;
}
ads--SectionTitleWidget QLabel, SectionTitleWidget QLabel {
color: #000000;
}

ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] {
background: #000000;
border-right: 1px solid #000000;
padding: 9px;
}
ads--SectionTitleWidget[activeTab="true"] QLabel, SectionTitleWidget[activeTab="true"] QLabel {
color: #ffffff;
}

ads--SectionContentWidget, SectionContentWidget {
border: 1px solid #000000;
}

QAbstractItemView {
border: 0;
}
34 changes: 31 additions & 3 deletions AdvancedDockingSystemDemo/src/icontitlewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,41 @@ IconTitleWidget::IconTitleWidget(const QIcon& icon, const QString& title, QWidge
setLayout(l);

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

_titleLabel = new QLabel();
_titleLabel->setText(title);
l->addWidget(_titleLabel, 1);

setIcon(icon);
setTitle(title);
}

void IconTitleWidget::setIcon(const QIcon& icon)
{
if (icon.isNull())
{
_iconLabel->setPixmap(QPixmap());
_iconLabel->setVisible(false);
}
else
{
_iconLabel->setPixmap(icon.pixmap(16, 16));
_iconLabel->setVisible(true);
}
}

void IconTitleWidget::setTitle(const QString& title)
{
if (title.isEmpty())
{
_titleLabel->setText(QString());
_titleLabel->setVisible(false);
}
else
{
_titleLabel->setText(title);
_titleLabel->setVisible(true);
}
}

void IconTitleWidget::polishUpdate()
Expand Down
4 changes: 4 additions & 0 deletions AdvancedDockingSystemDemo/src/icontitlewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class IconTitleWidget : public QFrame

public:
explicit IconTitleWidget(const QIcon& icon, const QString& title, QWidget *parent = 0);

public slots:
void setIcon(const QIcon& icon);
void setTitle(const QString& title);
void polishUpdate();

public:
Expand Down
56 changes: 12 additions & 44 deletions AdvancedDockingSystemDemo/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,27 @@

#include "mainwindow.h"

int main(int argc, char *argv[])
static void initStyleSheet(QApplication& a)
{
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(true);

//Q_INIT_RESOURCE(ads);

// Load style sheet
// QFile f(":/stylesheets/default-windows.css");
QFile f(":/stylesheets/vendor-partsolutions.css");
QFile f(":/stylesheets/default-windows.css");
// QFile f(":/stylesheets/modern-windows.css");
// QFile f(":/stylesheets/vendor-partsolutions.css");
if (f.open(QFile::ReadOnly))
{
QByteArray ba = f.readAll();
f.close();
a.setStyleSheet(QString(ba));
}
}

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//Q_INIT_RESOURCE(ads);
a.setQuitOnLastWindowClosed(true);
initStyleSheet(a);

MainWindow mw;
mw.show();
return a.exec();
}

// a.setStyleSheet(""
// " QSplitter::handle { border: 1px solid #000000; background: #000000; } "
// " ads--ContainerWidget { border: 1px solid #ff0000; background: #FFE6E6; padding: 6px; } "
// " ads--SectionWidget { border: 1px solid #00ff00; background: #E6FFE6; padding: 6px; } "
// " ads--SectionTitleWidget { border: 1px solid #0000ff; background: #E6E6FF; padding: 6px; } "
// " ads--SectionTitleWidget[activeTab=\"true\"] { border: 1px solid #0000ff; background: #9696FF; padding: 6px; } "
// " ads--SectionContentWidget { border: 1px solid #FFFF00; background: #FFFFE6; padding: 6px; } "
// );

//static void centerWidget(QWidget* widget)
//{
// if (widget)
// {
// QDesktopWidget deskWidget;
// const int screenIndex = deskWidget.primaryScreen();
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
// const int x = (deskRect.width() - widget->rect().width()) / 2;
// const int y = (deskRect.height() - widget->rect().height()) / 2;
// widget->move(x, y);
// }
//}

//static void resizeWidgetPerCent(QWidget* widget, qreal widthPC, qreal heightPC)
//{
// if (widget && widthPC >= 0.0 && heightPC >= 0.0)
// {
// QDesktopWidget deskWidget;
// const int screenIndex = deskWidget.primaryScreen();
// const QRect deskRect = deskWidget.availableGeometry(screenIndex);
// const int w = (deskRect.width() / 100) * widthPC;
// const int h = (deskRect.height() / 100) * heightPC;
// widget->resize(w, h);
// }
//}
22 changes: 9 additions & 13 deletions AdvancedDockingSystemDemo/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static ADS_NS::SectionContent::RefPtr createCalendarSC(ADS_NS::ContainerWidget*
static ADS_NS::SectionContent::RefPtr createFileSystemTreeSC(ADS_NS::ContainerWidget* container)
{
QTreeView* w = new QTreeView();
w->setFrameShape(QFrame::NoFrame);
// QFileSystemModel* m = new QFileSystemModel(w);
// m->setRootPath(QDir::currentPath());
// w->setModel(m);
Expand Down Expand Up @@ -84,14 +85,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->mainToolBar->hide();
ui->statusBar->hide();
#if QT_VERSION >= 0x050000
QObject::connect(ui->actionAddSectionContent, &QAction::triggered, this, &MainWindow::onActionAddSectionContentTriggered);
#else
QObject::connect(ui->actionAddSectionContent, SIGNAL(triggered(bool)), this, SLOT(onActionAddSectionContentTriggered()));
#endif

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

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

// _container->addSectionContent(createCalendarSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
// _container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createCalendarSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
_container->addSectionContent(createLongTextLabelSC(_container));
}

// Default window geometry
resize(800, 600);

// Restore window geometry and ContainerWidget state from last session
restoreGeometry(loadDataHelper("MainWindow"));

// ADS - Restore geometries and states of contents.
_container->restoreState(loadDataHelper("ContainerWidget"));
}

Expand Down
51 changes: 42 additions & 9 deletions AdvancedDockingSystemDemo/src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actionAddSectionContent"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
Expand All @@ -33,12 +24,54 @@
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuView">
<property name="title">
<string>View</string>
</property>
<addaction name="actionDemo_1"/>
<addaction name="actionDemo_2"/>
<addaction name="actionDemo_3"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
<string>About</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuAbout"/>
</widget>
<action name="actionAddSectionContent">
<property name="text">
<string>Add SectionContent</string>
</property>
</action>
<action name="actionDemo_1">
<property name="text">
<string>Demo 1</string>
</property>
</action>
<action name="actionDemo_2">
<property name="text">
<string>Demo 2</string>
</property>
</action>
<action name="actionDemo_3">
<property name="text">
<string>Demo 3</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
Expand Down
Loading

0 comments on commit 34cf851

Please sign in to comment.