From a19ead9728381c41f18fa59ad79c02f863f15977 Mon Sep 17 00:00:00 2001 From: johanneshilden Date: Thu, 28 Sep 2017 15:52:06 +0300 Subject: [PATCH] Split project setup into executable and lib parts --- components/components.pro | 13 +++++++++++ {lib => components/lib}/qtmaterialstyle.cpp | 0 {lib => components/lib}/qtmaterialstyle.h | 2 +- {lib => components/lib}/qtmaterialstyle_p.h | 0 {lib => components/lib}/qtmaterialtheme.cpp | 0 {lib => components/lib}/qtmaterialtheme.h | 0 {lib => components/lib}/qtmaterialtheme_p.h | 0 components/qtmaterialavatar.cpp | 4 ++-- components/qtmaterialavatar.h | 2 +- examples/examples.pro | 7 ++++++ main.cpp => examples/main.cpp | 8 ++++--- examples/mainwindow.cpp | 26 +++++++++++++++++++++ mainwindow.h => examples/mainwindow.h | 2 +- mainwindow.cpp | 10 -------- qt-material-widgets.pro | 26 ++------------------- 15 files changed, 58 insertions(+), 42 deletions(-) create mode 100644 components/components.pro rename {lib => components/lib}/qtmaterialstyle.cpp (100%) rename {lib => components/lib}/qtmaterialstyle.h (95%) rename {lib => components/lib}/qtmaterialstyle_p.h (100%) rename {lib => components/lib}/qtmaterialtheme.cpp (100%) rename {lib => components/lib}/qtmaterialtheme.h (100%) rename {lib => components/lib}/qtmaterialtheme_p.h (100%) create mode 100644 examples/examples.pro rename main.cpp => examples/main.cpp (54%) create mode 100644 examples/mainwindow.cpp rename mainwindow.h => examples/mainwindow.h (85%) delete mode 100644 mainwindow.cpp diff --git a/components/components.pro b/components/components.pro new file mode 100644 index 0000000..fe8e37a --- /dev/null +++ b/components/components.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += staticlib +SOURCES = \ + qtmaterialavatar.cpp \ + lib/qtmaterialstyle.cpp \ + lib/qtmaterialtheme.cpp +HEADERS = \ + qtmaterialavatar_p.h \ + qtmaterialavatar.h \ + lib/qtmaterialstyle_p.h \ + lib/qtmaterialstyle.h \ + lib/qtmaterialtheme_p.h \ + lib/qtmaterialtheme.h diff --git a/lib/qtmaterialstyle.cpp b/components/lib/qtmaterialstyle.cpp similarity index 100% rename from lib/qtmaterialstyle.cpp rename to components/lib/qtmaterialstyle.cpp diff --git a/lib/qtmaterialstyle.h b/components/lib/qtmaterialstyle.h similarity index 95% rename from lib/qtmaterialstyle.h rename to components/lib/qtmaterialstyle.h index 7ae7ab9..db10353 100644 --- a/lib/qtmaterialstyle.h +++ b/components/lib/qtmaterialstyle.h @@ -1,7 +1,7 @@ #ifndef QTMATERIALSTYLE_H #define QTMATERIALSTYLE_H -#include +#include #include "lib/qtmaterialstyle_p.h" class QtMaterialTheme; diff --git a/lib/qtmaterialstyle_p.h b/components/lib/qtmaterialstyle_p.h similarity index 100% rename from lib/qtmaterialstyle_p.h rename to components/lib/qtmaterialstyle_p.h diff --git a/lib/qtmaterialtheme.cpp b/components/lib/qtmaterialtheme.cpp similarity index 100% rename from lib/qtmaterialtheme.cpp rename to components/lib/qtmaterialtheme.cpp diff --git a/lib/qtmaterialtheme.h b/components/lib/qtmaterialtheme.h similarity index 100% rename from lib/qtmaterialtheme.h rename to components/lib/qtmaterialtheme.h diff --git a/lib/qtmaterialtheme_p.h b/components/lib/qtmaterialtheme_p.h similarity index 100% rename from lib/qtmaterialtheme_p.h rename to components/lib/qtmaterialtheme_p.h diff --git a/components/qtmaterialavatar.cpp b/components/qtmaterialavatar.cpp index 3c76265..08d09ed 100644 --- a/components/qtmaterialavatar.cpp +++ b/components/qtmaterialavatar.cpp @@ -1,5 +1,5 @@ -#include "components/qtmaterialavatar.h" -#include "components/qtmaterialavatar_p.h" +#include "qtmaterialavatar.h" +#include "qtmaterialavatar_p.h" #include #include "lib/qtmaterialstyle.h" diff --git a/components/qtmaterialavatar.h b/components/qtmaterialavatar.h index c1cab88..9b99ef2 100644 --- a/components/qtmaterialavatar.h +++ b/components/qtmaterialavatar.h @@ -1,7 +1,7 @@ #ifndef QTMATERIALAVATAR_H #define QTMATERIALAVATAR_H -#include +#include #include "lib/qtmaterialtheme.h" class QtMaterialAvatarPrivate; diff --git a/examples/examples.pro b/examples/examples.pro new file mode 100644 index 0000000..8a1c7fd --- /dev/null +++ b/examples/examples.pro @@ -0,0 +1,7 @@ +QT += core gui widgets +TEMPLATE = app +SOURCES = mainwindow.cpp main.cpp +HEADERS = mainwindow.h +LIBS += ../components/libcomponents.a +INCLUDEPATH += ../components/ +TARGET = ../examples-exe diff --git a/main.cpp b/examples/main.cpp similarity index 54% rename from main.cpp rename to examples/main.cpp index b48f94e..e41b03d 100644 --- a/main.cpp +++ b/examples/main.cpp @@ -1,11 +1,13 @@ +#include +#include #include "mainwindow.h" -#include int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; - w.show(); + + MainWindow window; + window.show(); return a.exec(); } diff --git a/examples/mainwindow.cpp b/examples/mainwindow.cpp new file mode 100644 index 0000000..cd1c3d3 --- /dev/null +++ b/examples/mainwindow.cpp @@ -0,0 +1,26 @@ +#include "mainwindow.h" +#include +#include + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + QtMaterialAvatar *avatars[3]; + avatars[0] = new QtMaterialAvatar; + avatars[1] = new QtMaterialAvatar('W'); + avatars[2] = new QtMaterialAvatar; + + QWidget *widget = new QWidget; + QVBoxLayout *layout = new QVBoxLayout; + + widget->setLayout(layout); + setCentralWidget(widget); + + layout->addWidget(avatars[0]); + layout->addWidget(avatars[1]); + layout->addWidget(avatars[2]); +} + +MainWindow::~MainWindow() +{ +} diff --git a/mainwindow.h b/examples/mainwindow.h similarity index 85% rename from mainwindow.h rename to examples/mainwindow.h index f834c00..1f39a8c 100644 --- a/mainwindow.h +++ b/examples/mainwindow.h @@ -1,7 +1,7 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -#include +#include class MainWindow : public QMainWindow { diff --git a/mainwindow.cpp b/mainwindow.cpp deleted file mode 100644 index 689c798..0000000 --- a/mainwindow.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ -} - -MainWindow::~MainWindow() -{ -} diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro index fb44d77..dc19ed5 100644 --- a/qt-material-widgets.pro +++ b/qt-material-widgets.pro @@ -1,15 +1,8 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2017-09-28T12:54:30 -# -#------------------------------------------------- - -QT += core gui - greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = qt-material-widgets -TEMPLATE = app +TEMPLATE = subdirs +SUBDIRS = components examples # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked as deprecated (the exact warnings @@ -21,18 +14,3 @@ DEFINES += QT_DEPRECATED_WARNINGS # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 - - -SOURCES += main.cpp\ - mainwindow.cpp \ - components/qtmaterialavatar.cpp \ - lib/qtmaterialstyle.cpp \ - lib/qtmaterialtheme.cpp - -HEADERS += mainwindow.h \ - components/qtmaterialavatar_p.h \ - components/qtmaterialavatar.h \ - lib/qtmaterialstyle_p.h \ - lib/qtmaterialstyle.h \ - lib/qtmaterialtheme_p.h \ - lib/qtmaterialtheme.h