mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-30 11:38:50 -07:00
Fix functions and macros using to support both Qt4 and Qt5.
This commit is contained in:
parent
763d8a392f
commit
ce3aac5f9d
51 changed files with 260 additions and 181 deletions
|
@ -51,7 +51,7 @@ class about : public QDialog, private Ui::AboutDlg{
|
||||||
// About
|
// About
|
||||||
QString aboutText =
|
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;\">") +
|
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 />") +
|
QString::fromUtf8(" <br /><br />") +
|
||||||
trUtf8("Copyright ©2006-2013 The qBittorrent project") +
|
trUtf8("Copyright ©2006-2013 The qBittorrent project") +
|
||||||
QString::fromUtf8("<br /><br />") +
|
QString::fromUtf8("<br /><br />") +
|
||||||
|
|
|
@ -439,7 +439,7 @@ void AddNewTorrentDialog::renameSelectedFile()
|
||||||
// Check for overwriting
|
// Check for overwriting
|
||||||
for (int i=0; i<m_torrentInfo->num_files(); ++i) {
|
for (int i=0; i<m_torrentInfo->num_files(); ++i) {
|
||||||
const QString ¤t_name = m_filesPath.at(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)) {
|
if (current_name.startsWith(new_path, Qt::CaseSensitive)) {
|
||||||
#else
|
#else
|
||||||
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
#include <QUrlQuery>
|
||||||
|
#endif
|
||||||
#include "dnsupdater.h"
|
#include "dnsupdater.h"
|
||||||
#include "qbtsession.h"
|
#include "qbtsession.h"
|
||||||
|
|
||||||
|
@ -148,9 +151,18 @@ QUrl DNSUpdater::getUpdateUrl() const
|
||||||
Q_ASSERT(0);
|
Q_ASSERT(0);
|
||||||
}
|
}
|
||||||
url.setPath("/nic/update");
|
url.setPath("/nic/update");
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
url.addQueryItem("hostname", m_domain);
|
url.addQueryItem("hostname", m_domain);
|
||||||
url.addQueryItem("myip", m_lastIP.toString());
|
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());
|
Q_ASSERT(url.isValid());
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << url.toString();
|
qDebug() << Q_FUNC_INFO << url.toString();
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <errno.h>
|
#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/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -47,7 +47,7 @@ class FileSystemWatcher: public QFileSystemWatcher {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QList<QDir> watched_folders;
|
QList<QDir> watched_folders;
|
||||||
QPointer<QTimer> watch_timer;
|
QPointer<QTimer> watch_timer;
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,7 +56,7 @@ private:
|
||||||
QHash<QString, int> m_partialTorrents;
|
QHash<QString, int> m_partialTorrents;
|
||||||
QPointer<QTimer> m_partialTorrentTimer;
|
QPointer<QTimer> m_partialTorrentTimer;
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
private:
|
private:
|
||||||
static bool isNetworkFileSystem(QString path) {
|
static bool isNetworkFileSystem(QString path) {
|
||||||
QString file = path;
|
QString file = path;
|
||||||
|
@ -65,7 +65,7 @@ private:
|
||||||
file += ".";
|
file += ".";
|
||||||
struct statfs buf;
|
struct statfs buf;
|
||||||
if (!statfs(file.toLocal8Bit().constData(), &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?
|
// 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);
|
return (strcmp(buf.f_fstypename, "nfs") == 0 || strcmp(buf.f_fstypename, "cifs") == 0 || strcmp(buf.f_fstypename, "smbfs") == 0);
|
||||||
#else
|
#else
|
||||||
|
@ -124,7 +124,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~FileSystemWatcher() {
|
~FileSystemWatcher() {
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (watch_timer)
|
if (watch_timer)
|
||||||
delete watch_timer;
|
delete watch_timer;
|
||||||
#endif
|
#endif
|
||||||
|
@ -134,7 +134,7 @@ public:
|
||||||
|
|
||||||
QStringList directories() const {
|
QStringList directories() const {
|
||||||
QStringList dirs;
|
QStringList dirs;
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
if (watch_timer) {
|
if (watch_timer) {
|
||||||
foreach (const QDir &dir, watched_folders)
|
foreach (const QDir &dir, watched_folders)
|
||||||
dirs << dir.canonicalPath();
|
dirs << dir.canonicalPath();
|
||||||
|
@ -145,7 +145,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPath(const QString & path) {
|
void addPath(const QString & path) {
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
return;
|
return;
|
||||||
|
@ -167,13 +167,13 @@ public:
|
||||||
qDebug("FS Watching is watching %s in normal mode", qPrintable(path));
|
qDebug("FS Watching is watching %s in normal mode", qPrintable(path));
|
||||||
QFileSystemWatcher::addPath(path);
|
QFileSystemWatcher::addPath(path);
|
||||||
scanLocalFolder(path);
|
scanLocalFolder(path);
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void removePath(const QString & path) {
|
void removePath(const QString & path) {
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QDir dir(path);
|
QDir dir(path);
|
||||||
for (int i = 0; i < watched_folders.count(); ++i) {
|
for (int i = 0; i < watched_folders.count(); ++i) {
|
||||||
if (QDir(watched_folders.at(i)) == dir) {
|
if (QDir(watched_folders.at(i)) == dir) {
|
||||||
|
@ -202,7 +202,7 @@ protected slots:
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanNetworkFolders() {
|
void scanNetworkFolders() {
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
qDebug("scanNetworkFolders() called");
|
qDebug("scanNetworkFolders() called");
|
||||||
QStringList torrents;
|
QStringList torrents;
|
||||||
// Network folders scan
|
// Network folders scan
|
||||||
|
|
|
@ -43,13 +43,13 @@
|
||||||
#endif
|
#endif
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
#if defined(Q_WS_MAC) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#else
|
#else
|
||||||
|
@ -60,8 +60,12 @@
|
||||||
#include <winbase.h>
|
#include <winbase.h>
|
||||||
#endif
|
#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>
|
#include <QDesktopServices>
|
||||||
|
#else
|
||||||
|
#include <QStandardPaths>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
@ -125,9 +129,9 @@ bool fsutils::smartRemoveEmptyFolderTree(const QString& dir_path)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Remove Files created by the OS
|
// Remove Files created by the OS
|
||||||
#if defined Q_WS_MAC
|
#if defined Q_OS_MAC
|
||||||
fsutils::forceRemove(dir_path + QLatin1String("/.DS_Store"));
|
fsutils::forceRemove(dir_path + QLatin1String("/.DS_Store"));
|
||||||
#elif defined Q_WS_WIN
|
#elif defined Q_OS_WIN
|
||||||
fsutils::forceRemove(dir_path + QLatin1String("/Thumbs.db"));
|
fsutils::forceRemove(dir_path + QLatin1String("/Thumbs.db"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -283,7 +287,7 @@ long long fsutils::freeDiskSpaceOnPath(QString path) {
|
||||||
}
|
}
|
||||||
Q_ASSERT(dir_path.exists());
|
Q_ASSERT(dir_path.exists());
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
unsigned long long available;
|
unsigned long long available;
|
||||||
struct statfs stats;
|
struct statfs stats;
|
||||||
const QString statfs_path = dir_path.path()+"/.";
|
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)
|
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;
|
return QString::compare(first, second, Qt::CaseSensitive) == 0;
|
||||||
#else
|
#else
|
||||||
return QString::compare(first, second, Qt::CaseInsensitive) == 0;
|
return QString::compare(first, second, Qt::CaseInsensitive) == 0;
|
||||||
|
@ -364,14 +368,14 @@ QString fsutils::expandPathAbs(const QString& path) {
|
||||||
|
|
||||||
QString fsutils::QDesktopServicesDataLocation() {
|
QString fsutils::QDesktopServicesDataLocation() {
|
||||||
QString result;
|
QString result;
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
LPWSTR path=new WCHAR[256];
|
LPWSTR path=new WCHAR[256];
|
||||||
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE))
|
||||||
result = fsutils::fromNativePath(QString::fromWCharArray(path));
|
result = fsutils::fromNativePath(QString::fromWCharArray(path));
|
||||||
if (!QCoreApplication::applicationName().isEmpty())
|
if (!QCoreApplication::applicationName().isEmpty())
|
||||||
result += QLatin1String("/") + qApp->applicationName();
|
result += QLatin1String("/") + qApp->applicationName();
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
FSRef ref;
|
FSRef ref;
|
||||||
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
|
OSErr err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, false, &ref);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -397,10 +401,10 @@ QString fsutils::QDesktopServicesDataLocation() {
|
||||||
|
|
||||||
QString fsutils::QDesktopServicesCacheLocation() {
|
QString fsutils::QDesktopServicesCacheLocation() {
|
||||||
QString result;
|
QString result;
|
||||||
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
|
||||||
result = QDesktopServicesDataLocation() + QLatin1String("cache");
|
result = QDesktopServicesDataLocation() + QLatin1String("cache");
|
||||||
#else
|
#else
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
// http://developer.apple.com/documentation/Carbon/Reference/Folder_Manager/Reference/reference.html
|
||||||
FSRef ref;
|
FSRef ref;
|
||||||
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
|
OSErr err = FSFindFolder(kUserDomain, kCachedDataFolderType, false, &ref);
|
||||||
|
@ -424,16 +428,21 @@ QString fsutils::QDesktopServicesCacheLocation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fsutils::QDesktopServicesDownloadLocation() {
|
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
|
// as long as it stays WinXP like we do the same on OS/2
|
||||||
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
// TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads
|
||||||
// instead of hardcoding "Downloads"
|
// instead of hardcoding "Downloads"
|
||||||
// Unfortunately, this would break compatibility with WinXP
|
// Unfortunately, this would break compatibility with WinXP
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath(
|
||||||
QCoreApplication::translate("fsutils", "Downloads"));
|
QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
|
#else
|
||||||
|
return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath(
|
||||||
|
QCoreApplication::translate("fsutils", "Downloads"));
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
QString save_path;
|
QString save_path;
|
||||||
// Default save path on Linux
|
// Default save path on Linux
|
||||||
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
QString config_path = QString::fromLocal8Bit(qgetenv("XDG_CONFIG_HOME").constData());
|
||||||
|
@ -468,7 +477,7 @@ QString fsutils::QDesktopServicesDownloadLocation() {
|
||||||
return save_path;
|
return save_path;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// TODO: How to support this on Mac OS X?
|
// TODO: How to support this on Mac OS X?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
11
src/ico.cpp
11
src/ico.cpp
|
@ -309,11 +309,11 @@ bool ICOHandler::read(QImage *outImage)
|
||||||
QImage icon;
|
QImage icon;
|
||||||
if ( loadFromDIB( stream, *selected, 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 )
|
if ( header.type == IcoHeader::Cursor )
|
||||||
{
|
{
|
||||||
icon.setText( "X-HotspotX", 0, QString::number( selected->hotspotX ) );
|
icon.setText( "X-HotspotX", QString::number( selected->hotspotX ) );
|
||||||
icon.setText( "X-HotspotY", 0, QString::number( selected->hotspotY ) );
|
icon.setText( "X-HotspotY", QString::number( selected->hotspotY ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
*outImage = icon;
|
*outImage = icon;
|
||||||
|
@ -424,6 +424,9 @@ bool ICOHandler::canRead(QIODevice *device)
|
||||||
|
|
||||||
class ICOPlugin : public QImageIOPlugin
|
class ICOPlugin : public QImageIOPlugin
|
||||||
{
|
{
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
Q_PLUGIN_METADATA(IID "org.qbittorrent.ICOPlugin")
|
||||||
|
#endif
|
||||||
public:
|
public:
|
||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
|
Capabilities capabilities(QIODevice *device, const QByteArray &format) const;
|
||||||
|
@ -458,5 +461,7 @@ QImageIOHandler *ICOPlugin::create(QIODevice *device, const QByteArray &format)
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
|
Q_EXPORT_STATIC_PLUGIN(ICOPlugin)
|
||||||
Q_EXPORT_PLUGIN2(ico, ICOPlugin)
|
Q_EXPORT_PLUGIN2(ico, ICOPlugin)
|
||||||
|
#endif
|
||||||
|
|
|
@ -35,7 +35,7 @@ IconProvider* IconProvider::m_instance = 0;
|
||||||
|
|
||||||
IconProvider::IconProvider()
|
IconProvider::IconProvider()
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
m_useSystemTheme = Preferences().useSystemIconTheme();
|
m_useSystemTheme = Preferences().useSystemIconTheme();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ void IconProvider::drop()
|
||||||
|
|
||||||
QIcon IconProvider::getIcon(const QString &iconId)
|
QIcon IconProvider::getIcon(const QString &iconId)
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (m_useSystemTheme) {
|
if (m_useSystemTheme) {
|
||||||
QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png"));
|
QIcon icon = QIcon::fromTheme(iconId, QIcon(":/Icons/oxygen/"+iconId+".png"));
|
||||||
icon = generateDifferentSizes(icon);
|
icon = generateDifferentSizes(icon);
|
||||||
|
@ -67,7 +67,7 @@ QIcon IconProvider::getIcon(const QString &iconId)
|
||||||
return QIcon(":/Icons/oxygen/"+iconId+".png");
|
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)
|
void IconProvider::useSystemIconTheme(bool enable)
|
||||||
{
|
{
|
||||||
m_useSystemTheme = enable;
|
m_useSystemTheme = enable;
|
||||||
|
@ -102,7 +102,7 @@ QIcon IconProvider::generateDifferentSizes(const QIcon& icon)
|
||||||
|
|
||||||
QString IconProvider::getIconPath(const QString& iconId)
|
QString IconProvider::getIconPath(const QString& iconId)
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (m_useSystemTheme) {
|
if (m_useSystemTheme) {
|
||||||
QString path = QDir::temp().absoluteFilePath(iconId+".png");
|
QString path = QDir::temp().absoluteFilePath(iconId+".png");
|
||||||
if (!QFile::exists(path)) {
|
if (!QFile::exists(path)) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
QIcon getIcon(const QString& iconId);
|
QIcon getIcon(const QString& iconId);
|
||||||
QString getIconPath(const QString& iconId);
|
QString getIconPath(const QString& iconId);
|
||||||
|
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
public:
|
public:
|
||||||
void useSystemIconTheme(bool enable);
|
void useSystemIconTheme(bool enable);
|
||||||
|
|
||||||
|
|
10
src/main.cpp
10
src/main.cpp
|
@ -59,7 +59,7 @@ Q_IMPORT_PLUGIN(qico)
|
||||||
|
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "qinisettings.h"
|
#include "qinisettings.h"
|
||||||
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
#if defined(Q_OS_UNIX)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include "stacktrace.h"
|
#include "stacktrace.h"
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
|
|
||||||
#include "main.moc"
|
#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) {
|
void sigintHandler(int) {
|
||||||
signal(SIGINT, 0);
|
signal(SIGINT, 0);
|
||||||
qDebug("Catching SIGINT, exiting cleanly");
|
qDebug("Catching SIGINT, exiting cleanly");
|
||||||
|
@ -353,7 +353,7 @@ int main(int argc, char *argv[]) {
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
app.setQuitOnLastWindowClosed(false);
|
app.setQuitOnLastWindowClosed(false);
|
||||||
#endif
|
#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(SIGABRT, sigabrtHandler);
|
||||||
signal(SIGTERM, sigtermHandler);
|
signal(SIGTERM, sigtermHandler);
|
||||||
signal(SIGINT, sigintHandler);
|
signal(SIGINT, sigintHandler);
|
||||||
|
@ -374,9 +374,9 @@ int main(int argc, char *argv[]) {
|
||||||
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
|
QObject::connect(&app, SIGNAL(messageReceived(const QString&)),
|
||||||
&window, SLOT(processParams(const QString&)));
|
&window, SLOT(processParams(const QString&)));
|
||||||
app.setActivationWindow(&window);
|
app.setActivationWindow(&window);
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
static_cast<QMacApplication*>(&app)->setReadyToProcessEvents();
|
static_cast<QMacApplication*>(&app)->setReadyToProcessEvents();
|
||||||
#endif // Q_WS_MAC
|
#endif // Q_OS_MAC
|
||||||
#else
|
#else
|
||||||
// Load Headless class
|
// Load Headless class
|
||||||
HeadlessLoader loader(torrents);
|
HeadlessLoader loader(torrents);
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGlobal>
|
#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 <QDBusConnection>
|
||||||
#include "notifications.h"
|
#include "notifications.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -44,6 +44,7 @@
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "transferlistwidget.h"
|
#include "transferlistwidget.h"
|
||||||
|
@ -75,13 +76,13 @@
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
#include "autoexpandabledialog.h"
|
#include "autoexpandabledialog.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include "qmacapplication.h"
|
#include "qmacapplication.h"
|
||||||
void qt_mac_set_dock_menu(QMenu *menu);
|
void qt_mac_set_dock_menu(QMenu *menu);
|
||||||
#endif
|
#endif
|
||||||
#include "lineedit.h"
|
#include "lineedit.h"
|
||||||
#include "sessionapplication.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"
|
#include "programupdater.h"
|
||||||
#endif
|
#endif
|
||||||
#include "powermanagement.h"
|
#include "powermanagement.h"
|
||||||
|
@ -108,7 +109,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
|
||||||
// Clean exit on log out
|
// Clean exit on log out
|
||||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(shutdownCleanUp()), Qt::DirectConnection);
|
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(shutdownCleanUp()), Qt::DirectConnection);
|
||||||
// Setting icons
|
// Setting icons
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (Preferences().useSystemIconTheme())
|
if (Preferences().useSystemIconTheme())
|
||||||
setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))));
|
setWindowIcon(QIcon::fromTheme("qbittorrent", QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png"))));
|
||||||
else
|
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(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
|
||||||
connect(QBtSession::instance(), SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
connect(QBtSession::instance(), SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
||||||
connect(QBtSession::instance(), SIGNAL(recursiveTorrentDownloadPossible(QTorrentHandle)), this, SLOT(askRecursiveTorrentDownloadConfirmation(QTorrentHandle)));
|
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)));
|
connect(static_cast<QMacApplication*>(qApp), SIGNAL(newFileOpenMacEvent(QString)), this, SLOT(processParams(QString)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -211,7 +212,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
|
||||||
connect(actionToggleVisibility, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
|
connect(actionToggleVisibility, SIGNAL(triggered()), this, SLOT(toggleVisibility()));
|
||||||
connect(actionMinimize, SIGNAL(triggered()), SLOT(minimizeWindow()));
|
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.setInterval(60*60*1000);
|
||||||
programUpdateTimer.setSingleShot(true);
|
programUpdateTimer.setSingleShot(true);
|
||||||
connect(&programUpdateTimer, SIGNAL(timeout()), SLOT(checkProgramUpdate()));
|
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(status_bar->connectionStatusButton(), SIGNAL(clicked()), SLOT(showConnectionSettings()));
|
||||||
connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds()));
|
connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds()));
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
setUnifiedTitleAndToolBarOnMac(true);
|
setUnifiedTitleAndToolBarOnMac(true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -260,7 +261,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
|
||||||
autoShutdownGroup->addAction(actionAutoExit_qBittorrent);
|
autoShutdownGroup->addAction(actionAutoExit_qBittorrent);
|
||||||
autoShutdownGroup->addAction(actionAutoShutdown_system);
|
autoShutdownGroup->addAction(actionAutoShutdown_system);
|
||||||
autoShutdownGroup->addAction(actionAutoSuspend_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());
|
actionAutoShutdown_system->setChecked(pref.shutdownWhenDownloadsComplete());
|
||||||
actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete());
|
actionAutoSuspend_system->setChecked(pref.suspendWhenDownloadsComplete());
|
||||||
#else
|
#else
|
||||||
|
@ -304,7 +305,7 @@ MainWindow::MainWindow(QWidget *parent, const QStringList& torrentCmdLine) : QMa
|
||||||
connect(transferList->getSourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(updateNbTorrents()));
|
connect(transferList->getSourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(updateNbTorrents()));
|
||||||
|
|
||||||
qDebug("GUI Built");
|
qDebug("GUI Built");
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (!pref.neverCheckFileAssoc() && (!Preferences::isTorrentFileAssocSet() || !Preferences::isMagnetLinkAssocSet())) {
|
if (!pref.neverCheckFileAssoc() && (!Preferences::isTorrentFileAssocSet() || !Preferences::isMagnetLinkAssocSet())) {
|
||||||
if (QMessageBox::question(0, tr("Torrent file association"),
|
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?"),
|
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
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
qt_mac_set_dock_menu(getTrayIconMenu());
|
qt_mac_set_dock_menu(getTrayIconMenu());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -341,7 +342,7 @@ void MainWindow::shutdownCleanUp() {
|
||||||
QBtSession::drop();
|
QBtSession::drop();
|
||||||
// Save window size, columns size
|
// Save window size, columns size
|
||||||
writeSettings();
|
writeSettings();
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// Workaround to avoid bug http://bugreports.qt.nokia.com/browse/QTBUG-7305
|
// Workaround to avoid bug http://bugreports.qt.nokia.com/browse/QTBUG-7305
|
||||||
setUnifiedTitleAndToolBarOnMac(false);
|
setUnifiedTitleAndToolBarOnMac(false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -567,7 +568,7 @@ void MainWindow::createKeyboardShortcuts() {
|
||||||
actionPause_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+P")));
|
actionPause_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+P")));
|
||||||
actionDecreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+-")));
|
actionDecreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+-")));
|
||||||
actionIncreasePriority->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")));
|
actionMinimize->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+M")));
|
||||||
addAction(actionMinimize);
|
addAction(actionMinimize);
|
||||||
#endif
|
#endif
|
||||||
|
@ -840,7 +841,7 @@ bool MainWindow::event(QEvent * e) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
case QEvent::ToolBarChange: {
|
case QEvent::ToolBarChange: {
|
||||||
qDebug("MAC: Received a toolbar change event!");
|
qDebug("MAC: Received a toolbar change event!");
|
||||||
bool ret = QMainWindow::event(e);
|
bool ret = QMainWindow::event(e);
|
||||||
|
@ -1094,14 +1095,14 @@ void MainWindow::loadPreferences(bool configure_session) {
|
||||||
properties->reloadPreferences();
|
properties->reloadPreferences();
|
||||||
|
|
||||||
// Icon provider
|
// Icon provider
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
IconProvider::instance()->useSystemIconTheme(pref.useSystemIconTheme());
|
IconProvider::instance()->useSystemIconTheme(pref.useSystemIconTheme());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (configure_session)
|
if (configure_session)
|
||||||
QBtSession::instance()->configureSession();
|
QBtSession::instance()->configureSession();
|
||||||
|
|
||||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||||
if (pref.isUpdateCheckEnabled())
|
if (pref.isUpdateCheckEnabled())
|
||||||
checkProgramUpdate();
|
checkProgramUpdate();
|
||||||
else
|
else
|
||||||
|
@ -1130,7 +1131,7 @@ void MainWindow::trackerAuthenticationRequired(const QTorrentHandle& h) {
|
||||||
void MainWindow::updateGUI() {
|
void MainWindow::updateGUI() {
|
||||||
// update global informations
|
// update global informations
|
||||||
if (systrayIcon) {
|
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;'>";
|
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
||||||
html += "qBittorrent";
|
html += "qBittorrent";
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
|
@ -1155,7 +1156,7 @@ void MainWindow::updateGUI() {
|
||||||
|
|
||||||
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
||||||
if (!Preferences().useProgramNotification()) return;
|
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 notifications("org.freedesktop.Notifications",
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
QDBusConnection::sessionBus());
|
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)
|
void MainWindow::handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser)
|
||||||
{
|
{
|
||||||
|
@ -1427,7 +1428,7 @@ void MainWindow::checkForActiveTorrents()
|
||||||
|
|
||||||
QIcon MainWindow::getSystrayIcon() const
|
QIcon MainWindow::getSystrayIcon() const
|
||||||
{
|
{
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
TrayIcon::Style style = Preferences().trayIconStyle();
|
TrayIcon::Style style = Preferences().trayIconStyle();
|
||||||
switch(style) {
|
switch(style) {
|
||||||
case TrayIcon::MONO_DARK:
|
case TrayIcon::MONO_DARK:
|
||||||
|
@ -1439,7 +1440,7 @@ QIcon MainWindow::getSystrayIcon() const
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
if (Preferences().useSystemIconTheme()) {
|
if (Preferences().useSystemIconTheme()) {
|
||||||
icon = QIcon::fromTheme("qbittorrent");
|
icon = QIcon::fromTheme("qbittorrent");
|
||||||
}
|
}
|
||||||
|
@ -1452,7 +1453,7 @@ QIcon MainWindow::getSystrayIcon() const
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||||
void MainWindow::checkProgramUpdate() {
|
void MainWindow::checkProgramUpdate() {
|
||||||
programUpdateTimer.stop(); // If the user had clicked the menu item
|
programUpdateTimer.stop(); // If the user had clicked the menu item
|
||||||
actionCheck_for_updates->setEnabled(false);
|
actionCheck_for_updates->setEnabled(false);
|
||||||
|
|
|
@ -139,7 +139,7 @@ protected slots:
|
||||||
void optionsSaved();
|
void optionsSaved();
|
||||||
// HTTP slots
|
// HTTP slots
|
||||||
void on_actionDownload_from_URL_triggered();
|
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);
|
void handleUpdateCheckFinished(bool update_available, QString new_version, bool invokedByUser);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ private:
|
||||||
// Power Management
|
// Power Management
|
||||||
PowerManagement *m_pwr;
|
PowerManagement *m_pwr;
|
||||||
QTimer *preventTimer;
|
QTimer *preventTimer;
|
||||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||||
QTimer programUpdateTimer;
|
QTimer programUpdateTimer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ private slots:
|
||||||
void on_actionAutoShutdown_system_toggled(bool );
|
void on_actionAutoShutdown_system_toggled(bool );
|
||||||
// Check for active torrents and set preventing from suspend state
|
// Check for active torrents and set preventing from suspend state
|
||||||
void checkForActiveTorrents();
|
void checkForActiveTorrents();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||||
void checkProgramUpdate();
|
void checkProgramUpdate();
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
16
src/misc.cpp
16
src/misc.cpp
|
@ -49,7 +49,7 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <PowrProf.h>
|
#include <PowrProf.h>
|
||||||
const int UNLEN = 256;
|
const int UNLEN = 256;
|
||||||
|
@ -58,13 +58,13 @@ const int UNLEN = 256;
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <CoreServices/CoreServices.h>
|
#include <CoreServices/CoreServices.h>
|
||||||
#include <Carbon/Carbon.h>
|
#include <Carbon/Carbon.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#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 <QDBusInterface>
|
||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,7 +82,7 @@ static struct { const char *source; const char *comment; } units[] = {
|
||||||
|
|
||||||
#ifndef DISABLE_GUI
|
#ifndef DISABLE_GUI
|
||||||
void misc::shutdownComputer(bool sleep) {
|
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
|
// Use dbus to power off / suspend the system
|
||||||
if (sleep) {
|
if (sleep) {
|
||||||
// Some recent systems use systemd's logind
|
// Some recent systems use systemd's logind
|
||||||
|
@ -126,7 +126,7 @@ void misc::shutdownComputer(bool sleep) {
|
||||||
halIface.call("Shutdown");
|
halIface.call("Shutdown");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
AEEventID EventToSend;
|
AEEventID EventToSend;
|
||||||
if (sleep)
|
if (sleep)
|
||||||
EventToSend = kAESleep;
|
EventToSend = kAESleep;
|
||||||
|
@ -167,7 +167,7 @@ void misc::shutdownComputer(bool sleep) {
|
||||||
|
|
||||||
AEDisposeDesc(&eventReply);
|
AEDisposeDesc(&eventReply);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
HANDLE hToken; // handle to process token
|
HANDLE hToken; // handle to process token
|
||||||
TOKEN_PRIVILEGES tkp; // pointer to token structure
|
TOKEN_PRIVILEGES tkp; // pointer to token structure
|
||||||
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
|
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);
|
const QString found = regHex.cap(1);
|
||||||
qDebug() << Q_FUNC_INFO << "regex found: " << found;
|
qDebug() << Q_FUNC_INFO << "regex found: " << found;
|
||||||
if (found.length() == 40) {
|
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)));
|
qDebug("magnetUriToHash (Hex): hash: %s", qPrintable(misc::toQString(sha1)));
|
||||||
return misc::toQString(sha1);
|
return misc::toQString(sha1);
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ QString misc::userFriendlyDuration(qlonglong seconds) {
|
||||||
|
|
||||||
QString misc::getUserIDString() {
|
QString misc::getUserIDString() {
|
||||||
QString uid = "0";
|
QString uid = "0";
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
char buffer[UNLEN+1] = {0};
|
char buffer[UNLEN+1] = {0};
|
||||||
DWORD buffer_len = UNLEN + 1;
|
DWORD buffer_len = UNLEN + 1;
|
||||||
if (!GetUserNameA(buffer, &buffer_len))
|
if (!GetUserNameA(buffer, &buffer_len))
|
||||||
|
|
|
@ -30,22 +30,22 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#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"
|
#include "powermanagement_x11.h"
|
||||||
#endif
|
#endif
|
||||||
#include "powermanagement.h"
|
#include "powermanagement.h"
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PowerManagement::PowerManagement(QObject *parent) : QObject(parent), m_busy(false)
|
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);
|
m_inhibitor = new PowerManagementInhibitor(this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -65,11 +65,11 @@ void PowerManagement::setBusy()
|
||||||
if (m_busy) return;
|
if (m_busy) return;
|
||||||
m_busy = true;
|
m_busy = true;
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
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();
|
m_inhibitor->RequestBusy();
|
||||||
#elif defined(Q_WS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID);
|
IOReturn success = IOPMAssertionCreate(kIOPMAssertionTypeNoIdleSleep, kIOPMAssertionLevelOn, &m_assertionID);
|
||||||
if (success != kIOReturnSuccess) m_busy = false;
|
if (success != kIOReturnSuccess) m_busy = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,11 +80,11 @@ void PowerManagement::setIdle()
|
||||||
if (!m_busy) return;
|
if (!m_busy) return;
|
||||||
m_busy = false;
|
m_busy = false;
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
SetThreadExecutionState(ES_CONTINUOUS);
|
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();
|
m_inhibitor->RequestIdle();
|
||||||
#elif defined(Q_WS_MAC)
|
#elif defined(Q_OS_MAC)
|
||||||
IOPMAssertionRelease(m_assertionID);
|
IOPMAssertionRelease(m_assertionID);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
// Require Mac OS X >= 10.5
|
// Require Mac OS X >= 10.5
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
#endif
|
#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
|
// Require DBus
|
||||||
class PowerManagementInhibitor;
|
class PowerManagementInhibitor;
|
||||||
#endif
|
#endif
|
||||||
|
@ -59,10 +59,10 @@ private:
|
||||||
void setBusy();
|
void setBusy();
|
||||||
void setIdle();
|
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;
|
PowerManagementInhibitor *m_inhibitor;
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
IOPMAssertionID m_assertionID;
|
IOPMAssertionID m_assertionID;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
enum AdvSettingsCols {PROPERTY, VALUE};
|
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,
|
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,
|
UPDATE_CHECK,
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
USE_ICON_THEME,
|
USE_ICON_THEME,
|
||||||
#endif
|
#endif
|
||||||
CONFIRM_DELETE_TORRENT, TRACKER_EXCHANGE,
|
CONFIRM_DELETE_TORRENT, TRACKER_EXCHANGE,
|
||||||
|
@ -34,10 +34,10 @@ private:
|
||||||
cb_enable_tracker_ext;
|
cb_enable_tracker_ext;
|
||||||
QComboBox combo_iface;
|
QComboBox combo_iface;
|
||||||
QSpinBox spin_cache_ttl;
|
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;
|
QCheckBox cb_update_check;
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
QCheckBox cb_use_icon_theme;
|
QCheckBox cb_use_icon_theme;
|
||||||
#endif
|
#endif
|
||||||
QCheckBox cb_announce_all_trackers;
|
QCheckBox cb_announce_all_trackers;
|
||||||
|
@ -107,11 +107,11 @@ public slots:
|
||||||
// Tracker
|
// Tracker
|
||||||
pref.setTrackerEnabled(cb_tracker_status.isChecked());
|
pref.setTrackerEnabled(cb_tracker_status.isChecked());
|
||||||
pref.setTrackerPort(spin_tracker_port.value());
|
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());
|
pref.setUpdateCheckEnabled(cb_update_check.isChecked());
|
||||||
#endif
|
#endif
|
||||||
// Icon theme
|
// Icon theme
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
pref.useSystemIconTheme(cb_use_icon_theme.isChecked());
|
pref.useSystemIconTheme(cb_use_icon_theme.isChecked());
|
||||||
#endif
|
#endif
|
||||||
pref.setConfirmTorrentDeletion(cb_confirm_torrent_deletion.isChecked());
|
pref.setConfirmTorrentDeletion(cb_confirm_torrent_deletion.isChecked());
|
||||||
|
@ -250,11 +250,11 @@ private slots:
|
||||||
spin_tracker_port.setMaximum(65535);
|
spin_tracker_port.setMaximum(65535);
|
||||||
spin_tracker_port.setValue(pref.getTrackerPort());
|
spin_tracker_port.setValue(pref.getTrackerPort());
|
||||||
setRow(TRACKER_PORT, tr("Embedded tracker port"), &spin_tracker_port);
|
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());
|
cb_update_check.setChecked(pref.isUpdateCheckEnabled());
|
||||||
setRow(UPDATE_CHECK, tr("Check for software updates"), &cb_update_check);
|
setRow(UPDATE_CHECK, tr("Check for software updates"), &cb_update_check);
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
cb_use_icon_theme.setChecked(pref.useSystemIconTheme());
|
cb_use_icon_theme.setChecked(pref.useSystemIconTheme());
|
||||||
setRow(USE_ICON_THEME, tr("Use system icon theme"), &cb_use_icon_theme);
|
setRow(USE_ICON_THEME, tr("Use system icon theme"), &cb_use_icon_theme);
|
||||||
#endif
|
#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);
|
scanFoldersView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
#else
|
||||||
|
scanFoldersView->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||||
|
#endif
|
||||||
scanFoldersView->setModel(ScanFoldersModel::instance());
|
scanFoldersView->setModel(ScanFoldersModel::instance());
|
||||||
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(enableApplyButton()));
|
connect(ScanFoldersModel::instance(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(enableApplyButton()));
|
||||||
connect(scanFoldersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleScanFolderViewSelectionChanged()));
|
connect(scanFoldersView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleScanFolderViewSelectionChanged()));
|
||||||
|
@ -102,15 +106,15 @@ options_imp::options_imp(QWidget *parent):
|
||||||
// Load options
|
// Load options
|
||||||
loadOptions();
|
loadOptions();
|
||||||
// Disable systray integration if it is not supported by the system
|
// Disable systray integration if it is not supported by the system
|
||||||
#ifndef Q_WS_MAC
|
#ifndef Q_OS_MAC
|
||||||
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||||
#endif
|
#endif
|
||||||
checkShowSystray->setChecked(false);
|
checkShowSystray->setChecked(false);
|
||||||
checkShowSystray->setEnabled(false);
|
checkShowSystray->setEnabled(false);
|
||||||
#ifndef Q_WS_MAC
|
#ifndef Q_OS_MAC
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if !defined(Q_WS_X11)
|
#if (!defined(Q_OS_UNIX) || defined(Q_OS_MAC))
|
||||||
label_trayIconStyle->setVisible(false);
|
label_trayIconStyle->setVisible(false);
|
||||||
comboTrayIcon->setVisible(false);
|
comboTrayIcon->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,7 +122,7 @@ options_imp::options_imp(QWidget *parent):
|
||||||
checkWebUiHttps->setVisible(false);
|
checkWebUiHttps->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
checkStartup->setVisible(false);
|
checkStartup->setVisible(false);
|
||||||
groupFileAssociation->setVisible(false);
|
groupFileAssociation->setVisible(false);
|
||||||
#endif
|
#endif
|
||||||
|
@ -136,17 +140,17 @@ options_imp::options_imp(QWidget *parent):
|
||||||
connect(checkCloseToSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkCloseToSystray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkMinimizeToSysTray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkMinimizeToSysTray, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkStartMinimized, 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()));
|
connect(checkStartup, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
#endif
|
#endif
|
||||||
connect(checkShowSplash, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkShowSplash, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkProgramExitConfirm, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkProgramExitConfirm, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkPreventFromSuspend, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkPreventFromSuspend, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(comboTrayIcon, SIGNAL(currentIndexChanged(int)), 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);
|
checkPreventFromSuspend->setDisabled(true);
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
connect(checkAssociateTorrents, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkAssociateTorrents, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
connect(checkAssociateMagnetLinks, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
connect(checkAssociateMagnetLinks, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -367,7 +371,7 @@ void options_imp::saveOptions() {
|
||||||
pref.setSplashScreenDisabled(isSlashScreenDisabled());
|
pref.setSplashScreenDisabled(isSlashScreenDisabled());
|
||||||
pref.setConfirmOnExit(checkProgramExitConfirm->isChecked());
|
pref.setConfirmOnExit(checkProgramExitConfirm->isChecked());
|
||||||
pref.setPreventFromSuspend(preventFromSuspend());
|
pref.setPreventFromSuspend(preventFromSuspend());
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
pref.setStartup(Startup());
|
pref.setStartup(Startup());
|
||||||
// Windows: file association settings
|
// Windows: file association settings
|
||||||
Preferences::setTorrentFileAssoc(checkAssociateTorrents->isChecked());
|
Preferences::setTorrentFileAssoc(checkAssociateTorrents->isChecked());
|
||||||
|
@ -524,7 +528,7 @@ void options_imp::loadOptions() {
|
||||||
comboTrayIcon->setCurrentIndex(pref.trayIconStyle());
|
comboTrayIcon->setCurrentIndex(pref.trayIconStyle());
|
||||||
checkProgramExitConfirm->setChecked(pref.confirmOnExit());
|
checkProgramExitConfirm->setChecked(pref.confirmOnExit());
|
||||||
checkPreventFromSuspend->setChecked(pref.preventFromSuspend());
|
checkPreventFromSuspend->setChecked(pref.preventFromSuspend());
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
checkStartup->setChecked(pref.Startup());
|
checkStartup->setChecked(pref.Startup());
|
||||||
// Windows: file association settings
|
// Windows: file association settings
|
||||||
checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
|
checkAssociateTorrents->setChecked(Preferences::isTorrentFileAssocSet());
|
||||||
|
@ -961,7 +965,7 @@ bool options_imp::isSlashScreenDisabled() const {
|
||||||
return !checkShowSplash->isChecked();
|
return !checkShowSplash->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool options_imp::Startup() const {
|
bool options_imp::Startup() const {
|
||||||
return checkStartup->isChecked();
|
return checkStartup->isChecked();
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ private:
|
||||||
bool startMinimized() const;
|
bool startMinimized() const;
|
||||||
bool isSlashScreenDisabled() const;
|
bool isSlashScreenDisabled() const;
|
||||||
bool preventFromSuspend() const;
|
bool preventFromSuspend() const;
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool Startup() const;
|
bool Startup() const;
|
||||||
#endif
|
#endif
|
||||||
// Downloads
|
// Downloads
|
||||||
|
|
|
@ -135,7 +135,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool systrayIntegration() const {
|
bool systrayIntegration() const {
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
return value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
return value(QString::fromUtf8("Preferences/General/SystrayEnabled"), true).toBool();
|
||||||
|
@ -195,7 +195,7 @@ public:
|
||||||
setValue("Preferences/General/PreventFromSuspend", b);
|
setValue("Preferences/General/PreventFromSuspend", b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool Startup() const {
|
bool Startup() const {
|
||||||
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
|
||||||
return settings.contains("qBittorrent");
|
return settings.contains("qBittorrent");
|
||||||
|
@ -1135,7 +1135,7 @@ public:
|
||||||
setValue(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), enabled);
|
setValue(QString::fromUtf8("Preferences/Advanced/AnnounceToAllTrackers"), enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(Q_WS_X11)
|
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
|
||||||
bool useSystemIconTheme() const {
|
bool useSystemIconTheme() const {
|
||||||
return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool();
|
return value(QString::fromUtf8("Preferences/Advanced/useSystemIconTheme"), true).toBool();
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1171,7 @@ public:
|
||||||
setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
|
setValue(QString::fromUtf8("Preferences/Advanced/DisableRecursiveDownload"), disable);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
static QString getPythonPath() {
|
static QString getPythonPath() {
|
||||||
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
QSettings reg_python("HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore", QIniSettings::NativeFormat);
|
||||||
QStringList versions = reg_python.childGroups();
|
QStringList versions = reg_python.childGroups();
|
||||||
|
@ -1311,7 +1311,7 @@ public:
|
||||||
setValue(QString::fromUtf8("Preferences/Advanced/trackerPort"), port);
|
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 {
|
bool isUpdateCheckEnabled() const {
|
||||||
return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool();
|
return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool();
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,12 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "previewselect.h"
|
#include "previewselect.h"
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QPlastiqueStyle>
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
#include <QPlastiqueStyle>
|
||||||
|
#else
|
||||||
|
#include <QProxyStyle>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class PreviewListDelegate: public QItemDelegate {
|
class PreviewListDelegate: public QItemDelegate {
|
||||||
|
@ -71,13 +75,17 @@ class PreviewListDelegate: public QItemDelegate {
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = true;
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
QPlastiqueStyle st;
|
QPlastiqueStyle st;
|
||||||
|
#else
|
||||||
|
QProxyStyle st("fusion");
|
||||||
|
#endif
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "fs_utils.h"
|
#include "fs_utils.h"
|
||||||
#include "preferences.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 RSS_URL = "http://sourceforge.net/api/file/index/project-id/163414/mtime/desc/rss?path=/qbittorrent-mac";
|
||||||
const QString FILE_EXT = "DMG";
|
const QString FILE_EXT = "DMG";
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
#include "ui_peer.h"
|
#include "ui_peer.h"
|
||||||
|
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
|
@ -209,7 +209,7 @@ void PeerListWidget::showPeerListMenu(const QPoint&)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (act == copyIPAct) {
|
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"));
|
QApplication::clipboard()->setText(selectedPeerIPs.join("\r\n"));
|
||||||
#else
|
#else
|
||||||
QApplication::clipboard()->setText(selectedPeerIPs.join("\n"));
|
QApplication::clipboard()->setText(selectedPeerIPs.join("\n"));
|
||||||
|
|
|
@ -561,7 +561,7 @@ void PropertiesWidget::renameSelectedFile() {
|
||||||
// Check if that name is already used
|
// Check if that name is already used
|
||||||
for (int i=0; i<h.num_files(); ++i) {
|
for (int i=0; i<h.num_files(); ++i) {
|
||||||
if (i == file_index) continue;
|
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) {
|
if (h.filepath_at(i).compare(new_name, Qt::CaseSensitive) == 0) {
|
||||||
#else
|
#else
|
||||||
if (h.filepath_at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
|
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();
|
const int num_files = h.num_files();
|
||||||
for (int i=0; i<num_files; ++i) {
|
for (int i=0; i<num_files; ++i) {
|
||||||
const QString current_name = h.filepath_at(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)) {
|
if (current_name.startsWith(new_path, Qt::CaseSensitive)) {
|
||||||
#else
|
#else
|
||||||
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
if (current_name.startsWith(new_path, Qt::CaseInsensitive)) {
|
||||||
|
|
|
@ -43,8 +43,12 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "propertieswidget.h"
|
#include "propertieswidget.h"
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
#include <QPlastiqueStyle>
|
#include <QPlastiqueStyle>
|
||||||
|
#else
|
||||||
|
#include <QProxyStyle>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Defines for properties list columns
|
// Defines for properties list columns
|
||||||
|
@ -84,11 +88,15 @@ public:
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = true;
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
QPlastiqueStyle st;
|
QPlastiqueStyle st;
|
||||||
|
#else
|
||||||
|
QProxyStyle st("fusion");
|
||||||
|
#endif
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class QIniSettings : public QSettings {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QIniSettings(const QString &organization = "qBittorrent", const QString &application = "qBittorrent", QObject *parent = 0 ):
|
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)
|
QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application, parent)
|
||||||
#else
|
#else
|
||||||
QSettings(organization, application, parent)
|
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 {
|
QVariant value(const QString & key, const QVariant &defaultValue = QVariant()) const {
|
||||||
QString key_tmp(key);
|
QString key_tmp(key);
|
||||||
QVariant ret = QSettings::value(key_tmp);
|
QVariant ret = QSettings::value(key_tmp);
|
||||||
|
|
|
@ -44,7 +44,7 @@ using namespace std;
|
||||||
|
|
||||||
// P2B Stuff
|
// P2B Stuff
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <Winsock2.h>
|
#include <Winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
|
@ -91,7 +91,7 @@ const int MAX_TRACKER_ERRORS = 2;
|
||||||
|
|
||||||
/* Converts a QString hash into a libtorrent sha1_hash */
|
/* Converts a QString hash into a libtorrent sha1_hash */
|
||||||
static libtorrent::sha1_hash QStringToSha1(const QString& s) {
|
static libtorrent::sha1_hash QStringToSha1(const QString& s) {
|
||||||
QByteArray raw = s.toAscii();
|
QByteArray raw = s.toLatin1();
|
||||||
Q_ASSERT(raw.size() == 40);
|
Q_ASSERT(raw.size() == 40);
|
||||||
libtorrent::sha1_hash ret;
|
libtorrent::sha1_hash ret;
|
||||||
from_hex(raw.constData(), 40, (char*)&ret[0]);
|
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
|
// Fix the input path if necessary
|
||||||
path = fsutils::fromNativePath(path);
|
path = fsutils::fromNativePath(path);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Windows hack
|
// Windows hack
|
||||||
if (!path.endsWith(".torrent"))
|
if (!path.endsWith(".torrent"))
|
||||||
if (QFile::rename(path, path+".torrent")) path += ".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());
|
qDebug("This network interface has %d IP addresses", network_iface.addressEntries().size());
|
||||||
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
|
foreach (const QNetworkAddressEntry &entry, network_iface.addressEntries()) {
|
||||||
qDebug("Trying to listen on IP %s (%s)", qPrintable(entry.ip().toString()), qPrintable(iface_name));
|
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) {
|
if (!ec) {
|
||||||
ip = entry.ip().toString();
|
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");
|
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;
|
boost::system::error_code ec;
|
||||||
string ip = p->ip.to_string(ec);
|
string ip = p->ip.to_string(ec);
|
||||||
if (!ec) {
|
if (!ec) {
|
||||||
addPeerBanMessage(QString::fromAscii(ip.c_str()), true);
|
addPeerBanMessage(QString::fromLatin1(ip.c_str()), true);
|
||||||
//emit peerBlocked(QString::fromAscii(ip.c_str()));
|
//emit peerBlocked(QString::fromLatin1(ip.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (peer_ban_alert* p = dynamic_cast<peer_ban_alert*>(a.get())) {
|
else if (peer_ban_alert* p = dynamic_cast<peer_ban_alert*>(a.get())) {
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
string ip = p->ip.address().to_string(ec);
|
string ip = p->ip.address().to_string(ec);
|
||||||
if (!ec) {
|
if (!ec) {
|
||||||
addPeerBanMessage(QString::fromAscii(ip.c_str()), false);
|
addPeerBanMessage(QString::fromLatin1(ip.c_str()), false);
|
||||||
//emit peerBlocked(QString::fromAscii(ip.c_str()));
|
//emit peerBlocked(QString::fromLatin1(ip.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
|
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) {
|
if (index < 0) {
|
||||||
// Add file to torrent download list
|
// Add file to torrent download list
|
||||||
file_path = fsutils::fromNativePath(file_path);
|
file_path = fsutils::fromNativePath(file_path);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Windows hack
|
// Windows hack
|
||||||
if (!file_path.endsWith(".torrent", Qt::CaseInsensitive)) {
|
if (!file_path.endsWith(".torrent", Qt::CaseInsensitive)) {
|
||||||
Q_ASSERT(QFile::exists(file_path));
|
Q_ASSERT(QFile::exists(file_path));
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include <libtorrent/bencode.hpp>
|
#include <libtorrent/bencode.hpp>
|
||||||
#include <libtorrent/entry.hpp>
|
#include <libtorrent/entry.hpp>
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -641,7 +641,7 @@ void QTorrentHandle::prioritize_files(const vector<int> &files) const {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool created = QDir().mkpath(unwanted_abspath);
|
bool created = QDir().mkpath(unwanted_abspath);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
qDebug() << "unwanted folder was created:" << created;
|
qDebug() << "unwanted folder was created:" << created;
|
||||||
if (created) {
|
if (created) {
|
||||||
// Hide the folder on Windows
|
// Hide the folder on Windows
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
|
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/";
|
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) {
|
void engineSelectDlg::dropEvent(QDropEvent *event) {
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
|
QStringList files = event->mimeData()->text().split(QString::fromUtf8("\n"));
|
||||||
foreach (QString file, files) {
|
foreach (QString file, files) {
|
||||||
qDebug("dropped %s", qPrintable(file));
|
qDebug("dropped %s", qPrintable(file));
|
||||||
if (misc::isUrl(file)) {
|
if (misc::isUrl(file)) {
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
||||||
// Boolean initialization
|
// Boolean initialization
|
||||||
search_stopped = false;
|
search_stopped = false;
|
||||||
// Creating Search Process
|
// Creating Search Process
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
has_python = addPythonPathToEnv();
|
has_python = addPythonPathToEnv();
|
||||||
#endif
|
#endif
|
||||||
searchProcess = new QProcess(this);
|
searchProcess = new QProcess(this);
|
||||||
|
@ -95,7 +95,7 @@ SearchEngine::SearchEngine(MainWindow* parent)
|
||||||
// Update nova.py search plugin if necessary
|
// Update nova.py search plugin if necessary
|
||||||
updateNova();
|
updateNova();
|
||||||
supported_engines = new SupportedEngines(
|
supported_engines = new SupportedEngines(
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
has_python
|
has_python
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
@ -115,7 +115,7 @@ void SearchEngine::fillCatCombobox() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool SearchEngine::addPythonPathToEnv() {
|
bool SearchEngine::addPythonPathToEnv() {
|
||||||
QString python_path = Preferences::getPythonPath();
|
QString python_path = Preferences::getPythonPath();
|
||||||
if (!python_path.isEmpty()) {
|
if (!python_path.isEmpty()) {
|
||||||
|
@ -227,7 +227,7 @@ void SearchEngine::giveFocusToSearchInput() {
|
||||||
|
|
||||||
// Function called when we click on search button
|
// Function called when we click on search button
|
||||||
void SearchEngine::on_search_button_clicked() {
|
void SearchEngine::on_search_button_clicked() {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (!has_python) {
|
if (!has_python) {
|
||||||
if (QMessageBox::question(this, tr("Missing Python Interpreter"),
|
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?"),
|
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
|
#endif
|
||||||
if (searchProcess->state() != QProcess::NotRunning) {
|
if (searchProcess->state() != QProcess::NotRunning) {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
searchProcess->kill();
|
searchProcess->kill();
|
||||||
#else
|
#else
|
||||||
searchProcess->terminate();
|
searchProcess->terminate();
|
||||||
|
@ -492,7 +492,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus) {
|
||||||
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
mp_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
||||||
}
|
}
|
||||||
if (exitcode) {
|
if (exitcode) {
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
search_status->setText(tr("Search aborted"));
|
search_status->setText(tr("Search aborted"));
|
||||||
#else
|
#else
|
||||||
search_status->setText(tr("An error occurred during search..."));
|
search_status->setText(tr("An error occurred during search..."));
|
||||||
|
|
|
@ -105,7 +105,7 @@ protected slots:
|
||||||
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
void downloadFinished(int exitcode, QProcess::ExitStatus);
|
||||||
void fillCatCombobox();
|
void fillCatCombobox();
|
||||||
void searchTextEdited(QString);
|
void searchTextEdited(QString);
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool addPythonPathToEnv();
|
bool addPythonPathToEnv();
|
||||||
void installPython();
|
void installPython();
|
||||||
void pythonDownloadSuccess(QString url, QString file_path);
|
void pythonDownloadSuccess(QString url, QString file_path);
|
||||||
|
@ -130,7 +130,7 @@ private:
|
||||||
QList<QPointer<SearchTab> > all_tab; // To store all tabs
|
QList<QPointer<SearchTab> > all_tab; // To store all tabs
|
||||||
const SearchCategories full_cat_names;
|
const SearchCategories full_cat_names;
|
||||||
MainWindow *mp_mainWindow;
|
MainWindow *mp_mainWindow;
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool has_python;
|
bool has_python;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
#include "sessionapplication.h"
|
#include "sessionapplication.h"
|
||||||
|
|
||||||
SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) :
|
SessionApplication::SessionApplication(const QString &id, int &argc, char **argv) :
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QMacApplication(id, argc, argv)
|
QMacApplication(id, argc, argv)
|
||||||
#else
|
#else
|
||||||
QtSingleApplication(id, argc, argv)
|
QtSingleApplication(id, argc, argv)
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include <QtCore/QtGlobal>
|
#include <QtCore/QtGlobal>
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
#include "qmacapplication.h"
|
#include "qmacapplication.h"
|
||||||
#else
|
#else
|
||||||
#include "qtsingleapplication.h"
|
#include "qtsingleapplication.h"
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
#include <QSessionManager>
|
#include <QSessionManager>
|
||||||
|
|
||||||
class SessionApplication :
|
class SessionApplication :
|
||||||
#ifdef Q_WS_MAC
|
#ifdef Q_OS_MAC
|
||||||
public QMacApplication
|
public QMacApplication
|
||||||
#else
|
#else
|
||||||
public QtSingleApplication
|
public QtSingleApplication
|
||||||
|
|
26
src/smtp.cpp
26
src/smtp.cpp
|
@ -192,7 +192,7 @@ void Smtp::readyRead()
|
||||||
case Authenticated:
|
case Authenticated:
|
||||||
if (code[0] == '2') {
|
if (code[0] == '2') {
|
||||||
qDebug() << "Sending <mail from>...";
|
qDebug() << "Sending <mail from>...";
|
||||||
socket->write("mail from:<" + from.toAscii() + ">\r\n");
|
socket->write("mail from:<" + from.toLatin1() + ">\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = Rcpt;
|
state = Rcpt;
|
||||||
} else {
|
} else {
|
||||||
|
@ -203,7 +203,7 @@ void Smtp::readyRead()
|
||||||
break;
|
break;
|
||||||
case Rcpt:
|
case Rcpt:
|
||||||
if (code[0] == '2') {
|
if (code[0] == '2') {
|
||||||
socket->write("rcpt to:<" + rcpt.toAscii() + ">\r\n");
|
socket->write("rcpt to:<" + rcpt.toLatin1() + ">\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = Data;
|
state = Data;
|
||||||
} else {
|
} 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 Smtp::encode_mime_header(const QString& key, const QString& value, QTextCodec* latin1, const QByteArray& prefix)
|
||||||
{
|
{
|
||||||
QByteArray rv = "";
|
QByteArray rv = "";
|
||||||
QByteArray line = key.toAscii() + ": ";
|
QByteArray line = key.toLatin1() + ": ";
|
||||||
if (!prefix.isEmpty()) line += prefix;
|
if (!prefix.isEmpty()) line += prefix;
|
||||||
if (!value.contains("=?") && latin1->canEncode(value)) {
|
if (!value.contains("=?") && latin1->canEncode(value)) {
|
||||||
bool firstWord = true;
|
bool firstWord = true;
|
||||||
foreach (const QByteArray& word, value.toAscii().split(' ')) {
|
foreach (const QByteArray& word, value.toLatin1().split(' ')) {
|
||||||
if (line.size() > 78) {
|
if (line.size() > 78) {
|
||||||
rv = rv + line + "\r\n";
|
rv = rv + line + "\r\n";
|
||||||
line.clear();
|
line.clear();
|
||||||
|
@ -295,7 +295,7 @@ void Smtp::ehlo()
|
||||||
{
|
{
|
||||||
if (addr == QHostAddress::LocalHost || addr == QHostAddress::LocalHostIPv6)
|
if (addr == QHostAddress::LocalHost || addr == QHostAddress::LocalHostIPv6)
|
||||||
continue;
|
continue;
|
||||||
address = addr.toString().toAscii();
|
address = addr.toString().toLatin1();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Send EHLO
|
// Send EHLO
|
||||||
|
@ -403,8 +403,8 @@ void Smtp::authCramMD5(const QByteArray& challenge)
|
||||||
authType = AuthCramMD5;
|
authType = AuthCramMD5;
|
||||||
state = AuthRequestSent;
|
state = AuthRequestSent;
|
||||||
} else {
|
} else {
|
||||||
QByteArray response = username.toAscii() + ' '
|
QByteArray response = username.toLatin1() + ' '
|
||||||
+ hmacMD5(password.toAscii(), QByteArray::fromBase64(challenge)).toHex();
|
+ hmacMD5(password.toLatin1(), QByteArray::fromBase64(challenge)).toHex();
|
||||||
socket->write(response.toBase64() + "\r\n");
|
socket->write(response.toBase64() + "\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = AuthSent;
|
state = AuthSent;
|
||||||
|
@ -418,11 +418,11 @@ void Smtp::authPlain()
|
||||||
// Prepare Auth string
|
// Prepare Auth string
|
||||||
QByteArray auth;
|
QByteArray auth;
|
||||||
auth += '\0';
|
auth += '\0';
|
||||||
auth += username.toAscii();
|
auth += username.toLatin1();
|
||||||
qDebug() << "username: " << username.toAscii();
|
qDebug() << "username: " << username.toLatin1();
|
||||||
auth += '\0';
|
auth += '\0';
|
||||||
auth += password.toAscii();
|
auth += password.toLatin1();
|
||||||
qDebug() << "password: " << password.toAscii();
|
qDebug() << "password: " << password.toLatin1();
|
||||||
// Send it
|
// Send it
|
||||||
socket->write("auth plain "+ auth.toBase64() + "\r\n");
|
socket->write("auth plain "+ auth.toBase64() + "\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
|
@ -439,12 +439,12 @@ void Smtp::authLogin()
|
||||||
state = AuthRequestSent;
|
state = AuthRequestSent;
|
||||||
}
|
}
|
||||||
else if (state == AuthRequestSent) {
|
else if (state == AuthRequestSent) {
|
||||||
socket->write(username.toAscii().toBase64() + "\r\n");
|
socket->write(username.toLatin1().toBase64() + "\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = AuthUsernameSent;
|
state = AuthUsernameSent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
socket->write(password.toAscii().toBase64() + "\r\n");
|
socket->write(password.toLatin1().toBase64() + "\r\n");
|
||||||
socket->flush();
|
socket->flush();
|
||||||
state = AuthSent;
|
state = AuthSent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@ nox {
|
||||||
}
|
}
|
||||||
QT += network
|
QT += network
|
||||||
|
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
|
||||||
# Vars
|
# Vars
|
||||||
LANG_PATH = lang
|
LANG_PATH = lang
|
||||||
ICONS_PATH = Icons
|
ICONS_PATH = Icons
|
||||||
|
@ -176,6 +178,7 @@ nox {
|
||||||
win32 {
|
win32 {
|
||||||
HEADERS += programupdater.h
|
HEADERS += programupdater.h
|
||||||
SOURCES += programupdater.cpp
|
SOURCES += programupdater.cpp
|
||||||
|
DEFINES += NOMINMAX
|
||||||
}
|
}
|
||||||
|
|
||||||
macx {
|
macx {
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
|
||||||
#include "torrentcontentmodelitem.h"
|
#include "torrentcontentmodelitem.h"
|
||||||
|
|
||||||
class TorrentContentModelFile;
|
class TorrentContentModelFile;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
|
|
||||||
namespace prio {
|
namespace prio {
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include <libtorrent/torrent_info.hpp>
|
#include <libtorrent/torrent_info.hpp>
|
||||||
#include <libtorrent/version.hpp>
|
#include <libtorrent/version.hpp>
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,8 @@ void QTracker::respondToAnnounceRequest(QTcpSocket *socket,
|
||||||
}
|
}
|
||||||
annonce_req.info_hash = get_parameters.value("info_hash");
|
annonce_req.info_hash = get_parameters.value("info_hash");
|
||||||
// info_hash cannot be longer than 20 bytes
|
// info_hash cannot be longer than 20 bytes
|
||||||
/*if (annonce_req.info_hash.toAscii().length() > 20) {
|
/*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.toAscii().length());
|
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");
|
respondInvalidRequest(socket, 150, "Invalid infohash");
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
|
|
||||||
#include "ui_login.h"
|
#include "ui_login.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,12 @@
|
||||||
#include "torrentmodel.h"
|
#include "torrentmodel.h"
|
||||||
#include "qbtsession.h"
|
#include "qbtsession.h"
|
||||||
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <QPlastiqueStyle>
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
#include <QPlastiqueStyle>
|
||||||
|
#else
|
||||||
|
#include <QProxyStyle>
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Defines for download list list columns
|
// Defines for download list list columns
|
||||||
|
@ -181,11 +185,15 @@ public:
|
||||||
newopt.minimum = 0;
|
newopt.minimum = 0;
|
||||||
newopt.state |= QStyle::State_Enabled;
|
newopt.state |= QStyle::State_Enabled;
|
||||||
newopt.textVisible = true;
|
newopt.textVisible = true;
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_OS_WIN
|
||||||
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
QApplication::style()->drawControl(QStyle::CE_ProgressBar, &newopt, painter);
|
||||||
#else
|
#else
|
||||||
// XXX: To avoid having the progress text on the right of the bar
|
// XXX: To avoid having the progress text on the right of the bar
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
QPlastiqueStyle st;
|
QPlastiqueStyle st;
|
||||||
|
#else
|
||||||
|
QProxyStyle st("fusion");
|
||||||
|
#endif
|
||||||
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
st.drawControl(QStyle::CE_ProgressBar, &newopt, painter, 0);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||||
setStyleSheet("QListWidget { background: transparent; border: 0 }");
|
setStyleSheet("QListWidget { background: transparent; border: 0 }");
|
||||||
#if defined(Q_WS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ public:
|
||||||
// Height is fixed (sizeHint().height() is used)
|
// Height is fixed (sizeHint().height() is used)
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||||
setStyleSheet("QListWidget { background: transparent; border: 0 }");
|
setStyleSheet("QListWidget { background: transparent; border: 0 }");
|
||||||
#if defined(Q_WS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
|
||||||
setItemsExpandable(false);
|
setItemsExpandable(false);
|
||||||
setAutoScroll(true);
|
setAutoScroll(true);
|
||||||
setDragDropMode(QAbstractItemView::DragOnly);
|
setDragDropMode(QAbstractItemView::DragOnly);
|
||||||
#if defined(Q_WS_MAC)
|
#if defined(Q_OS_MAC)
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#ifndef UPDOWNRATIODLG_H
|
#ifndef UPDOWNRATIODLG_H
|
||||||
#define UPDOWNRATIODLG_H
|
#define UPDOWNRATIODLG_H
|
||||||
|
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
@ -168,7 +168,11 @@ void HttpConnection::translateDocument(QString& data) {
|
||||||
if (isTranslationNeeded) {
|
if (isTranslationNeeded) {
|
||||||
int context_index = 0;
|
int context_index = 0;
|
||||||
while(context_index < context_count && translation == word) {
|
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);
|
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;
|
++context_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,10 +141,10 @@ Submit Query
|
||||||
m_error = true;
|
m_error = true;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
boundary = "--" + boundaryRegexNotQuoted.cap(1).toAscii();
|
boundary = "--" + boundaryRegexNotQuoted.cap(1).toLatin1();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boundary = "--" + boundaryRegexQuoted.cap(1).toAscii();
|
boundary = "--" + boundaryRegexQuoted.cap(1).toLatin1();
|
||||||
}
|
}
|
||||||
qDebug() << "Boundary is " << boundary;
|
qDebug() << "Boundary is " << boundary;
|
||||||
QList<QByteArray> parts = splitRawData(m_data, boundary);
|
QList<QByteArray> parts = splitRawData(m_data, boundary);
|
||||||
|
|
|
@ -156,7 +156,11 @@ void HttpServer::disableHttps() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
void HttpServer::incomingConnection(qintptr socketDescriptor)
|
||||||
|
#else
|
||||||
void HttpServer::incomingConnection(int socketDescriptor)
|
void HttpServer::incomingConnection(int socketDescriptor)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
QTcpSocket *serverSocket;
|
QTcpSocket *serverSocket;
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
|
|
|
@ -75,7 +75,11 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
|
||||||
|
void incomingConnection(qintptr socketDescriptor);
|
||||||
|
#else
|
||||||
void incomingConnection(int socketDescriptor);
|
void incomingConnection(int socketDescriptor);
|
||||||
|
#endif
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void UnbanTimerEvent();
|
void UnbanTimerEvent();
|
||||||
|
|
|
@ -58,7 +58,7 @@ QString json::toJson(const QVariant& v) {
|
||||||
QString result = "\"";
|
QString result = "\"";
|
||||||
for (int i=0; i<s.size(); ++i) {
|
for (int i=0; i<s.size(); ++i) {
|
||||||
const QChar ch = s[i];
|
const QChar ch = s[i];
|
||||||
switch(ch.toAscii())
|
switch(ch.toLatin1())
|
||||||
{
|
{
|
||||||
case '\b':
|
case '\b':
|
||||||
result += "\\b";
|
result += "\\b";
|
||||||
|
|
|
@ -130,8 +130,8 @@ QString prefjson::getPreferences()
|
||||||
data.add("web_ui_password", pref.getWebUiPassword());
|
data.add("web_ui_password", pref.getWebUiPassword());
|
||||||
data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
|
data.add("bypass_local_auth", !pref.isWebUiLocalAuthEnabled());
|
||||||
data.add("use_https", pref.isWebUiHttpsEnabled());
|
data.add("use_https", pref.isWebUiHttpsEnabled());
|
||||||
data.add("ssl_key", QString::fromAscii(pref.getWebUiHttpsKey()));
|
data.add("ssl_key", QString::fromLatin1(pref.getWebUiHttpsKey()));
|
||||||
data.add("ssl_cert", QString::fromAscii(pref.getWebUiHttpsCertificate()));
|
data.add("ssl_cert", QString::fromLatin1(pref.getWebUiHttpsCertificate()));
|
||||||
// DynDns
|
// DynDns
|
||||||
data.add("dyndns_enabled", pref.isDynDNSEnabled());
|
data.add("dyndns_enabled", pref.isDynDNSEnabled());
|
||||||
data.add("dyndns_service", pref.getDynDNSService());
|
data.add("dyndns_service", pref.getDynDNSService());
|
||||||
|
@ -317,12 +317,12 @@ void prefjson::setPreferences(const QString& json)
|
||||||
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
|
pref.setWebUiHttpsEnabled(m["use_https"].toBool());
|
||||||
#ifndef QT_NO_OPENSSL
|
#ifndef QT_NO_OPENSSL
|
||||||
if (m.contains("ssl_key")) {
|
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())
|
if (!QSslKey(raw_key, QSsl::Rsa).isNull())
|
||||||
pref.setWebUiHttpsKey(raw_key);
|
pref.setWebUiHttpsKey(raw_key);
|
||||||
}
|
}
|
||||||
if (m.contains("ssl_cert")) {
|
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())
|
if (!QSslCertificate(raw_cert).isNull())
|
||||||
pref.setWebUiHttpsCertificate(raw_cert);
|
pref.setWebUiHttpsCertificate(raw_cert);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue