1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

[Cleanup] Use QZ_WS_X11 only for X11 specific code

In other cases, use Q_OS_UNIX for determining UNIX platform.
UNIX platfroms without X11 should benefit from this commit, including
MAC and UNIXes on Wayland.
This commit is contained in:
nowrep 2014-03-03 14:47:47 +01:00
parent 82ca226127
commit a7d382ee42
16 changed files with 39 additions and 41 deletions

View File

@ -126,8 +126,8 @@ equals(d_disable_updates_check, "true") { DEFINES *= DISABLE_UPDATES_CHECK }
rev = $$system(cd ../ && sh $$PWD/../scripts/getrevision.sh) rev = $$system(cd ../ && sh $$PWD/../scripts/getrevision.sh)
!equals(rev, ""): DEFINES *= GIT_REVISION=\\\"""$$rev"\\\"" !equals(rev, ""): DEFINES *= GIT_REVISION=\\\"""$$rev"\\\""
# Define QZ_WS_X11 even with Qt5 # Define QZ_WS_X11 even with Qt5 (but only when building for X11)
DEFINES *= QZ_WS_X11 !contains(DEFINES, NO_X11) DEFINES *= QZ_WS_X11
} }
isEmpty(QMAKE_LRELEASE) { isEmpty(QMAKE_LRELEASE) {

View File

@ -17,7 +17,7 @@
* ============================================================ */ * ============================================================ */
#include "processinfo.h" #include "processinfo.h"
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
#include <dirent.h> #include <dirent.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -36,7 +36,7 @@ ProcessInfo::ProcessInfo(const QString &name)
bool ProcessInfo::isRunning() const bool ProcessInfo::isRunning() const
{ {
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
pid_t pid = GetPIDbyName(qPrintable(m_name)); pid_t pid = GetPIDbyName(qPrintable(m_name));
// -1 = process not found // -1 = process not found
// -2 = /proc fs access error // -2 = /proc fs access error
@ -46,7 +46,7 @@ bool ProcessInfo::isRunning() const
#endif #endif
} }
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
bool ProcessInfo::IsNumeric(const char* ccharptr_CharacterList) const bool ProcessInfo::IsNumeric(const char* ccharptr_CharacterList) const
{ {
for (; *ccharptr_CharacterList; ccharptr_CharacterList++) { for (; *ccharptr_CharacterList; ccharptr_CharacterList++) {

View File

@ -18,7 +18,7 @@
#ifndef PROCESSINFO_H #ifndef PROCESSINFO_H
#define PROCESSINFO_H #define PROCESSINFO_H
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -39,7 +39,7 @@ public:
bool isRunning() const; bool isRunning() const;
private: private:
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
bool IsNumeric(const char* ccharptr_CharacterList) const; bool IsNumeric(const char* ccharptr_CharacterList) const;
pid_t GetPIDbyName(const char* cchrptr_ProcessName) const; pid_t GetPIDbyName(const char* cchrptr_ProcessName) const;

View File

@ -95,7 +95,7 @@
#include "qwebkitversion.h" #include "qwebkitversion.h"
#endif #endif
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#endif #endif
@ -451,7 +451,7 @@ void BrowserWindow::setupMenu()
m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), MENU_RECEIVER, SLOT(editSelectAll()))->setShortcut(QKeySequence("Ctrl+A")); m_menuEdit->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &All"), MENU_RECEIVER, SLOT(editSelectAll()))->setShortcut(QKeySequence("Ctrl+A"));
m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), MENU_RECEIVER, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F")); m_menuEdit->addAction(QIcon::fromTheme("edit-find"), tr("&Find"), MENU_RECEIVER, SLOT(searchOnPage()))->setShortcut(QKeySequence("Ctrl+F"));
m_menuEdit->addSeparator(); m_menuEdit->addSeparator();
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
m_menuEdit->addAction(m_actionPreferences); m_menuEdit->addAction(m_actionPreferences);
#endif #endif
connect(m_menuEdit, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowEditMenu())); connect(m_menuEdit, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowEditMenu()));
@ -573,7 +573,7 @@ void BrowserWindow::setupMenu()
connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), mApp, SLOT(startPrivateBrowsing())); connect(m_actionPrivateBrowsing, SIGNAL(triggered(bool)), mApp, SLOT(startPrivateBrowsing()));
m_menuTools->addAction(m_actionPrivateBrowsing); m_menuTools->addAction(m_actionPrivateBrowsing);
m_menuTools->addSeparator(); m_menuTools->addSeparator();
#if !defined(QZ_WS_X11) && !defined(Q_OS_MAC) #if !defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
m_menuTools->addAction(m_actionPreferences); m_menuTools->addAction(m_actionPreferences);
#endif #endif
connect(m_menuTools, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowToolsMenu())); connect(m_menuTools, SIGNAL(aboutToShow()), MENU_RECEIVER, SLOT(aboutToShowToolsMenu()));
@ -2146,7 +2146,7 @@ void BrowserWindow::setMenuBookmarksAction(QAction* action)
QByteArray BrowserWindow::saveState(int version) const QByteArray BrowserWindow::saveState(int version) const
{ {
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
QByteArray data; QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly); QDataStream stream(&data, QIODevice::WriteOnly);
@ -2161,7 +2161,7 @@ QByteArray BrowserWindow::saveState(int version) const
bool BrowserWindow::restoreState(const QByteArray &state, int version) bool BrowserWindow::restoreState(const QByteArray &state, int version)
{ {
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
QByteArray windowState; QByteArray windowState;
int desktopId = -1; int desktopId = -1;
@ -2177,7 +2177,7 @@ bool BrowserWindow::restoreState(const QByteArray &state, int version)
#endif #endif
} }
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
int BrowserWindow::getCurrentVirtualDesktop() const int BrowserWindow::getCurrentVirtualDesktop() const
{ {
Display* display = static_cast<Display*>(QzTools::X11Display(this)); Display* display = static_cast<Display*>(QzTools::X11Display(this));

View File

@ -239,7 +239,7 @@ private:
bool eventFilter(QObject* object, QEvent* event); bool eventFilter(QObject* object, QEvent* event);
#endif #endif
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
int getCurrentVirtualDesktop() const; int getCurrentVirtualDesktop() const;
void moveToVirtualDesktop(int desktopId); void moveToVirtualDesktop(int desktopId);
#endif #endif

View File

@ -122,7 +122,7 @@ MainApplication::MainApplication(int &argc, char** argv)
setApplicationVersion(Qz::VERSION); setApplicationVersion(Qz::VERSION);
setOrganizationDomain("qupzilla"); setOrganizationDomain("qupzilla");
#if defined(QZ_WS_X11) && !defined(NO_SYSTEM_DATAPATH) #if defined(Q_OS_UNIX) && !defined(NO_SYSTEM_DATAPATH)
DATADIR = USE_DATADIR; DATADIR = USE_DATADIR;
#else #else
DATADIR = qApp->applicationDirPath() + "/"; DATADIR = qApp->applicationDirPath() + "/";
@ -765,7 +765,7 @@ void MainApplication::loadTheme(const QString &name)
* #id[style=QtStyle] (QtStyle = QMacStyle, QWindowsVistaStyle, QGtkStyle, ...) * #id[style=QtStyle] (QtStyle = QMacStyle, QWindowsVistaStyle, QGtkStyle, ...)
* should be enough instead of loading special stylesheets * should be enough instead of loading special stylesheets
*/ */
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
if (QFile(m_activeThemePath + "linux.css").exists()) { if (QFile(m_activeThemePath + "linux.css").exists()) {
cssFile.setFileName(m_activeThemePath + "linux.css"); cssFile.setFileName(m_activeThemePath + "linux.css");
cssFile.open(QFile::ReadOnly); cssFile.open(QFile::ReadOnly);
@ -1142,7 +1142,7 @@ QUrl MainApplication::userStyleSheet(const QString &filePath) const
{ {
QString userStyle; QString userStyle;
#ifndef QZ_WS_X11 #ifndef Q_OS_UNIX
// Don't grey out selection on losing focus (to prevent graying out found text) // Don't grey out selection on losing focus (to prevent graying out found text)
QString highlightColor; QString highlightColor;
QString highlightedTextColor; QString highlightedTextColor;
@ -1369,7 +1369,7 @@ QString MainApplication::tempPath() const
QString path = PROFILEDIR + "tmp/"; QString path = PROFILEDIR + "tmp/";
QDir dir(path); QDir dir(path);
if (!dir.exists()) { if (!dir.exists()) {
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
// Symlink it to standard temporary path /tmp // Symlink it to standard temporary path /tmp
QDir().mkpath(QDir::tempPath() + "/qupzilla/tmp"); QDir().mkpath(QDir::tempPath() + "/qupzilla/tmp");
QFile::remove(PROFILEDIR + "tmp"); QFile::remove(PROFILEDIR + "tmp");

View File

@ -115,14 +115,12 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qz::NewTabPositionFlags)
#define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt" #define ADBLOCK_EASYLIST_URL "https://easylist-downloads.adblockplus.org/easylist.txt"
#ifdef Q_OS_WIN #if defined(Q_OS_WIN) || defined(Q_OS_OS2)
#define DEFAULT_THEME_NAME "windows" #define DEFAULT_THEME_NAME "windows"
#elif defined(QZ_WS_X11)
#define DEFAULT_THEME_NAME "linux"
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
#define DEFAULT_THEME_NAME "mac" #define DEFAULT_THEME_NAME "mac"
#elif defined(Q_OS_OS2) #elif defined(Q_OS_UNIX)
#define DEFAULT_THEME_NAME "windows" #define DEFAULT_THEME_NAME "linux"
#else #else
#define DEFAULT_THEME_NAME "default" #define DEFAULT_THEME_NAME "default"
#endif #endif

View File

@ -24,7 +24,7 @@
#include <QDir> #include <QDir>
#include <QDebug> #include <QDebug>
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
#include <QDBusInterface> #include <QDBusInterface>
#endif #endif
@ -41,7 +41,7 @@ void DesktopNotificationsFactory::loadSettings()
settings.beginGroup("Notifications"); settings.beginGroup("Notifications");
m_enabled = settings.value("Enabled", true).toBool(); m_enabled = settings.value("Enabled", true).toBool();
m_timeout = settings.value("Timeout", 6000).toInt(); m_timeout = settings.value("Timeout", 6000).toInt();
#ifdef QZ_WS_X11 #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
m_notifType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNative : PopupWidget; m_notifType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNative : PopupWidget;
#else #else
m_notifType = PopupWidget; m_notifType = PopupWidget;
@ -52,7 +52,7 @@ void DesktopNotificationsFactory::loadSettings()
bool DesktopNotificationsFactory::supportsNativeNotifications() const bool DesktopNotificationsFactory::supportsNativeNotifications() const
{ {
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
return true; return true;
#else #else
return false; return false;
@ -78,7 +78,7 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
m_desktopNotif.data()->show(); m_desktopNotif.data()->show();
break; break;
case DesktopNative: case DesktopNative:
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
QFile tmp(mApp->tempPath() + "/qupzilla_notif.png"); QFile tmp(mApp->tempPath() + "/qupzilla_notif.png");
tmp.open(QFile::WriteOnly); tmp.open(QFile::WriteOnly);
icon.save(tmp.fileName()); icon.save(tmp.fileName());
@ -101,7 +101,7 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
void DesktopNotificationsFactory::nativeNotificationPreview() void DesktopNotificationsFactory::nativeNotificationPreview()
{ {
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
QFile tmp(mApp->tempPath() + "/qupzilla_notif.png"); QFile tmp(mApp->tempPath() + "/qupzilla_notif.png");
tmp.open(QFile::WriteOnly); tmp.open(QFile::WriteOnly);
QPixmap(":icons/preferences/dialog-question.png").save(tmp.fileName()); QPixmap(":icons/preferences/dialog-question.png").save(tmp.fileName());
@ -120,7 +120,7 @@ void DesktopNotificationsFactory::nativeNotificationPreview()
#endif #endif
} }
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
void DesktopNotificationsFactory::updateLastId(const QDBusMessage &msg) void DesktopNotificationsFactory::updateLastId(const QDBusMessage &msg)
{ {
QVariantList list = msg.arguments(); QVariantList list = msg.arguments();

View File

@ -47,7 +47,7 @@ public:
void nativeNotificationPreview(); void nativeNotificationPreview();
private slots: private slots:
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS) #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
void updateLastId(const QDBusMessage &msg); void updateLastId(const QDBusMessage &msg);
void error(const QDBusError &error); void error(const QDBusError &error);
#endif #endif

View File

@ -411,7 +411,7 @@ QString QupZillaSchemeReply::configPage()
QString debugBuild = tr("Disabled"); QString debugBuild = tr("Disabled");
#endif #endif
#if defined (USE_WEBGL) || (QTWEBKIT_FROM_2_3 && defined(QZ_WS_X11)) #if defined (USE_WEBGL) || (QTWEBKIT_FROM_2_3 && defined(Q_OS_UNIX))
QString webGLEnabled = tr("<b>Enabled</b>"); QString webGLEnabled = tr("<b>Enabled</b>");
#else #else
QString webGLEnabled = tr("Disabled"); QString webGLEnabled = tr("Disabled");
@ -423,7 +423,7 @@ QString QupZillaSchemeReply::configPage()
QString w7APIEnabled = tr("Disabled"); QString w7APIEnabled = tr("Disabled");
#endif #endif
#if defined(QZ_WS_X11) && defined(KDE_INTEGRATION) #if defined(Q_OS_UNIX) && defined(KDE_INTEGRATION)
QString KDEIntegration = tr("<b>Enabled</b>"); QString KDEIntegration = tr("<b>Enabled</b>");
#else #else
QString KDEIntegration = tr("Disabled"); QString KDEIntegration = tr("Disabled");

View File

@ -173,9 +173,9 @@ void Plugins::loadAvailablePlugins()
if (!mApp->isPortable()) { if (!mApp->isPortable()) {
dirs dirs
#if defined(QZ_WS_X11) && !defined(NO_SYSTEM_DATAPATH) #if defined(Q_OS_UNIX) && !defined(NO_SYSTEM_DATAPATH)
#ifdef USE_LIBPATH #ifdef USE_LIBPATH
<< USE_LIBPATH "qupzilla/" << USE_LIBPATH "/qupzilla/"
#else #else
<< "/usr/lib/qupzilla/" << "/usr/lib/qupzilla/"
#endif #endif

View File

@ -366,7 +366,7 @@ bool Speller::dictionaryExists(const QString &path) const
QString Speller::getDictionaryPath() const QString Speller::getDictionaryPath() const
{ {
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
const QString defaultDicPath = "/usr/share/hunspell/"; const QString defaultDicPath = "/usr/share/hunspell/";
#else #else
const QString defaultDicPath = mApp->DATADIR + "hunspell/"; const QString defaultDicPath = mApp->DATADIR + "hunspell/";

View File

@ -380,7 +380,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
DesktopNotificationsFactory::Type notifyType; DesktopNotificationsFactory::Type notifyType;
settings.beginGroup("Notifications"); settings.beginGroup("Notifications");
ui->notificationTimeout->setValue(settings.value("Timeout", 6000).toInt() / 1000); ui->notificationTimeout->setValue(settings.value("Timeout", 6000).toInt() / 1000);
#ifdef QZ_WS_X11 #if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
notifyType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNotificationsFactory::DesktopNative : DesktopNotificationsFactory::PopupWidget; notifyType = settings.value("UseNativeDesktop", true).toBool() ? DesktopNotificationsFactory::DesktopNative : DesktopNotificationsFactory::PopupWidget;
#else #else
notifyType = DesktopNotificationsFactory::PopupWidget; notifyType = DesktopNotificationsFactory::PopupWidget;

View File

@ -70,7 +70,7 @@ RSSNotification::RSSNotification(const QString &title, const QUrl &url, WebView*
m_rssApps << bloglines << myaol << netvibes << yahoo; m_rssApps << bloglines << myaol << netvibes << yahoo;
#ifdef QZ_WS_X11 #ifdef Q_OS_UNIX
const QString akregatorBin = QzTools::resolveFromPath("akregator"); const QString akregatorBin = QzTools::resolveFromPath("akregator");
const QString lifereaBin = QzTools::resolveFromPath("liferea"); const QString lifereaBin = QzTools::resolveFromPath("liferea");
const QString lifereaAddFeedBin = QzTools::resolveFromPath("liferea-add-feed"); const QString lifereaAddFeedBin = QzTools::resolveFromPath("liferea-add-feed");

View File

@ -46,7 +46,7 @@
#else #else
#include <QX11Info> #include <QX11Info>
#endif #endif
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#endif #endif
@ -787,7 +787,7 @@ QString QzTools::escape(const QString &string)
#endif #endif
} }
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
void* QzTools::X11Display(const QWidget* widget) void* QzTools::X11Display(const QWidget* widget)
{ {
Q_UNUSED(widget) Q_UNUSED(widget)
@ -802,7 +802,7 @@ void* QzTools::X11Display(const QWidget* widget)
void QzTools::setWmClass(const QString &name, const QWidget* widget) void QzTools::setWmClass(const QString &name, const QWidget* widget)
{ {
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
QByteArray nameData = name.toUtf8(); QByteArray nameData = name.toUtf8();
XClassHint classHint; XClassHint classHint;

View File

@ -84,7 +84,7 @@ QString QUPZILLA_EXPORT operatingSystem();
bool QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert); bool QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert);
QString QUPZILLA_EXPORT escape(const QString &string); QString QUPZILLA_EXPORT escape(const QString &string);
#if defined(QZ_WS_X11) && !defined(NO_X11) #ifdef QZ_WS_X11
void* X11Display(const QWidget* widget); void* X11Display(const QWidget* widget);
#endif #endif