mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[Code] Create singletons with Q_GLOBAL_STATIC macro
This commit is contained in:
parent
edbb87bd1f
commit
f558a836b0
|
@ -914,6 +914,7 @@ void MainApplication::saveSettings()
|
|||
|
||||
qzSettings->saveSettings();
|
||||
AdBlockManager::instance()->save();
|
||||
IconProvider::instance()->saveIconsToDatabase();
|
||||
QFile::remove(currentProfilePath() + "WebpageIcons.db");
|
||||
Settings::syncSettings();
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
DatabaseWriter* DatabaseWriter::s_instance = 0;
|
||||
Q_GLOBAL_STATIC(DatabaseWriter, qz_database_writer)
|
||||
|
||||
DatabaseWriter::DatabaseWriter(QObject* parent)
|
||||
: QObject(parent)
|
||||
DatabaseWriter::DatabaseWriter()
|
||||
: QObject()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -34,10 +34,7 @@ void DatabaseWriter::executeQuery(const QSqlQuery &query)
|
|||
|
||||
DatabaseWriter* DatabaseWriter::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = new DatabaseWriter;
|
||||
}
|
||||
return s_instance;
|
||||
return qz_database_writer();
|
||||
}
|
||||
|
||||
void DatabaseWriter::execute()
|
||||
|
|
|
@ -28,7 +28,7 @@ class QUPZILLA_EXPORT DatabaseWriter : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DatabaseWriter(QObject* parent = 0);
|
||||
explicit DatabaseWriter();
|
||||
|
||||
// Delayed execution of query
|
||||
void executeQuery(const QSqlQuery &query);
|
||||
|
@ -40,8 +40,6 @@ private slots:
|
|||
|
||||
private:
|
||||
QVector<QSqlQuery> m_queries;
|
||||
|
||||
static DatabaseWriter* s_instance;
|
||||
};
|
||||
|
||||
#endif // DATABASEWRITER_H
|
||||
|
|
|
@ -24,10 +24,10 @@
|
|||
#include <QTimer>
|
||||
#include <QBuffer>
|
||||
|
||||
IconProvider* IconProvider::s_instance = 0;
|
||||
Q_GLOBAL_STATIC(IconProvider, qz_icon_provider)
|
||||
|
||||
IconProvider::IconProvider(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
IconProvider::IconProvider()
|
||||
: QWidget()
|
||||
{
|
||||
m_autoSaver = new AutoSaver(this);
|
||||
connect(m_autoSaver, SIGNAL(save()), this, SLOT(saveIconsToDatabase()));
|
||||
|
@ -210,10 +210,7 @@ QIcon IconProvider::iconForDomain(const QUrl &url)
|
|||
|
||||
IconProvider* IconProvider::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = new IconProvider;
|
||||
}
|
||||
return s_instance;
|
||||
return qz_icon_provider();
|
||||
}
|
||||
|
||||
void IconProvider::saveIconsToDatabase()
|
||||
|
|
|
@ -38,7 +38,7 @@ class QUPZILLA_EXPORT IconProvider : public QWidget
|
|||
Q_PROPERTY(QPixmap bookmarkIcon READ bookmarkIcon WRITE setBookmarkIcon)
|
||||
|
||||
public:
|
||||
explicit IconProvider(QWidget* parent = 0);
|
||||
explicit IconProvider();
|
||||
|
||||
void saveIcon(WebView* view);
|
||||
|
||||
|
@ -74,8 +74,6 @@ private:
|
|||
QVector<BufferedIcon> m_iconBuffer;
|
||||
|
||||
AutoSaver* m_autoSaver;
|
||||
|
||||
static IconProvider* s_instance;
|
||||
};
|
||||
|
||||
#endif // ICONPROVIDER_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user