From 94b1fc85fc8fb385c308dac350e1dbc2bf2a0ddc Mon Sep 17 00:00:00 2001 From: mfreiholz Date: Mon, 18 Apr 2016 12:47:42 +0200 Subject: [PATCH] Use prefix for resources. Updates demo project and README with clean main() and initStyleSheet(). --- AdvancedDockingSystem/res/ads.qrc | 2 +- AdvancedDockingSystemDemo/src/main.cpp | 8 +++----- README.md | 25 ++++++++++++++++++++++++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/AdvancedDockingSystem/res/ads.qrc b/AdvancedDockingSystem/res/ads.qrc index e3dd656..ce64016 100644 --- a/AdvancedDockingSystem/res/ads.qrc +++ b/AdvancedDockingSystem/res/ads.qrc @@ -1,5 +1,5 @@ - + stylesheets/default-windows.css stylesheets/vendor-partsolutions.css stylesheets/modern-windows.css diff --git a/AdvancedDockingSystemDemo/src/main.cpp b/AdvancedDockingSystemDemo/src/main.cpp index e2edfc1..620f65e 100644 --- a/AdvancedDockingSystemDemo/src/main.cpp +++ b/AdvancedDockingSystemDemo/src/main.cpp @@ -6,12 +6,11 @@ static void initStyleSheet(QApplication& a) { - QFile f(":/stylesheets/default-windows.css"); -// QFile f(":/stylesheets/modern-windows.css"); -// QFile f(":/stylesheets/vendor-partsolutions.css"); + //Q_INIT_RESOURCE(ads); // If static linked. + QFile f(":ads/stylesheets/default-windows.css"); if (f.open(QFile::ReadOnly)) { - QByteArray ba = f.readAll(); + const QByteArray ba = f.readAll(); f.close(); a.setStyleSheet(QString(ba)); } @@ -20,7 +19,6 @@ static void initStyleSheet(QApplication& a) int main(int argc, char *argv[]) { QApplication a(argc, argv); - //Q_INIT_RESOURCE(ads); a.setQuitOnLastWindowClosed(true); initStyleSheet(a); diff --git a/README.md b/README.md index 5b0d407..16e5d66 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Advanced Docking System -![Travis Build](https://travis-ci.org/mfreiholz/Qt-Advanced-Docking-System.svg?branch=master) +[![Travis Build](https://travis-ci.org/mfreiholz/Qt-Advanced-Docking-System.svg?branch=master)](https://travis-ci.org/mfreiholz/Qt-Advanced-Docking-System) Manages content widgets more like Visual Studio or similar programs. I also try to get everything done with basic Qt functionality. @@ -59,6 +59,29 @@ MyWindow::MyWindow(QWidget* parent) : QMainWindow(parent) _sc1 = ADS_NS::SectionContent::newSectionContent(QString("Unique-Internal-Name"), _container, new QLabel("Visible Title"), new QLabel("Content Widget")); _container->addSectionContent(_sc1, NULL, ADS_NS::CenterDropArea); } + +static void initStyleSheet(QApplication& a) +{ + //Q_INIT_RESOURCE(ads); // If static linked. + QFile f(":ads/stylesheets/default-windows.css"); + if (f.open(QFile::ReadOnly)) + { + const QByteArray ba = f.readAll(); + f.close(); + a.setStyleSheet(QString(ba)); + } +} + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + a.setQuitOnLastWindowClosed(true); + initStyleSheet(a); + + MainWindow mw; + mw.show(); + return a.exec(); +} ``` ## Developers