From c0b04f660edb123e63c539bc43e43fce24981720 Mon Sep 17 00:00:00 2001 From: nowrep Date: Sun, 19 Aug 2012 19:47:28 +0200 Subject: [PATCH] Moved WebPage::applyDirectionToPage into globalfunctions.h --- src/lib/downloads/downloaditem.cpp | 4 ++-- src/lib/network/qupzillaschemehandler.cpp | 10 +++++----- src/lib/tools/globalfunctions.cpp | 19 +++++++++++++++++++ src/lib/tools/globalfunctions.h | 2 ++ src/lib/webview/webpage.cpp | 23 ++--------------------- src/lib/webview/webpage.h | 1 - 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/src/lib/downloads/downloaditem.cpp b/src/lib/downloads/downloaditem.cpp index 46641d96f..b0e86b06c 100644 --- a/src/lib/downloads/downloaditem.cpp +++ b/src/lib/downloads/downloaditem.cpp @@ -388,8 +388,8 @@ void DownloadItem::openFolder() { #ifdef Q_WS_WIN QString winFileName = m_path + m_fileName; - winFileName.replace("/","\\"); - QProcess::startDetached("explorer.exe /e,/select,\""+winFileName+"\""); + winFileName.replace("/", "\\"); + QProcess::startDetached("explorer.exe /e,/select,\"" + winFileName + "\""); #else QDesktopServices::openUrl(QUrl::fromLocalFile(m_path)); #endif diff --git a/src/lib/network/qupzillaschemehandler.cpp b/src/lib/network/qupzillaschemehandler.cpp index 62c3b2ee1..6d7ceccee 100644 --- a/src/lib/network/qupzillaschemehandler.cpp +++ b/src/lib/network/qupzillaschemehandler.cpp @@ -149,7 +149,7 @@ QString QupZillaSchemeReply::reportbugPage() bPage.replace("%SEND%", tr("Send")); bPage.replace("%E-MAIL-OPTIONAL%", tr("E-mail is optional
Note: Please read how to make a bug report here first.").arg("https://github.com/QupZilla/qupzilla/wiki/Bug-Reports target=_blank")); bPage.replace("%FIELDS-ARE-REQUIRED%", tr("Please fill out all required fields!")); - bPage = WebPage::applyDirectionToPage(bPage); + bPage = qz_applyDirectionToPage(bPage); return bPage; } @@ -173,7 +173,7 @@ QString QupZillaSchemeReply::startPage() sPage.replace("%WWW%", QupZilla::WIKIADDRESS); sPage.replace("%ABOUT-QUPZILLA%", tr("About QupZilla")); sPage.replace("%PRIVATE-BROWSING%", mApp->isPrivateSession() ? tr("

Private Browsing

") : ""); - sPage = WebPage::applyDirectionToPage(sPage); + sPage = qz_applyDirectionToPage(sPage); return sPage; } @@ -241,7 +241,7 @@ QString QupZillaSchemeReply::aboutPage() authorString("Piccoro McKay Lenz", "mckaygerhard@gmail.com") + " (Venezulean Spanish)
" + authorString("Stanislav Kuznietsov", "stanislav_kuznetsov@ukr.net") + " (Ukrainian)" ); - aPage = WebPage::applyDirectionToPage(aPage); + aPage = qz_applyDirectionToPage(aPage); } return aPage; @@ -288,7 +288,7 @@ QString QupZillaSchemeReply::speeddialPage() dPage.replace("%TXT_NRROWS%", tr("Maximum pages in a row:")); dPage.replace("%TXT_SDSIZE%", tr("Change size of pages:")); dPage.replace("%TXT_CNTRDLS%", tr("Center speed dials")); - dPage = WebPage::applyDirectionToPage(dPage); + dPage = qz_applyDirectionToPage(dPage); } QString page = dPage; @@ -380,7 +380,7 @@ QString QupZillaSchemeReply::configPage() QString("
%1
%2
").arg(tr("KDE integration"), KDEIntegration) + QString("
%1
%2
").arg(tr("Portable build"), portableBuild)); - cPage = WebPage::applyDirectionToPage(cPage); + cPage = qz_applyDirectionToPage(cPage); } QString page = cPage; diff --git a/src/lib/tools/globalfunctions.cpp b/src/lib/tools/globalfunctions.cpp index b368a196c..415cf0bc7 100644 --- a/src/lib/tools/globalfunctions.cpp +++ b/src/lib/tools/globalfunctions.cpp @@ -301,6 +301,25 @@ QPixmap qz_createPixmapForSite(const QIcon &icon, const QString &title, const QS return pixmap; } +QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents) +{ + QString direction = "ltr"; + QString right_str = "right"; + QString left_str = "left"; + + if (QApplication::isRightToLeft()) { + direction = "rtl"; + right_str = "left"; + left_str = "right"; + } + + pageContents.replace("%DIRECTION%", direction); + pageContents.replace("%RIGHT_STR%", right_str); + pageContents.replace("%LEFT_STR%", left_str); + + return pageContents; +} + QString qz_buildSystem() { #ifdef Q_OS_LINUX diff --git a/src/lib/tools/globalfunctions.h b/src/lib/tools/globalfunctions.h index 167718215..f4bebdf71 100644 --- a/src/lib/tools/globalfunctions.h +++ b/src/lib/tools/globalfunctions.h @@ -51,6 +51,8 @@ QString QT_QUPZILLA_EXPORT qz_filterCharsFromFilename(const QString &name); QString QT_QUPZILLA_EXPORT qz_alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width); QPixmap QT_QUPZILLA_EXPORT qz_createPixmapForSite(const QIcon &icon, const QString &title, const QString &url); +QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents); + QString QT_QUPZILLA_EXPORT qz_buildSystem(); diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index 50a17b89d..50f22e53b 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -691,7 +691,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte errString.replace("%FAVICON%", "qrc:html/adblock_big.png"); errString.replace("%RULE%", tr("Blocked by %1").arg(rule)); - errString = applyDirectionToPage(errString); + errString = qz_applyDirectionToPage(errString); exReturn->baseUrl = exOption->url; exReturn->content = QString(errString + "").toUtf8(); @@ -746,7 +746,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte errString.replace("%LI-2%", tr("If you are unable to load any pages, check your computer's network connection.")); errString.replace("%LI-3%", tr("If your computer or network is protected by a firewall or proxy, make sure that QupZilla is permitted to access the Web.")); errString.replace("%TRY-AGAIN%", tr("Try Again")); - errString = applyDirectionToPage(errString); + errString = qz_applyDirectionToPage(errString); exReturn->content = QString(errString + "").toUtf8(); return true; @@ -943,22 +943,3 @@ WebPage::~WebPage() s_livingPages.removeOne(this); } - -QString WebPage::applyDirectionToPage(const QString &pageContents) -{ - QString direction = "ltr"; - QString right_str = "right"; - QString left_str = "left"; - if (QApplication::isRightToLeft()) { - direction = "rtl"; - right_str = "left"; - left_str = "right"; - } - - QString result = pageContents; - result.replace("%DIRECTION%", direction); - result.replace("%RIGHT_STR%", right_str); - result.replace("%LEFT_STR%", left_str); - - return result; -} diff --git a/src/lib/webview/webpage.h b/src/lib/webview/webpage.h index e5b009f51..2ad635387 100644 --- a/src/lib/webview/webpage.h +++ b/src/lib/webview/webpage.h @@ -78,7 +78,6 @@ public: static bool isPointerSafeToUse(WebPage* page); void disconnectObjects(); - static QString applyDirectionToPage(const QString &pageContents); signals: void privacyChanged(bool status);