1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-25 20:22:39 +01:00

Add new c++ classes

This commit is contained in:
kelteseth 2017-04-23 12:53:00 +02:00
parent f9b2af952e
commit 6c1e3f62fb
9 changed files with 145 additions and 44 deletions

View File

@ -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 \

View File

@ -5,45 +5,55 @@
#include <QModelIndex>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickView>
#include <QQmlContext>
#include <QScreen>
#include <QUrl>
#include <QVariant>
#include <QWindow>
#include <qt_windows.h>
#include <QIcon>
#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.load(QUrl(QStringLiteral("qrc:/qml/main.qml")));
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);
sp.loadQQuickView(QUrl(QStringLiteral("qrc:/qml/Components/ScreenPlay.qml")));
sp.showQQuickView(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
QObject::connect(&ilm, &InstalledListModel::setScreenVisible,
&sp, &ScreenPlay::setVisible);
int status = app.exec();
//Shutdown
return status;
return app.exec();
}

11
src/backend.cpp Normal file
View File

@ -0,0 +1,11 @@
#include "backend.h"
Backend::Backend(QObject *parent) : QObject(parent)
{
}
void Backend::getTest()
{
emit setTest();
}

19
src/backend.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef BACKEND_H
#define BACKEND_H
#include <QObject>
class Backend : public QObject
{
Q_OBJECT
public:
explicit Backend(QObject *parent = nullptr);
signals:
void setTest();
public slots:
void getTest();
};
#endif // BACKEND_H

View File

@ -1,6 +0,0 @@
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
}

View File

@ -1,17 +0,0 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
signals:
public slots:
};
#endif // MAINWINDOW_H

34
src/monitors.cpp Normal file
View File

@ -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;
}

48
src/monitors.h Normal file
View File

@ -0,0 +1,48 @@
#ifndef MONITORS_H
#define MONITORS_H
#include <QApplication>
#include <QDebug>
#include <QList>
#include <QObject>
#include <QRect>
#include <QScreen>
#include <QSize>
#include <QVariantList>
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<Monitor> _monitors;
QList<QScreen *> _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

View File

@ -1,5 +1,4 @@
#include "screenplay.h"
#include <QDebug>
BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam)
{