Falkon Develop
Cross-platform Qt-based web browser
closedwindowsmanager.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#pragma once
19
20#include <QObject>
21#include <QVector>
22
23#include "qzcommon.h"
24#include "browserwindow.h"
25
26class FALKON_EXPORT ClosedWindowsManager : public QObject
27{
28 Q_OBJECT
29
30public:
31 struct Window {
32 QIcon icon;
33 QString title;
35
36 bool isValid() const {
37 return windowState.isValid();
38 }
39 };
40
41 explicit ClosedWindowsManager(QObject *parent = nullptr);
42
43 bool isClosedWindowAvailable() const;
44 QVector<Window> closedWindows() const;
45
46 void saveWindow(BrowserWindow *window);
47
48 // Takes window that was most recently closed
49 Window takeLastClosedWindow();
50 // Takes window at given index
51 Window takeClosedWindowAt(int index);
52
53 QByteArray saveState() const;
54 void restoreState(const QByteArray &state);
55
56public Q_SLOTS:
57 void restoreClosedWindow();
58 void restoreAllClosedWindows();
59 void clearClosedWindows();
60
61private:
62 QVector<Window> m_closedWindows;
63};
64
65// Hint to Qt to use std::realloc on item moving
Q_DECLARE_TYPEINFO(ClosedWindowsManager::Window, Q_MOVABLE_TYPE)
State state
#define FALKON_EXPORT
Definition: qzcommon.h:28
BrowserWindow::SavedWindow windowState