diff --git a/src/about_imp.h b/src/about_imp.h index db6bde2a0..1dc97e492 100644 --- a/src/about_imp.h +++ b/src/about_imp.h @@ -51,7 +51,7 @@ class about : public QDialog, private Ui::AboutDlg{ // About QString aboutText = QString::fromUtf8("

") + - tr("An advanced BitTorrent client programmed in C++, based on Qt4 toolkit and libtorrent-rasterbar.") + + tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar.") + QString::fromUtf8("

") + trUtf8("Copyright ©2006-2013 The qBittorrent project") + QString::fromUtf8("

") + diff --git a/src/addnewtorrentdialog.cpp b/src/addnewtorrentdialog.cpp index 520bc9682..a117cbfe1 100644 --- a/src/addnewtorrentdialog.cpp +++ b/src/addnewtorrentdialog.cpp @@ -439,7 +439,7 @@ void AddNewTorrentDialog::renameSelectedFile() // Check for overwriting for (int i=0; inum_files(); ++i) { const QString ¤t_name = m_filesPath.at(i); -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_OS_UNIX) || defined(Q_WS_QWS) if (current_name.startsWith(new_path, Qt::CaseSensitive)) { #else if (current_name.startsWith(new_path, Qt::CaseInsensitive)) { diff --git a/src/addnewtorrentdialog.h b/src/addnewtorrentdialog.h index 1e1bfb2ae..0d1b2dfe3 100644 --- a/src/addnewtorrentdialog.h +++ b/src/addnewtorrentdialog.h @@ -34,6 +34,7 @@ #include #include #include + #include #include "qtorrenthandle.h" diff --git a/src/dnsupdater.cpp b/src/dnsupdater.cpp index 896b004c5..053c8022d 100644 --- a/src/dnsupdater.cpp +++ b/src/dnsupdater.cpp @@ -31,6 +31,9 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#include +#endif #include "dnsupdater.h" #include "qbtsession.h" @@ -148,9 +151,18 @@ QUrl DNSUpdater::getUpdateUrl() const Q_ASSERT(0); } url.setPath("/nic/update"); + +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) url.addQueryItem("hostname", m_domain); url.addQueryItem("myip", m_lastIP.toString()); +#else + QUrlQuery urlQuery(url); + urlQuery.addQueryItem("hostname", m_domain); + urlQuery.addQueryItem("myip", m_lastIP.toString()); + url.setQuery(urlQuery); +#endif Q_ASSERT(url.isValid()); + qDebug() << Q_FUNC_INFO << url.toString(); return url; } diff --git a/src/filesystemwatcher.h b/src/filesystemwatcher.h index 42c228c9a..99fd68f1d 100644 --- a/src/filesystemwatcher.h +++ b/src/filesystemwatcher.h @@ -8,11 +8,11 @@ #include #include -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN #include #include #include -#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD) +#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) #include #include #include @@ -47,7 +47,7 @@ class FileSystemWatcher: public QFileSystemWatcher { Q_OBJECT private: -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN QList watched_folders; QPointer watch_timer; #endif @@ -56,7 +56,7 @@ private: QHash m_partialTorrents; QPointer m_partialTorrentTimer; -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN private: static bool isNetworkFileSystem(QString path) { QString file = path; @@ -65,7 +65,7 @@ private: file += "."; struct statfs buf; if (!statfs(file.toLocal8Bit().constData(), &buf)) { -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // XXX: should we make sure HAVE_STRUCT_FSSTAT_F_FSTYPENAME is defined? return (strcmp(buf.f_fstypename, "nfs") == 0 || strcmp(buf.f_fstypename, "cifs") == 0 || strcmp(buf.f_fstypename, "smbfs") == 0); #else @@ -124,7 +124,7 @@ public: } ~FileSystemWatcher() { -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN if (watch_timer) delete watch_timer; #endif @@ -134,7 +134,7 @@ public: QStringList directories() const { QStringList dirs; -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN if (watch_timer) { foreach (const QDir &dir, watched_folders) dirs << dir.canonicalPath(); @@ -145,7 +145,7 @@ public: } void addPath(const QString & path) { -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN QDir dir(path); if (!dir.exists()) return; @@ -167,13 +167,13 @@ public: qDebug("FS Watching is watching %s in normal mode", qPrintable(path)); QFileSystemWatcher::addPath(path); scanLocalFolder(path); -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN } #endif } void removePath(const QString & path) { -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN QDir dir(path); for (int i = 0; i < watched_folders.count(); ++i) { if (QDir(watched_folders.at(i)) == dir) { @@ -202,7 +202,7 @@ protected slots: } void scanNetworkFolders() { -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN qDebug("scanNetworkFolders() called"); QStringList torrents; // Network folders scan diff --git a/src/fs_utils.cpp b/src/fs_utils.cpp index f40e5e9ba..4e28145cd 100644 --- a/src/fs_utils.cpp +++ b/src/fs_utils.cpp @@ -43,13 +43,13 @@ #endif #include -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include #include #endif -#ifndef Q_WS_WIN -#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD) +#ifndef Q_OS_WIN +#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD) #include #include #else @@ -60,8 +60,12 @@ #include #endif -#if defined(Q_WS_WIN) || defined(Q_OS_OS2) +#if defined(Q_OS_WIN) || defined(Q_OS_OS2) +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #include +#else +#include +#endif #endif using namespace libtorrent; @@ -125,9 +129,9 @@ bool fsutils::smartRemoveEmptyFolderTree(const QString& dir_path) return true; // Remove Files created by the OS -#if defined Q_WS_MAC +#if defined Q_OS_MAC fsutils::forceRemove(dir_path + QLatin1String("/.DS_Store")); -#elif defined Q_WS_WIN +#elif defined Q_OS_WIN fsutils::forceRemove(dir_path + QLatin1String("/Thumbs.db")); #endif @@ -283,7 +287,7 @@ long long fsutils::freeDiskSpaceOnPath(QString path) { } Q_ASSERT(dir_path.exists()); -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN unsigned long long available; struct statfs stats; const QString statfs_path = dir_path.path()+"/."; @@ -338,7 +342,7 @@ QString fsutils::branchPath(const QString& file_path, QString* removed) bool fsutils::sameFileNames(const QString &first, const QString &second) { -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS) +#if defined(Q_OS_UNIX) || defined(Q_WS_QWS) return QString::compare(first, second, Qt::CaseSensitive) == 0; #else return QString::compare(first, second, Qt::CaseInsensitive) == 0; @@ -364,14 +368,14 @@ QString fsutils::expandPathAbs(const QString& path) { QString fsutils::QDesktopServicesDataLocation() { QString result; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN LPWSTR path=new WCHAR[256]; if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE)) result = fsutils::fromNativePath(QString::fromWCharArray(path)); if (!QCoreApplication::applicationName().isEmpty()) result += QLatin1String("/") + qApp->applicationName(); #else -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC FSRef ref; OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref); if (err) @@ -397,10 +401,10 @@ QString fsutils::QDesktopServicesDataLocation() { QString fsutils::QDesktopServicesCacheLocation() { QString result; -#if defined(Q_WS_WIN) || defined(Q_OS_OS2) +#if defined(Q_OS_WIN) || defined(Q_OS_OS2) result = QDesktopServicesDataLocation() + QLatin1String("cache"); #else -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html FSRef ref; OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref); @@ -424,16 +428,21 @@ QString fsutils::QDesktopServicesCacheLocation() { } QString fsutils::QDesktopServicesDownloadLocation() { -#if defined(Q_WS_WIN) || defined(Q_OS_OS2) +#if defined(Q_OS_WIN) || defined(Q_OS_OS2) // as long as it stays WinXP like we do the same on OS/2 // TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads // instead of hardcoding "Downloads" // Unfortunately, this would break compatibility with WinXP +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath( QCoreApplication::translate("fsutils", "Downloads")); +#else + return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath( + QCoreApplication::translate("fsutils", "Downloads")); +#endif #endif -#ifdef Q_WS_X11 +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) QString save_path; // Default save path on Linux QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData()); @@ -468,7 +477,7 @@ QString fsutils::QDesktopServicesDownloadLocation() { return save_path; #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // TODO: How to support this on Mac OS X? #endif diff --git a/src/ico.cpp b/src/ico.cpp index 652489f5c..a2184e626 100644 --- a/src/ico.cpp +++ b/src/ico.cpp @@ -309,11 +309,11 @@ bool ICOHandler::read(QImage *outImage) QImage icon; if ( loadFromDIB( stream, *selected, icon ) ) { - icon.setText( "X-Index", 0, QString::number( selected - icons.begin() ) ); + icon.setText( "X-Index", QString::number( selected - icons.begin() ) ); if ( header.type == IcoHeader::Cursor ) { - icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) ); - icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) ); + icon.setText( "X-HotspotX", QString::number( selected->hotspotX ) ); + icon.setText( "X-HotspotY", QString::number( selected->hotspotY ) ); } *outImage = icon; @@ -424,6 +424,9 @@ bool ICOHandler::canRead(QIODevice *device) class ICOPlugin : public QImageIOPlugin { +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin") +#endif public: QStringList keys() const; Capabilities capabilities(QIODevice *device, const QByteArray &format) const; @@ -458,5 +461,7 @@ QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format) return handler; } +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) Q_EXPORT_STATIC_PLUGIN(ICOPlugin) Q_EXPORT_PLUGIN2(ico, ICOPlugin) +#endif diff --git a/src/iconprovider.cpp b/src/iconprovider.cpp index 6adb7fad5..4b04e5853 100644 --- a/src/iconprovider.cpp +++ b/src/iconprovider.cpp @@ -35,7 +35,7 @@ IconProvider* IconProvider::m_instance = 0; IconProvider::IconProvider() { -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) m_useSystemTheme = Preferences().useSystemIconTheme(); #endif } @@ -57,7 +57,7 @@ void IconProvider::drop() QIcon IconProvider::getIcon(const QString &iconId) { -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (m_useSystemTheme) { QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png")); icon = generateDifferentSizes(icon); @@ -67,7 +67,7 @@ QIcon IconProvider::getIcon(const QString &iconId) return QIcon(":/Icons/oxygen/"+iconId+".png"); } -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) void IconProvider::useSystemIconTheme(bool enable) { m_useSystemTheme = enable; @@ -102,7 +102,7 @@ QIcon IconProvider::generateDifferentSizes(const QIcon& icon) QString IconProvider::getIconPath(const QString& iconId) { -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (m_useSystemTheme) { QString path = QDir::temp().absoluteFilePath(iconId+".png"); if (!QFile::exists(path)) { diff --git a/src/iconprovider.h b/src/iconprovider.h index 269721a4b..0f56df273 100644 --- a/src/iconprovider.h +++ b/src/iconprovider.h @@ -48,7 +48,7 @@ public: QIcon getIcon(const QString& iconId); QString getIconPath(const QString& iconId); -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) public: void useSystemIconTheme(bool enable); diff --git a/src/main.cpp b/src/main.cpp index d280a8b44..0c06d3c73 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -59,7 +59,7 @@ Q_IMPORT_PLUGIN(qico) #include "preferences.h" #include "qinisettings.h" -#if defined(Q_WS_X11) || defined(Q_WS_MAC) +#if defined(Q_OS_UNIX) #include #include #include "stacktrace.h" @@ -137,7 +137,7 @@ public: #include "main.moc" -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(STACKTRACE_WIN) +#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN) void sigintHandler(int) { signal(SIGINT, 0); qDebug("Catching SIGINT, exiting cleanly"); @@ -353,7 +353,7 @@ int main(int argc, char *argv[]) { #ifndef DISABLE_GUI app.setQuitOnLastWindowClosed(false); #endif -#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(STACKTRACE_WIN) +#if defined(Q_OS_UNIX) || defined(STACKTRACE_WIN) signal(SIGABRT, sigabrtHandler); signal(SIGTERM, sigtermHandler); signal(SIGINT, sigintHandler); @@ -374,9 +374,9 @@ int main(int argc, char *argv[]) { QObject::connect(&app, SIGNAL(messageReceived(const QString&)), &window, SLOT(processParams(const QString&))); app.setActivationWindow(&window); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC static_cast(&app)->setReadyToProcessEvents(); -#endif // Q_WS_MAC +#endif // Q_OS_MAC #else // Load Headless class HeadlessLoader loader(torrents); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3bc4e4189..a93b5ba65 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -29,7 +29,7 @@ */ #include -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) #include #include "notifications.h" #endif @@ -44,6 +44,7 @@ #include #include #include +#include #include "mainwindow.h" #include "transferlistwidget.h" @@ -75,13 +76,13 @@ #ifndef DISABLE_GUI #include "autoexpandabledialog.h" #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include "qmacapplication.h" void qt_mac_set_dock_menu(QMenu *menu); #endif #include "lineedit.h" #include "sessionapplication.h" -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) #include "programupdater.h" #endif #include "powermanagement.h" @@ -108,7 +109,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa // Clean exit on log out connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(shutdownCleanUp()), Qt::DirectConnection); // Setting icons -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (Preferences().useSystemIconTheme()) setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")))); else @@ -161,7 +162,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa connect(QBtSession::instance(), SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString))); connect(QBtSession::instance(), SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool))); connect(QBtSession::instance(), SIGNAL(recursiveTorrentDownloadPossible(QTorrentHandle)), this, SLOT(askRecursiveTorrentDownloadConfirmation(QTorrentHandle))); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC connect(static_cast(qApp), SIGNAL(newFileOpenMacEvent(QString)), this, SLOT(processParams(QString))); #endif @@ -211,7 +212,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa connect(actionToggleVisibility, SIGNAL(triggered()), this, SLOT(toggleVisibility())); connect(actionMinimize, SIGNAL(triggered()), SLOT(minimizeWindow())); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) programUpdateTimer.setInterval(60*60*1000); programUpdateTimer.setSingleShot(true); connect(&programUpdateTimer, SIGNAL(timeout()), SLOT(checkProgramUpdate())); @@ -239,7 +240,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa connect(status_bar->connectionStatusButton(), SIGNAL(clicked()), SLOT(showConnectionSettings())); connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds())); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC setUnifiedTitleAndToolBarOnMac(true); #endif @@ -260,7 +261,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa autoShutdownGroup->addAction(actionAutoExit_qBittorrent); autoShutdownGroup->addAction(actionAutoShutdown_system); autoShutdownGroup->addAction(actionAutoSuspend_system); -#if !defined(Q_WS_X11) || defined(QT_DBUS_LIB) +#if (!defined(Q_OS_UNIX) || defined(Q_OS_MAC)) || defined(QT_DBUS_LIB) actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete()); actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete()); #else @@ -304,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa connect(transferList->getSourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(updateNbTorrents())); qDebug("GUI Built"); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN if (!pref.neverCheckFileAssoc() && (!Preferences::isTorrentFileAssocSet() || !Preferences::isMagnetLinkAssocSet())) { if (QMessageBox::question(0, tr("Torrent file association"), tr("qBittorrent is not the default application to open torrent files or Magnet links.\nDo you want to associate qBittorrent to torrent files and Magnet links?"), @@ -316,7 +317,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa } } #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC qt_mac_set_dock_menu(getTrayIconMenu()); #endif @@ -341,7 +342,7 @@ void MainWindow::shutdownCleanUp() { QBtSession::drop(); // Save window size, columns size writeSettings(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // Workaround to avoid bug http://bugreports.qt.nokia.com/browse/QTBUG-7305 setUnifiedTitleAndToolBarOnMac(false); #endif @@ -567,7 +568,7 @@ void MainWindow::createKeyboardShortcuts() { actionPause_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+P"))); actionDecreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+-"))); actionIncreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl++"))); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC actionMinimize->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+M"))); addAction(actionMinimize); #endif @@ -840,7 +841,7 @@ bool MainWindow::event(QEvent * e) { } break; } -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC case QEvent::ToolBarChange: { qDebug("MAC: Received a toolbar change event!"); bool ret = QMainWindow::event(e); @@ -1094,14 +1095,14 @@ void MainWindow::loadPreferences(bool configure_session) { properties->reloadPreferences(); // Icon provider -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) IconProvider::instance()->useSystemIconTheme(pref.useSystemIconTheme()); #endif if (configure_session) QBtSession::instance()->configureSession(); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) if (pref.isUpdateCheckEnabled()) checkProgramUpdate(); else @@ -1130,7 +1131,7 @@ void MainWindow::trackerAuthenticationRequired(const QTorrentHandle& h) { void MainWindow::updateGUI() { // update global informations if (systrayIcon) { -#if defined(Q_WS_X11) || defined(Q_WS_MAC) +#if defined(Q_OS_UNIX) QString html = "

