1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36: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)
!equals(rev, ""): DEFINES *= GIT_REVISION=\\\"""$$rev"\\\""
# Define QZ_WS_X11 even with Qt5
DEFINES *= QZ_WS_X11
# Define QZ_WS_X11 even with Qt5 (but only when building for X11)
!contains(DEFINES, NO_X11) DEFINES *= QZ_WS_X11
}
isEmpty(QMAKE_LRELEASE) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -380,7 +380,7 @@ Preferences::Preferences(BrowserWindow* window, QWidget* parent)
DesktopNotificationsFactory::Type notifyType;
settings.beginGroup("Notifications");
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;
#else
notifyType = DesktopNotificationsFactory::PopupWidget;

View File

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

View File

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

View File

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