1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-13 10:32:11 +01:00

[CodeCleanup] Get rid of Qz::AppMessage enum

This commit is contained in:
nowrep 2014-03-09 12:49:45 +01:00
parent a61ce67d7c
commit a3c3dead87
14 changed files with 24 additions and 85 deletions

View File

@ -41,6 +41,11 @@ AdBlockIcon::AdBlockIcon(BrowserWindow* window, QWidget* parent)
setToolTip(tr("AdBlock lets you block unwanted content on web pages")); setToolTip(tr("AdBlock lets you block unwanted content on web pages"));
connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint))); connect(this, SIGNAL(clicked(QPoint)), this, SLOT(showMenu(QPoint)));
connect(AdBlockManager::instance(), SIGNAL(enabledChanged(bool)), this, SLOT(setEnabled(bool)));
}
AdBlockIcon::~AdBlockIcon()
{
} }
void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url) void AdBlockIcon::popupBlocked(const QString &ruleString, const QUrl &url)
@ -225,7 +230,3 @@ void AdBlockIcon::setEnabled(bool enabled)
m_enabled = enabled; m_enabled = enabled;
} }
AdBlockIcon::~AdBlockIcon()
{
}

View File

@ -37,8 +37,6 @@ public:
void popupBlocked(const QString &ruleString, const QUrl &url); void popupBlocked(const QString &ruleString, const QUrl &url);
QAction* menuAction(); QAction* menuAction();
signals:
public slots: public slots:
void setEnabled(bool enabled); void setEnabled(bool enabled);
void createMenu(QMenu* menu = 0); void createMenu(QMenu* menu = 0);

View File

@ -65,7 +65,7 @@ void AdBlockManager::setEnabled(bool enabled)
} }
m_enabled = enabled; m_enabled = enabled;
mApp->sendMessages(Qz::AM_SetAdBlockIconEnabled, enabled); emit enabledChanged(enabled);
Settings settings; Settings settings;
settings.beginGroup("AdBlock"); settings.beginGroup("AdBlock");

View File

@ -68,6 +68,9 @@ public:
AdBlockCustomList* customList() const; AdBlockCustomList* customList() const;
signals:
void enabledChanged(bool enabled);
public slots: public slots:
void setEnabled(bool enabled); void setEnabled(bool enabled);
void showRule(); void showRule();

View File

