From e28f9d438e4253a432ae57752a4cb87c682987ae Mon Sep 17 00:00:00 2001 From: nowrep Date: Tue, 22 Jan 2013 19:04:22 +0100 Subject: [PATCH] [Code] qz_ prefixed functions moved to QzTools namespace. --- src/lib/adblock/adblockmanager.cpp | 6 +- src/lib/adblock/adblocksubscription.cpp | 12 +-- src/lib/app/mainapplication.cpp | 4 +- src/lib/app/profileupdater.cpp | 6 +- src/lib/app/qupzilla.cpp | 8 +- src/lib/bookmarks/bookmarksmanager.cpp | 2 +- src/lib/bookmarksimport/chromeimporter.cpp | 2 +- src/lib/cookies/cookiemanager.cpp | 4 +- src/lib/downloads/downloadfilehelper.cpp | 8 +- src/lib/downloads/downloaditem.cpp | 6 +- src/lib/downloads/downloadmanager.cpp | 4 +- src/lib/history/historyitem.cpp | 6 +- src/lib/lib.pro | 4 +- src/lib/navigation/locationbar.cpp | 4 +- src/lib/navigation/siteicon.cpp | 4 +- src/lib/network/cabundleupdater.cpp | 4 +- src/lib/network/networkmanager.cpp | 10 +-- .../schemehandlers/fileschemehandler.cpp | 14 ++-- .../schemehandlers/qupzillaschemehandler.cpp | 36 ++++----- src/lib/other/browsinglibrary.cpp | 8 +- src/lib/other/clearprivatedata.cpp | 6 +- src/lib/other/licenseviewer.cpp | 6 +- src/lib/other/pagescreen.cpp | 4 +- src/lib/other/sourceviewer.cpp | 4 +- src/lib/other/useragentmanager.cpp | 4 +- src/lib/plugins/clicktoflash.cpp | 28 +++---- src/lib/popupwindow/popuplocationbar.cpp | 4 +- src/lib/popupwindow/popupwindow.cpp | 4 +- src/lib/preferences/pluginsmanager.cpp | 4 +- src/lib/preferences/preferences.cpp | 6 +- src/lib/preferences/sslmanager.cpp | 4 +- src/lib/preferences/thememanager.cpp | 6 +- src/lib/preferences/useragentdialog.cpp | 4 +- src/lib/rss/rssmanager.cpp | 2 +- src/lib/tools/certificateinfowidget.cpp | 4 +- src/lib/tools/globalfunctions.h | 74 ------------------ .../{globalfunctions.cpp => qztools.cpp} | 54 ++++++------- src/lib/tools/qztools.h | 77 +++++++++++++++++++ src/lib/webview/siteinfo.cpp | 12 +-- src/lib/webview/siteinfowidget.cpp | 4 +- src/lib/webview/webpage.cpp | 20 ++--- src/lib/webview/webtab.cpp | 2 +- src/lib/webview/webview.cpp | 6 +- .../GreaseMonkey/gm_addscriptdialog.cpp | 4 +- src/plugins/GreaseMonkey/gm_downloader.cpp | 8 +- src/plugins/GreaseMonkey/gm_manager.cpp | 6 +- 46 files changed, 256 insertions(+), 253 deletions(-) delete mode 100644 src/lib/tools/globalfunctions.h rename src/lib/tools/{globalfunctions.cpp => qztools.cpp} (85%) create mode 100644 src/lib/tools/qztools.h diff --git a/src/lib/adblock/adblockmanager.cpp b/src/lib/adblock/adblockmanager.cpp index d00681cdb..4a88c8065 100644 --- a/src/lib/adblock/adblockmanager.cpp +++ b/src/lib/adblock/adblockmanager.cpp @@ -21,7 +21,7 @@ #include "adblockblockednetworkreply.h" #include "mainapplication.h" #include "webpage.h" -#include "globalfunctions.h" +#include "qztools.h" #include "networkmanager.h" #include "qupzilla.h" #include "settings.h" @@ -128,8 +128,8 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString &title, const return 0; } - QString fileName = qz_filterCharsFromFilename(title.toLower()) + ".txt"; - QString filePath = qz_ensureUniqueFilename(mApp->currentProfilePath() + "adblock/" + fileName); + QString fileName = QzTools::filterCharsFromFilename(title.toLower()) + ".txt"; + QString filePath = QzTools::ensureUniqueFilename(mApp->currentProfilePath() + "adblock/" + fileName); QByteArray data = QString("Title: %1\nUrl: %2\n[Adblock Plus 1.1.1]").arg(title, url).toLatin1(); diff --git a/src/lib/adblock/adblocksubscription.cpp b/src/lib/adblock/adblocksubscription.cpp index b960f0eda..d14e7356a 100644 --- a/src/lib/adblock/adblocksubscription.cpp +++ b/src/lib/adblock/adblocksubscription.cpp @@ -46,7 +46,7 @@ #include "adblockmanager.h" #include "mainapplication.h" #include "networkmanager.h" -#include "globalfunctions.h" +#include "qztools.h" #include "followredirectreply.h" #include @@ -257,7 +257,7 @@ QString AdBlockSubscription::elementHidingRulesForDomain(const QString &domain) const AdBlockRule* AdBlockSubscription::rule(int offset) const { - if (!qz_listContainsIndex(m_rules, offset)) { + if (!QzTools::listContainsIndex(m_rules, offset)) { return 0; } @@ -271,7 +271,7 @@ QList AdBlockSubscription::allRules() const const AdBlockRule* AdBlockSubscription::enableRule(int offset) { - if (!qz_listContainsIndex(m_rules, offset)) { + if (!QzTools::listContainsIndex(m_rules, offset)) { return 0; } @@ -289,7 +289,7 @@ const AdBlockRule* AdBlockSubscription::enableRule(int offset) const AdBlockRule* AdBlockSubscription::disableRule(int offset) { - if (!qz_listContainsIndex(m_rules, offset)) { + if (!QzTools::listContainsIndex(m_rules, offset)) { return 0; } @@ -479,7 +479,7 @@ int AdBlockCustomList::addRule(const AdBlockRule &rule) bool AdBlockCustomList::removeRule(int offset) { - if (!qz_listContainsIndex(m_rules, offset)) { + if (!QzTools::listContainsIndex(m_rules, offset)) { return false; } @@ -497,7 +497,7 @@ bool AdBlockCustomList::removeRule(int offset) const AdBlockRule* AdBlockCustomList::replaceRule(const AdBlockRule &rule, int offset) { - if (!qz_listContainsIndex(m_rules, offset)) { + if (!QzTools::listContainsIndex(m_rules, offset)) { return 0; } diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 02937ac2a..ad0ae3b3d 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -37,7 +37,7 @@ #include "qtwin.h" #include "mainapplication.h" #include "webhistoryinterface.h" -#include "globalfunctions.h" +#include "qztools.h" #include "profileupdater.h" #include "searchenginesmanager.h" #include "databasewriter.h" @@ -1057,7 +1057,7 @@ void MainApplication::clearTempPath() QDir dir(path); if (dir.exists()) { - qz_removeDir(path); + QzTools::removeDir(path); } } diff --git a/src/lib/app/profileupdater.cpp b/src/lib/app/profileupdater.cpp index b684efb7d..803d5a96b 100644 --- a/src/lib/app/profileupdater.cpp +++ b/src/lib/app/profileupdater.cpp @@ -18,7 +18,7 @@ #include "profileupdater.h" #include "qupzilla.h" #include "updater.h" -#include "globalfunctions.h" +#include "qztools.h" #include "mainapplication.h" #include @@ -112,8 +112,8 @@ void ProfileUpdater::copyDataToProfile() QFile browseData(m_profilePath + "browsedata.db"); if (browseData.exists()) { - const QString &browseDataBackup = qz_ensureUniqueFilename(m_profilePath + "browsedata-backup.db"); - const QString &settingsBackup = qz_ensureUniqueFilename(m_profilePath + "settings-backup.ini"); + const QString &browseDataBackup = QzTools::ensureUniqueFilename(m_profilePath + "browsedata-backup.db"); + const QString &settingsBackup = QzTools::ensureUniqueFilename(m_profilePath + "settings-backup.ini"); browseData.copy(browseDataBackup); QFile(m_profilePath + "settings.ini").copy(settingsBackup); const QString &text = "Incompatible profile version has been detected. To avoid losing your profile data, they were " diff --git a/src/lib/app/qupzilla.cpp b/src/lib/app/qupzilla.cpp index af50cba12..c328d7172 100644 --- a/src/lib/app/qupzilla.cpp +++ b/src/lib/app/qupzilla.cpp @@ -56,7 +56,7 @@ #include "pagescreen.h" #include "webinspectordockwidget.h" #include "bookmarksimportdialog.h" -#include "globalfunctions.h" +#include "qztools.h" #include "reloadstopbutton.h" #include "enhancedmenu.h" #include "settings.h" @@ -1286,7 +1286,7 @@ void QupZilla::showSource(QWebFrame* frame, const QString &selectedHtml) } SourceViewer* source = new SourceViewer(frame, selectedHtml); - qz_centerWidgetToParent(source, this); + QzTools::centerWidgetToParent(source, this); source->show(); } @@ -1953,7 +1953,7 @@ bool QupZilla::restoreState(const QByteArray &state, int version) #ifdef QZ_WS_X11 int QupZilla::getCurrentVirtualDesktop() const { - Display* display = static_cast(qz_X11Display(this)); + Display* display = static_cast(QzTools::X11Display(this)); Atom actual_type; int actual_format; unsigned long nitems; @@ -1986,7 +1986,7 @@ void QupZilla::moveToVirtualDesktop(int desktopId) return; } - Display* display = static_cast(qz_X11Display(this)); + Display* display = static_cast(QzTools::X11Display(this)); Atom net_wm_desktop = XInternAtom(display, "_NET_WM_DESKTOP", False); if (net_wm_desktop == None) { diff --git a/src/lib/bookmarks/bookmarksmanager.cpp b/src/lib/bookmarks/bookmarksmanager.cpp index cad14400c..983074877 100644 --- a/src/lib/bookmarks/bookmarksmanager.cpp +++ b/src/lib/bookmarks/bookmarksmanager.cpp @@ -25,7 +25,7 @@ #include "bookmarksmodel.h" #include "iconprovider.h" #include "browsinglibrary.h" -#include "globalfunctions.h" +#include "qztools.h" #include "bookmarksimportdialog.h" #include "iconchooser.h" #include "webtab.h" diff --git a/src/lib/bookmarksimport/chromeimporter.cpp b/src/lib/bookmarksimport/chromeimporter.cpp index 0d66d9f03..8cf217697 100644 --- a/src/lib/bookmarksimport/chromeimporter.cpp +++ b/src/lib/bookmarksimport/chromeimporter.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "chromeimporter.h" -#include "globalfunctions.h" +#include "qztools.h" #include "bookmarksimportdialog.h" #include diff --git a/src/lib/cookies/cookiemanager.cpp b/src/lib/cookies/cookiemanager.cpp index 4d3a7271a..82cdab912 100644 --- a/src/lib/cookies/cookiemanager.cpp +++ b/src/lib/cookies/cookiemanager.cpp @@ -20,7 +20,7 @@ #include "qupzilla.h" #include "cookiejar.h" #include "mainapplication.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include @@ -37,7 +37,7 @@ CookieManager::CookieManager(QWidget* parent) , m_refreshCookieJar(true) { ui->setupUi(this); - qz_centerWidgetOnScreen(this); + QzTools::centerWidgetOnScreen(this); // Stored Cookies connect(ui->cookieTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), this, SLOT(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*))); diff --git a/src/lib/downloads/downloadfilehelper.cpp b/src/lib/downloads/downloadfilehelper.cpp index 93258d847..0985e765e 100644 --- a/src/lib/downloads/downloadfilehelper.cpp +++ b/src/lib/downloads/downloadfilehelper.cpp @@ -23,7 +23,7 @@ #include "qupzilla.h" #include "downloaditem.h" #include "downloadmanager.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include @@ -78,7 +78,7 @@ void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, const Do m_fileSize = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(); if (m_fileSize > 0) { - mimeType.append(QString(" (%1)").arg(qz_fileSizeToString(m_fileSize))); + mimeType.append(QString(" (%1)").arg(QzTools::fileSizeToString(m_fileSize))); } // Close Empty Tab @@ -222,7 +222,7 @@ void DownloadFileHelper::fileNameChoosed(const QString &name, bool fileNameAutoG } if (fileNameAutoGenerated) { - m_fileName = qz_ensureUniqueFilename(m_fileName); + m_fileName = QzTools::ensureUniqueFilename(m_fileName); } if (!m_path.contains(mApp->tempPath())) { @@ -291,7 +291,7 @@ QString DownloadFileHelper::getFileName(QNetworkReply* reply) name.remove(QLatin1String("\";")); } - return qz_filterCharsFromFilename(name); + return QzTools::filterCharsFromFilename(name); } DownloadFileHelper::~DownloadFileHelper() diff --git a/src/lib/downloads/downloaditem.cpp b/src/lib/downloads/downloaditem.cpp index cc6976680..6d2c50cba 100644 --- a/src/lib/downloads/downloaditem.cpp +++ b/src/lib/downloads/downloaditem.cpp @@ -24,7 +24,7 @@ #include "downloadmanager.h" #include "iconprovider.h" #include "networkmanager.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -255,8 +255,8 @@ void DownloadItem::updateDownloadInfo(double currSpeed, qint64 received, qint64 QString remTime = remaingTimeToString(time); m_remTime = time; - QString currSize = qz_fileSizeToString(received); - QString fileSize = qz_fileSizeToString(total); + QString currSize = QzTools::fileSizeToString(received); + QString fileSize = QzTools::fileSizeToString(total); if (fileSize == tr("Unknown size")) { ui->downloadInfo->setText(tr("%2 - unknown size (%3)").arg(currSize, speed)); diff --git a/src/lib/downloads/downloadmanager.cpp b/src/lib/downloads/downloadmanager.cpp index 9b6dd89aa..4a30263e4 100644 --- a/src/lib/downloads/downloadmanager.cpp +++ b/src/lib/downloads/downloadmanager.cpp @@ -25,7 +25,7 @@ #include "networkmanager.h" #include "qtwin.h" #include "desktopnotificationsfactory.h" -#include "globalfunctions.h" +#include "qztools.h" #include "webpage.h" #include "downloadfilehelper.h" #include "settings.h" @@ -48,7 +48,7 @@ DownloadManager::DownloadManager(QWidget* parent) } #endif ui->clearButton->setIcon(QIcon::fromTheme("edit-clear")); - qz_centerWidgetOnScreen(this); + QzTools::centerWidgetOnScreen(this); m_networkManager = mApp->networkManager(); diff --git a/src/lib/history/historyitem.cpp b/src/lib/history/historyitem.cpp index c75554bf8..73012357e 100644 --- a/src/lib/history/historyitem.cpp +++ b/src/lib/history/historyitem.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "historyitem.h" -#include "globalfunctions.h" +#include "qztools.h" HistoryItem::HistoryItem(HistoryItem* parent) : canFetchMore(false) @@ -82,7 +82,7 @@ void HistoryItem::insertChild(int row, HistoryItem* child) void HistoryItem::removeChild(int row) { - if (qz_listContainsIndex(m_children, row)) { + if (QzTools::listContainsIndex(m_children, row)) { removeChild(m_children.at(row)); } } @@ -94,7 +94,7 @@ void HistoryItem::removeChild(HistoryItem* child) HistoryItem* HistoryItem::child(int row) const { - if (qz_listContainsIndex(m_children, row)) { + if (QzTools::listContainsIndex(m_children, row)) { return m_children.at(row); } diff --git a/src/lib/lib.pro b/src/lib/lib.pro index 586f24688..b3ae4961f 100644 --- a/src/lib/lib.pro +++ b/src/lib/lib.pro @@ -127,7 +127,7 @@ SOURCES += \ navigation/navigationbar.cpp \ navigation/reloadstopbutton.cpp \ preferences/thememanager.cpp \ - tools/globalfunctions.cpp \ + tools/qztools.cpp \ other/pagescreen.cpp \ downloads/downloadfilehelper.cpp \ tools/certificateinfowidget.cpp \ @@ -286,7 +286,7 @@ HEADERS += \ navigation/navigationbar.h \ navigation/reloadstopbutton.h \ preferences/thememanager.h \ - tools/globalfunctions.h \ + tools/qztools.h \ other/pagescreen.h \ downloads/downloadfilehelper.h \ tools/certificateinfowidget.h \ diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index d50fde91c..c50eb40f3 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -35,7 +35,7 @@ #include "goicon.h" #include "rssicon.h" #include "downicon.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include "qzsettings.h" #include "colors.h" @@ -162,7 +162,7 @@ QUrl LocationBar::createUrl() QString LocationBar::convertUrlToText(const QUrl &url) const { - QString stringUrl = qz_urlEncodeQueryString(url); + QString stringUrl = QzTools::urlEncodeQueryString(url); if (stringUrl == QLatin1String("qupzilla:speeddial") || stringUrl == QLatin1String("about:blank")) { stringUrl = ""; diff --git a/src/lib/navigation/siteicon.cpp b/src/lib/navigation/siteicon.cpp index 67ccdf4c4..c11c45308 100644 --- a/src/lib/navigation/siteicon.cpp +++ b/src/lib/navigation/siteicon.cpp @@ -18,7 +18,7 @@ #include "siteicon.h" #include "locationbar.h" #include "tabbedwebview.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -82,7 +82,7 @@ void SiteIcon::mouseMoveEvent(QMouseEvent* e) mime->setImageData(icon().pixmap(16, 16).toImage()); drag->setMimeData(mime); - drag->setPixmap(qz_createPixmapForSite(icon(), title, url.toString())); + drag->setPixmap(QzTools::createPixmapForSite(icon(), title, url.toString())); drag->exec(); } diff --git a/src/lib/network/cabundleupdater.cpp b/src/lib/network/cabundleupdater.cpp index 56c84b81d..f2cac7870 100644 --- a/src/lib/network/cabundleupdater.cpp +++ b/src/lib/network/cabundleupdater.cpp @@ -19,7 +19,7 @@ #include "mainapplication.h" #include "networkmanager.h" #include "qupzilla.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -79,7 +79,7 @@ void CaBundleUpdater::replyFinished() } m_latestBundleVersion = response.toInt(); - int currentBundleVersion = qz_readAllFileContents(m_bundleVersionFileName).trimmed().toInt(); + int currentBundleVersion = QzTools::readAllFileContents(m_bundleVersionFileName).trimmed().toInt(); if (m_latestBundleVersion == 0) { return; diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index d9487b1aa..101cebf8d 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -25,7 +25,7 @@ #include "adblockmanager.h" #include "networkproxyfactory.h" #include "certificateinfowidget.h" -#include "globalfunctions.h" +#include "qztools.h" #include "acceptlanguage.h" #include "cabundleupdater.h" #include "settings.h" @@ -53,7 +53,7 @@ static QString fileNameForCert(const QSslCertificate &cert) QString certFileName = CertificateInfoWidget::certificateItemText(cert); certFileName.remove(QLatin1Char(' ')); certFileName.append(QLatin1String(".crt")); - certFileName = qz_filterCharsFromFilename(certFileName); + certFileName = QzTools::filterCharsFromFilename(certFileName); while (certFileName.startsWith(QLatin1Char('.'))) { certFileName = certFileName.mid(1); @@ -134,7 +134,7 @@ void NetworkManager::setSSLConfiguration(QNetworkReply* reply) { if (!reply->sslConfiguration().isNull()) { QSslCertificate cert = reply->sslConfiguration().peerCertificate(); - if (!qz_isCertificateValid(cert) || reply->property("downReply").toBool()) { + if (!QzTools::isCertificateValid(cert) || reply->property("downReply").toBool()) { return; } @@ -273,7 +273,7 @@ void NetworkManager::authentication(QNetworkReply* reply, QAuthenticator* auth) connect(box, SIGNAL(accepted()), dialog, SLOT(accept())); label->setText(tr("A username and password are being requested by %1. " - "The site says: \"%2\"").arg(reply->url().toEncoded(), qz_escape(auth->realm()))); + "The site says: \"%2\"").arg(reply->url().toEncoded(), QzTools::escape(auth->realm()))); formLa->addRow(label); formLa->addRow(userLab, user); @@ -455,7 +455,7 @@ void NetworkManager::addLocalCertificate(const QSslCertificate &cert) } QString certFileName = fileNameForCert(cert); - QString fileName = qz_ensureUniqueFilename(mApp->currentProfilePath() + "certificates/" + certFileName); + QString fileName = QzTools::ensureUniqueFilename(mApp->currentProfilePath() + "certificates/" + certFileName); QFile file(fileName); if (file.open(QFile::WriteOnly)) { diff --git a/src/lib/network/schemehandlers/fileschemehandler.cpp b/src/lib/network/schemehandlers/fileschemehandler.cpp index ea29f7c7d..887ae2fa6 100644 --- a/src/lib/network/schemehandlers/fileschemehandler.cpp +++ b/src/lib/network/schemehandlers/fileschemehandler.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "fileschemehandler.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include "downloadoptionsdialog.h" #include "mainapplication.h" @@ -81,7 +81,7 @@ void FileSchemeHandler::handleUrl(const QUrl &url) // Save const QString &savePath = QFileDialog::getSaveFileName(mApp->getWindow(), QObject::tr("Save file as..."), - QDir::homePath() + "/" + qz_getFileNameFromUrl(url)); + QDir::homePath() + "/" + QzTools::getFileNameFromUrl(url)); if (!savePath.isEmpty()) { file.copy(savePath); @@ -143,15 +143,15 @@ QString FileSchemeReply::loadDirectory() static QString sPage; if (sPage.isEmpty()) { - sPage = qz_readAllFileContents(":/html/dirlist.html"); + sPage = QzTools::readAllFileContents(":/html/dirlist.html"); sPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); - sPage.replace(QLatin1String("%UP-IMG%"), qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_FileDialogToParent).pixmap(22))); + sPage.replace(QLatin1String("%UP-IMG%"), QzTools::pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_FileDialogToParent).pixmap(22))); sPage.replace(QLatin1String("%UP-DIR-TEXT%"), tr("Up to higher level directory")); sPage.replace(QLatin1String("%SHOW-HIDDEN-TEXT%"), tr("Show hidden files")); sPage.replace(QLatin1String("%NAME%"), tr("Name")); sPage.replace(QLatin1String("%SIZE%"), tr("Size")); sPage.replace(QLatin1String("%MODIFIED%"), tr("Last modified")); - sPage = qz_applyDirectionToPage(sPage); + sPage = QzTools::applyDirectionToPage(sPage); } QString page = sPage; @@ -182,14 +182,14 @@ QString FileSchemeReply::loadDirectory() } line += QLatin1String(">"); line += QLatin1String(""); line += info.fileName(); line += QLatin1String(""); - line += info.isDir() ? QString() : qz_fileSizeToString(info.size()); + line += info.isDir() ? QString() : QzTools::fileSizeToString(info.size()); line += QLatin1String(""); line += info.lastModified().toString("dd.MM.yyyy"); line += QLatin1String(""); diff --git a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp index 097f7ee2c..7b8977b8a 100644 --- a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp +++ b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "qupzillaschemehandler.h" -#include "globalfunctions.h" +#include "qztools.h" #include "qupzilla.h" #include "mainapplication.h" #include "tabbedwebview.h" @@ -138,7 +138,7 @@ QString QupZillaSchemeReply::reportbugPage() return bPage; } - bPage.append(qz_readAllFileContents(":html/reportbug.html")); + bPage.append(QzTools::readAllFileContents(":html/reportbug.html")); bPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); bPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); @@ -152,7 +152,7 @@ QString QupZillaSchemeReply::reportbugPage() bPage.replace(QLatin1String("%SEND%"), tr("Send")); bPage.replace(QLatin1String("%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(QLatin1String("%FIELDS-ARE-REQUIRED%"), tr("Please fill out all required fields!")); - bPage = qz_applyDirectionToPage(bPage); + bPage = QzTools::applyDirectionToPage(bPage); return bPage; } @@ -165,7 +165,7 @@ QString QupZillaSchemeReply::startPage() return sPage; } - sPage.append(qz_readAllFileContents(":html/start.html")); + sPage.append(QzTools::readAllFileContents(":html/start.html")); sPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); sPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); sPage.replace(QLatin1String("%ABOUT-IMG%"), QLatin1String("qrc:icons/other/about.png")); @@ -176,7 +176,7 @@ QString QupZillaSchemeReply::startPage() sPage.replace(QLatin1String("%WWW%"), QupZilla::WIKIADDRESS); sPage.replace(QLatin1String("%ABOUT-QUPZILLA%"), tr("About QupZilla")); sPage.replace(QLatin1String("%PRIVATE-BROWSING%"), mApp->isPrivateSession() ? tr("

