Lomiri
Loading...
Searching...
No Matches
windowstatestorage.h
1/*
2 * Copyright 2015-2016 Canonical Ltd.
3 * Copyright 2021 UBports Foundation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <QObject>
19#include <QSqlDatabase>
20#include <QSqlQuery>
21#include <QMutex>
22#include <QFuture>
23#include <QThread>
24
25// lomiri-api
26#include <lomiri/shell/application/Mir.h>
27
28class AsyncQuery;
29
30class WindowStateStorage: public QObject
31{
32 Q_OBJECT
33public:
34 WindowStateStorage(const QString &dbName = QString(), QObject *parent = nullptr);
35 virtual ~WindowStateStorage();
36
37 Q_INVOKABLE Mir::State getState(const QString &windowId, Mir::State defaultValue) const;
38
39 Q_INVOKABLE QRect getGeometry(const QString &windowId, const QRect &defaultValue) const;
40
41 Q_INVOKABLE int getStage(const QString &appId, int defaultValue) const;
42
43 const QString getDbName();
44
45Q_SIGNALS:
46 void saveStage(const QString &appId, int stage);
47 void saveGeometry(const QString &windowId, const QRect &rect);
48 void saveState(const QString &windowId, Mir::State state);
49
50private:
51 QThread m_thread;
52 AsyncQuery *m_asyncQuery;
53};