Falkon Develop
Cross-platform Qt-based web browser
speeddial.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2014 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#ifndef SPEEDDIAL_H
19#define SPEEDDIAL_H
20
21#include <QObject>
22#include <QPointer>
23#include <QWebEnginePage>
24
25#include "qzcommon.h"
26
27class QUrl;
28class QPixmap;
29
30class AutoSaver;
31class PageThumbnailer;
32
33class FALKON_EXPORT SpeedDial : public QObject
34{
35 Q_OBJECT
36public:
37 struct Page {
38 QString title;
39 QString url;
40
41 bool isValid() const {
42 return !url.isEmpty();
43 }
44
45 bool operator==(const Page &other) const {
46 return (this->title == other.title &&
47 this->url == other.url);
48 }
49 };
50
51 explicit SpeedDial(QObject* parent = nullptr);
52 ~SpeedDial();
53
54 void loadSettings();
55
56 Page pageForUrl(const QUrl &url);
57 QUrl urlForShortcut(int key);
58
59 void addPage(const QUrl &url, const QString &title);
60 void removePage(const Page &page);
61
62 int pagesInRow();
63 int sdSize();
64 bool sdCenter();
65 bool lockDials();
66
67 QString backgroundImage();
68 QString backgroundImageUrl();
69 QString backgroundImageSize();
70 QString initialScript();
71 QList<Page> pages();
72
73Q_SIGNALS:
75 void thumbnailLoaded(const QString &url, const QString &src);
76 void pageTitleLoaded(const QString &url, const QString &title);
77
78public Q_SLOTS:
79 void changed(const QString &allPages);
80 void loadThumbnail(const QString &url, bool loadTitle);
81 void removeImageForUrl(const QString &url);
82
83 QStringList getOpenFileName();
84 QString urlFromUserInput(const QString &url);
85 void setBackgroundImage(const QString &image);
86 void setBackgroundImageSize(const QString &size);
87 void setPagesInRow(int count);
88 void setSdSize(int count);
89 void setSdCentered(bool centered);
90 void setLockDials(bool lockDials);
91
92private Q_SLOTS:
93 void thumbnailCreated(const QPixmap &pixmap);
94 void saveSettings();
95
96private:
97 QString escapeTitle(QString string) const;
98 QString escapeUrl(QString url) const;
99
100 QString generateAllPages();
101
102 QString m_initialScript;
103 QString m_thumbnailsDir;
104 QString m_backgroundImage;
105 QString m_backgroundImageUrl;
106 QString m_backgroundImageSize;
107 int m_maxPagesInRow;
108 int m_sizeOfSpeedDials;
109 bool m_sdcentered;
110 bool m_lockDials;
111
112 QList<Page> m_pages;
113 AutoSaver* m_autoSaver;
114
115 bool m_loaded;
116 bool m_regenerateScript;
117};
118
119#endif // SPEEDDIAL_H
void pageTitleLoaded(const QString &url, const QString &title)
void thumbnailLoaded(const QString &url, const QString &src)
void pagesChanged()
#define FALKON_EXPORT
Definition: qzcommon.h:28
bool operator==(const Page &other) const
Definition: speeddial.h:45
bool isValid() const
Definition: speeddial.h:41
QString url
Definition: speeddial.h:39
QString title
Definition: speeddial.h:38