Private Browsing

") : QString()); - sPage = qz_applyDirectionToPage(sPage); + sPage = QzTools::applyDirectionToPage(sPage); return sPage; } @@ -186,11 +186,11 @@ QString QupZillaSchemeReply::aboutPage() static QString aPage; if (aPage.isEmpty()) { - aPage.append(qz_readAllFileContents(":html/about.html")); + aPage.append(QzTools::readAllFileContents(":html/about.html")); aPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); aPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); aPage.replace(QLatin1String("%ABOUT-IMG%"), QLatin1String("qrc:icons/other/about.png")); - aPage.replace(QLatin1String("%COPYRIGHT-INCLUDE%"), qz_escape(qz_readAllFileContents(":html/copyright"))); + aPage.replace(QLatin1String("%COPYRIGHT-INCLUDE%"), QzTools::escape(QzTools::readAllFileContents(":html/copyright"))); aPage.replace(QLatin1String("%TITLE%"), tr("About QupZilla")); aPage.replace(QLatin1String("%ABOUT-QUPZILLA%"), tr("About QupZilla")); @@ -247,7 +247,7 @@ QString QupZillaSchemeReply::aboutPage() authorString("Stanislav Kuznietsov", "stanislav_kuznetsov@ukr.net") + " (Ukrainian)
" + authorString("Seyyed Razi Alavizadeh", "s.r.alavizadeh@gmail.com") + " (Persian)" ); - aPage = qz_applyDirectionToPage(aPage); + aPage = QzTools::applyDirectionToPage(aPage); } return aPage; @@ -258,7 +258,7 @@ QString QupZillaSchemeReply::speeddialPage() static QString dPage; if (dPage.isEmpty()) { - dPage.append(qz_readAllFileContents(":html/speeddial.html")); + dPage.append(QzTools::readAllFileContents(":html/speeddial.html")); dPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); dPage.replace(QLatin1String("%IMG_PLUS%"), QLatin1String("qrc:html/plus.png")); dPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border-small.png")); @@ -294,7 +294,7 @@ QString QupZillaSchemeReply::speeddialPage() dPage.replace(QLatin1String("%TXT_NRROWS%"), tr("Maximum pages in a row:")); dPage.replace(QLatin1String("%TXT_SDSIZE%"), tr("Change size of pages:")); dPage.replace(QLatin1String("%TXT_CNTRDLS%"), tr("Center speed dials")); - dPage = qz_applyDirectionToPage(dPage); + dPage = QzTools::applyDirectionToPage(dPage); } QString page = dPage; @@ -315,10 +315,10 @@ QString QupZillaSchemeReply::restorePage() static QString rPage; if (rPage.isEmpty()) { - rPage.append(qz_readAllFileContents(":html/restore.html")); + rPage.append(QzTools::readAllFileContents(":html/restore.html")); rPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); rPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); - rPage.replace(QLatin1String("%IMAGE%"), qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45))); + rPage.replace(QLatin1String("%IMAGE%"), QzTools::pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45))); rPage.replace(QLatin1String("%TITLE%"), tr("Restore Session")); @@ -326,7 +326,7 @@ QString QupZillaSchemeReply::restorePage() rPage.replace(QLatin1String("%APOLOGIZE%"), tr("We apologize for this. Would you like to restore the last saved state?")); rPage.replace(QLatin1String("%TRY-REMOVING%"), tr("Try removing one or more tabs that you think cause troubles")); rPage.replace(QLatin1String("%START-NEW%"), tr("Or you can start completely new session")); - rPage = qz_applyDirectionToPage(rPage); + rPage = QzTools::applyDirectionToPage(rPage); } return rPage; @@ -337,7 +337,7 @@ QString QupZillaSchemeReply::configPage() static QString cPage; if (cPage.isEmpty()) { - cPage.append(qz_readAllFileContents(":html/config.html")); + cPage.append(QzTools::readAllFileContents(":html/config.html")); cPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png")); cPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); cPage.replace(QLatin1String("%ABOUT-IMG%"), QLatin1String("qrc:icons/other/about.png")); @@ -367,7 +367,7 @@ QString QupZillaSchemeReply::configPage() QString("
%1
%2
").arg(tr("Qt version"), QT_VERSION_STR) + QString("
%1
%2
").arg(tr("WebKit version"), QupZilla::WEBKITVERSION) + QString("
%1
%2
").arg(tr("Build time"), QupZilla::BUILDTIME) + - QString("
%1
%2
").arg(tr("Platform"), qz_buildSystem())); + QString("
%1
%2
").arg(tr("Platform"), QzTools::buildSystem())); cPage.replace(QLatin1String("%PATHS-TEXT%"), QString("
%1
%2
").arg(tr("Profile"), mApp->currentProfilePath()) + @@ -407,7 +407,7 @@ QString QupZillaSchemeReply::configPage() QString("
%1
%2
").arg(tr("KDE integration"), KDEIntegration) + QString("
%1
%2
").arg(tr("Portable build"), portableBuild)); - cPage = qz_applyDirectionToPage(cPage); + cPage = QzTools::applyDirectionToPage(cPage); } QString page = cPage; @@ -419,7 +419,7 @@ QString QupZillaSchemeReply::configPage() foreach(const Plugins::Plugin & plugin, availablePlugins) { PluginSpec spec = plugin.pluginSpec; pluginsString.append(QString("%1%2%3%4").arg( - spec.name, spec.version, qz_escape(spec.author), spec.description)); + spec.name, spec.version, QzTools::escape(spec.author), spec.description)); } if (pluginsString.isEmpty()) { @@ -461,7 +461,7 @@ QString QupZillaSchemeReply::configPage() keyString = QLatin1String("\"empty\""); } - groupString.append(QString("%1%2").arg(key, qz_escape(keyString))); + groupString.append(QString("%1%2").arg(key, QzTools::escape(keyString))); } settings->endGroup(); diff --git a/src/lib/other/browsinglibrary.cpp b/src/lib/other/browsinglibrary.cpp index 1e9c5b42a..31672a554 100644 --- a/src/lib/other/browsinglibrary.cpp +++ b/src/lib/other/browsinglibrary.cpp @@ -22,7 +22,7 @@ #include "rssmanager.h" #include "mainapplication.h" #include "downloaditem.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include "history.h" @@ -47,7 +47,7 @@ BrowsingLibrary::BrowsingLibrary(QupZilla* mainClass, QWidget* parent) m_historyManager->restoreState(settings.value("historyState", QByteArray()).toByteArray()); settings.endGroup(); - qz_centerWidgetOnScreen(this); + QzTools::centerWidgetOnScreen(this); ui->tabs->AddTab(m_historyManager, QIcon(":/icons/other/bighistory.png"), tr("History")); ui->tabs->AddTab(m_bookmarksManager, QIcon(":/icons/other/bigstar.png"), tr("Bookmarks")); @@ -141,9 +141,9 @@ void BrowsingLibrary::optimizeDatabase() { mApp->setOverrideCursor(Qt::WaitCursor); QString profilePath = mApp->currentProfilePath(); - QString sizeBefore = qz_fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); + QString sizeBefore = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); mApp->history()->optimizeHistory(); - QString sizeAfter = qz_fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); + QString sizeAfter = QzTools::fileSizeToString(QFileInfo(profilePath + "browsedata.db").size()); mApp->restoreOverrideCursor(); QMessageBox::information(this, tr("Database Optimized"), tr("Database successfully optimized.

