C++ / fmt (pull_request) Failing after 4s
C++ / build (pull_request) Failing after 9s
C++ / clang-tidy (pull_request) Failing after 10s
JS/TS / fmt (pull_request) Successful in 10s
JS/TS / lint (pull_request) Successful in 8s
Python / static (pull_request) Successful in 28s
Rust / build (pull_request) Successful in 47s
Python / verify (pull_request) Successful in 1m40s
Rust / fmt (pull_request) Successful in 29s
Rust / clippy (pull_request) Successful in 46s
84 lines
1.7 KiB
C++
84 lines
1.7 KiB
C++
#include "wallpaperobject.hpp"
|
|
|
|
namespace ZShell::internal {
|
|
|
|
WallpaperObject::WallpaperObject(QObject* parent) : QObject(parent) {}
|
|
|
|
WallpaperObject::~WallpaperObject() {
|
|
if (m_service && !m_screen.isEmpty()) m_service->removeScreen(m_screen);
|
|
}
|
|
|
|
void WallpaperObject::registerScreen() {
|
|
if (!m_service || m_screen.isEmpty()) return;
|
|
|
|
m_service->addScreen(m_screen);
|
|
}
|
|
|
|
void WallpaperObject::setService(WallpaperService* service) {
|
|
if (m_service == service) return;
|
|
m_service = service;
|
|
emit serviceChanged();
|
|
|
|
registerScreen();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setScreen(const QString& screen) {
|
|
if (m_screen == screen) return;
|
|
m_screen = screen;
|
|
emit screenChanged();
|
|
|
|
registerScreen();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setCropX(qreal x) {
|
|
if (qFuzzyCompare(m_cropX, x)) return;
|
|
m_cropX = x;
|
|
emit cropXChanged();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setCropY(qreal y) {
|
|
if (qFuzzyCompare(m_cropY, y)) return;
|
|
m_cropY = y;
|
|
emit cropYChanged();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setCropWidth(qreal w) {
|
|
if (qFuzzyCompare(m_cropWidth, w)) return;
|
|
m_cropWidth = w;
|
|
emit cropWidthChanged();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setCropHeight(qreal h) {
|
|
if (qFuzzyCompare(m_cropHeight, h)) return;
|
|
m_cropHeight = h;
|
|
emit cropHeightChanged();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::setZoom(qreal zoom) {
|
|
if (qFuzzyCompare(m_zoom, zoom)) return;
|
|
m_zoom = zoom;
|
|
emit zoomChanged();
|
|
push();
|
|
}
|
|
|
|
void WallpaperObject::push() {
|
|
if (!m_service || m_screen.isEmpty()) return;
|
|
|
|
QVariantMap crop;
|
|
crop.insert("x", m_cropX);
|
|
crop.insert("y", m_cropY);
|
|
crop.insert("width", m_cropWidth);
|
|
crop.insert("height", m_cropHeight);
|
|
crop.insert("zoom", m_zoom);
|
|
|
|
m_service->setCrop(m_screen, crop);
|
|
}
|
|
|
|
} // namespace ZShell::internal
|