mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-29 16:04:21 +00:00
Fix functions and macros using to support both Qt4 and Qt5.
This commit is contained in:
parent
763d8a392f
commit
ce3aac5f9d
@ -51,7 +51,7 @@ class about : public QDialog, private Ui::AboutDlg{
|
||||
// About
|
||||
QString aboutText =
|
||||
QString::fromUtf8("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\"><html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">p, li { white-space: pre-wrap; }</style></head><body style=\" font-size:11pt; font-weight:400; font-style:normal;\"><p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">") +
|
||||
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(" <br /><br />") +
|
||||
trUtf8("Copyright ©2006-2013 The qBittorrent project") +
|
||||
QString::fromUtf8("<br /><br />") +
|
||||
|
@ -439,7 +439,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||
// Check for overwriting
|
||||
for (int i=0; i<m_torrentInfo->num_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)) {
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <QShortcut>
|
||||
#include <QDialog>
|
||||
#include <QUrl>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include "qtorrenthandle.h"
|
||||
|
||||
|
@ -31,6 +31,9 @@
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QDebug>
|
||||
#include <QRegExp>
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QUrlQuery>
|
||||
#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;
|
||||
}
|
||||
|
@ -8,11 +8,11 @@
|
||||
#include <QStringList>
|
||||
#include <QHash>
|
||||
|
||||
#ifndef Q_WS_WIN
|
||||
#ifndef Q_OS_WIN
|
||||
#include <QSet>
|
||||
#include <iostream>
|
||||
#include <errno.h>
|
||||
#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
|
||||
#include <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#include <string.h>
|
||||
@ -47,7 +47,7 @@ class FileSystemWatcher: public QFileSystemWatcher {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
#ifndef Q_WS_WIN
|
||||
#ifndef Q_OS_WIN
|
||||
QList<QDir> watched_folders;
|
||||
QPointer<QTimer> watch_timer;
|
||||
#endif
|
||||
@ -56,7 +56,7 @@ private:
|
||||
QHash<QString, int> m_partialTorrents;
|
||||
QPointer<QTimer> 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
|
||||
|
@ -43,13 +43,13 @@
|
||||
#endif
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#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 <sys/param.h>
|
||||
#include <sys/mount.h>
|
||||
#else
|
||||
@ -60,8 +60,12 @@
|
||||
#include <winbase.h>
|
||||
#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 <QDesktopServices>
|
||||
#else
|
||||
#include <QStandardPaths>
|
||||
#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
|
||||
|
||||
|
11
src/ico.cpp
11
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
|
||||
|
@ -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)) {
|
||||
|
@ -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);
|
||||
|
||||
|
10
src/main.cpp
10
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 <signal.h>
|
||||
#include <execinfo.h>
|
||||
#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<QMacApplication*>(&app)->setReadyToProcessEvents();
|
||||
#endif // Q_WS_MAC
|
||||
#endif // Q_OS_MAC
|
||||
#else
|
||||
// Load Headless class
|
||||
HeadlessLoader loader(torrents);
|
||||
|
@ -29,7 +29,7 @@
|
||||
*/
|
||||
|
||||
#include <QtGlobal>
|
||||
#if defined(Q_WS_X11) && defined(QT_DBUS_LIB)
|
||||
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) && defined(QT_DBUS_LIB)
|
||||
#include <QDBusConnection>
|
||||
#include "notifications.h"
|
||||
#endif
|
||||
@ -44,6 +44,7 @@
|
||||
#include <QCloseEvent>
|
||||
#include <QShortcut>
|
||||
#include <QScrollBar>
|
||||
#include <QMimeData>
|
||||
|
||||
#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<QMacApplication*>(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 = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
||||
html += "qBittorrent";
|
||||
html += "</div>";
|
||||
@ -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);
|
||||
|
@ -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
|
||||
};
|
||||
|
16
src/misc.cpp
16
src/misc.cpp
@ -49,7 +49,7 @@
|
||||
#include <QDesktopWidget>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <windows.h>
|
||||
#include <PowrProf.h>
|
||||
const int UNLEN = 256;
|
||||
@ -58,13 +58,13 @@ const int UNLEN = 256;
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#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 <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#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))
|
||||
|
@ -30,22 +30,22 @@
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#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 <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#endif
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Windows.h>
|
||||
#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
|
||||
}
|
||||
|
@ -33,12 +33,12 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
// Require Mac OS X >= 10.5
|
||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||
#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
|
||||
};
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -40,8 +40,12 @@
|
||||
#include "misc.h"
|
||||
#include "previewselect.h"
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#include <QPlastiqueStyle>
|
||||
#ifdef Q_OS_WIN
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QPlastiqueStyle>
|
||||
#else
|
||||
#include <QProxyStyle>
|
||||
#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:
|
||||
|
@ -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
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QHostAddress>
|
||||
#include "ui_peer.h"
|
||||
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
@ -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"));
|
||||
|
@ -561,7 +561,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
// Check if that name is already used
|
||||
for (int i=0; i<h.num_files(); ++i) {
|
||||
if (i == file_index) continue;
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
|
||||
#if defined(Q_OS_UNIX) || defined(Q_WS_QWS)
|
||||
if (h.filepath_at(i).compare(new_name, Qt::CaseSensitive) == 0) {
|
||||
#else
|
||||
if (h.filepath_at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
|
||||
@ -600,7 +600,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||
const int num_files = h.num_files();
|
||||
for (int i=0; i<num_files; ++i) {
|
||||
const QString current_name = h.filepath_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)) {
|
||||
|
@ -43,8 +43,12 @@
|
||||
#include "misc.h"
|
||||
#include "propertieswidget.h"
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QPlastiqueStyle>
|
||||
#else
|
||||
#include <QProxyStyle>
|
||||
#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)
|
||||
|
@ -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);
|
||||
|
@ -44,7 +44,7 @@ using namespace std;
|
||||
|
||||
// P2B Stuff
|
||||
#include <string.h>
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Winsock2.h>
|
||||
#else
|
||||
#include <arpa/inet.h>
|
||||
|
@ -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<peer_ban_alert*>(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<fastresume_rejected_alert*>(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));
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include <libtorrent/bencode.hpp>
|
||||
#include <libtorrent/entry.hpp>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
@ -641,7 +641,7 @@ void QTorrentHandle::prioritize_files(const vector<int> &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
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QDropEvent>
|
||||
#include <QTemporaryFile>
|
||||
#include <QMimeData>
|
||||
|
||||
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)) {
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopServices>
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#ifdef Q_OS_WIN
|
||||
#include <stdlib.h>
|
||||
#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..."));
|
||||
|
@ -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<QPointer<SearchTab> > 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
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#include <QtCore/QtGlobal>
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
#include "qmacapplication.h"
|
||||
#else
|
||||
#include "qtsingleapplication.h"
|
||||
@ -42,7 +42,7 @@
|
||||
#include <QSessionManager>
|
||||
|
||||
class SessionApplication :
|
||||
#ifdef Q_WS_MAC
|
||||
#ifdef Q_OS_MAC
|
||||
public QMacApplication
|
||||
#else
|
||||
public QtSingleApplication
|
||||
|
26
src/smtp.cpp
26
src/smtp.cpp
@ -192,7 +192,7 @@ void Smtp::readyRead()
|
||||
case Authenticated:
|
||||
if (code[0] == '2') {
|
||||
qDebug() << "Sending <mail from>...";
|
||||
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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -35,7 +35,9 @@
|
||||
#include <QModelIndex>
|
||||
#include <QVector>
|
||||
#include <QVariant>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
#include "torrentcontentmodelitem.h"
|
||||
|
||||
class TorrentContentModelFile;
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <QList>
|
||||
#include <QVariant>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
|
||||
namespace prio {
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStringList>
|
||||
|
||||
#include <libtorrent/torrent_info.hpp>
|
||||
#include <libtorrent/version.hpp>
|
||||
|
||||
|
@ -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;
|
||||
}*/
|
||||
|
@ -33,7 +33,9 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <libtorrent/session.hpp>
|
||||
|
||||
#include "ui_login.h"
|
||||
#include "qtorrenthandle.h"
|
||||
|
||||
|
@ -40,8 +40,12 @@
|
||||
#include "torrentmodel.h"
|
||||
#include "qbtsession.h"
|
||||
|
||||
#ifdef Q_WS_WIN
|
||||
#include <QPlastiqueStyle>
|
||||
#ifdef Q_OS_WIN
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
#include <QPlastiqueStyle>
|
||||
#else
|
||||
#include <QProxyStyle>
|
||||
#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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#ifndef UPDOWNRATIODLG_H
|
||||
#define UPDOWNRATIODLG_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<QByteArray> parts = splitRawData(m_data, boundary);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -58,7 +58,7 @@ QString json::toJson(const QVariant& v) {
|
||||
QString result = "\"";
|
||||
for (int i=0; i<s.size(); ++i) {
|
||||
const QChar ch = s[i];
|
||||
switch(ch.toAscii())
|
||||
switch(ch.toLatin1())
|
||||
{
|
||||
case '\b':
|
||||
result += "\\b";
|
||||
|
@ -130,8 +130,8 @@ QString prefjson::getPreferences()
|
||||
data.add("web_ui_password", pref.getWebUiPassword());
|
||||
data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
|
||||
data.add("use_https", pref.isWebUiHttpsEnabled());
|
||||
data.add("ssl_key", QString::fromAscii(pref.getWebUiHttpsKey()));
|
||||
data.add("ssl_cert", QString::fromAscii(pref.getWebUiHttpsCertificate()));
|
||||
data.add("ssl_key", QString::fromLatin1(pref.getWebUiHttpsKey()));
|
||||
data.add("ssl_cert", QString::fromLatin1(pref.getWebUiHttpsCertificate()));
|
||||
// DynDns
|
||||
data.add("dyndns_enabled", pref.isDynDNSEnabled());
|
||||
data.add("dyndns_service", pref.getDynDNSService());
|
||||
@ -317,12 +317,12 @@ void prefjson::setPreferences(const QString& json)
|
||||
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
|
||||
#ifndef QT_NO_OPENSSL
|
||||
if (m.contains("ssl_key")) {
|
||||
QByteArray raw_key = m["ssl_key"].toString().toAscii();
|
||||
QByteArray raw_key = m["ssl_key"].toString().toLatin1();
|
||||
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
||||
pref.setWebUiHttpsKey(raw_key);
|
||||
}
|
||||
if (m.contains("ssl_cert")) {
|
||||
QByteArray raw_cert = m["ssl_cert"].toString().toAscii();
|
||||
QByteArray raw_cert = m["ssl_cert"].toString().toLatin1();
|
||||
if (!QSslCertificate(raw_cert).isNull())
|
||||
pref.setWebUiHttpsCertificate(raw_cert);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user