@ -111,7 +111,6 @@ const QString BrowserWindow::WEBKITVERSION = qWebKitVersion();
BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, QUrl startUrl) BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, QUrl startUrl)
: QMainWindow(0) : QMainWindow(0)
, m_historyMenuChanged(true)
, m_bookmarksMenuChanged(true) , m_bookmarksMenuChanged(true)
, m_isClosing(false) , m_isClosing(false)
, m_isStarting(false) , m_isStarting(false)
@ -147,7 +146,7 @@ BrowserWindow::BrowserWindow(Qz::BrowserWindowType type, QUrl startUrl)
m_hideNavigationTimer->setSingleShot(true); m_hideNavigationTimer->setSingleShot(true);
connect(m_hideNavigationTimer, SIGNAL(timeout()), this, SLOT(hideNavigationSlot())); connect(m_hideNavigationTimer, SIGNAL(timeout()), this, SLOT(hideNavigationSlot()));
connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(receiveMessage(Qz::AppMessageType,bool))); connect(mApp, SIGNAL(reloadSettings()), this, SLOT(loadSettings()));
QTimer::singleShot(0, this, SLOT(postLaunch())); QTimer::singleShot(0, this, SLOT(postLaunch()));
@ -945,38 +944,6 @@ void BrowserWindow::setWindowTitle(const QString &t)
QMainWindow::setWindowTitle(title); QMainWindow::setWindowTitle(title);
} }
void BrowserWindow::receiveMessage(Qz::AppMessageType mes, bool state)
{
switch (mes) {
case Qz::AM_SetAdBlockIconEnabled:
m_adblockIcon->setEnabled(state);
break;
case Qz::AM_CheckPrivateBrowsing:
m_privateBrowsing->setVisible(state);
m_actionPrivateBrowsing->setChecked(state);
weView()->titleChanged();
break;
case Qz::AM_ReloadSettings:
loadSettings();
m_tabWidget->loadSettings();
break;
case Qz::AM_HistoryStateChanged:
m_historyMenuChanged = true;
break;
case Qz::AM_BookmarksChanged:
setBookmarksMenuChanged(true);
break;
default:
qWarning("Unresolved message sent! This could never happen!");
break;
}
}
void BrowserWindow::aboutToShowFileMenu() void BrowserWindow::aboutToShowFileMenu()
{ {
#ifndef Q_OS_MAC #ifndef Q_OS_MAC

View File

@ -64,7 +64,6 @@ public:
void openWithTab(WebTab* tab); void openWithTab(WebTab* tab);
void loadSettings();
void saveSideBarWidth(); void saveSideBarWidth();
bool fullScreenNavigationVisible() const; bool fullScreenNavigationVisible() const;
@ -113,7 +112,6 @@ public:
signals: signals:
void startingCompleted(); void startingCompleted();
void message(Qz::AppMessageType mes, bool state);
void setWebViewMouseTracking(bool state); void setWebViewMouseTracking(bool state);
public slots: public slots:
@ -138,10 +136,11 @@ public slots:
void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString()); void showSource(QWebFrame* frame = 0, const QString &selectedHtml = QString());
void printPage(QWebFrame* frame = 0); void printPage(QWebFrame* frame = 0);
void showPageInfo(); void showPageInfo();
void receiveMessage(Qz::AppMessageType mes, bool state);
private slots: private slots:
void loadSettings();
void postLaunch(); void postLaunch();
void stop(); void stop();
void reload(); void reload();
void reloadByPassCache(); void reloadByPassCache();

View File

@ -302,7 +302,6 @@ MainApplication::MainApplication(int &argc, char** argv)
BrowserWindow* qupzilla = new BrowserWindow(Qz::BW_FirstAppWindow, startUrl); BrowserWindow* qupzilla = new BrowserWindow(Qz::BW_FirstAppWindow, startUrl);
m_mainWindows.prepend(qupzilla); m_mainWindows.prepend(qupzilla);
connect(qupzilla, SIGNAL(message(Qz::AppMessageType,bool)), this, SLOT(sendMessages(Qz::AppMessageType,bool)));
connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor())); connect(qupzilla, SIGNAL(startingCompleted()), this, SLOT(restoreCursor()));
loadSettings(); loadSettings();
@ -456,11 +455,10 @@ void MainApplication::loadSettings()
m_uaManager->loadSettings(); m_uaManager->loadSettings();
} }
void MainApplication::reloadSettings() void MainApplication::doReloadSettings()
{ {
QTimer::singleShot(0, this, SLOT(loadSettings())); loadSettings();
emit reloadSettings();
emit message(Qz::AM_ReloadSettings, true);
} }
void MainApplication::restoreCursor() void MainApplication::restoreCursor()
@ -494,7 +492,6 @@ BrowserWindow* MainApplication::getWindow()
void MainApplication::setStateChanged() void MainApplication::setStateChanged()
{ {
m_autoSaver->changeOcurred(); m_autoSaver->changeOcurred();
sendMessages(Qz::AM_HistoryStateChanged, true);
} }
QList<BrowserWindow*> MainApplication::mainWindows() QList<BrowserWindow*> MainApplication::mainWindows()
@ -567,11 +564,6 @@ QString MainApplication::currentProfilePath() const
return m_activeProfil; return m_activeProfil;
} }
void MainApplication::sendMessages(Qz::AppMessageType mes, bool state)
{
emit message(mes, state);
}
void MainApplication::receiveAppMessage(QString message) void MainApplication::receiveAppMessage(QString message)
{ {
QWidget* actWin = getWindow(); QWidget* actWin = getWindow();

View File

@ -69,7 +69,7 @@ public:
~MainApplication(); ~MainApplication();
void connectDatabase(); void connectDatabase();
void reloadSettings(); void doReloadSettings();
bool restoreStateSlot(BrowserWindow* window, RestoreData recoveryData); bool restoreStateSlot(BrowserWindow* window, RestoreData recoveryData);
BrowserWindow* makeNewWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl()); BrowserWindow* makeNewWindow(Qz::BrowserWindowType type, const QUrl &startUrl = QUrl());
void aboutToCloseWindow(BrowserWindow* window); void aboutToCloseWindow(BrowserWindow* window);
@ -131,7 +131,6 @@ public:
public slots: public slots:
bool saveStateSlot(); bool saveStateSlot();
void quitApplication(); void quitApplication();
void sendMessages(Qz::AppMessageType mes, bool state);
void receiveAppMessage(QString message); void receiveAppMessage(QString message);
void setStateChanged(); void setStateChanged();
void addNewTab(const QUrl &url = QUrl()); void addNewTab(const QUrl &url = QUrl());
@ -141,7 +140,7 @@ public slots:
bool checkDefaultWebBrowser(); bool checkDefaultWebBrowser();
signals: signals:
void message(Qz::AppMessageType mes, bool state); void reloadSettings();
private slots: private slots:
void loadSettings(); void loadSettings();

View File

@ -55,14 +55,6 @@ static const QString COPYRIGHT = "2010-2014";
static const QString WWWADDRESS = "http://www.qupzilla.com"; static const QString WWWADDRESS = "http://www.qupzilla.com";
static const QString WIKIADDRESS = "https://github.com/QupZilla/qupzilla/wiki"; static const QString WIKIADDRESS = "https://github.com/QupZilla/qupzilla/wiki";
enum AppMessageType {
AM_SetAdBlockIconEnabled,
AM_CheckPrivateBrowsing,
AM_ReloadSettings,
AM_HistoryStateChanged,
AM_BookmarksChanged
};
enum BrowserWindowType { enum BrowserWindowType {
BW_FirstAppWindow, BW_FirstAppWindow,
BW_OtherRestoredWindow, BW_OtherRestoredWindow,

View File

@ -96,7 +96,7 @@ LocationBar::LocationBar(BrowserWindow* window)
connect(down, SIGNAL(clicked(QPoint)), m_completer, SLOT(showMostVisited())); connect(down, SIGNAL(clicked(QPoint)), m_completer, SLOT(showMostVisited()));
connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText())); connect(mApp->searchEnginesManager(), SIGNAL(activeEngineChanged()), this, SLOT(updatePlaceHolderText()));
connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText())); connect(mApp->searchEnginesManager(), SIGNAL(defaultEngineChanged()), this, SLOT(updatePlaceHolderText()));
connect(mApp, SIGNAL(message(Qz::AppMessageType,bool)), SLOT(onMessage(Qz::AppMessageType,bool))); connect(mApp, SIGNAL(reloadSettings()), SLOT(loadSettings()));
loadSettings(); loadSettings();
clearIcon(); clearIcon();
@ -610,18 +610,6 @@ void LocationBar::loadSettings()
settings.endGroup(); settings.endGroup();
} }
void LocationBar::onMessage(Qz::AppMessageType msg, bool state)
{
Q_UNUSED(state)
if (!qzSettings->showLoadingProgress) {
return;
}
if (msg == Qz::AM_ReloadSettings) {
loadSettings();
}
}
void LocationBar::hideProgress() void LocationBar::hideProgress()
{ {
if (qzSettings->showLoadingProgress && m_loadProgress == 100) { if (qzSettings->showLoadingProgress && m_loadProgress == 100) {

View File

@ -78,7 +78,7 @@ private slots:
void onLoadFinished(); void onLoadFinished();
void hideProgress(); void hideProgress();
void onMessage(Qz::AppMessageType, bool); void loadSettings();
private: private:
enum ProgressStyle { enum ProgressStyle {
@ -101,8 +101,6 @@ private:
void showGoButton(); void showGoButton();
void hideGoButton(); void hideGoButton();
void loadSettings();
LocationCompleter* m_completer; LocationCompleter* m_completer;
BookmarksIcon* m_bookmarkIcon; BookmarksIcon* m_bookmarkIcon;

View File

@ -1078,7 +1078,7 @@ void Preferences::saveSettings()
m_themesManager->save(); m_themesManager->save();
mApp->cookieJar()->loadSettings(); mApp->cookieJar()->loadSettings();
mApp->history()->loadSettings(); mApp->history()->loadSettings();
mApp->reloadSettings(); mApp->doReloadSettings();
mApp->plugins()->c2f_saveSettings(); mApp->plugins()->c2f_saveSettings();
mApp->networkManager()->loadSettings(); mApp->networkManager()->loadSettings();
mApp->desktopNotifications()->loadSettings(); mApp->desktopNotifications()->loadSettings();

View File

@ -142,6 +142,8 @@ TabWidget::TabWidget(BrowserWindow* window, QWidget* parent)
connect(m_tabBar, SIGNAL(showButtons()), this, SLOT(showButtons())); connect(m_tabBar, SIGNAL(showButtons()), this, SLOT(showButtons()));
connect(m_tabBar, SIGNAL(hideButtons()), this, SLOT(hideButtons())); connect(m_tabBar, SIGNAL(hideButtons()), this, SLOT(hideButtons()));
connect(mApp, SIGNAL(reloadSettings()), this, SLOT(loadSettings()));
m_menuTabs = new MenuTabs(m_tabBar); m_menuTabs = new MenuTabs(m_tabBar);
m_buttonListTabs = new ToolButton(m_tabBar); m_buttonListTabs = new ToolButton(m_tabBar);

View File

@ -72,8 +72,6 @@ public:
explicit TabWidget(BrowserWindow* mainclass, QWidget* parent = 0); explicit TabWidget(BrowserWindow* mainclass, QWidget* parent = 0);
~TabWidget(); ~TabWidget();
void loadSettings();
QByteArray saveState(); QByteArray saveState();
bool restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab); bool restoreState(const QVector<WebTab::SavedTab> &tabs, int currentTab);
void closeRecoveryTab(); void closeRecoveryTab();
@ -139,6 +137,8 @@ signals:
void changed(); void changed();
private slots: private slots:
void loadSettings();
void aboutToShowTabsMenu(); void aboutToShowTabsMenu();
void actionChangeIndex(); void actionChangeIndex();
void tabMoved(int before, int after); void tabMoved(int before, int after);