diff --git a/AdvancedDockingSystem/include/ads/ContainerWidget.h b/AdvancedDockingSystem/include/ads/ContainerWidget.h index cb18624..36c0b56 100644 --- a/AdvancedDockingSystem/include/ads/ContainerWidget.h +++ b/AdvancedDockingSystem/include/ads/ContainerWidget.h @@ -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 { @@ -130,7 +130,7 @@ signals: /*! * 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); diff --git a/AdvancedDockingSystem/res/ads.qrc b/AdvancedDockingSystem/res/ads.qrc index 9846f49..c862541 100644 --- a/AdvancedDockingSystem/res/ads.qrc +++ b/AdvancedDockingSystem/res/ads.qrc @@ -14,5 +14,6 @@ img/splitter-vertical.png stylesheets/default-windows.css stylesheets/vendor-partsolutions.css + stylesheets/modern-windows.css diff --git a/AdvancedDockingSystem/res/stylesheets/default-windows.css b/AdvancedDockingSystem/res/stylesheets/default-windows.css index 89e6992..5801978 100644 --- a/AdvancedDockingSystem/res/stylesheets/default-windows.css +++ b/AdvancedDockingSystem/res/stylesheets/default-windows.css @@ -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); -} - -ads--SectionTitleWidget, SectionTitleWidget { - background: palette(window); - border-right: 1px solid palette(light); - padding: 9px; -} - -ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] { - background: palette(light); -} - -ads--SectionContentWidget, SectionContentWidget { border: 1px solid palette(light); } + +ads--SectionTitleWidget, +SectionTitleWidget +{ + background: palette(window); + 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--SectionContentWidget, +SectionContentWidget +{ + background: palette(light); + border-color: palette(light); + border-style: solid; + border-width: 1px 0 0 0; +} + +/* 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); +} diff --git a/AdvancedDockingSystem/res/stylesheets/modern-windows.css b/AdvancedDockingSystem/res/stylesheets/modern-windows.css new file mode 100644 index 0000000..7bb5773 --- /dev/null +++ b/AdvancedDockingSystem/res/stylesheets/modern-windows.css @@ -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; +} \ No newline at end of file diff --git a/AdvancedDockingSystemDemo/src/icontitlewidget.cpp b/AdvancedDockingSystemDemo/src/icontitlewidget.cpp index f5f8d2e..9bf7b45 100644 --- a/AdvancedDockingSystemDemo/src/icontitlewidget.cpp +++ b/AdvancedDockingSystemDemo/src/icontitlewidget.cpp @@ -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() diff --git a/AdvancedDockingSystemDemo/src/icontitlewidget.h b/AdvancedDockingSystemDemo/src/icontitlewidget.h index 4be1582..35bb982 100644 --- a/AdvancedDockingSystemDemo/src/icontitlewidget.h +++ b/AdvancedDockingSystemDemo/src/icontitlewidget.h @@ -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: diff --git a/AdvancedDockingSystemDemo/src/main.cpp b/AdvancedDockingSystemDemo/src/main.cpp index f723add..e2edfc1 100644 --- a/AdvancedDockingSystemDemo/src/main.cpp +++ b/AdvancedDockingSystemDemo/src/main.cpp @@ -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); -// } -//} diff --git a/AdvancedDockingSystemDemo/src/mainwindow.cpp b/AdvancedDockingSystemDemo/src/mainwindow.cpp index e383fee..2164af4 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.cpp +++ b/AdvancedDockingSystemDemo/src/mainwindow.cpp @@ -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); @@ -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 @@ -101,6 +96,7 @@ MainWindow::MainWindow(QWidget *parent) : #endif setCentralWidget(_container); + // ADS - Adding some contents. // Test #1: Use high-level public API if (true) { @@ -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")); } diff --git a/AdvancedDockingSystemDemo/src/mainwindow.ui b/AdvancedDockingSystemDemo/src/mainwindow.ui index 9f3fd73..cc65f8b 100644 --- a/AdvancedDockingSystemDemo/src/mainwindow.ui +++ b/AdvancedDockingSystemDemo/src/mainwindow.ui @@ -14,15 +14,6 @@ MainWindow - - - TopToolBarArea - - - false - - - @@ -33,12 +24,54 @@ 21 + + + File + + + + + + View + + + + + + + + About + + + + + Add SectionContent + + + Demo 1 + + + + + Demo 2 + + + + + Demo 3 + + + + + Exit + + diff --git a/README.md b/README.md index fe80f37..ff00194 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ Manages content widgets more like Visual Studio or similar programs. I also try to get everything done with basic Qt functionality. Basic usage of QWidgets an QLayouts and using basic styles as much as possible. -![Layout of widgets](preview01.png) -![Dropping widgets](preview02.png) +![Layout of widgets](preview.png) +![Dropping widgets](preview-dragndrop.png) ## Tested Compatible Environments - Windows 10 / Qt 5.5.1 / VC12 diff --git a/preview-dragndrop.png b/preview-dragndrop.png new file mode 100644 index 0000000..1ebabca Binary files /dev/null and b/preview-dragndrop.png differ diff --git a/preview.png b/preview.png new file mode 100644 index 0000000..38f3c6d Binary files /dev/null and b/preview.png differ diff --git a/preview01.png b/preview01.png deleted file mode 100644 index d879ae3..0000000 Binary files a/preview01.png and /dev/null differ diff --git a/preview02.png b/preview02.png deleted file mode 100644 index b45f8a4..0000000 Binary files a/preview02.png and /dev/null differ