From 45e28fa0aa79731ae4b89a52b72e2ca2da7f6afb Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Thu, 16 Jan 2014 22:15:14 +0100 Subject: [PATCH] Refactoring. --- src/gui/skinfactory.h | 6 +++--- src/gui/webbrowser.cpp | 15 --------------- src/gui/webbrowser.h | 10 +++++++--- src/gui/webview.cpp | 4 +--- src/gui/webview.h | 4 +++- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/src/gui/skinfactory.h b/src/gui/skinfactory.h index 67230a1ef..d970d8f7d 100644 --- a/src/gui/skinfactory.h +++ b/src/gui/skinfactory.h @@ -38,9 +38,6 @@ class SkinFactory : public QObject { bool loadSkinFromData(const Skin &skin); public: - // Singleton getter. - static SkinFactory *instance(); - // Destructor. virtual ~SkinFactory(); @@ -70,6 +67,9 @@ class SkinFactory : public QObject { // Sets the desired skin as the active one if it exists. void setCurrentSkinName(const QString &skin_name); + // Singleton getter. + static SkinFactory *instance(); + private: // Holds name of the current skin. Skin m_currentSkin; diff --git a/src/gui/webbrowser.cpp b/src/gui/webbrowser.cpp index 3e40dfc47..de164fb4d 100644 --- a/src/gui/webbrowser.cpp +++ b/src/gui/webbrowser.cpp @@ -6,7 +6,6 @@ #include "gui/skinfactory.h" #include "gui/webview.h" #include "gui/formmain.h" -#include "gui/locationlineedit.h" #include "gui/iconthemefactory.h" #include "gui/tabwidget.h" @@ -162,10 +161,6 @@ void WebBrowser::navigateToUrl(const QUrl &url) { } } -void WebBrowser::clear() { - m_webView->load(QUrl()); -} - void WebBrowser::navigateToMessages(const QList &messages) { SkinFactory *factory = SkinFactory::instance(); QString messages_layout; @@ -232,16 +227,6 @@ WebBrowser::~WebBrowser() { delete m_actionZoom; } - - - - - - -void WebBrowser::setFocus(Qt::FocusReason reason) { - m_txtLocation->setFocus(reason); -} - void WebBrowser::setupIcons() { m_actionZoom->setIcon(IconThemeFactory::instance()->fromTheme("zoom-fit-best")); m_actionBack->setIcon(IconThemeFactory::instance()->fromTheme("go-previous")); diff --git a/src/gui/webbrowser.h b/src/gui/webbrowser.h index 6f217e986..6b52e414b 100644 --- a/src/gui/webbrowser.h +++ b/src/gui/webbrowser.h @@ -4,6 +4,7 @@ #include "core/messagesmodel.h" #include "gui/tabcontent.h" #include "gui/webview.h" +#include "gui/locationlineedit.h" #include #include @@ -15,7 +16,6 @@ class QToolButton; class QVBoxLayout; class QMenu; -class LocationLineEdit; class WebBrowserNetworkAccessManager; class TabWidget; @@ -36,7 +36,9 @@ class WebBrowser : public TabContent { } // Sets this WebBrowser instance as focused. - void setFocus(Qt::FocusReason reason); + inline void setFocus(Qt::FocusReason reason) { + m_txtLocation->setFocus(reason); + } // Returns this instance. // NOTE: This is needed due to TabContent interface. @@ -77,7 +79,9 @@ class WebBrowser : public TabContent { void navigateToMessages(const QList &messages); // Clears contents. - void clear(); + inline void clear() { + m_webView->load(QUrl()); + } // Zoom manipulators. void increaseZoom(); diff --git a/src/gui/webview.cpp b/src/gui/webview.cpp index ac0dc8be0..5c14b1eb8 100644 --- a/src/gui/webview.cpp +++ b/src/gui/webview.cpp @@ -28,9 +28,7 @@ WebView::~WebView() { qDebug("Destroying BaseWebView."); } -WebPage *WebView::page() const { - return m_page; -} + void WebView::onLoadFinished(bool ok) { // If page was not loaded, then display custom error page. diff --git a/src/gui/webview.h b/src/gui/webview.h index a769b7400..b8a02a729 100644 --- a/src/gui/webview.h +++ b/src/gui/webview.h @@ -17,7 +17,9 @@ class WebView : public QWebView { virtual ~WebView(); // Page accessor. - WebPage *page() const; + inline WebPage *page() const { + return m_page; + } void setupIcons();