Move Controller::setBlur and Controller::hasWindowSystem to WindowController
This commit is contained in:
@@ -8,9 +8,6 @@
|
|||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KWindowConfig>
|
#include <KWindowConfig>
|
||||||
#ifdef HAVE_WINDOWSYSTEM
|
|
||||||
#include <KWindowEffects>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@@ -392,32 +389,6 @@ QString Controller::formatDuration(quint64 msecs, KFormat::DurationFormatOptions
|
|||||||
return KFormat().formatDuration(msecs, options);
|
return KFormat().formatDuration(msecs, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::setBlur(QQuickItem *item, bool blur)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_WINDOWSYSTEM
|
|
||||||
auto setWindows = [item, blur]() {
|
|
||||||
auto reg = QRect(QPoint(0, 0), item->window()->size());
|
|
||||||
KWindowEffects::enableBackgroundContrast(item->window(), blur, 1, 1, 1, reg);
|
|
||||||
KWindowEffects::enableBlurBehind(item->window(), blur, reg);
|
|
||||||
};
|
|
||||||
|
|
||||||
disconnect(item->window(), &QQuickWindow::heightChanged, this, nullptr);
|
|
||||||
disconnect(item->window(), &QQuickWindow::widthChanged, this, nullptr);
|
|
||||||
connect(item->window(), &QQuickWindow::heightChanged, this, setWindows);
|
|
||||||
connect(item->window(), &QQuickWindow::widthChanged, this, setWindows);
|
|
||||||
setWindows();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Controller::hasWindowSystem() const
|
|
||||||
{
|
|
||||||
#ifdef HAVE_WINDOWSYSTEM
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void Controller::forceRefreshTextDocument(QQuickTextDocument *textDocument, QQuickItem *item)
|
void Controller::forceRefreshTextDocument(QQuickTextDocument *textDocument, QQuickItem *item)
|
||||||
{
|
{
|
||||||
// HACK: Workaround bug QTBUG 93281
|
// HACK: Workaround bug QTBUG 93281
|
||||||
|
|||||||
@@ -64,11 +64,6 @@ class Controller : public QObject
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool supportSystemTray READ supportSystemTray CONSTANT)
|
Q_PROPERTY(bool supportSystemTray READ supportSystemTray CONSTANT)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Whether KWindowSystem specific features are available.
|
|
||||||
*/
|
|
||||||
Q_PROPERTY(bool hasWindowSystem READ hasWindowSystem CONSTANT)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Whether NeoChat is currently able to connect to the server.
|
* @brief Whether NeoChat is currently able to connect to the server.
|
||||||
*/
|
*/
|
||||||
@@ -128,11 +123,6 @@ public:
|
|||||||
|
|
||||||
[[nodiscard]] bool supportSystemTray() const;
|
[[nodiscard]] bool supportSystemTray() const;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the background blur status of the given item.
|
|
||||||
*/
|
|
||||||
Q_INVOKABLE void setBlur(QQuickItem *item, bool blur);
|
|
||||||
|
|
||||||
bool isOnline() const;
|
bool isOnline() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,8 +170,6 @@ private:
|
|||||||
bool m_isOnline = true;
|
bool m_isOnline = true;
|
||||||
QMap<Quotient::Room *, int> m_notificationCounts;
|
QMap<Quotient::Room *, int> m_notificationCounts;
|
||||||
|
|
||||||
bool hasWindowSystem() const;
|
|
||||||
|
|
||||||
QPointer<PushRuleModel> m_pushRuleModel;
|
QPointer<PushRuleModel> m_pushRuleModel;
|
||||||
Quotient::AccountRegistry m_accountRegistry;
|
Quotient::AccountRegistry m_accountRegistry;
|
||||||
|
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ FormCard.FormCardPage {
|
|||||||
|
|
||||||
FormCard.FormCheckDelegate {
|
FormCard.FormCheckDelegate {
|
||||||
id: hasWindowSystemDelegate
|
id: hasWindowSystemDelegate
|
||||||
visible: Controller.hasWindowSystem
|
visible: WindowController.hasWindowSystem
|
||||||
text: i18n("Use transparent chat page")
|
text: i18n("Use transparent chat page")
|
||||||
enabled: !Config.compactLayout && !Config.isBlurImmutable
|
enabled: !Config.compactLayout && !Config.isBlurImmutable
|
||||||
checked: Config.blur
|
checked: Config.blur
|
||||||
@@ -249,7 +249,7 @@ FormCard.FormCardPage {
|
|||||||
|
|
||||||
FormCard.AbstractFormDelegate {
|
FormCard.AbstractFormDelegate {
|
||||||
id: transparencyDelegate
|
id: transparencyDelegate
|
||||||
visible: Controller.hasWindowSystem && Config.blur
|
visible: WindowController.hasWindowSystem && Config.blur
|
||||||
enabled: !Config.isTransparancyImmutable
|
enabled: !Config.isTransparancyImmutable
|
||||||
background: Item {}
|
background: Item {}
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ Kirigami.ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
Controller.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
WindowController.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
||||||
if (Config.minimizeToSystemTrayOnStartup && !Kirigami.Settings.isMobile && Controller.supportSystemTray && Config.systemTray) {
|
if (Config.minimizeToSystemTrayOnStartup && !Kirigami.Settings.isMobile && Controller.supportSystemTray && Config.systemTray) {
|
||||||
restoreWindowGeometryConnections.enabled = true; // To restore window size and position
|
restoreWindowGeometryConnections.enabled = true; // To restore window size and position
|
||||||
} else {
|
} else {
|
||||||
@@ -201,10 +201,10 @@ Kirigami.ApplicationWindow {
|
|||||||
Connections {
|
Connections {
|
||||||
target: Config
|
target: Config
|
||||||
function onBlurChanged() {
|
function onBlurChanged() {
|
||||||
Controller.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
WindowController.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
||||||
}
|
}
|
||||||
function onCompactLayoutChanged() {
|
function onCompactLayoutChanged() {
|
||||||
Controller.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
WindowController.setBlur(pageStack, Config.blur && !Config.compactLayout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,4 +76,30 @@ void WindowController::showAndRaiseWindow(const QString &startupId)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WindowController::hasWindowSystem() const
|
||||||
|
{
|
||||||
|
#ifdef HAVE_WINDOWSYSTEM
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowController::setBlur(QQuickItem *item, bool blur)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_WINDOWSYSTEM
|
||||||
|
auto setWindows = [item, blur]() {
|
||||||
|
auto reg = QRect(QPoint(0, 0), item->window()->size());
|
||||||
|
KWindowEffects::enableBackgroundContrast(item->window(), blur, 1, 1, 1, reg);
|
||||||
|
KWindowEffects::enableBlurBehind(item->window(), blur, reg);
|
||||||
|
};
|
||||||
|
|
||||||
|
disconnect(item->window(), &QQuickWindow::heightChanged, this, nullptr);
|
||||||
|
disconnect(item->window(), &QQuickWindow::widthChanged, this, nullptr);
|
||||||
|
connect(item->window(), &QQuickWindow::heightChanged, this, setWindows);
|
||||||
|
connect(item->window(), &QQuickWindow::widthChanged, this, setWindows);
|
||||||
|
setWindows();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#include "moc_windowcontroller.cpp"
|
#include "moc_windowcontroller.cpp"
|
||||||
|
|||||||
@@ -4,8 +4,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWindow>
|
#include <QQmlEngine>
|
||||||
|
#include <QQuickItem>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
#ifdef HAVE_WINDOWSYSTEM
|
||||||
|
#include <KWindowEffects>
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @class WindowController
|
* @class WindowController
|
||||||
*
|
*
|
||||||
@@ -14,9 +18,21 @@
|
|||||||
class WindowController : public QObject
|
class WindowController : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
QML_ELEMENT
|
||||||
|
QML_SINGLETON
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether KWindowSystem specific features are available.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool hasWindowSystem READ hasWindowSystem CONSTANT)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WindowController &instance();
|
static WindowController &instance();
|
||||||
|
static WindowController *create(QQmlEngine *engine, QJSEngine *)
|
||||||
|
{
|
||||||
|
engine->setObjectOwnership(&instance(), QQmlEngine::CppOwnership);
|
||||||
|
return &instance();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set the window that the will be managed.
|
* @brief Set the window that the will be managed.
|
||||||
@@ -43,6 +59,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void showAndRaiseWindow(const QString &startupId);
|
void showAndRaiseWindow(const QString &startupId);
|
||||||
|
|
||||||
|
bool hasWindowSystem() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set the background blur status of the given item.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE void setBlur(QQuickItem *item, bool blur);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* @brief Triggered if the managed window is changed.
|
* @brief Triggered if the managed window is changed.
|
||||||
|
|||||||
Reference in New Issue
Block a user