From 6c1e3f62fb7141a49c4655377032e88d36403bed Mon Sep 17 00:00:00 2001 From: kelteseth Date: Sun, 23 Apr 2017 12:53:00 +0200 Subject: [PATCH] Add new c++ classes --- ScreenPlay.pro | 27 ++++++++++++++------------ main.cpp | 26 +++++++++++++++++-------- src/backend.cpp | 11 +++++++++++ src/backend.h | 19 ++++++++++++++++++ src/mainwindow.cpp | 6 ------ src/mainwindow.h | 17 ---------------- src/monitors.cpp | 34 ++++++++++++++++++++++++++++++++ src/monitors.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++ src/screenplay.cpp | 1 - 9 files changed, 145 insertions(+), 44 deletions(-) create mode 100644 src/backend.cpp create mode 100644 src/backend.h delete mode 100644 src/mainwindow.cpp delete mode 100644 src/mainwindow.h create mode 100644 src/monitors.cpp create mode 100644 src/monitors.h diff --git a/ScreenPlay.pro b/ScreenPlay.pro index 0a83e69d..879583b5 100644 --- a/ScreenPlay.pro +++ b/ScreenPlay.pro @@ -1,14 +1,16 @@ TEMPLATE = app -QT += qml quick gui opengl gui +QT += qml quick av widgets CONFIG += c++14 SOURCES += main.cpp \ src/screenplay.cpp \ src/steamworkshop.cpp \ src/installedlistmodel.cpp \ - src/mainwindow.cpp \ + src/backend.cpp \ + src/monitors.cpp \ +include(ThirdParty/qsyncable/qsyncable.pri) RESOURCES += qml.qrc @@ -38,20 +40,21 @@ HEADERS += \ src/screenplay.h \ src/steamworkshop.h \ src/installedlistmodel.h \ - src/mainwindow.h + src/backend.h \ + src/monitors.h \ INCLUDEPATH += $$PWD/ThirdParty/Steam/ INCLUDEPATH += $$PWD/src/ -contains(QT_ARCH, i386) { - #32-bit - win32: LIBS += -L$$PWD/ThirdParty/Steam/redistributable_bin/ -lsteam_api - DEPENDPATH += $$PWD/ThirdParty/Steam/redistributable_bin/ -} else { - #64-bit - win32: LIBS += -L$$PWD/ThirdParty/Steam/redistributable_bin/win64/ -lsteam_api64 - DEPENDPATH += $$PWD/ThirdParty/Steam/redistributable_bin/win64 -} +#contains(QT_ARCH, i386) { +# #32-bit +# win32: LIBS += -L$$PWD/ThirdParty/Steam/redistributable_bin/ -lsteam_api +# DEPENDPATH += $$PWD/ThirdParty/Steam/redistributable_bin/ +#} else { +# #64-bit +# win32: LIBS += -L$$PWD/ThirdParty/Steam/redistributable_bin/win64/ -lsteam_api64 +# DEPENDPATH += $$PWD/ThirdParty/Steam/redistributable_bin/win64 +#} DISTFILES += \ steam_appid.txt \ diff --git a/main.cpp b/main.cpp index cca10fe8..1f4b9db3 100644 --- a/main.cpp +++ b/main.cpp @@ -5,45 +5,55 @@ #include #include #include +#include #include +#include #include #include #include #include #include +#include +#include "backend.h" #include "installedlistmodel.h" +#include "monitors.h" #include "screenplay.h" -#include "mainwindow.h" int main(int argc, char* argv[]) { + QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QCoreApplication::setOrganizationName("Aimber"); QCoreApplication::setOrganizationDomain("aimber.net"); QCoreApplication::setApplicationName("ScreenPlay"); - QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); app.setWindowIcon(QIcon(":/assets/icons/favicon.ico")); InstalledListModel ilm; + Backend backend; + Monitors monitors; QQmlApplicationEngine mainWindow; + mainWindow.rootContext()->setContextProperty("monitorList", &monitors); mainWindow.rootContext()->setContextProperty("installedListModel", &ilm); + mainWindow.rootContext()->setContextProperty("backend", &backend); + mainWindow.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); + QObject::connect(&mainWindow, SIGNAL(exitScreenPlay()), &app, SLOT(app.exit())); + ScreenPlay sp(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + sp.context()->setContextProperty("installedListModel", &ilm); + sp.context()->setContextProperty("backend", &backend); - ScreenPlay sp(GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN)); - sp.context()->setContextProperty("installedListModel",&ilm); sp.loadQQuickView(QUrl(QStringLiteral("qrc:/qml/Components/ScreenPlay.qml"))); - sp.showQQuickView(GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN)); + sp.showQQuickView(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); QObject::connect(&ilm, &InstalledListModel::setScreenVisible, - &sp,&ScreenPlay::setVisible); - + &sp, &ScreenPlay::setVisible); int status = app.exec(); //Shutdown - return status; + return app.exec(); } diff --git a/src/backend.cpp b/src/backend.cpp new file mode 100644 index 00000000..e58523c8 --- /dev/null +++ b/src/backend.cpp @@ -0,0 +1,11 @@ +#include "backend.h" + +Backend::Backend(QObject *parent) : QObject(parent) +{ + +} + +void Backend::getTest() +{ + emit setTest(); +} diff --git a/src/backend.h b/src/backend.h new file mode 100644 index 00000000..0c1c402e --- /dev/null +++ b/src/backend.h @@ -0,0 +1,19 @@ +#ifndef BACKEND_H +#define BACKEND_H + +#include + +class Backend : public QObject +{ + Q_OBJECT +public: + explicit Backend(QObject *parent = nullptr); + +signals: + void setTest(); + +public slots: + void getTest(); +}; + +#endif // BACKEND_H diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp deleted file mode 100644 index ec0bd080..00000000 --- a/src/mainwindow.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) -{ - -} diff --git a/src/mainwindow.h b/src/mainwindow.h deleted file mode 100644 index acdad1ca..00000000 --- a/src/mainwindow.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - explicit MainWindow(QWidget *parent = nullptr); - -signals: - -public slots: -}; - -#endif // MAINWINDOW_H \ No newline at end of file diff --git a/src/monitors.cpp b/src/monitors.cpp new file mode 100644 index 00000000..b3db4b9b --- /dev/null +++ b/src/monitors.cpp @@ -0,0 +1,34 @@ +#include "monitors.h" + +Monitors::Monitors(QObject* parent) + : QObject(parent) +{ +loadScreens(); +} + +void Monitors::loadScreens() +{ + for (int i = 0; i < QApplication::screens().count(); i++) { + QScreen* screen = QApplication::screens().at(i); + qDebug() << screen->geometry(); + _screen.append(QApplication::screens().at(i)); + + _monitors.append(Monitor(screen->name(), screen->size(), screen->availableGeometry(), i, false)); + } +} + +QVariantList Monitors::get() +{ + QVariantList list; + + return list; +} + +Monitor::Monitor(QString name, QSize size, QRect availableGeometry, int number, bool isVirtualDesktop) +{ + _name = name; + _size = size; + _availableGeometry = availableGeometry; + _number = number; + _isVirtualDesktop = isVirtualDesktop; +} diff --git a/src/monitors.h b/src/monitors.h new file mode 100644 index 00000000..e6dc5f3a --- /dev/null +++ b/src/monitors.h @@ -0,0 +1,48 @@ +#ifndef MONITORS_H +#define MONITORS_H + +#include +#include +#include +#include +#include +#include +#include +#include + +class Monitor; + +class Monitors : public QObject { + Q_OBJECT + + +public: + explicit Monitors(QObject* parent = nullptr); + + Q_INVOKABLE void loadScreens(); + Q_INVOKABLE QVariantList get(); + +signals: + +public slots: + +private: + QList _monitors; + QList _screen; + int primaryScreen; +}; + +class Monitor { + +public: + Monitor(QString name, QSize size, QRect availableGeometry, int number, bool isVirtualDesktop); + + QString _name; + QSize _size; + QRect _availableGeometry; + int _number; + bool _isVirtualDesktop; + QScreen* _screen = nullptr; +}; + +#endif // MONITORS_H diff --git a/src/screenplay.cpp b/src/screenplay.cpp index 1189b819..7dec2323 100644 --- a/src/screenplay.cpp +++ b/src/screenplay.cpp @@ -1,5 +1,4 @@ #include "screenplay.h" -#include BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam) {