Fix functions and macros using to support both Qt4 and Qt5.

This commit is contained in:
Vladimir Golovnev (Glassez)
2013-09-21 11:59:58 +04:00
committed by sledgehammer999
parent 763d8a392f
commit ce3aac5f9d
51 changed files with 260 additions and 181 deletions

View File

@@ -14,10 +14,10 @@
enum AdvSettingsCols {PROPERTY, VALUE};
enum AdvSettingsRows {DISK_CACHE, DISK_CACHE_TTL, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, NETWORK_ADDRESS, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT,
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
UPDATE_CHECK,
#endif
#if defined(Q_WS_X11)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
USE_ICON_THEME,
#endif
CONFIRM_DELETE_TORRENT, TRACKER_EXCHANGE,
@@ -34,10 +34,10 @@ private:
cb_enable_tracker_ext;
QComboBox combo_iface;
QSpinBox spin_cache_ttl;
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
QCheckBox cb_update_check;
#endif
#if defined(Q_WS_X11)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
QCheckBox cb_use_icon_theme;
#endif
QCheckBox cb_announce_all_trackers;
@@ -107,11 +107,11 @@ public slots:
// Tracker
pref.setTrackerEnabled(cb_tracker_status.isChecked());
pref.setTrackerPort(spin_tracker_port.value());
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
pref.setUpdateCheckEnabled(cb_update_check.isChecked());
#endif
// Icon theme
#if defined(Q_WS_X11)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
pref.useSystemIconTheme(cb_use_icon_theme.isChecked());
#endif
pref.setConfirmTorrentDeletion(cb_confirm_torrent_deletion.isChecked());
@@ -250,11 +250,11 @@ private slots:
spin_tracker_port.setMaximum(65535);
spin_tracker_port.setValue(pref.getTrackerPort());
setRow(TRACKER_PORT, tr("Embedded tracker port"), &spin_tracker_port);
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
cb_update_check.setChecked(pref.isUpdateCheckEnabled());
setRow(UPDATE_CHECK, tr("Check for software updates"), &cb_update_check);
#endif
#if defined(Q_WS_X11)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
cb_use_icon_theme.setChecked(pref.useSystemIconTheme());
setRow(USE_ICON_THEME, tr("Use system icon theme"), &cb_use_icon_theme);
#endif

View File

@@ -85,7 +85,11 @@ options_imp::options_imp(QWidget *parent):
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
scanFoldersView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
#else
scanFoldersView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
#endif
scanFoldersView->setModel(ScanFoldersModel::instance());
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(enableApplyButton()));
connect(scanFoldersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleScanFolderViewSelectionChanged()));
@@ -102,15 +106,15 @@ options_imp::options_imp(QWidget *parent):
// Load options
loadOptions();
// Disable systray integration if it is not supported by the system
#ifndef Q_WS_MAC
#ifndef Q_OS_MAC
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
#endif
checkShowSystray->setChecked(false);
checkShowSystray->setEnabled(false);
#ifndef Q_WS_MAC
#ifndef Q_OS_MAC
}
#endif
#if !defined(Q_WS_X11)
#if (!defined(Q_OS_UNIX) || defined(Q_OS_MAC))
label_trayIconStyle->setVisible(false);
comboTrayIcon->setVisible(false);
#endif
@@ -118,7 +122,7 @@ options_imp::options_imp(QWidget *parent):
checkWebUiHttps->setVisible(false);
#endif
#ifndef Q_WS_WIN
#ifndef Q_OS_WIN
checkStartup->setVisible(false);
groupFileAssociation->setVisible(false);
#endif
@@ -136,17 +140,17 @@ options_imp::options_imp(QWidget *parent):
connect(checkCloseToSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkMinimizeToSysTray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkStartMinimized, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
connect(checkStartup, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#endif
connect(checkShowSplash, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkProgramExitConfirm, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkPreventFromSuspend, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(comboTrayIcon, SIGNAL(currentIndexChanged(int)), this, SLOT(enableApplyButton()));
#if defined(Q_WS_X11) && !defined(QT_DBUS_LIB)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && !defined(QT_DBUS_LIB)
checkPreventFromSuspend->setDisabled(true);
#endif
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
connect(checkAssociateTorrents, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkAssociateMagnetLinks, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
#endif
@@ -367,7 +371,7 @@ void options_imp::saveOptions() {
pref.setSplashScreenDisabled(isSlashScreenDisabled());
pref.setConfirmOnExit(checkProgramExitConfirm->isChecked());
pref.setPreventFromSuspend(preventFromSuspend());
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
pref.setStartup(Startup());
// Windows: file association settings
Preferences::setTorrentFileAssoc(checkAssociateTorrents->isChecked());
@@ -524,7 +528,7 @@ void options_imp::loadOptions() {
comboTrayIcon->setCurrentIndex(pref.trayIconStyle());
checkProgramExitConfirm->setChecked(pref.confirmOnExit());
checkPreventFromSuspend->setChecked(pref.preventFromSuspend());
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
checkStartup->setChecked(pref.Startup());
// Windows: file association settings
checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
@@ -961,7 +965,7 @@ bool options_imp::isSlashScreenDisabled() const {
return !checkShowSplash->isChecked();
}
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool options_imp::Startup() const {
return checkStartup->isChecked();
}

View File

@@ -101,7 +101,7 @@ private:
bool startMinimized() const;
bool isSlashScreenDisabled() const;
bool preventFromSuspend() const;
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool Startup() const;
#endif
// Downloads

View File

@@ -135,7 +135,7 @@ public:
}
bool systrayIntegration() const {
#ifdef Q_WS_MAC
#ifdef Q_OS_MAC
return false;
#else
return value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
@@ -195,7 +195,7 @@ public:
setValue("Preferences/General/PreventFromSuspend", b);
}
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
bool Startup() const {
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
return settings.contains("qBittorrent");
@@ -1135,7 +1135,7 @@ public:
setValue(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), enabled);
}
#if defined(Q_WS_X11)
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
bool useSystemIconTheme() const {
return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool();
}
@@ -1171,7 +1171,7 @@ public:
setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
}
#ifdef Q_WS_WIN
#ifdef Q_OS_WIN
static QString getPythonPath() {
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
QStringList versions = reg_python.childGroups();
@@ -1311,7 +1311,7 @@ public:
setValue(QString::fromUtf8("Preferences/Advanced/trackerPort"), port);
}
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
bool isUpdateCheckEnabled() const {
return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool();
}