Database Size Before: %1
Database Size After: %2").arg(sizeBefore, sizeAfter)); } diff --git a/src/lib/other/clearprivatedata.cpp b/src/lib/other/clearprivatedata.cpp index b6e8c5343..3b58cecfa 100644 --- a/src/lib/other/clearprivatedata.cpp +++ b/src/lib/other/clearprivatedata.cpp @@ -26,7 +26,7 @@ #include "clickablelabel.h" #include "ui_clearprivatedata.h" #include "iconprovider.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -65,7 +65,7 @@ void ClearPrivateData::clearLocalStorage() { const QString &profile = mApp->currentProfilePath(); - qz_removeDir(profile + "LocalStorage"); + QzTools::removeDir(profile + "LocalStorage"); } void ClearPrivateData::clearWebDatabases() @@ -73,7 +73,7 @@ void ClearPrivateData::clearWebDatabases() const QString &profile = mApp->currentProfilePath(); QWebDatabase::removeAllDatabases(); - qz_removeDir(profile + "Databases"); + QzTools::removeDir(profile + "Databases"); } void ClearPrivateData::clearCache() diff --git a/src/lib/other/licenseviewer.cpp b/src/lib/other/licenseviewer.cpp index 120f443b9..79fa44e92 100644 --- a/src/lib/other/licenseviewer.cpp +++ b/src/lib/other/licenseviewer.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . * ============================================================ */ #include "licenseviewer.h" -#include "globalfunctions.h" +#include "qztools.h" LicenseViewer::LicenseViewer(QWidget* parent) : QTextBrowser() @@ -26,10 +26,10 @@ LicenseViewer::LicenseViewer(QWidget* parent) resize(450, 500); - qz_centerWidgetToParent(this, parent); + QzTools::centerWidgetToParent(this, parent); } void LicenseViewer::setLicenseFile(const QString &fileName) { - setText(qz_readAllFileContents(fileName)); + setText(QzTools::readAllFileContents(fileName)); } diff --git a/src/lib/other/pagescreen.cpp b/src/lib/other/pagescreen.cpp index d75838999..c4a16ef7a 100644 --- a/src/lib/other/pagescreen.cpp +++ b/src/lib/other/pagescreen.cpp @@ -19,7 +19,7 @@ #include "ui_pagescreen.h" #include "tabbedwebview.h" #include "webpage.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -61,7 +61,7 @@ PageScreen::PageScreen(WebView* view, QWidget* parent) void PageScreen::dialogAccepted() { const QString &suggestedPath = QString("%1/%2.png").arg(QDir::homePath(), - qz_filterCharsFromFilename(m_pageTitle)); + QzTools::filterCharsFromFilename(m_pageTitle)); m_filePath = QFileDialog::getSaveFileName(this, tr("Save Page Screen..."), suggestedPath); if (!m_filePath.isEmpty()) { diff --git a/src/lib/other/sourceviewer.cpp b/src/lib/other/sourceviewer.cpp index 949d5b9cf..b6ac27798 100644 --- a/src/lib/other/sourceviewer.cpp +++ b/src/lib/other/sourceviewer.cpp @@ -19,7 +19,7 @@ #include "tabbedwebview.h" #include "htmlhighlighter.h" #include "sourceviewersearch.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include "enhancedmenu.h" #include "plaineditwithlines.h" @@ -65,7 +65,7 @@ SourceViewer::SourceViewer(QWebFrame* frame, const QString &selectedHtml) new HtmlHighlighter(m_sourceEdit->document()); resize(650, 600); - qz_centerWidgetToParent(this, frame->page()->view()); + QzTools::centerWidgetToParent(this, frame->page()->view()); QMenu* menuFile = new QMenu(tr("File")); menuFile->addAction(QIcon::fromTheme("document-save"), tr("Save as..."), this, SLOT(save()))->setShortcut(QKeySequence("Ctrl+S")); diff --git a/src/lib/other/useragentmanager.cpp b/src/lib/other/useragentmanager.cpp index 2d6bfd722..9c9cec329 100644 --- a/src/lib/other/useragentmanager.cpp +++ b/src/lib/other/useragentmanager.cpp @@ -17,14 +17,14 @@ * ============================================================ */ #include "useragentmanager.h" #include "qupzilla.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include // QTWEBKIT_VERSION_CHECK macro UserAgentManager::UserAgentManager() { - m_fakeUserAgent = QString("Mozilla/5.0 (%1) AppleWebKit/%2 (KHTML, like Gecko) Chrome/10.0 Safari/%2").arg(qz_buildSystem(), QupZilla::WEBKITVERSION); + m_fakeUserAgent = QString("Mozilla/5.0 (%1) AppleWebKit/%2 (KHTML, like Gecko) Chrome/10.0 Safari/%2").arg(QzTools::buildSystem(), QupZilla::WEBKITVERSION); } void UserAgentManager::loadSettings() diff --git a/src/lib/plugins/clicktoflash.cpp b/src/lib/plugins/clicktoflash.cpp index a3c4f678a..5b0b0a775 100644 --- a/src/lib/plugins/clicktoflash.cpp +++ b/src/lib/plugins/clicktoflash.cpp @@ -43,7 +43,7 @@ #include "pluginproxy.h" #include "squeezelabelv2.h" #include "webpage.h" -#include "globalfunctions.h" +#include "qztools.h" #include "qupzilla.h" #include @@ -228,17 +228,17 @@ void ClickToFlash::load() So asynchronous JavaScript code is used to remove element from page and then substitute it with unblocked Flash. The JavaScript code is: - var qz_c2f_clone = this.cloneNode(true); - var qz_c2f_parentNode = this.parentNode; - var qz_c2f_substituteElement = document.createElement(this.tagName); + var QzTools::c2f_clone = this.cloneNode(true); + var QzTools::c2f_parentNode = this.parentNode; + var QzTools::c2f_substituteElement = document.createElement(this.tagName); - qz_c2f_substituteElement.width = this.width; - qz_c2f_substituteElement.height = this.height; + QzTools::c2f_substituteElement.width = this.width; + QzTools::c2f_substituteElement.height = this.height; - this.parentNode.replaceChild(qz_c2f_substituteElement, this); + this.parentNode.replaceChild(QzTools::c2f_substituteElement, this); setTimeout(function(){ - qz_c2f_parentNode.replaceChild(qz_c2f_clone, qz_c2f_substituteElement); + QzTools::c2f_parentNode.replaceChild(QzTools::c2f_clone, QzTools::c2f_substituteElement); }, 250); */ @@ -249,11 +249,11 @@ void ClickToFlash::load() m_element.setAttribute("type", "application/futuresplash"); - QString js = "var qz_c2f_clone=this.cloneNode(true);var qz_c2f_parentNode=this.parentNode;" - "var qz_c2f_substituteElement=document.createElement(this.tagName);" - "qz_c2f_substituteElement.width=this.width;qz_c2f_substituteElement.height=this.height;" - "this.parentNode.replaceChild(qz_c2f_substituteElement,this);setTimeout(function(){" - "qz_c2f_parentNode.replaceChild(qz_c2f_clone,qz_c2f_substituteElement);},250);"; + QString js = "var QzTools::c2f_clone=this.cloneNode(true);var QzTools::c2f_parentNode=this.parentNode;" + "var QzTools::c2f_substituteElement=document.createElement(this.tagName);" + "QzTools::c2f_substituteElement.width=this.width;QzTools::c2f_substituteElement.height=this.height;" + "this.parentNode.replaceChild(QzTools::c2f_substituteElement,this);setTimeout(function(){" + "QzTools::c2f_parentNode.replaceChild(QzTools::c2f_clone,QzTools::c2f_substituteElement);},250);"; m_element.evaluateJavaScript(js); } @@ -312,6 +312,6 @@ void ClickToFlash::showInfo() } widg->setMaximumHeight(500); - qz_centerWidgetToParent(widg, m_page->view()); + QzTools::centerWidgetToParent(widg, m_page->view()); widg->show(); } diff --git a/src/lib/popupwindow/popuplocationbar.cpp b/src/lib/popupwindow/popuplocationbar.cpp index db37e8a14..6940450d4 100644 --- a/src/lib/popupwindow/popuplocationbar.cpp +++ b/src/lib/popupwindow/popuplocationbar.cpp @@ -18,7 +18,7 @@ #include "popuplocationbar.h" #include "popupwebview.h" #include "toolbutton.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include @@ -86,7 +86,7 @@ void PopupLocationBar::stopLoading() void PopupLocationBar::showUrl(const QUrl &url) { - setText(qz_urlEncodeQueryString(url)); + setText(QzTools::urlEncodeQueryString(url)); setCursorPosition(0); } diff --git a/src/lib/popupwindow/popupwindow.cpp b/src/lib/popupwindow/popupwindow.cpp index d488477cf..69c080d99 100644 --- a/src/lib/popupwindow/popupwindow.cpp +++ b/src/lib/popupwindow/popupwindow.cpp @@ -23,7 +23,7 @@ #include "qupzilla.h" #include "qzsettings.h" #include "popuplocationbar.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -174,7 +174,7 @@ void PopupWindow::setWindowGeometry(const QRect &newRect) resize(newSize); if (newRect.topLeft() == QPoint(0, 0) && oldRect.topLeft() == QPoint(0, 0)) { - qz_centerWidgetOnScreen(this); + QzTools::centerWidgetOnScreen(this); } } } diff --git a/src/lib/preferences/pluginsmanager.cpp b/src/lib/preferences/pluginsmanager.cpp index 8c5809637..7eee8f353 100644 --- a/src/lib/preferences/pluginsmanager.cpp +++ b/src/lib/preferences/pluginsmanager.cpp @@ -21,7 +21,7 @@ #include "mainapplication.h" #include "plugininterface.h" #include "pluginlistdelegate.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include @@ -177,7 +177,7 @@ void PluginsManager::refresh() } item->setIcon(icon); - QString pluginInfo = QString("%1 %2
%3
%4").arg(spec.name, spec.version, qz_escape(spec.author), spec.info); + QString pluginInfo = QString("%1 %2
%3
%4").arg(spec.name, spec.version, QzTools::escape(spec.author), spec.info); item->setToolTip(pluginInfo); item->setText(spec.name); diff --git a/src/lib/preferences/preferences.cpp b/src/lib/preferences/preferences.cpp index 45564587b..332f229e6 100644 --- a/src/lib/preferences/preferences.cpp +++ b/src/lib/preferences/preferences.cpp @@ -38,7 +38,7 @@ #include "navigationbar.h" #include "thememanager.h" #include "acceptlanguage.h" -#include "globalfunctions.h" +#include "qztools.h" #include "autofillmodel.h" #include "settings.h" #include "tabbedwebview.h" @@ -722,7 +722,7 @@ void Preferences::buttonClicked(QAbstractButton* button) void Preferences::createProfile() { QString name = QInputDialog::getText(this, tr("New Profile"), tr("Enter the new profile's name:")); - name = qz_filterCharsFromFilename(name); + name = QzTools::filterCharsFromFilename(name); if (name.isEmpty()) { return; } @@ -758,7 +758,7 @@ void Preferences::deleteProfile() return; } - qz_removeDir(mApp->PROFILEDIR + "profiles/" + name); + QzTools::removeDir(mApp->PROFILEDIR + "profiles/" + name); ui->startProfile->removeItem(ui->startProfile->currentIndex()); } diff --git a/src/lib/preferences/sslmanager.cpp b/src/lib/preferences/sslmanager.cpp index fd0f78a55..527a5c012 100644 --- a/src/lib/preferences/sslmanager.cpp +++ b/src/lib/preferences/sslmanager.cpp @@ -19,7 +19,7 @@ #include "ui_sslmanager.h" #include "networkmanager.h" #include "mainapplication.h" -#include "globalfunctions.h" +#include "qztools.h" #include "certificateinfowidget.h" #include @@ -166,7 +166,7 @@ void SSLManager::showCertificateInfo(const QSslCertificate &cert) connect(b, SIGNAL(clicked(QAbstractButton*)), w, SLOT(close())); w->layout()->addWidget(b); w->resize(w->sizeHint()); - qz_centerWidgetToParent(w, this); + QzTools::centerWidgetToParent(w, this); w->show(); } diff --git a/src/lib/preferences/thememanager.cpp b/src/lib/preferences/thememanager.cpp index 425f135db..14ef9cf89 100644 --- a/src/lib/preferences/thememanager.cpp +++ b/src/lib/preferences/thememanager.cpp @@ -18,7 +18,7 @@ #include "thememanager.h" #include "ui_thememanager.h" #include "mainapplication.h" -#include "globalfunctions.h" +#include "qztools.h" #include "settings.h" #include "licenseviewer.h" #include "preferences.h" @@ -114,10 +114,10 @@ ThemeManager::Theme ThemeManager::parseTheme(const QString &name) } if (QFile(path + "theme.license").exists()) { - info.license = qz_readAllFileContents(path + "theme.license"); + info.license = QzTools::readAllFileContents(path + "theme.license"); } - QString theme_info = qz_readAllFileContents(path + "theme.info"); + QString theme_info = QzTools::readAllFileContents(path + "theme.info"); QRegExp rx("Name:(.*)\\n"); rx.setMinimal(true); diff --git a/src/lib/preferences/useragentdialog.cpp b/src/lib/preferences/useragentdialog.cpp index 3a303cebb..3354d122e 100644 --- a/src/lib/preferences/useragentdialog.cpp +++ b/src/lib/preferences/useragentdialog.cpp @@ -18,7 +18,7 @@ #include "useragentdialog.h" #include "ui_useragentdialog.h" #include "useragentmanager.h" -#include "globalfunctions.h" +#include "qztools.h" #include "mainapplication.h" #include "settings.h" @@ -33,7 +33,7 @@ UserAgentDialog::UserAgentDialog(QWidget* parent) { ui->setupUi(this); - const QString &os = qz_buildSystem(); + const QString &os = QzTools::buildSystem(); m_knownUserAgents << QString("Opera/9.80 (%1) Presto/2.10.229 Version/11.61").arg(os) << QString("Mozilla/5.0 (%1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7").arg(os) << QString("Mozilla/5.0 (%1) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1").arg(os) diff --git a/src/lib/rss/rssmanager.cpp b/src/lib/rss/rssmanager.cpp index d438426c3..19f493dc6 100644 --- a/src/lib/rss/rssmanager.cpp +++ b/src/lib/rss/rssmanager.cpp @@ -23,7 +23,7 @@ #include "treewidget.h" #include "iconprovider.h" #include "browsinglibrary.h" -#include "globalfunctions.h" +#include "qztools.h" #include "followredirectreply.h" #include "networkmanager.h" #include "qzsettings.h" diff --git a/src/lib/tools/certificateinfowidget.cpp b/src/lib/tools/certificateinfowidget.cpp index 1b3577551..84619b035 100644 --- a/src/lib/tools/certificateinfowidget.cpp +++ b/src/lib/tools/certificateinfowidget.cpp @@ -18,7 +18,7 @@ #include "certificateinfowidget.h" #include "ui_certificateinfowidget.h" #include "mainapplication.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -42,7 +42,7 @@ QString CertificateInfoWidget::certificateItemText(const QSslCertificate &cert) QString CertificateInfoWidget::clearCertSpecialSymbols(const QString &string) { - QString n = qz_escape(string); + QString n = QzTools::escape(string); if (!n.contains(QLatin1String("\\"))) { return n; diff --git a/src/lib/tools/globalfunctions.h b/src/lib/tools/globalfunctions.h deleted file mode 100644 index cefd2c654..000000000 --- a/src/lib/tools/globalfunctions.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ============================================================ -* QupZilla - WebKit based browser -* Copyright (C) 2010-2012 David Rosca -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -* ============================================================ */ -#ifndef GLOBALFUNCTIONS_H -#define GLOBALFUNCTIONS_H - -#include -#include - -#include "qz_namespace.h" - -class QSslCertificate; -class QFontMetrics; -class QPixmap; -class QIcon; -class QWidget; -class QUrl; - -QByteArray QT_QUPZILLA_EXPORT qz_pixmapToByteArray(const QPixmap &pix); -QPixmap QT_QUPZILLA_EXPORT qz_pixmapFromByteArray(const QByteArray &data); - -QString QT_QUPZILLA_EXPORT qz_readAllFileContents(const QString &filename); - -void QT_QUPZILLA_EXPORT qz_centerWidgetOnScreen(QWidget* w); -void QT_QUPZILLA_EXPORT qz_centerWidgetToParent(QWidget* w, QWidget* parent); - -bool QT_QUPZILLA_EXPORT qz_removeFile(const QString &fullFileName); -void QT_QUPZILLA_EXPORT qz_removeDir(const QString &d); - -QString QT_QUPZILLA_EXPORT qz_samePartOfStrings(const QString &one, const QString &other); -QUrl QT_QUPZILLA_EXPORT qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl); -QString QT_QUPZILLA_EXPORT qz_urlEncodeQueryString(const QUrl &url); - -QString QT_QUPZILLA_EXPORT qz_ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)")); -QString QT_QUPZILLA_EXPORT qz_getFileNameFromUrl(const QUrl &url); -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); -QString QT_QUPZILLA_EXPORT qz_fileSizeToString(qint64 size); - -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(); - -// Qt5 migration help functions -bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert); -QString QT_QUPZILLA_EXPORT qz_escape(const QString &string); - -#ifdef QZ_WS_X11 -void QT_QUPZILLA_EXPORT* qz_X11Display(const QWidget* widget); -#endif - -template -bool qz_listContainsIndex(const QList &list, int index) -{ - return (index >= 0 && list.count() > index); -} - -#endif // GLOBALFUNCTIONS_H diff --git a/src/lib/tools/globalfunctions.cpp b/src/lib/tools/qztools.cpp similarity index 85% rename from src/lib/tools/globalfunctions.cpp rename to src/lib/tools/qztools.cpp index 0ad0992c5..35bf9e577 100644 --- a/src/lib/tools/globalfunctions.cpp +++ b/src/lib/tools/qztools.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -39,7 +39,7 @@ #include #endif -QByteArray qz_pixmapToByteArray(const QPixmap &pix) +QByteArray QzTools::pixmapToByteArray(const QPixmap &pix) { QByteArray bytes; QBuffer buffer(&bytes); @@ -51,7 +51,7 @@ QByteArray qz_pixmapToByteArray(const QPixmap &pix) return QByteArray(); } -QPixmap qz_pixmapFromByteArray(const QByteArray &data) +QPixmap QzTools::pixmapFromByteArray(const QByteArray &data) { QPixmap image; QByteArray bArray = QByteArray::fromBase64(data); @@ -60,7 +60,7 @@ QPixmap qz_pixmapFromByteArray(const QByteArray &data) return image; } -QString qz_readAllFileContents(const QString &filename) +QString QzTools::readAllFileContents(const QString &filename) { QFile file(filename); if (file.open(QFile::ReadOnly)) { @@ -72,7 +72,7 @@ QString qz_readAllFileContents(const QString &filename) return QByteArray(); } -void qz_centerWidgetOnScreen(QWidget* w) +void QzTools::centerWidgetOnScreen(QWidget* w) { const QRect screen = QApplication::desktop()->screenGeometry(); const QRect &size = w->geometry(); @@ -80,7 +80,7 @@ void qz_centerWidgetOnScreen(QWidget* w) } // Very, very, very simplified QDialog::adjustPosition from qdialog.cpp -void qz_centerWidgetToParent(QWidget* w, QWidget* parent) +void QzTools::centerWidgetToParent(QWidget* w, QWidget* parent) { if (!parent || !w) { return; @@ -95,7 +95,7 @@ void qz_centerWidgetToParent(QWidget* w, QWidget* parent) w->move(p); } -bool qz_removeFile(const QString &fullFileName) +bool QzTools::removeFile(const QString &fullFileName) { QFile f(fullFileName); if (f.exists()) { @@ -106,7 +106,7 @@ bool qz_removeFile(const QString &fullFileName) } } -void qz_removeDir(const QString &d) +void QzTools::removeDir(const QString &d) { QDir dir(d); if (dir.exists()) { @@ -115,10 +115,10 @@ void qz_removeDir(const QString &d) for (int l = 0; l < list.size(); l++) { fi = list.at(l); if (fi.isDir() && fi.fileName() != QLatin1String(".") && fi.fileName() != QLatin1String("..")) { - qz_removeDir(fi.absoluteFilePath()); + QzTools::removeDir(fi.absoluteFilePath()); } else if (fi.isFile()) { - qz_removeFile(fi.absoluteFilePath()); + QzTools::removeFile(fi.absoluteFilePath()); } } @@ -126,7 +126,7 @@ void qz_removeDir(const QString &d) } } -QString qz_samePartOfStrings(const QString &one, const QString &other) +QString QzTools::samePartOfStrings(const QString &one, const QString &other) { int i = 0; int maxSize = qMin(one.size(), other.size()); @@ -139,12 +139,12 @@ QString qz_samePartOfStrings(const QString &one, const QString &other) return one.left(i); } -QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl) +QUrl QzTools::makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl) { QString baseUrlPath = baseUrl.path(); QString rUrlPath = rUrl.path(); - QString samePart = qz_samePartOfStrings(baseUrlPath, rUrlPath); + QString samePart = QzTools::samePartOfStrings(baseUrlPath, rUrlPath); QUrl returnUrl; if (samePart.isEmpty()) { @@ -171,7 +171,7 @@ QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl) return returnUrl; } -QString qz_urlEncodeQueryString(const QUrl &url) +QString QzTools::urlEncodeQueryString(const QUrl &url) { QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment); @@ -196,7 +196,7 @@ QString qz_urlEncodeQueryString(const QUrl &url) return returnString; } -QString qz_ensureUniqueFilename(const QString &name, const QString &appendFormat) +QString QzTools::ensureUniqueFilename(const QString &name, const QString &appendFormat) { if (!QFile::exists(name)) { return name; @@ -220,7 +220,7 @@ QString qz_ensureUniqueFilename(const QString &name, const QString &appendFormat return tmpFileName; } -QString qz_getFileNameFromUrl(const QUrl &url) +QString QzTools::getFileNameFromUrl(const QUrl &url) { QString fileName = url.toString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveScheme | QUrl::RemovePort); if (fileName.indexOf(QLatin1Char('/')) != -1) { @@ -229,16 +229,16 @@ QString qz_getFileNameFromUrl(const QUrl &url) fileName.remove(QLatin1Char('/')); } - fileName = qz_filterCharsFromFilename(fileName); + fileName = filterCharsFromFilename(fileName); if (fileName.isEmpty()) { - fileName = qz_filterCharsFromFilename(url.host().replace(QLatin1Char('.'), QLatin1Char('-'))); + fileName = filterCharsFromFilename(url.host().replace(QLatin1Char('.'), QLatin1Char('-'))); } return fileName; } -QString qz_filterCharsFromFilename(const QString &name) +QString QzTools::filterCharsFromFilename(const QString &name) { QString value = name; @@ -255,7 +255,7 @@ QString qz_filterCharsFromFilename(const QString &name) return value; } -QString qz_alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width) +QString QzTools::alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width) { int pos = 0; QString returnString; @@ -283,7 +283,7 @@ QString qz_alignTextToWidth(const QString &string, const QString &text, const QF return returnString; } -QString qz_fileSizeToString(qint64 size) +QString QzTools::fileSizeToString(qint64 size) { if (size < 0) { return QObject::tr("Unknown size"); @@ -305,7 +305,7 @@ QString qz_fileSizeToString(qint64 size) } -QPixmap qz_createPixmapForSite(const QIcon &icon, const QString &title, const QString &url) +QPixmap QzTools::createPixmapForSite(const QIcon &icon, const QString &title, const QString &url) { const QFontMetrics fontMetrics = QApplication::fontMetrics(); const int padding = 4; @@ -341,7 +341,7 @@ QPixmap qz_createPixmapForSite(const QIcon &icon, const QString &title, const QS return pixmap; } -QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents) +QString QzTools::applyDirectionToPage(QString &pageContents) { QString direction = QLatin1String("ltr"); QString right_str = QLatin1String("right"); @@ -361,7 +361,7 @@ QString QT_QUPZILLA_EXPORT qz_applyDirectionToPage(QString &pageContents) } // Qt5 migration help functions -bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert) +bool QzTools::isCertificateValid(const QSslCertificate &cert) { #if QT_VERSION >= 0x050000 const QDateTime currentTime = QDateTime::currentDateTime(); @@ -373,7 +373,7 @@ bool QT_QUPZILLA_EXPORT qz_isCertificateValid(const QSslCertificate &cert) #endif } -QString QT_QUPZILLA_EXPORT qz_escape(const QString &string) +QString QzTools::escape(const QString &string) { #if QT_VERSION >= 0x050000 return string.toHtmlEscaped(); @@ -383,7 +383,7 @@ QString QT_QUPZILLA_EXPORT qz_escape(const QString &string) } #ifdef QZ_WS_X11 -void QT_QUPZILLA_EXPORT* qz_X11Display(const QWidget* widget) +void* QzTools::X11Display(const QWidget* widget) { Q_UNUSED(widget) @@ -395,7 +395,7 @@ void QT_QUPZILLA_EXPORT* qz_X11Display(const QWidget* widget) } #endif -QString qz_buildSystem() +QString QzTools::buildSystem() { #ifdef Q_OS_LINUX return "Linux"; diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h new file mode 100644 index 000000000..c43f0b7dc --- /dev/null +++ b/src/lib/tools/qztools.h @@ -0,0 +1,77 @@ +/* ============================================================ +* QupZilla - WebKit based browser +* Copyright (C) 2010-2012 David Rosca +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +* ============================================================ */ +#ifndef GLOBALFUNCTIONS_H +#define GLOBALFUNCTIONS_H + +#include +#include + +#include "qz_namespace.h" + +class QSslCertificate; +class QFontMetrics; +class QPixmap; +class QIcon; +class QWidget; +class QUrl; + +namespace QzTools { + QByteArray QT_QUPZILLA_EXPORT pixmapToByteArray(const QPixmap &pix); + QPixmap QT_QUPZILLA_EXPORT pixmapFromByteArray(const QByteArray &data); + + QString QT_QUPZILLA_EXPORT readAllFileContents(const QString &filename); + + void QT_QUPZILLA_EXPORT centerWidgetOnScreen(QWidget* w); + void QT_QUPZILLA_EXPORT centerWidgetToParent(QWidget* w, QWidget* parent); + + bool QT_QUPZILLA_EXPORT removeFile(const QString &fullFileName); + void QT_QUPZILLA_EXPORT removeDir(const QString &d); + + QString QT_QUPZILLA_EXPORT samePartOfStrings(const QString &one, const QString &other); + QUrl QT_QUPZILLA_EXPORT makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl); + QString QT_QUPZILLA_EXPORT urlEncodeQueryString(const QUrl &url); + + QString QT_QUPZILLA_EXPORT ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)")); + QString QT_QUPZILLA_EXPORT getFileNameFromUrl(const QUrl &url); + QString QT_QUPZILLA_EXPORT filterCharsFromFilename(const QString &name); + + QString QT_QUPZILLA_EXPORT alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width); + QString QT_QUPZILLA_EXPORT fileSizeToString(qint64 size); + + QPixmap QT_QUPZILLA_EXPORT createPixmapForSite(const QIcon &icon, const QString &title, const QString &url); + QString QT_QUPZILLA_EXPORT applyDirectionToPage(QString &pageContents); + + QString QT_QUPZILLA_EXPORT buildSystem(); + + // Qt5 migration help functions + bool QT_QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert); + QString QT_QUPZILLA_EXPORT escape(const QString &string); + + #ifdef QZ_WS_X11 + void QT_QUPZILLA_EXPORT* X11Display(const QWidget* widget); + #endif + + template + bool listContainsIndex(const QList &list, int index) + { + return (index >= 0 && list.count() > index); + } + +} // namespace + +#endif // GLOBALFUNCTIONS_H diff --git a/src/lib/webview/siteinfo.cpp b/src/lib/webview/siteinfo.cpp index 61d195ce1..3a1eca1e7 100644 --- a/src/lib/webview/siteinfo.cpp +++ b/src/lib/webview/siteinfo.cpp @@ -23,7 +23,7 @@ #include "mainapplication.h" #include "downloaditem.h" #include "certificateinfowidget.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include @@ -74,7 +74,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) //GENERAL ui->heading->setText(QString("%1:").arg(title)); ui->siteAddress->setText(view->url().toString()); - ui->sizeLabel->setText(qz_fileSizeToString(webPage->totalBytes())); + ui->sizeLabel->setText(QzTools::fileSizeToString(webPage->totalBytes())); QString encoding; //Meta @@ -152,7 +152,7 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) } //SECURITY - if (qz_isCertificateValid(cert)) { + if (QzTools::isCertificateValid(cert)) { ui->securityLabel->setText(tr("Connection is Encrypted.")); ui->certLabel->setText(tr("Your connection to this page is secured with this certificate: ")); m_certWidget = new CertificateInfoWidget(cert); @@ -212,7 +212,7 @@ void SiteInfo::databaseItemChanged(QListWidgetItem* item) ui->databaseName->setText(QString("%1 (%2)").arg(db.displayName(), db.name())); ui->databasePath->setText(db.fileName()); - ui->databaseSize->setText(qz_fileSizeToString(db.size())); + ui->databaseSize->setText(QzTools::fileSizeToString(db.size())); } void SiteInfo::copyActionData() @@ -234,7 +234,7 @@ void SiteInfo::downloadImage() return; } - QString imageFileName = qz_getFileNameFromUrl(QUrl(item->text(1))); + QString imageFileName = QzTools::getFileNameFromUrl(QUrl(item->text(1))); QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath() + "/" + imageFileName); if (filePath.isEmpty()) { @@ -268,7 +268,7 @@ void SiteInfo::showImagePreview(QTreeWidgetItem* item) if (imageUrl.scheme() == QLatin1String("data")) { QByteArray encodedUrl = item->text(1).toUtf8(); QByteArray imageData = encodedUrl.mid(encodedUrl.indexOf(',') + 1); - m_activePixmap = qz_pixmapFromByteArray(imageData); + m_activePixmap = QzTools::pixmapFromByteArray(imageData); } else if (imageUrl.scheme() == QLatin1String("file")) { m_activePixmap = QPixmap(imageUrl.toLocalFile()); diff --git a/src/lib/webview/siteinfowidget.cpp b/src/lib/webview/siteinfowidget.cpp index cb8c2021a..3eedf973c 100644 --- a/src/lib/webview/siteinfowidget.cpp +++ b/src/lib/webview/siteinfowidget.cpp @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ============================================================ */ -#include "globalfunctions.h" +#include "qztools.h" #include "siteinfowidget.h" #include "ui_siteinfowidget.h" #include "qupzilla.h" @@ -40,7 +40,7 @@ SiteInfoWidget::SiteInfoWidget(QupZilla* mainClass, QWidget* parent) WebPage* webPage = view->page(); QUrl url = view->url(); - if (qz_isCertificateValid(webPage->sslCertificate())) { + if (QzTools::isCertificateValid(webPage->sslCertificate())) { ui->secureLabel->setText(tr("Your connection to this site is secured.")); ui->secureIcon->setPixmap(QPixmap(":/icons/locationbar/accept.png")); } diff --git a/src/lib/webview/webpage.cpp b/src/lib/webview/webpage.cpp index ae9b27b63..fb287e6cb 100644 --- a/src/lib/webview/webpage.cpp +++ b/src/lib/webview/webpage.cpp @@ -25,7 +25,7 @@ #include "mainapplication.h" #include "checkboxdialog.h" #include "widget.h" -#include "globalfunctions.h" +#include "qztools.h" #include "speeddial.h" #include "popupwebpage.h" #include "popupwebview.h" @@ -197,11 +197,11 @@ void WebPage::progress(int prog) { m_loadProgress = prog; - bool secStatus = qz_isCertificateValid(sslCertificate()); + bool secStatus = QzTools::isCertificateValid(sslCertificate()); if (secStatus != m_secureStatus) { m_secureStatus = secStatus; - emit privacyChanged(qz_isCertificateValid(sslCertificate())); + emit privacyChanged(QzTools::isCertificateValid(sslCertificate())); } } @@ -328,7 +328,7 @@ void WebPage::handleUnknownProtocol(const QUrl &url) CheckBoxDialog dialog(QDialogButtonBox::Yes | QDialogButtonBox::No, view()); - const QString &wrappedUrl = qz_alignTextToWidth(url.toString(), "
", dialog.fontMetrics(), 450); + const QString &wrappedUrl = QzTools::alignTextToWidth(url.toString(), "
", dialog.fontMetrics(), 450); const QString &text = tr("QupZilla cannot handle %1: links. The requested link " "is
  • %2
