File indexing completed on 2024-04-28 16:10:26

0001 // SPDX-FileCopyrightText: 2022 Nicolas Fella <nicolas.fella@gmx.de>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QWindow>
0008 
0009 /**
0010  * @class WindowController
0011  *
0012  * A singleton class to help manage the NeoChat window.
0013  */
0014 class WindowController : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     static WindowController &instance();
0020 
0021     /**
0022      * @brief Set the window that the will be managed.
0023      */
0024     void setWindow(QWindow *window);
0025 
0026     /**
0027      * @brief Get the window that the will be managed.
0028      */
0029     QWindow *window() const;
0030 
0031     /**
0032      * @brief Restore any saved window geometry if available.
0033      */
0034     void restoreGeometry();
0035 
0036     /**
0037      * @brief Save the current window geometry.
0038      */
0039     void saveGeometry();
0040 
0041     /**
0042      * @brief Show the window and raise to the top.
0043      */
0044     void showAndRaiseWindow(const QString &startupId);
0045 
0046 Q_SIGNALS:
0047     /**
0048      * @brief Triggered if the managed window is changed.
0049      */
0050     void windowChanged();
0051 
0052 private:
0053     WindowController() = default;
0054 
0055     QWindow *m_window = nullptr;
0056 };