"; html += "qBittorrent"; html += "
"; @@ -1155,7 +1156,7 @@ void MainWindow::updateGUI() { void MainWindow::showNotificationBaloon(QString title, QString msg) const { if (!Preferences().useProgramNotification()) return; -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) org::freedesktop::Notifications notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", QDBusConnection::sessionBus()); @@ -1343,7 +1344,7 @@ void MainWindow::on_actionDownload_from_URL_triggered() { } } -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) void MainWindow::handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser) { @@ -1427,7 +1428,7 @@ void MainWindow::checkForActiveTorrents() QIcon MainWindow::getSystrayIcon() const { -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) TrayIcon::Style style = Preferences().trayIconStyle(); switch(style) { case TrayIcon::MONO_DARK: @@ -1439,7 +1440,7 @@ QIcon MainWindow::getSystrayIcon() const } #endif QIcon icon; -#if defined(Q_WS_X11) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) if (Preferences().useSystemIconTheme()) { icon = QIcon::fromTheme("qbittorrent"); } @@ -1452,7 +1453,7 @@ QIcon MainWindow::getSystrayIcon() const return icon; } -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) void MainWindow::checkProgramUpdate() { programUpdateTimer.stop(); // If the user had clicked the menu item actionCheck_for_updates->setEnabled(false); diff --git a/src/mainwindow.h b/src/mainwindow.h index abdc61486..4c38e33a2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -139,7 +139,7 @@ protected slots: void optionsSaved(); // HTTP slots void on_actionDownload_from_URL_triggered(); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser); #endif @@ -197,7 +197,7 @@ private: // Power Management PowerManagement *m_pwr; QTimer *preventTimer; -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) QTimer programUpdateTimer; #endif @@ -214,7 +214,7 @@ private slots: void on_actionAutoShutdown_system_toggled(bool ); // Check for active torrents and set preventing from suspend state void checkForActiveTorrents(); -#if defined(Q_WS_WIN) || defined(Q_WS_MAC) +#if defined(Q_OS_WIN) || defined(Q_OS_MAC) void checkProgramUpdate(); #endif }; diff --git a/src/misc.cpp b/src/misc.cpp index ce0a71c42..7addb0d86 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -49,7 +49,7 @@ #include #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #include const int UNLEN = 256; @@ -58,13 +58,13 @@ const int UNLEN = 256; #include #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include #include #endif #ifndef DISABLE_GUI -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) #include #include #endif @@ -82,7 +82,7 @@ static struct { const char *source; const char *comment; } units[] = { #ifndef DISABLE_GUI void misc::shutdownComputer(bool sleep) { -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) // Use dbus to power off / suspend the system if (sleep) { // Some recent systems use systemd's logind @@ -126,7 +126,7 @@ void misc::shutdownComputer(bool sleep) { halIface.call("Shutdown"); } #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC AEEventID EventToSend; if (sleep) EventToSend = kAESleep; @@ -167,7 +167,7 @@ void misc::shutdownComputer(bool sleep) { AEDisposeDesc(&eventReply); #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN HANDLE hToken; // handle to process token TOKEN_PRIVILEGES tkp; // pointer to token structure if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) @@ -367,7 +367,7 @@ QString misc::magnetUriToHash(const QString& magnet_uri) { const QString found = regHex.cap(1); qDebug() << Q_FUNC_INFO << "regex found: " << found; if (found.length() == 40) { - const sha1_hash sha1(QByteArray::fromHex(found.toAscii()).constData()); + const sha1_hash sha1(QByteArray::fromHex(found.toLatin1()).constData()); qDebug("magnetUriToHash (Hex): hash: %s", qPrintable(misc::toQString(sha1))); return misc::toQString(sha1); } @@ -417,7 +417,7 @@ QString misc::userFriendlyDuration(qlonglong seconds) { QString misc::getUserIDString() { QString uid = "0"; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN char buffer[UNLEN+1] = {0}; DWORD buffer_len = UNLEN + 1; if (!GetUserNameA(buffer, &buffer_len)) diff --git a/src/powermanagement/powermanagement.cpp b/src/powermanagement/powermanagement.cpp index 2b882a881..ec07aa8d7 100644 --- a/src/powermanagement/powermanagement.cpp +++ b/src/powermanagement/powermanagement.cpp @@ -30,22 +30,22 @@ #include -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) #include "powermanagement_x11.h" #endif #include "powermanagement.h" -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include #endif -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #endif PowerManagement::PowerManagement(QObject *parent) : QObject(parent), m_busy(false) { -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) m_inhibitor = new PowerManagementInhibitor(this); #endif } @@ -65,11 +65,11 @@ void PowerManagement::setBusy() if (m_busy) return; m_busy = true; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); -#elif defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#elif (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) m_inhibitor->RequestBusy(); -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID); if (success != kIOReturnSuccess) m_busy = false; #endif @@ -80,11 +80,11 @@ void PowerManagement::setIdle() if (!m_busy) return; m_busy = false; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN SetThreadExecutionState(ES_CONTINUOUS); -#elif defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#elif (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) m_inhibitor->RequestIdle(); -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) IOPMAssertionRelease(m_assertionID); #endif } diff --git a/src/powermanagement/powermanagement.h b/src/powermanagement/powermanagement.h index 3234d22b1..435f76a2f 100644 --- a/src/powermanagement/powermanagement.h +++ b/src/powermanagement/powermanagement.h @@ -33,12 +33,12 @@ #include -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // Require Mac OS X >= 10.5 #include #endif -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) // Require DBus class PowerManagementInhibitor; #endif @@ -59,10 +59,10 @@ private: void setBusy(); void setIdle(); -#if defined(Q_WS_X11) && defined(QT_DBUS_LIB) +#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB) PowerManagementInhibitor *m_inhibitor; #endif -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC IOPMAssertionID m_assertionID; #endif }; diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index 1b7dad66c..bf5861709 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -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 diff --git a/src/preferences/options_imp.cpp b/src/preferences/options_imp.cpp index 003335a88..9122c1693 100755 --- a/src/preferences/options_imp.cpp +++ b/src/preferences/options_imp.cpp @@ -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(); } diff --git a/src/preferences/options_imp.h b/src/preferences/options_imp.h index 1b0172dd2..7f86b61cd 100755 --- a/src/preferences/options_imp.h +++ b/src/preferences/options_imp.h @@ -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 diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index 64e530b69..1db115801 100755 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -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(); } diff --git a/src/previewlistdelegate.h b/src/previewlistdelegate.h index 2cf6ecf4f..7df55806e 100644 --- a/src/previewlistdelegate.h +++ b/src/previewlistdelegate.h @@ -40,8 +40,12 @@ #include "misc.h" #include "previewselect.h" -#ifdef Q_WS_WIN - #include +#ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#include +#else +#include +#endif #endif class PreviewListDelegate: public QItemDelegate { @@ -71,13 +75,17 @@ class PreviewListDelegate: public QItemDelegate { newopt.minimum = 0; newopt.state |= QStyle::State_Enabled; newopt.textVisible = true; - #ifndef Q_WS_WIN +#ifndef Q_OS_WIN QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); - #else +#else // XXX: To avoid having the progress text on the right of the bar +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) QPlastiqueStyle st; +#else + QProxyStyle st("fusion"); +#endif st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); - #endif +#endif break; } default: diff --git a/src/programupdater.cpp b/src/programupdater.cpp index 6739d7333..a2f1d35d2 100644 --- a/src/programupdater.cpp +++ b/src/programupdater.cpp @@ -39,7 +39,7 @@ #include "fs_utils.h" #include "preferences.h" -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC const QString RSS_URL = "http://sourceforge.net/api/file/index/project-id/163414/mtime/desc/rss?path=/qbittorrent-mac"; const QString FILE_EXT = "DMG"; #else diff --git a/src/properties/peeraddition.h b/src/properties/peeraddition.h index 7c5709292..07cde7994 100644 --- a/src/properties/peeraddition.h +++ b/src/properties/peeraddition.h @@ -36,6 +36,7 @@ #include #include #include "ui_peer.h" + #include #include diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index 055327023..a697de937 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -209,7 +209,7 @@ void PeerListWidget::showPeerListMenu(const QPoint&) return; } if (act == copyIPAct) { -#if defined(Q_WS_WIN) || defined(Q_OS_OS2) +#if defined(Q_OS_WIN) || defined(Q_OS_OS2) QApplication::clipboard()->setText(selectedPeerIPs.join("\r\n")); #else QApplication::clipboard()->setText(selectedPeerIPs.join("\n")); diff --git a/src/properties/propertieswidget.cpp b/src/properties/propertieswidget.cpp index 479a576f4..07a4edca7 100644 --- a/src/properties/propertieswidget.cpp +++ b/src/properties/propertieswidget.cpp @@ -561,7 +561,7 @@ void PropertiesWidget::renameSelectedFile() { // Check if that name is already used for (int i=0; i +#else +#include +#endif #endif // Defines for properties list columns @@ -84,12 +88,16 @@ public: newopt.minimum = 0; newopt.state |= QStyle::State_Enabled; newopt.textVisible = true; -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else - // XXX: To avoid having the progress text on the right of the bar - QPlastiqueStyle st; - st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); + // XXX: To avoid having the progress text on the right of the bar +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) + QPlastiqueStyle st; +#else + QProxyStyle st("fusion"); +#endif + st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); #endif } else { // Do not display anything if the file is disabled (progress == -1) diff --git a/src/qinisettings.h b/src/qinisettings.h index 0f5dedde7..d5c5ccc66 100644 --- a/src/qinisettings.h +++ b/src/qinisettings.h @@ -39,7 +39,7 @@ class QIniSettings : public QSettings { public: QIniSettings(const QString &organization = "qBittorrent", const QString &application = "qBittorrent", QObject *parent = 0 ): -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application, parent) #else QSettings(organization, application, parent) @@ -52,7 +52,7 @@ public: } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QVariant value(const QString & key, const QVariant &defaultValue = QVariant()) const { QString key_tmp(key); QVariant ret = QSettings::value(key_tmp); diff --git a/src/qtlibtorrent/filterparserthread.h b/src/qtlibtorrent/filterparserthread.h index 3384a3384..9ef911a9f 100644 --- a/src/qtlibtorrent/filterparserthread.h +++ b/src/qtlibtorrent/filterparserthread.h @@ -44,7 +44,7 @@ using namespace std; // P2B Stuff #include -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #else #include diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp index 27e6c528c..bf0ee9065 100755 --- a/src/qtlibtorrent/qbtsession.cpp +++ b/src/qtlibtorrent/qbtsession.cpp @@ -91,7 +91,7 @@ const int MAX_TRACKER_ERRORS = 2; /* Converts a QString hash into a libtorrent sha1_hash */ static libtorrent::sha1_hash QStringToSha1(const QString& s) { - QByteArray raw = s.toAscii(); + QByteArray raw = s.toLatin1(); Q_ASSERT(raw.size() == 40); libtorrent::sha1_hash ret; from_hex(raw.constData(), 40, (char*)&ret[0]); @@ -1021,7 +1021,7 @@ QTorrentHandle QBtSession::addTorrent(QString path, bool fromScanDir, QString fr // Fix the input path if necessary path = fsutils::fromNativePath(path); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN // Windows hack if (!path.endsWith(".torrent")) if (QFile::rename(path, path+".torrent")) path += ".torrent"; @@ -1890,7 +1890,7 @@ void QBtSession::setListeningPort(int port) { qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size()); foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) { qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name)); - s->listen_on(ports, ec, entry.ip().toString().toAscii().constData(), session::listen_no_system_port); + s->listen_on(ports, ec, entry.ip().toString().toLatin1().constData(), session::listen_no_system_port); if (!ec) { ip = entry.ip().toString(); addConsoleMessage(tr("qBittorrent is trying to listen on interface %1 port: %2", "e.g: qBittorrent is trying to listen on interface 192.168.0.1 port: TCP/6881").arg(ip).arg(QString::number(port)), "blue"); @@ -2443,16 +2443,16 @@ void QBtSession::readAlerts() { boost::system::error_code ec; string ip = p->ip.to_string(ec); if (!ec) { - addPeerBanMessage(QString::fromAscii(ip.c_str()), true); - //emit peerBlocked(QString::fromAscii(ip.c_str())); + addPeerBanMessage(QString::fromLatin1(ip.c_str()), true); + //emit peerBlocked(QString::fromLatin1(ip.c_str())); } } else if (peer_ban_alert* p = dynamic_cast(a.get())) { boost::system::error_code ec; string ip = p->ip.address().to_string(ec); if (!ec) { - addPeerBanMessage(QString::fromAscii(ip.c_str()), false); - //emit peerBlocked(QString::fromAscii(ip.c_str())); + addPeerBanMessage(QString::fromLatin1(ip.c_str()), false); + //emit peerBlocked(QString::fromLatin1(ip.c_str())); } } else if (fastresume_rejected_alert* p = dynamic_cast(a.get())) { @@ -2670,7 +2670,7 @@ void QBtSession::processDownloadedFile(QString url, QString file_path) { if (index < 0) { // Add file to torrent download list file_path = fsutils::fromNativePath(file_path); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN // Windows hack if (!file_path.endsWith(".torrent", Qt::CaseInsensitive)) { Q_ASSERT(QFile::exists(file_path)); diff --git a/src/qtlibtorrent/qtorrenthandle.cpp b/src/qtlibtorrent/qtorrenthandle.cpp index 0c8951fd9..e6987a1f3 100644 --- a/src/qtlibtorrent/qtorrenthandle.cpp +++ b/src/qtlibtorrent/qtorrenthandle.cpp @@ -45,7 +45,7 @@ #include #include -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #endif @@ -641,7 +641,7 @@ void QTorrentHandle::prioritize_files(const vector &files) const { continue; } bool created = QDir().mkpath(unwanted_abspath); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN qDebug() << "unwanted folder was created:" << created; if (created) { // Hide the folder on Windows diff --git a/src/searchengine/engineselectdlg.cpp b/src/searchengine/engineselectdlg.cpp index 972991c15..e8736fac8 100644 --- a/src/searchengine/engineselectdlg.cpp +++ b/src/searchengine/engineselectdlg.cpp @@ -44,6 +44,7 @@ #include #include #include +#include enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID}; const QString UPDATE_URL = QString("https://raw.github.com/qbittorrent/qBittorrent/master/src/searchengine/") + (misc::pythonVersion() >= 3 ? "nova3" : "nova") + "/engines/"; @@ -76,7 +77,7 @@ engineSelectDlg::~engineSelectDlg() { void engineSelectDlg::dropEvent(QDropEvent *event) { event->acceptProposedAction(); - QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n")); + QStringList files = event->mimeData()->text().split(QString::fromUtf8("\n")); foreach (QString file, files) { qDebug("dropped %s", qPrintable(file)); if (misc::isUrl(file)) { diff --git a/src/searchengine/searchengine.cpp b/src/searchengine/searchengine.cpp index 5eaab2169..6f00ce47d 100644 --- a/src/searchengine/searchengine.cpp +++ b/src/searchengine/searchengine.cpp @@ -43,7 +43,7 @@ #include #include -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN #include #endif @@ -80,7 +80,7 @@ SearchEngine::SearchEngine(MainWindow* parent) // Boolean initialization search_stopped = false; // Creating Search Process -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN has_python = addPythonPathToEnv(); #endif searchProcess = new QProcess(this); @@ -95,7 +95,7 @@ SearchEngine::SearchEngine(MainWindow* parent) // Update nova.py search plugin if necessary updateNova(); supported_engines = new SupportedEngines( - #ifdef Q_WS_WIN + #ifdef Q_OS_WIN has_python #endif ); @@ -115,7 +115,7 @@ void SearchEngine::fillCatCombobox() { } } -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN bool SearchEngine::addPythonPathToEnv() { QString python_path = Preferences::getPythonPath(); if (!python_path.isEmpty()) { @@ -227,7 +227,7 @@ void SearchEngine::giveFocusToSearchInput() { // Function called when we click on search button void SearchEngine::on_search_button_clicked() { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN if (!has_python) { if (QMessageBox::question(this, tr("Missing Python Interpreter"), tr("Python 2.x is required to use the search engine but it does not seem to be installed.\nDo you want to install it now?"), @@ -239,7 +239,7 @@ void SearchEngine::on_search_button_clicked() { } #endif if (searchProcess->state() != QProcess::NotRunning) { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN searchProcess->kill(); #else searchProcess->terminate(); @@ -492,7 +492,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) { mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished")); } if (exitcode) { -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN search_status->setText(tr("Search aborted")); #else search_status->setText(tr("An error occurred during search...")); diff --git a/src/searchengine/searchengine.h b/src/searchengine/searchengine.h index c10c04338..668cf5db0 100644 --- a/src/searchengine/searchengine.h +++ b/src/searchengine/searchengine.h @@ -105,7 +105,7 @@ protected slots: void downloadFinished(int exitcode, QProcess::ExitStatus); void fillCatCombobox(); void searchTextEdited(QString); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN bool addPythonPathToEnv(); void installPython(); void pythonDownloadSuccess(QString url, QString file_path); @@ -130,7 +130,7 @@ private: QList > all_tab; // To store all tabs const SearchCategories full_cat_names; MainWindow *mp_mainWindow; -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN bool has_python; #endif }; diff --git a/src/sessionapplication.cpp b/src/sessionapplication.cpp index 9342fd88b..fb834cece 100644 --- a/src/sessionapplication.cpp +++ b/src/sessionapplication.cpp @@ -32,7 +32,7 @@ #include "sessionapplication.h" SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) : -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC QMacApplication(id, argc, argv) #else QtSingleApplication(id, argc, argv) diff --git a/src/sessionapplication.h b/src/sessionapplication.h index 1f6232ab3..3ad8d4e93 100644 --- a/src/sessionapplication.h +++ b/src/sessionapplication.h @@ -33,7 +33,7 @@ #include -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include "qmacapplication.h" #else #include "qtsingleapplication.h" @@ -42,7 +42,7 @@ #include class SessionApplication : -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC public QMacApplication #else public QtSingleApplication diff --git a/src/smtp.cpp b/src/smtp.cpp index ff38b5754..8dbaa499e 100644 --- a/src/smtp.cpp +++ b/src/smtp.cpp @@ -192,7 +192,7 @@ void Smtp::readyRead() case Authenticated: if (code[0] == '2') { qDebug() << "Sending ..."; - socket->write("mail from:<" + from.toAscii() + ">\r\n"); + socket->write("mail from:<" + from.toLatin1() + ">\r\n"); socket->flush(); state = Rcpt; } else { @@ -203,7 +203,7 @@ void Smtp::readyRead() break; case Rcpt: if (code[0] == '2') { - socket->write("rcpt to:<" + rcpt.toAscii() + ">\r\n"); + socket->write("rcpt to:<" + rcpt.toLatin1() + ">\r\n"); socket->flush(); state = Data; } else { @@ -253,11 +253,11 @@ void Smtp::readyRead() QByteArray Smtp::encode_mime_header(const QString& key, const QString& value, QTextCodec* latin1, const QByteArray& prefix) { QByteArray rv = ""; - QByteArray line = key.toAscii() + ": "; + QByteArray line = key.toLatin1() + ": "; if (!prefix.isEmpty()) line += prefix; if (!value.contains("=?") && latin1->canEncode(value)) { bool firstWord = true; - foreach (const QByteArray& word, value.toAscii().split(' ')) { + foreach (const QByteArray& word, value.toLatin1().split(' ')) { if (line.size() > 78) { rv = rv + line + "\r\n"; line.clear(); @@ -295,7 +295,7 @@ void Smtp::ehlo() { if (addr == QHostAddress::LocalHost || addr == QHostAddress::LocalHostIPv6) continue; - address = addr.toString().toAscii(); + address = addr.toString().toLatin1(); break; } // Send EHLO @@ -403,8 +403,8 @@ void Smtp::authCramMD5(const QByteArray& challenge) authType = AuthCramMD5; state = AuthRequestSent; } else { - QByteArray response = username.toAscii() + ' ' - + hmacMD5(password.toAscii(), QByteArray::fromBase64(challenge)).toHex(); + QByteArray response = username.toLatin1() + ' ' + + hmacMD5(password.toLatin1(), QByteArray::fromBase64(challenge)).toHex(); socket->write(response.toBase64() + "\r\n"); socket->flush(); state = AuthSent; @@ -418,11 +418,11 @@ void Smtp::authPlain() // Prepare Auth string QByteArray auth; auth += '\0'; - auth += username.toAscii(); - qDebug() << "username: " << username.toAscii(); + auth += username.toLatin1(); + qDebug() << "username: " << username.toLatin1(); auth += '\0'; - auth += password.toAscii(); - qDebug() << "password: " << password.toAscii(); + auth += password.toLatin1(); + qDebug() << "password: " << password.toLatin1(); // Send it socket->write("auth plain "+ auth.toBase64() + "\r\n"); socket->flush(); @@ -439,12 +439,12 @@ void Smtp::authLogin() state = AuthRequestSent; } else if (state == AuthRequestSent) { - socket->write(username.toAscii().toBase64() + "\r\n"); + socket->write(username.toLatin1().toBase64() + "\r\n"); socket->flush(); state = AuthUsernameSent; } else { - socket->write(password.toAscii().toBase64() + "\r\n"); + socket->write(password.toLatin1().toBase64() + "\r\n"); socket->flush(); state = AuthSent; } diff --git a/src/src.pro b/src/src.pro index e71a23f5c..d2df1f929 100644 --- a/src/src.pro +++ b/src/src.pro @@ -36,6 +36,8 @@ nox { } QT += network +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + # Vars LANG_PATH = lang ICONS_PATH = Icons @@ -176,6 +178,7 @@ nox { win32 { HEADERS += programupdater.h SOURCES += programupdater.cpp + DEFINES += NOMINMAX } macx { diff --git a/src/torrentcontentmodel.h b/src/torrentcontentmodel.h index 63b270ef9..04c1c1628 100644 --- a/src/torrentcontentmodel.h +++ b/src/torrentcontentmodel.h @@ -35,7 +35,9 @@ #include #include #include + #include + #include "torrentcontentmodelitem.h" class TorrentContentModelFile; diff --git a/src/torrentcontentmodelitem.h b/src/torrentcontentmodelitem.h index 8145430ac..df9399275 100644 --- a/src/torrentcontentmodelitem.h +++ b/src/torrentcontentmodelitem.h @@ -33,6 +33,7 @@ #include #include + #include namespace prio { diff --git a/src/torrentimportdlg.h b/src/torrentimportdlg.h index a7e6ea7d0..bbb513581 100644 --- a/src/torrentimportdlg.h +++ b/src/torrentimportdlg.h @@ -33,6 +33,7 @@ #include #include + #include #include diff --git a/src/tracker/qtracker.cpp b/src/tracker/qtracker.cpp index d7dd88a12..fd6349ee2 100644 --- a/src/tracker/qtracker.cpp +++ b/src/tracker/qtracker.cpp @@ -141,8 +141,8 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket, } annonce_req.info_hash = get_parameters.value("info_hash"); // info_hash cannot be longer than 20 bytes - /*if (annonce_req.info_hash.toAscii().length() > 20) { - qDebug("QTracker: Info_hash is not 20 byte long: %s (%d)", qPrintable(annonce_req.info_hash), annonce_req.info_hash.toAscii().length()); + /*if (annonce_req.info_hash.toLatin1().length() > 20) { + qDebug("QTracker: Info_hash is not 20 byte long: %s (%d)", qPrintable(annonce_req.info_hash), annonce_req.info_hash.toLatin1().length()); respondInvalidRequest(socket, 150, "Invalid infohash"); return; }*/ diff --git a/src/trackerlogin.h b/src/trackerlogin.h index 7572d7d09..4d017a399 100644 --- a/src/trackerlogin.h +++ b/src/trackerlogin.h @@ -33,7 +33,9 @@ #include #include + #include + #include "ui_login.h" #include "qtorrenthandle.h" diff --git a/src/transferlistdelegate.h b/src/transferlistdelegate.h index ca2ff2373..17e52b296 100644 --- a/src/transferlistdelegate.h +++ b/src/transferlistdelegate.h @@ -40,8 +40,12 @@ #include "torrentmodel.h" #include "qbtsession.h" -#ifdef Q_WS_WIN - #include +#ifdef Q_OS_WIN +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) +#include +#else +#include +#endif #endif // Defines for download list list columns @@ -181,11 +185,15 @@ public: newopt.minimum = 0; newopt.state |= QStyle::State_Enabled; newopt.textVisible = true; -#ifndef Q_WS_WIN +#ifndef Q_OS_WIN QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter); #else // XXX: To avoid having the progress text on the right of the bar - QPlastiqueStyle st; +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) + QPlastiqueStyle st; +#else + QProxyStyle st("fusion"); +#endif st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0); #endif break; diff --git a/src/transferlistfilterswidget.h b/src/transferlistfilterswidget.h index 74d17adef..9d1ab7dbc 100644 --- a/src/transferlistfilterswidget.h +++ b/src/transferlistfilterswidget.h @@ -65,7 +65,7 @@ public: setAcceptDrops(true); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); setStyleSheet("QListWidget { background: transparent; border: 0 }"); -#if defined(Q_WS_MAC) +#if defined(Q_OS_MAC) setAttribute(Qt::WA_MacShowFocusRect, false); #endif } @@ -165,7 +165,7 @@ public: // Height is fixed (sizeHint().height() is used) setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); setStyleSheet("QListWidget { background: transparent; border: 0 }"); -#if defined(Q_WS_MAC) +#if defined(Q_OS_MAC) setAttribute(Qt::WA_MacShowFocusRect, false); #endif } diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index 4283be0fa..44dcc81e4 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -108,7 +108,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window, setItemsExpandable(false); setAutoScroll(true); setDragDropMode(QAbstractItemView::DragOnly); -#if defined(Q_WS_MAC) +#if defined(Q_OS_MAC) setAttribute(Qt::WA_MacShowFocusRect, false); #endif diff --git a/src/updownratiodlg.h b/src/updownratiodlg.h index 2675dc99a..31721b707 100644 --- a/src/updownratiodlg.h +++ b/src/updownratiodlg.h @@ -31,7 +31,7 @@ #ifndef UPDOWNRATIODLG_H #define UPDOWNRATIODLG_H -#include +#include QT_BEGIN_NAMESPACE namespace Ui { diff --git a/src/webui/httpconnection.cpp b/src/webui/httpconnection.cpp index 93c4e23de..2e3d4d472 100644 --- a/src/webui/httpconnection.cpp +++ b/src/webui/httpconnection.cpp @@ -168,7 +168,11 @@ void HttpConnection::translateDocument(QString& data) { if (isTranslationNeeded) { int context_index = 0; while(context_index < context_count && translation == word) { +#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, QCoreApplication::UnicodeUTF8, 1); +#else + translation = qApp->translate(contexts[context_index].c_str(), word.constData(), 0, 1); +#endif ++context_index; } } diff --git a/src/webui/httprequestparser.cpp b/src/webui/httprequestparser.cpp index 17350dea1..3ccf7f602 100644 --- a/src/webui/httprequestparser.cpp +++ b/src/webui/httprequestparser.cpp @@ -141,10 +141,10 @@ Submit Query m_error = true; return; } else { - boundary = "--" + boundaryRegexNotQuoted.cap(1).toAscii(); + boundary = "--" + boundaryRegexNotQuoted.cap(1).toLatin1(); } } else { - boundary = "--" + boundaryRegexQuoted.cap(1).toAscii(); + boundary = "--" + boundaryRegexQuoted.cap(1).toLatin1(); } qDebug() << "Boundary is " << boundary; QList parts = splitRawData(m_data, boundary); diff --git a/src/webui/httpserver.cpp b/src/webui/httpserver.cpp index 36e6a5071..cb115c603 100644 --- a/src/webui/httpserver.cpp +++ b/src/webui/httpserver.cpp @@ -156,7 +156,11 @@ void HttpServer::disableHttps() { } #endif +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +void HttpServer::incomingConnection(qintptr socketDescriptor) +#else void HttpServer::incomingConnection(int socketDescriptor) +#endif { QTcpSocket *serverSocket; #ifndef QT_NO_OPENSSL diff --git a/src/webui/httpserver.h b/src/webui/httpserver.h index de83df6fd..d596d090f 100644 --- a/src/webui/httpserver.h +++ b/src/webui/httpserver.h @@ -75,7 +75,11 @@ public: #endif private: +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) + void incomingConnection(qintptr socketDescriptor); +#else void incomingConnection(int socketDescriptor); +#endif private slots: void UnbanTimerEvent(); diff --git a/src/webui/json.cpp b/src/webui/json.cpp index 8982912bf..94ac8d6dd 100644 --- a/src/webui/json.cpp +++ b/src/webui/json.cpp @@ -58,7 +58,7 @@ QString json::toJson(const QVariant& v) { QString result = "\""; for (int i=0; i