Do you want QupZilla to try " "open this link in system application?").arg(protocol, wrappedUrl); @@ -451,7 +451,7 @@ void WebPage::setSSLCertificate(const QSslCertificate &cert) QSslCertificate WebPage::sslCertificate() { - if (url().scheme() == QLatin1String("https") && qz_isCertificateValid(m_sslCert)) { + if (url().scheme() == QLatin1String("https") && QzTools::isCertificateValid(m_sslCert)) { return m_sslCert; } @@ -703,13 +703,13 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte QString rule = exOption->errorString; rule.remove(QLatin1String("AdBlock: ")); - QString errString = qz_readAllFileContents(":/html/adblockPage.html"); + QString errString = QzTools::readAllFileContents(":/html/adblockPage.html"); errString.replace(QLatin1String("%TITLE%"), tr("AdBlocked Content")); errString.replace(QLatin1String("%IMAGE%"), QLatin1String("qrc:html/adblock_big.png")); errString.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:html/adblock_big.png")); errString.replace(QLatin1String("%RULE%"), tr("Blocked by %1").arg(rule)); - errString = qz_applyDirectionToPage(errString); + errString = QzTools::applyDirectionToPage(errString); exReturn->baseUrl = exOption->url; exReturn->content = QString(errString + "").toUtf8(); @@ -754,8 +754,8 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte QString errString = file.readAll(); errString.replace(QLatin1String("%TITLE%"), tr("Failed loading page")); - errString.replace(QLatin1String("%IMAGE%"), qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45))); - errString.replace(QLatin1String("%FAVICON%"), qz_pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16, 16))); + errString.replace(QLatin1String("%IMAGE%"), QzTools::pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45))); + errString.replace(QLatin1String("%FAVICON%"), QzTools::pixmapToByteArray(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning).pixmap(16, 16))); errString.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png")); QString heading2 = loadedUrl.host().isEmpty() ? tr("QupZilla can't load page.") : tr("QupZilla can't load page from %1.").arg(loadedUrl.host()); @@ -766,7 +766,7 @@ bool WebPage::extension(Extension extension, const ExtensionOption* option, Exte errString.replace(QLatin1String("%LI-2%"), tr("If you are unable to load any pages, check your computer's network connection.")); errString.replace(QLatin1String("%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(QLatin1String("%TRY-AGAIN%"), tr("Try Again")); - errString = qz_applyDirectionToPage(errString); + errString = QzTools::applyDirectionToPage(errString); exReturn->content = QString(errString + "").toUtf8(); return true; diff --git a/src/lib/webview/webtab.cpp b/src/lib/webview/webtab.cpp index 1f1b9310c..3e540f0ea 100644 --- a/src/lib/webview/webtab.cpp +++ b/src/lib/webview/webtab.cpp @@ -22,7 +22,7 @@ #include "tabbar.h" #include "tabwidget.h" #include "locationbar.h" -#include "globalfunctions.h" +#include "qztools.h" #include "qzsettings.h" #include diff --git a/src/lib/webview/webview.cpp b/src/lib/webview/webview.cpp index 5d82b8883..eb4118be5 100644 --- a/src/lib/webview/webview.cpp +++ b/src/lib/webview/webview.cpp @@ -19,7 +19,7 @@ #include "webview.h" #include "webpage.h" #include "mainapplication.h" -#include "globalfunctions.h" +#include "qztools.h" #include "iconprovider.h" #include "history.h" #include "autofillmodel.h" @@ -440,7 +440,7 @@ void WebView::copyLinkToClipboard() void WebView::savePageAs() { QNetworkRequest request(url()); - QString suggestedFileName = qz_getFileNameFromUrl(url()); + QString suggestedFileName = QzTools::getFileNameFromUrl(url()); if (!suggestedFileName.contains(QLatin1Char('.'))) { suggestedFileName.append(QLatin1String(".html")); } @@ -490,7 +490,7 @@ void WebView::showSource(QWebFrame* frame, const QString &selectedHtml) } SourceViewer* source = new SourceViewer(frame, selectedHtml); - qz_centerWidgetToParent(source, this); + QzTools::centerWidgetToParent(source, this); source->show(); } diff --git a/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp b/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp index 1d7d8a620..6ef7f54d7 100644 --- a/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp +++ b/src/plugins/GreaseMonkey/gm_addscriptdialog.cpp @@ -25,7 +25,7 @@ #include "qupzilla.h" #include "tabwidget.h" #include "tabbedwebview.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -66,7 +66,7 @@ void GM_AddScriptDialog::showSource() return; } - const QString &tmpFileName = qz_ensureUniqueFilename(mApp->tempPath() + "/tmp-userscript.js"); + const QString &tmpFileName = QzTools::ensureUniqueFilename(mApp->tempPath() + "/tmp-userscript.js"); if (QFile::copy(m_script->fileName(), tmpFileName)) { int index = qz->tabWidget()->addView(QUrl::fromLocalFile(tmpFileName), Qz::NT_SelectedTabAtTheEnd); diff --git a/src/plugins/GreaseMonkey/gm_downloader.cpp b/src/plugins/GreaseMonkey/gm_downloader.cpp index df11b1d8b..26e749bf6 100644 --- a/src/plugins/GreaseMonkey/gm_downloader.cpp +++ b/src/plugins/GreaseMonkey/gm_downloader.cpp @@ -24,7 +24,7 @@ #include "followredirectreply.h" #include "mainapplication.h" #include "networkmanager.h" -#include "globalfunctions.h" +#include "qztools.h" #include #include @@ -55,8 +55,8 @@ void GM_Downloader::scriptDownloaded() QByteArray response = QString::fromUtf8(m_reply->readAll()).toUtf8(); if (m_reply->error() == QNetworkReply::NoError && response.contains("// ==UserScript==")) { - const QString &filePath = m_manager->scriptsDirectory() + qz_getFileNameFromUrl(m_reply->url()); - m_fileName = qz_ensureUniqueFilename(filePath); + const QString &filePath = m_manager->scriptsDirectory() + QzTools::getFileNameFromUrl(m_reply->url()); + m_fileName = QzTools::ensureUniqueFilename(filePath); QFile file(m_fileName); @@ -101,7 +101,7 @@ void GM_Downloader::requireDownloaded() if (m_reply->error() == QNetworkReply::NoError && !response.isEmpty()) { const QString &filePath = m_manager->settinsPath() + "/greasemonkey/requires/require.js"; - const QString &fileName = qz_ensureUniqueFilename(filePath, "%1"); + const QString &fileName = QzTools::ensureUniqueFilename(filePath, "%1"); QFile file(fileName); diff --git a/src/plugins/GreaseMonkey/gm_manager.cpp b/src/plugins/GreaseMonkey/gm_manager.cpp index a8f27d905..815b203b2 100644 --- a/src/plugins/GreaseMonkey/gm_manager.cpp +++ b/src/plugins/GreaseMonkey/gm_manager.cpp @@ -21,7 +21,7 @@ #include "settings/gm_settings.h" #include "webpage.h" -#include "globalfunctions.h" +#include "qztools.h" #include "mainapplication.h" #include "desktopnotificationsfactory.h" @@ -78,7 +78,7 @@ QString GM_Manager::requireScripts(const QStringList &urlList) const foreach(const QString & url, urlList) { if (settings.contains(url)) { const QString &fileName = settings.value(url).toString(); - script.append(qz_readAllFileContents(fileName).trimmed() + '\n'); + script.append(QzTools::readAllFileContents(fileName).trimmed() + '\n'); } } @@ -240,7 +240,7 @@ void GM_Manager::load() } } - m_bootstrap = qz_readAllFileContents(":gm/data/bootstrap.min.js"); + m_bootstrap = QzTools::readAllFileContents(":gm/data/bootstrap.min.js"); } bool GM_Manager::canRunOnScheme(const QString &scheme)