mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-09-15 06:52:34 +02:00
Add working wallpaper via settings
This commit is contained in:
parent
1c39a2a595
commit
6bb1c69a59
2
main.cpp
2
main.cpp
@ -46,7 +46,7 @@ int main(int argc, char* argv[])
|
||||
ProfileListModel profileListModel;
|
||||
// Create settings at the end because for now it depends on
|
||||
// such things as the profile list model to complete
|
||||
Settings settings(&profileListModel);
|
||||
Settings settings(&profileListModel, &monitorListModel, &installedListModel);
|
||||
|
||||
|
||||
QQmlApplicationEngine mainWindowEngine;
|
||||
|
@ -9,14 +9,14 @@
|
||||
#include <QScreen>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include "settings.h"
|
||||
|
||||
|
||||
class Monitor;
|
||||
|
||||
class MonitorListModel : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
friend Settings;
|
||||
|
||||
|
||||
public:
|
||||
explicit MonitorListModel(QObject *parent = nullptr);
|
||||
|
@ -1,10 +1,12 @@
|
||||
#include "settings.h"
|
||||
|
||||
Settings::Settings(ProfileListModel* plm, QObject* parent)
|
||||
Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
|
||||
m_plm = plm;
|
||||
m_mlm = mlm;
|
||||
m_ilm = ilm;
|
||||
|
||||
QFile configTmp;
|
||||
QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
|
||||
@ -64,7 +66,7 @@ Settings::Settings(ProfileListModel* plm, QObject* parent)
|
||||
Profile profile;
|
||||
if (!m_plm->getProfileByName(profileName, &profile))
|
||||
continue;
|
||||
m_activeProfiles.append(ActiveProfiles(monitorID, profile));
|
||||
|
||||
constructWallpaper(profile, monitorID);
|
||||
}
|
||||
}
|
||||
@ -76,8 +78,8 @@ void Settings::createNewProfile(int screenNumber)
|
||||
|
||||
void Settings::constructWallpaper(Profile profile, QString monitorID)
|
||||
{
|
||||
qDebug() << monitorID;
|
||||
//m_wallpapers.append(Wallpaper( ));
|
||||
|
||||
m_wallpapers.append(QSharedPointer<Wallpaper>(new Wallpaper(profile)));
|
||||
}
|
||||
|
||||
void Settings::createDefaultConfig()
|
||||
|
@ -16,18 +16,20 @@
|
||||
#include <QUrl>
|
||||
#include <QVariant>
|
||||
#include <QVector>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "profile.h"
|
||||
#include "monitorlistmodel.h"
|
||||
#include "installedlistmodel.h"
|
||||
#include "profilelistmodel.h"
|
||||
#include "profile.h"
|
||||
#include "wallpaper.h"
|
||||
|
||||
class ActiveProfiles;
|
||||
class Profile;
|
||||
|
||||
class Settings : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Settings(ProfileListModel* plm, QObject* parent = nullptr);
|
||||
explicit Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListModel* ilm, QObject* parent = nullptr);
|
||||
|
||||
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
|
||||
Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged)
|
||||
@ -142,9 +144,11 @@ private:
|
||||
bool m_sendStatistics;
|
||||
Version m_version;
|
||||
ProfileListModel* m_plm;
|
||||
InstalledListModel* m_ilm;
|
||||
MonitorListModel* m_mlm;
|
||||
|
||||
QVector<Wallpaper> m_wallpapers;
|
||||
QVector<ActiveProfiles> m_activeProfiles;
|
||||
QVector<QSharedPointer<Wallpaper>> m_wallpapers;
|
||||
QVector<QSharedPointer<ActiveProfiles>> m_activeProfiles;
|
||||
};
|
||||
|
||||
class ActiveProfiles {
|
||||
|
@ -18,10 +18,37 @@ Wallpaper::Wallpaper(QWindow* parent)
|
||||
{
|
||||
}
|
||||
|
||||
Wallpaper::Wallpaper(QRect rect, float playback, bool isLooping, int fillmode)
|
||||
Wallpaper::Wallpaper(Profile profile)
|
||||
{
|
||||
m_rect = rect;
|
||||
m_playback = playback;
|
||||
m_isLooping = isLooping;
|
||||
m_fillmode = fillmode;
|
||||
qDebug() << "Creating Wallpaper" << profile.m_rect;
|
||||
m_profile = profile;
|
||||
this->setX(m_profile.m_rect.x());
|
||||
this->setY(m_profile.m_rect.y());
|
||||
this->setWidth(m_profile.m_rect.width());
|
||||
this->setHeight(m_profile.m_rect.height());
|
||||
this->m_hwnd = (HWND)this->winId();
|
||||
|
||||
HWND progman_hwnd = FindWindowW(L"Progman", L"Program Manager");
|
||||
|
||||
// Spawn new worker window below desktop (using some undocumented Win32 magic)
|
||||
// See
|
||||
// https://www.codeproject.com/articles/856020/draw-behind-desktop-icons-in-windows
|
||||
// for more details
|
||||
const DWORD WM_SPAWN_WORKER = 0x052C;
|
||||
SendMessageTimeoutW(progman_hwnd, WM_SPAWN_WORKER, 0xD, 0x1, SMTO_NORMAL,
|
||||
1000, nullptr);
|
||||
|
||||
EnumWindows(SearchForWorkerWindow, reinterpret_cast<LPARAM>(&m_worker_hwnd));
|
||||
ShowWindow(m_worker_hwnd, SW_SHOWDEFAULT);
|
||||
|
||||
SetParent(m_hwnd, m_worker_hwnd);
|
||||
SetWindowLongPtr(m_hwnd, GWL_STYLE,
|
||||
WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
|
||||
SetWindowLongPtr(m_hwnd, GWL_EXSTYLE,
|
||||
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_NOACTIVATE | WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW);
|
||||
|
||||
Qt::WindowFlags flags = this->flags();
|
||||
this->setFlags(flags | Qt::FramelessWindowHint | Qt::WindowStaysOnBottomHint);
|
||||
this->show();
|
||||
ShowWindow(m_hwnd, SW_SHOWDEFAULT);
|
||||
}
|
||||
|
@ -4,30 +4,27 @@
|
||||
#include <QDebug>
|
||||
#include <QQmlContext>
|
||||
#include <QQuickView>
|
||||
#include <QRect>
|
||||
#include <QWindow>
|
||||
#include <qt_windows.h>
|
||||
|
||||
#include <QRect>
|
||||
#include "profile.h"
|
||||
|
||||
class Wallpaper : public QWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Wallpaper(QWindow* parent = 0);
|
||||
|
||||
Wallpaper(QRect rect, float playback, bool isLooping, int fillmode);
|
||||
|
||||
Wallpaper(Profile profile);
|
||||
QQmlContext* context() const;
|
||||
|
||||
private:
|
||||
HWND hwnd = nullptr;
|
||||
HWND worker_hwnd = nullptr;
|
||||
QQuickView* quickRenderer = nullptr;
|
||||
QQmlContext* _context = nullptr;
|
||||
|
||||
QRect m_rect;
|
||||
float m_playback;
|
||||
bool m_isLooping;
|
||||
int m_fillmode;
|
||||
private:
|
||||
HWND m_hwnd = nullptr;
|
||||
HWND m_worker_hwnd = nullptr;
|
||||
QQuickView* m_quickRenderer = nullptr;
|
||||
QQmlContext* m_context = nullptr;
|
||||
|
||||
Profile m_profile;
|
||||
};
|
||||
|
||||
#endif // WALLPAPER_H
|
||||
|
Loading…
Reference in New Issue
Block a user