mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[QzTools] Make QzTools class and export only the class
Also fixed building on Windows
This commit is contained in:
parent
fdf4fcc54e
commit
417da146e5
|
@ -301,7 +301,7 @@ QString AdBlockSubscription::elementHidingRulesForDomain(const QString &domain)
|
|||
|
||||
const AdBlockRule* AdBlockSubscription::rule(int offset) const
|
||||
{
|
||||
if (!QzTools::vectorContainsIndex(m_rules, offset)) {
|
||||
if (!QzTools::containsIndex(m_rules, offset)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -315,7 +315,7 @@ QVector<AdBlockRule*> AdBlockSubscription::allRules() const
|
|||
|
||||
const AdBlockRule* AdBlockSubscription::enableRule(int offset)
|
||||
{
|
||||
if (!QzTools::vectorContainsIndex(m_rules, offset)) {
|
||||
if (!QzTools::containsIndex(m_rules, offset)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ const AdBlockRule* AdBlockSubscription::enableRule(int offset)
|
|||
|
||||
const AdBlockRule* AdBlockSubscription::disableRule(int offset)
|
||||
{
|
||||
if (!QzTools::vectorContainsIndex(m_rules, offset)) {
|
||||
if (!QzTools::containsIndex(m_rules, offset)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ int AdBlockCustomList::addRule(AdBlockRule* rule)
|
|||
|
||||
bool AdBlockCustomList::removeRule(int offset)
|
||||
{
|
||||
if (!QzTools::vectorContainsIndex(m_rules, offset)) {
|
||||
if (!QzTools::containsIndex(m_rules, offset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ bool AdBlockCustomList::removeRule(int offset)
|
|||
|
||||
const AdBlockRule* AdBlockCustomList::replaceRule(AdBlockRule* rule, int offset)
|
||||
{
|
||||
if (!QzTools::vectorContainsIndex(m_rules, offset)) {
|
||||
if (!QzTools::containsIndex(m_rules, offset)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1100,7 +1100,7 @@ bool MainApplication::checkDefaultWebBrowser()
|
|||
dialog.setCheckBoxText(tr("Always perform this check when starting QupZilla."));
|
||||
dialog.setDefaultCheckState(Qt::Checked);
|
||||
dialog.setWindowTitle(tr("Default Browser"));
|
||||
dialog.setIcon(qIconProvider->standardIcon(QStyle::SP_MessageBoxWarning));
|
||||
dialog.setIcon(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning));
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
associationManager()->registerAllAssociation();
|
||||
|
|
|
@ -65,7 +65,7 @@ void AutoFillWidget::loginToPage()
|
|||
bool ok;
|
||||
int index = button->property("data-index").toInt(&ok);
|
||||
|
||||
if (ok && QzTools::vectorContainsIndex(m_data, index)) {
|
||||
if (ok && QzTools::containsIndex(m_data, index)) {
|
||||
const PasswordEntry entry = m_data.at(index);
|
||||
|
||||
PageFormCompleter completer(m_view->page());
|
||||
|
|
|
@ -82,7 +82,7 @@ void HistoryItem::insertChild(int row, HistoryItem* child)
|
|||
|
||||
void HistoryItem::removeChild(int row)
|
||||
{
|
||||
if (QzTools::listContainsIndex(m_children, row)) {
|
||||
if (QzTools::containsIndex(m_children, row)) {
|
||||
removeChild(m_children.at(row));
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ void HistoryItem::removeChild(HistoryItem* child)
|
|||
|
||||
HistoryItem* HistoryItem::child(int row) const
|
||||
{
|
||||
if (QzTools::listContainsIndex(m_children, row)) {
|
||||
if (QzTools::containsIndex(m_children, row)) {
|
||||
return m_children.at(row);
|
||||
}
|
||||
|
||||
|
|
|
@ -787,19 +787,21 @@ QString QzTools::escape(const QString &string)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef QZ_WS_X11
|
||||
void* QzTools::X11Display(const QWidget* widget)
|
||||
{
|
||||
Q_UNUSED(widget)
|
||||
|
||||
#ifdef QZ_WS_X11
|
||||
#if QT_VERSION >= 0x050000
|
||||
return qApp->platformNativeInterface()->nativeResourceForWindow("display", widget->windowHandle());
|
||||
#else
|
||||
return QX11Info::display();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QzTools::setWmClass(const QString &name, const QWidget* widget)
|
||||
{
|
||||
#ifdef QZ_WS_X11
|
||||
|
|
|
@ -15,12 +15,9 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef GLOBALFUNCTIONS_H
|
||||
#define GLOBALFUNCTIONS_H
|
||||
#ifndef QZTOOLS_H
|
||||
#define QZTOOLS_H
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QRegion>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "qzcommon.h"
|
||||
|
@ -32,76 +29,67 @@ class QIcon;
|
|||
class QWidget;
|
||||
class QUrl;
|
||||
|
||||
namespace QzTools
|
||||
class QUPZILLA_EXPORT QzTools
|
||||
{
|
||||
QByteArray QUPZILLA_EXPORT pixmapToByteArray(const QPixmap &pix);
|
||||
QPixmap QUPZILLA_EXPORT pixmapFromByteArray(const QByteArray &data);
|
||||
public:
|
||||
static QByteArray pixmapToByteArray(const QPixmap &pix);
|
||||
static QPixmap pixmapFromByteArray(const QByteArray &data);
|
||||
|
||||
QString QUPZILLA_EXPORT readAllFileContents(const QString &filename);
|
||||
QByteArray QUPZILLA_EXPORT readAllFileByteContents(const QString &filename);
|
||||
static QString readAllFileContents(const QString &filename);
|
||||
static QByteArray readAllFileByteContents(const QString &filename);
|
||||
|
||||
void QUPZILLA_EXPORT centerWidgetOnScreen(QWidget* w);
|
||||
void QUPZILLA_EXPORT centerWidgetToParent(QWidget* w, QWidget* parent);
|
||||
static void centerWidgetOnScreen(QWidget* w);
|
||||
static void centerWidgetToParent(QWidget* w, QWidget* parent);
|
||||
|
||||
bool QUPZILLA_EXPORT removeFile(const QString &fullFileName);
|
||||
void QUPZILLA_EXPORT removeDir(const QString &d);
|
||||
static bool removeFile(const QString &fullFileName);
|
||||
static void removeDir(const QString &d);
|
||||
|
||||
QString QUPZILLA_EXPORT samePartOfStrings(const QString &one, const QString &other);
|
||||
QString QUPZILLA_EXPORT urlEncodeQueryString(const QUrl &url);
|
||||
static QString samePartOfStrings(const QString &one, const QString &other);
|
||||
static QString urlEncodeQueryString(const QUrl &url);
|
||||
|
||||
QString QUPZILLA_EXPORT ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
|
||||
QString QUPZILLA_EXPORT getFileNameFromUrl(const QUrl &url);
|
||||
QString QUPZILLA_EXPORT filterCharsFromFilename(const QString &name);
|
||||
static QString ensureUniqueFilename(const QString &name, const QString &appendFormat = QString("(%1)"));
|
||||
static QString getFileNameFromUrl(const QUrl &url);
|
||||
static QString filterCharsFromFilename(const QString &name);
|
||||
|
||||
QString QUPZILLA_EXPORT lastPathForFileDialog(const QString &dialogName, const QString &fallbackPath);
|
||||
void QUPZILLA_EXPORT saveLastPathForFileDialog(const QString &dialogName, const QString &path);
|
||||
static QString lastPathForFileDialog(const QString &dialogName, const QString &fallbackPath);
|
||||
static void saveLastPathForFileDialog(const QString &dialogName, const QString &path);
|
||||
|
||||
QString QUPZILLA_EXPORT alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width);
|
||||
QString QUPZILLA_EXPORT fileSizeToString(qint64 size);
|
||||
static QString alignTextToWidth(const QString &string, const QString &text, const QFontMetrics &metrics, int width);
|
||||
static QString fileSizeToString(qint64 size);
|
||||
|
||||
QPixmap QUPZILLA_EXPORT createPixmapForSite(const QIcon &icon, const QString &title, const QString &url);
|
||||
QString QUPZILLA_EXPORT applyDirectionToPage(QString &pageContents);
|
||||
static QPixmap createPixmapForSite(const QIcon &icon, const QString &title, const QString &url);
|
||||
static QString applyDirectionToPage(QString &pageContents);
|
||||
|
||||
QString QUPZILLA_EXPORT resolveFromPath(const QString &name);
|
||||
QStringList QUPZILLA_EXPORT splitCommandArguments(const QString &command);
|
||||
bool QUPZILLA_EXPORT startExternalProcess(const QString &executable, const QString &args);
|
||||
static QString resolveFromPath(const QString &name);
|
||||
static QStringList splitCommandArguments(const QString &command);
|
||||
static bool startExternalProcess(const QString &executable, const QString &args);
|
||||
|
||||
QRegion QUPZILLA_EXPORT roundedRect(const QRect &rect, int radius);
|
||||
QIcon QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
|
||||
bool QUPZILLA_EXPORT isUtf8(const char* string);
|
||||
static QRegion roundedRect(const QRect &rect, int radius);
|
||||
static QIcon iconFromFileName(const QString &fileName);
|
||||
static bool isUtf8(const char* string);
|
||||
|
||||
// QFileDialog static functions that remembers last used directory
|
||||
QString QUPZILLA_EXPORT getExistingDirectory(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = QFileDialog::ShowDirsOnly);
|
||||
QString QUPZILLA_EXPORT getOpenFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
QStringList QUPZILLA_EXPORT getOpenFileNames(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
QString QUPZILLA_EXPORT getSaveFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
// QFileDialog static functions that remembers last used directory
|
||||
static QString getExistingDirectory(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), QFileDialog::Options options = QFileDialog::ShowDirsOnly);
|
||||
static QString getOpenFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
static QStringList getOpenFileNames(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
static QString getSaveFileName(const QString &name, QWidget* parent = 0, const QString &caption = QString(), const QString &dir = QString(), const QString &filter = QString(), QString* selectedFilter = 0, QFileDialog::Options options = 0);
|
||||
|
||||
bool QUPZILLA_EXPORT matchDomain(const QString &pattern, const QString &domain);
|
||||
static bool matchDomain(const QString &pattern, const QString &domain);
|
||||
|
||||
QString QUPZILLA_EXPORT operatingSystem();
|
||||
static QString operatingSystem();
|
||||
|
||||
// Qt5 migration help functions
|
||||
bool QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert);
|
||||
QString QUPZILLA_EXPORT escape(const QString &string);
|
||||
// Qt5 migration help functions
|
||||
static bool isCertificateValid(const QSslCertificate &cert);
|
||||
static QString escape(const QString &string);
|
||||
|
||||
#ifdef QZ_WS_X11
|
||||
void* X11Display(const QWidget* widget);
|
||||
#endif
|
||||
static void* X11Display(const QWidget* widget);
|
||||
static void setWmClass(const QString &name, const QWidget* widget);
|
||||
|
||||
void QUPZILLA_EXPORT setWmClass(const QString &name, const QWidget* widget);
|
||||
template <typename T>
|
||||
static bool containsIndex(const T &container, int index)
|
||||
{
|
||||
return (index >= 0 && container.count() > index);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
bool listContainsIndex(const QList<T> &list, int index)
|
||||
{
|
||||
return (index >= 0 && list.count() > index);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool vectorContainsIndex(const QVector<T> &list, int index)
|
||||
{
|
||||
return (index >= 0 && list.count() > index);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // GLOBALFUNCTIONS_H
|
||||
#endif // QZTOOLS_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user