1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/*
* Copyright 2015-2016 Canonical Ltd.
* Copyright 2021 UBports Foundation
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QObject>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QMutex>
#include <QFuture>
#include <QThread>
// lomiri-api
#include <lomiri/shell/application/Mir.h>
class AsyncQuery;
class WindowStateStorage: public QObject
{
Q_OBJECT
public:
enum WindowState {
WindowStateNormal = 1 << 0,
WindowStateMaximized = 1 << 1,
WindowStateMinimized = 1 << 2,
WindowStateFullscreen = 1 << 3,
WindowStateMaximizedLeft = 1 << 4,
WindowStateMaximizedRight = 1 << 5,
WindowStateMaximizedHorizontally = 1 << 6,
WindowStateMaximizedVertically = 1 << 7,
WindowStateMaximizedTopLeft = 1 << 8,
WindowStateMaximizedTopRight = 1 << 9,
WindowStateMaximizedBottomLeft = 1 << 10,
WindowStateMaximizedBottomRight = 1 << 11,
WindowStateRestored = 1 << 12
};
Q_ENUM(WindowState)
Q_DECLARE_FLAGS(WindowStates, WindowState)
Q_FLAG(WindowStates)
WindowStateStorage(const QString &dbName = QString(), QObject *parent = nullptr);
virtual ~WindowStateStorage();
Q_INVOKABLE WindowState getState(const QString &windowId, WindowState defaultValue) const;
Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect &defaultValue) const;
Q_INVOKABLE int getStage(const QString &appId, int defaultValue) const;
Q_INVOKABLE Mir::State toMirState(WindowState state) const;
const QString getDbName();
Q_SIGNALS:
void saveStage(const QString &appId, int stage);
void saveGeometry(const QString &windowId, const QRect &rect);
void saveState(const QString &windowId, WindowStateStorage::WindowState state);
private:
QThread m_thread;
AsyncQuery *m_asyncQuery;
};
|