diff --git a/demo/main.cpp b/demo/main.cpp index f67f69f..44e1b7a 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -5,17 +5,6 @@ #include "mainwindow.h" -static void initStyleSheet(QApplication& a) -{ - QFile f(":ads/stylesheets/default-windows2.css"); - if (f.open(QFile::ReadOnly)) - { - const QByteArray ba = f.readAll(); - f.close(); - a.setStyleSheet(QString(ba)); - } -} - void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { @@ -46,7 +35,6 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setQuitOnLastWindowClosed(true); - initStyleSheet(a); qInstallMessageHandler(myMessageOutput); qDebug() << "Message handler test"; diff --git a/demo/mainwindow.cpp b/demo/mainwindow.cpp index eb4fa3e..bc2fa26 100644 --- a/demo/mainwindow.cpp +++ b/demo/mainwindow.cpp @@ -111,7 +111,7 @@ void MainWindow::createContent() m_DockManager->addDockWidget(ads::LeftDockWidgetArea, DockWidget); m_DockManager->addDockWidget(ads::LeftDockWidgetArea, createLongTextLabelDockWidget(ViewMenu)); m_DockManager->addDockWidget(ads::BottomDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu)); - /*auto TopDockArea = m_DockManager->addDockWidget(ads::TopDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu)); + auto TopDockArea = m_DockManager->addDockWidget(ads::TopDockWidgetArea, createFileSystemTreeDockWidget(ViewMenu)); DockWidget = createCalendarDockWidget(ViewMenu); DockWidget->setFeatures(DockWidget->features().setFlag(ads::CDockWidget::DockWidgetClosable, false)); m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DockWidget, TopDockArea); @@ -121,15 +121,15 @@ void MainWindow::createContent() m_DockManager->addDockWidget(ads::TopDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); auto BottomDockArea = m_DockManager->addDockWidget(ads::BottomDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); m_DockManager->addDockWidget(ads::RightDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), RighDockArea); - m_DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea);*/ + m_DockManager->addDockWidget(ads::CenterDockWidgetArea, createLongTextLabelDockWidget(ViewMenu), BottomDockArea); } void MainWindow::closeEvent(QCloseEvent* event) { - /*QSettings Settings("Settings.ini", QSettings::IniFormat); + QSettings Settings("Settings.ini", QSettings::IniFormat); Settings.setValue("mainWindow/Geometry", saveGeometry()); - Settings.setValue("mainWindow/DockingState", m_DockManager->saveState());*/ + Settings.setValue("mainWindow/DockingState", m_DockManager->saveState()); QMainWindow::closeEvent(event); } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 7a2f021..fd8b142 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include "FloatingDockContainer.h" #include "DockOverlay.h" @@ -78,6 +80,11 @@ struct DockManagerPrivate * Restores the container with the given index */ bool restoreContainer(int Index, QDataStream& stream, bool Testing); + + /** + * Loads the stylesheet + */ + void loadStylesheet(); }; // struct DockManagerPrivate @@ -89,6 +96,19 @@ DockManagerPrivate::DockManagerPrivate(CDockManager* _public) : } +//============================================================================ +void DockManagerPrivate::loadStylesheet() +{ + QString Result; + QFile StyleSheetFile(":ads/stylesheets/default.css"); + StyleSheetFile.open(QIODevice::ReadOnly); + QTextStream StyleSheetStream(&StyleSheetFile); + Result = StyleSheetStream.readAll(); + StyleSheetFile.close(); + _this->setStyleSheet(Result); +} + + //============================================================================ bool DockManagerPrivate::checkFormat(const QByteArray &state, int version) { @@ -202,6 +222,7 @@ CDockManager::CDockManager(QWidget *parent) : d->DockAreaOverlay = new CDockOverlay(this, CDockOverlay::ModeDockAreaOverlay); d->ContainerOverlay = new CDockOverlay(this, CDockOverlay::ModeContainerOverlay); d->Containers.append(this); + d->loadStylesheet(); } //============================================================================ @@ -314,11 +335,17 @@ bool CDockManager::restoreState(const QByteArray &state, int version) DockWidget->setProperty("dirty", true); } + //this->hide(); + QMainWindow* MainWindow = internal::findParent(this); + MainWindow->hide(); + QApplication::processEvents(); if (!d->restoreState(state, version)) { qDebug() << "restoreState: Error restoring state!!!!!!!"; return false; } + MainWindow->show(); + // this->show(); // All dock widgets, that have not been processed in the restore state // function are invisible to the user now and have no assigned dock area diff --git a/src/ads.qrc b/src/ads.qrc index dcf3ae7..81aa482 100644 --- a/src/ads.qrc +++ b/src/ads.qrc @@ -1,8 +1,5 @@ - stylesheets/default-windows.css - stylesheets/vendor-partsolutions.css - stylesheets/modern-windows.css - stylesheets/default-windows2.css + stylesheets/default.css diff --git a/src/stylesheets/default-windows.css b/src/stylesheets/default-windows.css deleted file mode 100644 index 6fb505b..0000000 --- a/src/stylesheets/default-windows.css +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Default style sheet on Windows Platforms - * Note: Always use CSS-classes with and without "ads--" namespace to support Qt4 & Qt5 - */ - -ads--ContainerWidget, -ContainerWidget -{ - background: palette(dark); -} - -ads--ContainerWidget QSplitter::handle, -ContainerWidget QSplitter::handle -{ - background: palette(dark); -} - -ads--SectionWidget, -SectionWidget -{ - background: palette(window); - border: 1px solid palette(light); -} - -ads--SectionWidget #tabsMenuButton::menu-indicator, -SectionWidget #tabsMenuButton::menu-indicator -{ - image: none; -} - -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/src/stylesheets/default-windows2.css b/src/stylesheets/default.css similarity index 100% rename from src/stylesheets/default-windows2.css rename to src/stylesheets/default.css diff --git a/src/stylesheets/modern-windows.css b/src/stylesheets/modern-windows.css deleted file mode 100644 index 64d683c..0000000 --- a/src/stylesheets/modern-windows.css +++ /dev/null @@ -1,35 +0,0 @@ -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/src/stylesheets/vendor-partsolutions.css b/src/stylesheets/vendor-partsolutions.css deleted file mode 100644 index d73bbae..0000000 --- a/src/stylesheets/vendor-partsolutions.css +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Style sheet used by CADENAS PARTsolutions product line - * Requires Qt4 compatibility - */ - -QSplitter::handle:vertical { - image: url(:/img/splitter-horizontal.png); -} - -QSplitter::handle:horizontal { - image: url(:/img/splitter-vertical.png); -} - -ads--ContainerWidget, ContainerWidget { - background: #9ab6ca; - border: 0; -} - -ads--SectionWidget, SectionWidget { - background: #7c9eb3; - border-color: #ffffff; - border-style: solid; - border-width: 1px; -} - -ads--SectionTitleWidget, SectionTitleWidget { - background: #7c9eb3; - border-right: 1px solid #E7F3F8; - padding: 6px 6px; -} - -ads--SectionTitleWidget[activeTab="true"], SectionTitleWidget[activeTab="true"] { - background: #E7F3F8; - border: 1px solid #E7F3F8; -} - -ads--SectionWidget QPushButton#closeButton, SectionWidget QPushButton#closeButton, -ads--FloatingWidget QPushButton#closeButton, FloatingWidget QPushButton#closeButton { - background: #ff0000; - border: 1px solid red; -} - -ads--SectionContentWidget, SectionContentWidget { - background: #ffffff; - border: 0px solid #E7F3F8; -} - -/* Special */ - -IconTitleWidget { - padding: 0; - margin: 0; -} - -ads--SectionTitleWidget QLabel, SectionTitleWidget QLabel { - color: #ffffff; - background: #7c9eb3; -} - -ads--SectionTitleWidget[activeTab="true"] QLabel, SectionTitleWidget[activeTab="true"] QLabel { - color: #000000; - background: #E7F3F8; -} \ No newline at end of file