diff --git a/.travis.yml b/.travis.yml
index 77196513a0ec..2e097e34065f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -76,10 +76,13 @@ before_install:
- shopt -s expand_aliases
- alias make="colormake -j3" # Using nprocs/2 sometimes may fail (gcc is killed by system)
- #- libt_path="$HOME/libt_install"
- #- ltconf="$ltconf --prefix="$libt_path" --disable-geoip"
- qbt_path="$HOME/qbt_install"
- - qbtconf="$qbtconf --prefix="$qbt_path" PKG_CONFIG_PATH="$libt_path/lib/pkgconfig":/opt/qt55/lib/pkgconfig:$PKG_CONFIG_PATH"
+ - |
+ if [ "$TRAVIS_OS_NAME" = "linux" ]; then
+ qbtconf="$qbtconf --prefix="$qbt_path" PKG_CONFIG_PATH=/opt/qt55/lib/pkgconfig:$PKG_CONFIG_PATH"
+ else
+ qbtconf="$qbtconf --prefix="$qbt_path""
+ fi
# options for specific branches
- if [ "$gui" = false ]; then qbtconf="$qbtconf --disable-gui" ; fi
@@ -131,13 +134,13 @@ install:
cp "version" $HOME/hombebrew_cache
cd "$HOME/hombebrew_cache"
wget https://builds.shiki.hu/homebrew/libtorrent-rasterbar.rb
- wget https://builds.shiki.hu/homebrew/libtorrent-rasterbar-1.0.11+git20170910.6d5625e0ea.el_capitan.bottle.tar.gz
+ wget https://builds.shiki.hu/homebrew/libtorrent-rasterbar-1.1.6+git20180101.b45acf28a5+patched-configure.el_capitan.bottle.tar.gz
fi
# Copy custom libtorrent bottle to homebrew's cache so it can find and install it
# Also install our custom libtorrent formula by passing the local path to it
# These 2 files are restored from Travis' cache.
- cp "$HOME/hombebrew_cache/libtorrent-rasterbar-1.0.11+git20170910.6d5625e0ea.el_capitan.bottle.tar.gz" "$(brew --cache)"
+ cp "$HOME/hombebrew_cache/libtorrent-rasterbar-1.1.6+git20180101.b45acf28a5+patched-configure.el_capitan.bottle.tar.gz" "$(brew --cache)"
brew install "$HOME/hombebrew_cache/libtorrent-rasterbar.rb"
if [ "$build_system" = "cmake" ]; then
@@ -168,11 +171,15 @@ script:
BUILD_TOOL="ninja"
fi
if [ "$build_system" = "qmake" ]; then
- ./bootstrap.sh && ./configure $qbtconf
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ # For some reason for RC_1_1 we need to also specify the OpenSSL compiler/linker flags
+ # Homebrew doesn't symlink OpenSSL for security reasons
+ ./bootstrap.sh && ./configure $qbtconf CXXFLAGS="$(PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH" pkg-config --cflags openssl)" LDFLAGS="$(PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH" pkg-config --libs openssl)"
sed -i "" -e "s/^\(CC.*&&\).*$/\1 $CC/" src/Makefile # workaround for Qt & ccache: https://bugreports.qt.io/browse/QTBUG-31034
sed -i "" -e "s/^\(CXX.*&&\).*$/\1 $CXX/" src/Makefile
sed -i "" -e 's/^\(CXXFLAGS.*\)$/\1 -Wno-unused-local-typedefs -Wno-inconsistent-missing-override/' src/Makefile
+ else
+ ./bootstrap.sh && ./configure $qbtconf
fi
BUILD_TOOL="make"
fi
diff --git a/CODING_GUIDELINES.md b/CODING_GUIDELINES.md
index 5f5cc6572650..503d3d46ecbe 100644
--- a/CODING_GUIDELINES.md
+++ b/CODING_GUIDELINES.md
@@ -240,7 +240,23 @@ Example:
```
-### 9. Misc. ###
+### 9. Include guard. ###
+`#pragma once` should be used instead of "include guard" in new code:
+```c++
+// examplewidget.h
+
+#pragma once
+
+#include
+
+class ExampleWidget : public QWidget
+{
+ // (some code omitted)
+};
+
+```
+
+### 10. Misc. ###
* Line breaks for long lines with operation:
diff --git a/Changelog b/Changelog
index 9cfbc159fcf5..7cd050da0d6c 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,42 @@
+* Fri Feb 16 2018 - sledgehammer999 - v4.0.4
+ - FEATURE: Add source field in Torrent creator. Closes #7965. (Chocobo1)
+ - FEATURE: Torrent creator: raise maximum piece size to 32 MiB (Chocobo1)
+ - FEATURE: Add a force reannounce option in the transfer list context menu. Closes #6448. (Jesse Bryan)
+ - BUGFIX: Fix sorting of country flags column in Peers tab. (sledgehammer999)
+ - BUGFIX: Fix natural sorting when the common part of 2 strings ends partially in a number which continues in the uncommon part. Closes #8080 #6732. (sledgehammer999)
+ - BUGFIX: Fix application of speed limits on LAN and μTP connections. Closes #7745. (sledgehammer999)
+ - BUGFIX: Make peer information flags in peerlist more readable. (thalieht)
+ - BUGFIX: Fix gui issues on high DPI monitor. (Chocobo1)
+ - BUGFIX: Fix dialog and column size on high DPI monitors. (Chocobo1)
+ - BUGFIX: Fix constant status of '[F] Downloading'. Closes #7628. (sledgehammer999)
+ - BUGFIX: Fix translation context. Closes #8211. (sledgehammer999)
+ - BUGFIX: Separate subnet whitelist options into two lines. (Thomas Piccirello)
+ - BUGFIX: Don't set application name twice. (Luís Pereira)
+ - BUGFIX: Set default file log size to 65 KiB and delete backup logs older than 1 month. (sledgehammer999)
+ - WEBUI: Only prepend scheme when it is not present. Closes #8057. (Chocobo1)
+ - WEBUI: Add "Remaining" and "Availability" columns to webui Content tab. (Thomas Piccirello)
+ - WEBUI: Make value formatting consistent with GUI (Thomas Piccirello)
+ - WEBUI: Reposition Total Size column to match gui (Thomas Piccirello)
+ - WEBUI: Add Tags and Time Active columns (Thomas Piccirello)
+ - WEBUI: Use https for www.qbittorrent.org (Thomas Piccirello)
+ - WEBUI: Match webui statuses to gui, closes #7516 (Thomas Piccirello)
+ - WEBUI: Right-align stat values (Thomas Piccirello)
+ - WEBUI: Add missing units. (Thomas Piccirello)
+ - RSS: Fix crash when deleting rule because it tries to update. Closes #8094 (glassez)
+ - RSS: Don't process new/updated RSS rules when disabled (glassez)
+ - RSS: Remove legacy and corrupted RSS settings (glassez)
+ - SEARCH: Search only when category is supported by plugin. Closes #8053. (jan.karberg)
+ - SEARCH: Only add search separators as needed. (Thomas Piccirello)
+ - COSMETIC: Tweak spacing in torrent properties widget and speed widget. (Chocobo1)
+ - WINDOWS: Use standard folder icon for open file behavior on Windows. Closes #7880. (Chocobo1)
+ - WINDOWS: Revert "Run external program" function. Now you will not be able to directly run batch scripts. (Chocobo1)
+ - MACOS: Fix torrent file selection in Finder on mac (vit9696)
+ - MACOS: Fix Finder reveal in preview and torrent contents (vit9696)
+ - MACOS: Fix cmd+w not closing the main window on macOS (vit9696)
+ - OTHER: Fix splitting of compiler flags in configure. Autoconf removes a set of [] during script translation, resulting in a wrong sed command. (sledgehammer999)
+ - OTHER: configure: Parse all compiler related flags together. (sledgehammer999)
+ - OTHER: Update copyright year. (sledgehammer999)
+
* Sun Dec 17 2017 - sledgehammer999 - v4.0.3
- BUGFIX: Add height padding to the transfer list icons. Closes #7951. (sledgehammer999)
- BUGFIX: Allow to drag-n-drop URLs into mainwindow to initiate download. (Chocobo1)
diff --git a/README.md b/README.md
index 79f7e2a9d054..a2c75ef5263e 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ You can also download it from [here](https://github.com/qbittorrent/qBittorrent/
### Misc:
For more information please visit:
-http://www.qbittorrent.org
+https://www.qbittorrent.org
or our wiki here:
http://wiki.qbittorrent.org
diff --git a/configure b/configure
index 7e03e07c911a..d8f1592f2eb7 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for qbittorrent v3.2.0alpha.
+# Generated by GNU Autoconf 2.69 for qbittorrent v4.0.4.
#
# Report bugs to .
#
@@ -580,10 +580,10 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='qbittorrent'
PACKAGE_TARNAME='qbittorrent'
-PACKAGE_VERSION='v3.2.0alpha'
-PACKAGE_STRING='qbittorrent v3.2.0alpha'
+PACKAGE_VERSION='v4.0.4'
+PACKAGE_STRING='qbittorrent v4.0.4'
PACKAGE_BUGREPORT='bugs.qbittorrent.org'
-PACKAGE_URL='http://www.qbittorrent.org/'
+PACKAGE_URL='https://www.qbittorrent.org/'
ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
@@ -690,6 +690,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -783,6 +784,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1035,6 +1037,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1172,7 +1183,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1285,7 +1296,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures qbittorrent v3.2.0alpha to adapt to many kinds of systems.
+\`configure' configures qbittorrent v4.0.4 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1325,6 +1336,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1355,7 +1367,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of qbittorrent v3.2.0alpha:";;
+ short | recursive ) echo "Configuration of qbittorrent v4.0.4:";;
esac
cat <<\_ACEOF
@@ -1426,7 +1438,7 @@ Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to .
-qbittorrent home page: .
+qbittorrent home page: .
_ACEOF
ac_status=$?
fi
@@ -1489,7 +1501,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-qbittorrent configure v3.2.0alpha
+qbittorrent configure v4.0.4
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1628,7 +1640,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by qbittorrent $as_me v3.2.0alpha, which was
+It was created by qbittorrent $as_me v4.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -3806,7 +3818,7 @@ fi
# Define the identity of the package.
PACKAGE='qbittorrent'
- VERSION='v3.2.0alpha'
+ VERSION='v4.0.4'
cat >>confdefs.h <<_ACEOF
@@ -5489,7 +5501,7 @@ extract() {
new_line='
'
# Convert " -" to "\n" if not between quotes and remove possible leading white spaces
- string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[:space:]*//')
+ string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[:space:]]*//')
SAVEIFS=$IFS
IFS=$(printf "\n\b")
for i in $string; do
@@ -5503,9 +5515,8 @@ extract() {
IFS=$SAVEIFS
}
-extract $CPPFLAGS
+extract "$CFLAGS $CPPFLAGS $CXXFLAGS"
QBT_ADD_DEFINES="$QBT_ADD_DEFINES $QBT_CONF_DEFINES"
-QBT_CONF_EXTRA_CFLAGS="$QBT_CONF_EXTRA_CFLAGS $CXXFLAGS"
# Substitute the values of these vars in conf.pri.in
@@ -6087,7 +6098,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by qbittorrent $as_me v3.2.0alpha, which was
+This file was extended by qbittorrent $as_me v4.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6139,13 +6150,13 @@ Configuration commands:
$config_commands
Report bugs to .
-qbittorrent home page: ."
+qbittorrent home page: ."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-qbittorrent config.status v3.2.0alpha
+qbittorrent config.status v4.0.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
@@ -7402,7 +7413,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by qbittorrent $as_me v3.2.0alpha, which was
+This file was extended by qbittorrent $as_me v4.0.4, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7454,13 +7465,13 @@ Configuration commands:
$config_commands
Report bugs to .
-qbittorrent home page: ."
+qbittorrent home page: ."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-qbittorrent config.status v3.2.0alpha
+qbittorrent config.status v4.0.4
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 2d9d74c1b3ac..489a17dfeac1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([qbittorrent], [v3.2.0alpha], [bugs.qbittorrent.org], [], [http://www.qbittorrent.org/])
+AC_INIT([qbittorrent], [v4.0.4], [bugs.qbittorrent.org], [], [https://www.qbittorrent.org/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC
@@ -190,7 +190,7 @@ extract() {
new_line='
'
# Convert " -" to "\n" if not between quotes and remove possible leading white spaces
- string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[:space:]]*//')
+ string=$(echo " $*" | $SED -e "s: -:\\${new_line}:g" -e 's:"\(.*\)\n\(.*\)":\"\1 -\2":g' -e "s:'\(.*\)\n\(.*\)':\'\1 -\2':g" -e 's/^[[[:space:]]]*//')
SAVEIFS=$IFS
IFS=$(printf "\n\b")
for i in $string; do
@@ -204,9 +204,8 @@ extract() {
IFS=$SAVEIFS
}
-extract $CPPFLAGS
+extract "$CFLAGS $CPPFLAGS $CXXFLAGS"
QBT_ADD_DEFINES="$QBT_ADD_DEFINES $QBT_CONF_DEFINES"
-QBT_CONF_EXTRA_CFLAGS="$QBT_CONF_EXTRA_CFLAGS $CXXFLAGS"
# Substitute the values of these vars in conf.pri.in
AC_SUBST(QBT_CONF_INCLUDES)
diff --git a/dist/mac/Info.plist b/dist/mac/Info.plist
index 33b193e4949c..49dd78fb2e68 100644
--- a/dist/mac/Info.plist
+++ b/dist/mac/Info.plist
@@ -45,7 +45,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 4.0.3
+ 4.0.4
CFBundleSignature
qBit
CFBundleExecutable
@@ -59,7 +59,7 @@
NSAppleScriptEnabled
YES
NSHumanReadableCopyright
- Copyright © 2006-2017 The qBittorrent project
+ Copyright © 2006-2018 The qBittorrent project
UTExportedTypeDeclarations
diff --git a/dist/unix/qbittorrent.appdata.xml b/dist/unix/qbittorrent.appdata.xml
index 908a2928bed5..344da31d5a1b 100644
--- a/dist/unix/qbittorrent.appdata.xml
+++ b/dist/unix/qbittorrent.appdata.xml
@@ -56,7 +56,7 @@
- http://www.qbittorrent.org/
+ https://www.qbittorrent.org/
sledgehammer999@qbittorrent.org
The qBittorrent Project
http://bugs.qbittorrent.org/
diff --git a/dist/windows/installer.nsi b/dist/windows/installer.nsi
index 2651112e45cc..ca5717503482 100644
--- a/dist/windows/installer.nsi
+++ b/dist/windows/installer.nsi
@@ -86,7 +86,7 @@ Section $(inst_qbt_req) ;"qBittorrent (required)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "UninstallString" '"$INSTDIR\uninst.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayIcon" '"$INSTDIR\qbittorrent.exe",0'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "Publisher" "The qBittorrent project"
- WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "URLInfoAbout" "http://www.qbittorrent.org"
+ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "URLInfoAbout" "https://www.qbittorrent.org"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "DisplayVersion" "${PROG_VERSION}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\qBittorrent" "NoRepair" 1
diff --git a/dist/windows/options.nsi b/dist/windows/options.nsi
index 35e694f5feac..816506806bfc 100644
--- a/dist/windows/options.nsi
+++ b/dist/windows/options.nsi
@@ -27,7 +27,7 @@ XPStyle on
!define CSIDL_LOCALAPPDATA '0x1C' ;Local Application Data path
; Program specific
-!define PROG_VERSION "4.0.3"
+!define PROG_VERSION "4.0.4"
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_FUNCTION PageFinishRun
@@ -50,7 +50,7 @@ XPStyle on
;Installer Version Information
VIAddVersionKey "ProductName" "qBittorrent"
VIAddVersionKey "CompanyName" "The qBittorrent project"
-VIAddVersionKey "LegalCopyright" "Copyright ©2006-2017 The qBittorrent project"
+VIAddVersionKey "LegalCopyright" "Copyright ©2006-2018 The qBittorrent project"
VIAddVersionKey "FileDescription" "qBittorrent - A Bittorrent Client"
VIAddVersionKey "FileVersion" "${PROG_VERSION}"
diff --git a/src/app/application.cpp b/src/app/application.cpp
index b3221efa88b2..ebc32f9097c7 100644
--- a/src/app/application.cpp
+++ b/src/app/application.cpp
@@ -87,7 +87,7 @@ namespace
const QString KEY_FILELOGGER_PATH = FILELOGGER_SETTINGS_KEY("Path");
const QString KEY_FILELOGGER_BACKUP = FILELOGGER_SETTINGS_KEY("Backup");
const QString KEY_FILELOGGER_DELETEOLD = FILELOGGER_SETTINGS_KEY("DeleteOld");
- const QString KEY_FILELOGGER_MAXSIZE = FILELOGGER_SETTINGS_KEY("MaxSize");
+ const QString KEY_FILELOGGER_MAXSIZEBYTES = FILELOGGER_SETTINGS_KEY("MaxSizeBytes");
const QString KEY_FILELOGGER_AGE = FILELOGGER_SETTINGS_KEY("Age");
const QString KEY_FILELOGGER_AGETYPE = FILELOGGER_SETTINGS_KEY("AgeType");
@@ -98,6 +98,10 @@ namespace
const char PARAMS_SEPARATOR[] = "|";
const QString DEFAULT_PORTABLE_MODE_PROFILE_DIR = QLatin1String("profile");
+
+ const int MIN_FILELOG_SIZE = 1024; // 1KiB
+ const int MAX_FILELOG_SIZE = 1000 * 1024 * 1024; // 1000MiB
+ const int DEFAULT_FILELOG_SIZE = 65 * 1024; // 65KiB
}
Application::Application(const QString &id, int &argc, char **argv)
@@ -128,7 +132,6 @@ Application::Application(const QString &id, int &argc, char **argv)
if (m_commandLineArgs.webUiPort > 0) // it will be -1 when user did not set any value
Preferences::instance()->setWebUiPort(m_commandLineArgs.webUiPort);
- setApplicationName("qBittorrent");
initializeTranslation();
#if !defined(DISABLE_GUI)
@@ -221,29 +224,22 @@ void Application::setFileLoggerDeleteOld(bool value)
int Application::fileLoggerMaxSize() const
{
- int val = settings()->loadValue(KEY_FILELOGGER_MAXSIZE, 10).toInt();
- if (val < 1)
- return 1;
- if (val > 1000)
- return 1000;
- return val;
+ int val = settings()->loadValue(KEY_FILELOGGER_MAXSIZEBYTES, DEFAULT_FILELOG_SIZE).toInt();
+ return std::min(std::max(val, MIN_FILELOG_SIZE), MAX_FILELOG_SIZE);
}
-void Application::setFileLoggerMaxSize(const int value)
+void Application::setFileLoggerMaxSize(const int bytes)
{
+ int clampedValue = std::min(std::max(bytes, MIN_FILELOG_SIZE), MAX_FILELOG_SIZE);
if (m_fileLogger)
- m_fileLogger->setMaxSize(value);
- settings()->storeValue(KEY_FILELOGGER_MAXSIZE, std::min(std::max(value, 1), 1000));
+ m_fileLogger->setMaxSize(clampedValue);
+ settings()->storeValue(KEY_FILELOGGER_MAXSIZEBYTES, clampedValue);
}
int Application::fileLoggerAge() const
{
- int val = settings()->loadValue(KEY_FILELOGGER_AGE, 6).toInt();
- if (val < 1)
- return 1;
- if (val > 365)
- return 365;
- return val;
+ int val = settings()->loadValue(KEY_FILELOGGER_AGE, 1).toInt();
+ return std::min(std::max(val, 1), 365);
}
void Application::setFileLoggerAge(const int value)
@@ -291,27 +287,6 @@ void Application::runExternalProgram(BitTorrent::TorrentHandle *const torrent) c
#if defined(Q_OS_UNIX)
QProcess::startDetached(QLatin1String("/bin/sh"), {QLatin1String("-c"), program});
-#elif defined(Q_OS_WIN) // test cmd: `echo "%F" > "c:\ab ba.txt"`
- program.prepend(QLatin1String("\"")).append(QLatin1String("\""));
- program.prepend(Utils::Misc::windowsSystemPath() + QLatin1String("\\cmd.exe /C "));
- const int cmdMaxLength = 32768; // max length (incl. terminate char) for `lpCommandLine` in `CreateProcessW()`
- if ((program.size() + 1) > cmdMaxLength) {
- logger->addMessage(tr("Torrent: %1, run external program command too long (length > %2), execution failed.").arg(torrent->name()).arg(cmdMaxLength), Log::CRITICAL);
- return;
- }
-
- STARTUPINFOW si = {0};
- si.cb = sizeof(si);
- PROCESS_INFORMATION pi = {0};
-
- WCHAR *arg = new WCHAR[program.size() + 1];
- program.toWCharArray(arg);
- arg[program.size()] = L'\0';
- if (CreateProcessW(NULL, arg, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi)) {
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- }
- delete[] arg;
#else
QProcess::startDetached(program);
#endif
diff --git a/src/app/application.h b/src/app/application.h
index ae3bb63ef2de..f9014d9fbabc 100644
--- a/src/app/application.h
+++ b/src/app/application.h
@@ -101,7 +101,7 @@ class Application : public BaseApplication
bool isFileLoggerDeleteOld() const;
void setFileLoggerDeleteOld(bool value);
int fileLoggerMaxSize() const;
- void setFileLoggerMaxSize(const int value);
+ void setFileLoggerMaxSize(const int bytes);
int fileLoggerAge() const;
void setFileLoggerAge(const int value);
int fileLoggerAgeType() const;
diff --git a/src/app/filelogger.cpp b/src/app/filelogger.cpp
index 0c8426bc6122..0e464cf9c77e 100644
--- a/src/app/filelogger.cpp
+++ b/src/app/filelogger.cpp
@@ -135,7 +135,7 @@ void FileLogger::addLogMessage(const Log::Msg &msg)
str << QDateTime::fromMSecsSinceEpoch(msg.timestamp).toString(Qt::ISODate) << " - " << msg.message << endl;
- if (m_backup && (m_logFile->size() >= (m_maxSize * 1024 * 1024))) {
+ if (m_backup && (m_logFile->size() >= m_maxSize)) {
closeLogFile();
int counter = 0;
QString backupLogFilename = m_path + ".bak";
diff --git a/src/base/base.pri b/src/base/base.pri
index b302c9436617..5a62fe982752 100644
--- a/src/base/base.pri
+++ b/src/base/base.pri
@@ -1,124 +1,124 @@
HEADERS += \
$$PWD/asyncfilestorage.h \
- $$PWD/types.h \
- $$PWD/tristatebool.h \
+ $$PWD/bittorrent/addtorrentparams.h \
+ $$PWD/bittorrent/cachestatus.h \
+ $$PWD/bittorrent/infohash.h \
+ $$PWD/bittorrent/magneturi.h \
+ $$PWD/bittorrent/peerinfo.h \
+ $$PWD/bittorrent/private/bandwidthscheduler.h \
+ $$PWD/bittorrent/private/filterparserthread.h \
+ $$PWD/bittorrent/private/resumedatasavingmanager.h \
+ $$PWD/bittorrent/private/speedmonitor.h \
+ $$PWD/bittorrent/private/statistics.h \
+ $$PWD/bittorrent/session.h \
+ $$PWD/bittorrent/sessionstatus.h \
+ $$PWD/bittorrent/torrentcreatorthread.h \
+ $$PWD/bittorrent/torrenthandle.h \
+ $$PWD/bittorrent/torrentinfo.h \
+ $$PWD/bittorrent/tracker.h \
+ $$PWD/bittorrent/trackerentry.h \
$$PWD/filesystemwatcher.h \
- $$PWD/logger.h \
- $$PWD/settingsstorage.h \
- $$PWD/settingvalue.h \
- $$PWD/preferences.h \
- $$PWD/indexrange.h \
- $$PWD/iconprovider.h \
- $$PWD/http/irequesthandler.h \
+ $$PWD/global.h \
$$PWD/http/connection.h \
+ $$PWD/http/irequesthandler.h \
$$PWD/http/requestparser.h \
+ $$PWD/http/responsebuilder.h \
$$PWD/http/responsegenerator.h \
$$PWD/http/server.h \
$$PWD/http/types.h \
- $$PWD/http/responsebuilder.h \
+ $$PWD/iconprovider.h \
+ $$PWD/indexrange.h \
+ $$PWD/logger.h \
$$PWD/net/dnsupdater.h \
- $$PWD/net/downloadmanager.h \
$$PWD/net/downloadhandler.h \
+ $$PWD/net/downloadmanager.h \
$$PWD/net/geoipmanager.h \
$$PWD/net/portforwarder.h \
+ $$PWD/net/private/geoipdatabase.h \
$$PWD/net/proxyconfigurationmanager.h \
$$PWD/net/reverseresolution.h \
$$PWD/net/smtp.h \
- $$PWD/net/private/geoipdatabase.h \
- $$PWD/bittorrent/addtorrentparams.h \
- $$PWD/bittorrent/infohash.h \
- $$PWD/bittorrent/session.h \
- $$PWD/bittorrent/sessionstatus.h \
- $$PWD/bittorrent/cachestatus.h \
- $$PWD/bittorrent/magneturi.h \
- $$PWD/bittorrent/torrentinfo.h \
- $$PWD/bittorrent/torrenthandle.h \
- $$PWD/bittorrent/peerinfo.h \
- $$PWD/bittorrent/trackerentry.h \
- $$PWD/bittorrent/tracker.h \
- $$PWD/bittorrent/torrentcreatorthread.h \
- $$PWD/bittorrent/private/speedmonitor.h \
- $$PWD/bittorrent/private/bandwidthscheduler.h \
- $$PWD/bittorrent/private/filterparserthread.h \
- $$PWD/bittorrent/private/statistics.h \
- $$PWD/bittorrent/private/resumedatasavingmanager.h \
+ $$PWD/preferences.h \
+ $$PWD/private/profile_p.h \
+ $$PWD/profile.h \
+ $$PWD/rss/private/rss_parser.h \
$$PWD/rss/rss_article.h \
- $$PWD/rss/rss_item.h \
+ $$PWD/rss/rss_autodownloader.h \
+ $$PWD/rss/rss_autodownloadrule.h \
$$PWD/rss/rss_feed.h \
$$PWD/rss/rss_folder.h \
+ $$PWD/rss/rss_item.h \
$$PWD/rss/rss_session.h \
- $$PWD/rss/rss_autodownloader.h \
- $$PWD/rss/rss_autodownloadrule.h \
- $$PWD/rss/private/rss_parser.h \
+ $$PWD/scanfoldersmodel.h \
+ $$PWD/searchengine.h \
+ $$PWD/settingsstorage.h \
+ $$PWD/settingvalue.h \
+ $$PWD/torrentfileguard.h \
+ $$PWD/torrentfilter.h \
+ $$PWD/tristatebool.h \
+ $$PWD/types.h \
+ $$PWD/unicodestrings.h \
$$PWD/utils/fs.h \
$$PWD/utils/gzip.h \
$$PWD/utils/misc.h \
$$PWD/utils/net.h \
$$PWD/utils/random.h \
$$PWD/utils/string.h \
- $$PWD/utils/version.h \
- $$PWD/profile.h \
- $$PWD/private/profile_p.h \
- $$PWD/unicodestrings.h \
- $$PWD/torrentfileguard.h \
- $$PWD/torrentfilter.h \
- $$PWD/scanfoldersmodel.h \
- $$PWD/searchengine.h \
- $$PWD/global.h
+ $$PWD/utils/version.h
SOURCES += \
$$PWD/asyncfilestorage.cpp \
- $$PWD/tristatebool.cpp \
+ $$PWD/bittorrent/infohash.cpp \
+ $$PWD/bittorrent/magneturi.cpp \
+ $$PWD/bittorrent/peerinfo.cpp \
+ $$PWD/bittorrent/private/bandwidthscheduler.cpp \
+ $$PWD/bittorrent/private/filterparserthread.cpp \
+ $$PWD/bittorrent/private/resumedatasavingmanager.cpp \
+ $$PWD/bittorrent/private/speedmonitor.cpp \
+ $$PWD/bittorrent/private/statistics.cpp \
+ $$PWD/bittorrent/session.cpp \
+ $$PWD/bittorrent/torrentcreatorthread.cpp \
+ $$PWD/bittorrent/torrenthandle.cpp \
+ $$PWD/bittorrent/torrentinfo.cpp \
+ $$PWD/bittorrent/tracker.cpp \
+ $$PWD/bittorrent/trackerentry.cpp \
$$PWD/filesystemwatcher.cpp \
- $$PWD/logger.cpp \
- $$PWD/settingsstorage.cpp \
- $$PWD/preferences.cpp \
- $$PWD/iconprovider.cpp \
$$PWD/http/connection.cpp \
$$PWD/http/requestparser.cpp \
+ $$PWD/http/responsebuilder.cpp \
$$PWD/http/responsegenerator.cpp \
$$PWD/http/server.cpp \
- $$PWD/http/responsebuilder.cpp \
+ $$PWD/iconprovider.cpp \
+ $$PWD/logger.cpp \
$$PWD/net/dnsupdater.cpp \
- $$PWD/net/downloadmanager.cpp \
$$PWD/net/downloadhandler.cpp \
+ $$PWD/net/downloadmanager.cpp \
$$PWD/net/geoipmanager.cpp \
$$PWD/net/portforwarder.cpp \
+ $$PWD/net/private/geoipdatabase.cpp \
$$PWD/net/proxyconfigurationmanager.cpp \
$$PWD/net/reverseresolution.cpp \
$$PWD/net/smtp.cpp \
- $$PWD/net/private/geoipdatabase.cpp \
- $$PWD/bittorrent/infohash.cpp \
- $$PWD/bittorrent/session.cpp \
- $$PWD/bittorrent/magneturi.cpp \
- $$PWD/bittorrent/torrentinfo.cpp \
- $$PWD/bittorrent/torrenthandle.cpp \
- $$PWD/bittorrent/peerinfo.cpp \
- $$PWD/bittorrent/trackerentry.cpp \
- $$PWD/bittorrent/tracker.cpp \
- $$PWD/bittorrent/torrentcreatorthread.cpp \
- $$PWD/bittorrent/private/speedmonitor.cpp \
- $$PWD/bittorrent/private/bandwidthscheduler.cpp \
- $$PWD/bittorrent/private/filterparserthread.cpp \
- $$PWD/bittorrent/private/statistics.cpp \
- $$PWD/bittorrent/private/resumedatasavingmanager.cpp \
+ $$PWD/preferences.cpp \
+ $$PWD/private/profile_p.cpp \
+ $$PWD/profile.cpp \
+ $$PWD/rss/private/rss_parser.cpp \
$$PWD/rss/rss_article.cpp \
- $$PWD/rss/rss_item.cpp \
+ $$PWD/rss/rss_autodownloader.cpp \
+ $$PWD/rss/rss_autodownloadrule.cpp \
$$PWD/rss/rss_feed.cpp \
$$PWD/rss/rss_folder.cpp \
+ $$PWD/rss/rss_item.cpp \
$$PWD/rss/rss_session.cpp \
- $$PWD/rss/rss_autodownloader.cpp \
- $$PWD/rss/rss_autodownloadrule.cpp \
- $$PWD/rss/private/rss_parser.cpp \
+ $$PWD/scanfoldersmodel.cpp \
+ $$PWD/searchengine.cpp \
+ $$PWD/settingsstorage.cpp \
+ $$PWD/torrentfileguard.cpp \
+ $$PWD/torrentfilter.cpp \
+ $$PWD/tristatebool.cpp \
$$PWD/utils/fs.cpp \
$$PWD/utils/gzip.cpp \
$$PWD/utils/misc.cpp \
$$PWD/utils/net.cpp \
$$PWD/utils/random.cpp \
- $$PWD/utils/string.cpp \
- $$PWD/profile.cpp \
- $$PWD/private/profile_p.cpp \
- $$PWD/torrentfileguard.cpp \
- $$PWD/torrentfilter.cpp \
- $$PWD/scanfoldersmodel.cpp \
- $$PWD/searchengine.cpp
+ $$PWD/utils/string.cpp
diff --git a/src/base/bittorrent/peerinfo.cpp b/src/base/bittorrent/peerinfo.cpp
index 67fad2a2a0df..dc0bd7c88832 100644
--- a/src/base/bittorrent/peerinfo.cpp
+++ b/src/base/bittorrent/peerinfo.cpp
@@ -283,18 +283,20 @@ qreal PeerInfo::relevance() const
void PeerInfo::determineFlags()
{
+ QStringList flagsDescriptionList;
+
if (isInteresting()) {
// d = Your client wants to download, but peer doesn't want to send (interested and choked)
if (isRemoteChocked()) {
m_flags += "d ";
- m_flagsDescription += tr("interested(local) and choked(peer)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "d = "
+ + tr("Interested(local) and Choked(peer)");
}
else {
// D = Currently downloading (interested and not choked)
m_flags += "D ";
- m_flagsDescription += tr("interested(local) and unchoked(peer)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "D = "
+ + tr("interested(local) and unchoked(peer)");
}
}
@@ -302,97 +304,95 @@ void PeerInfo::determineFlags()
// u = Peer wants your client to upload, but your client doesn't want to (interested and choked)
if (isChocked()) {
m_flags += "u ";
- m_flagsDescription += tr("interested(peer) and choked(local)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "u = "
+ + tr("interested(peer) and choked(local)");
}
else {
// U = Currently uploading (interested and not choked)
m_flags += "U ";
- m_flagsDescription += tr("interested(peer) and unchoked(local)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "U = "
+ + tr("interested(peer) and unchoked(local)");
}
}
// O = Optimistic unchoke
if (optimisticUnchoke()) {
m_flags += "O ";
- m_flagsDescription += tr("optimistic unchoke");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "O = "
+ + tr("optimistic unchoke");
}
// S = Peer is snubbed
if (isSnubbed()) {
m_flags += "S ";
- m_flagsDescription += tr("peer snubbed");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "S = "
+ + tr("peer snubbed");
}
// I = Peer is an incoming connection
if (!isLocalConnection()) {
m_flags += "I ";
- m_flagsDescription += tr("incoming connection");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "I = "
+ + tr("incoming connection");
}
// K = Peer is unchoking your client, but your client is not interested
if (!isRemoteChocked() && !isInteresting()) {
m_flags += "K ";
- m_flagsDescription += tr("not interested(local) and unchoked(peer)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "K = "
+ + tr("not interested(local) and unchoked(peer)");
}
// ? = Your client unchoked the peer but the peer is not interested
if (!isChocked() && !isRemoteInterested()) {
m_flags += "? ";
- m_flagsDescription += tr("not interested(peer) and unchoked(local)");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "? = "
+ + tr("not interested(peer) and unchoked(local)");
}
// X = Peer was included in peerlists obtained through Peer Exchange (PEX)
if (fromPeX()) {
m_flags += "X ";
- m_flagsDescription += tr("peer from PEX");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "X = "
+ + tr("peer from PEX");
}
// H = Peer was obtained through DHT
if (fromDHT()) {
m_flags += "H ";
- m_flagsDescription += tr("peer from DHT");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "H = "
+ + tr("peer from DHT");
}
// E = Peer is using Protocol Encryption (all traffic)
if (isRC4Encrypted()) {
m_flags += "E ";
- m_flagsDescription += tr("encrypted traffic");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "E = "
+ + tr("encrypted traffic");
}
// e = Peer is using Protocol Encryption (handshake)
if (isPlaintextEncrypted()) {
m_flags += "e ";
- m_flagsDescription += tr("encrypted handshake");
- m_flagsDescription += ", ";
+ flagsDescriptionList += "e = "
+ + tr("encrypted handshake");
}
// P = Peer is using uTorrent uTP
if (useUTPSocket()) {
m_flags += "P ";
- m_flagsDescription += QString::fromUtf8(C_UTP);
- m_flagsDescription += ", ";
+ flagsDescriptionList += "P = "
+ + QString::fromUtf8(C_UTP);
}
// L = Peer is local
if (fromLSD()) {
m_flags += "L";
- m_flagsDescription += tr("peer from LSD");
+ flagsDescriptionList += "L = "
+ + tr("peer from LSD");
}
-
m_flags = m_flags.trimmed();
- m_flagsDescription = m_flagsDescription.trimmed();
- if (m_flagsDescription.endsWith(',', Qt::CaseInsensitive))
- m_flagsDescription.chop(1);
+ m_flagsDescription = flagsDescriptionList.join('\n');
}
QString PeerInfo::flags() const
diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp
index c5185b2019dd..0f59ceec1902 100644
--- a/src/base/bittorrent/session.cpp
+++ b/src/base/bittorrent/session.cpp
@@ -1482,14 +1482,10 @@ void Session::configurePeerClasses()
peerClassTypeFilter.add(libt::peer_class_type_filter::tcp_socket, libt::session::tcp_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_tcp_socket, libt::session::tcp_peer_class_id);
peerClassTypeFilter.add(libt::peer_class_type_filter::i2p_socket, libt::session::tcp_peer_class_id);
- if (isUTPRateLimited()) {
- peerClassTypeFilter.add(libt::peer_class_type_filter::utp_socket
- , libt::session::local_peer_class_id);
- peerClassTypeFilter.add(libt::peer_class_type_filter::utp_socket
+ if (!isUTPRateLimited()) {
+ peerClassTypeFilter.disallow(libt::peer_class_type_filter::utp_socket
, libt::session::global_peer_class_id);
- peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_utp_socket
- , libt::session::local_peer_class_id);
- peerClassTypeFilter.add(libt::peer_class_type_filter::ssl_utp_socket
+ peerClassTypeFilter.disallow(libt::peer_class_type_filter::ssl_utp_socket
, libt::session::global_peer_class_id);
}
m_nativeSession->set_peer_class_type_filter(peerClassTypeFilter);
diff --git a/src/base/bittorrent/torrentcreatorthread.cpp b/src/base/bittorrent/torrentcreatorthread.cpp
index 27265da5c120..aaec193240a3 100644
--- a/src/base/bittorrent/torrentcreatorthread.cpp
+++ b/src/base/bittorrent/torrentcreatorthread.cpp
@@ -59,8 +59,6 @@ using namespace BitTorrent;
TorrentCreatorThread::TorrentCreatorThread(QObject *parent)
: QThread(parent)
- , m_private(false)
- , m_pieceSize(0)
{
}
@@ -70,97 +68,91 @@ TorrentCreatorThread::~TorrentCreatorThread()
wait();
}
-void TorrentCreatorThread::create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
- const QStringList &urlSeeds, const QString &comment, bool isPrivate, int pieceSize)
+void TorrentCreatorThread::create(const TorrentCreatorParams ¶ms)
{
- m_inputPath = Utils::Fs::fromNativePath(inputPath);
- m_savePath = Utils::Fs::fromNativePath(savePath);
- if (QFile(m_savePath).exists())
- Utils::Fs::forceRemove(m_savePath);
- m_trackers = trackers;
- m_urlSeeds = urlSeeds;
- m_comment = comment;
- m_private = isPrivate;
- m_pieceSize = pieceSize;
-
+ m_params = params;
start();
}
-void TorrentCreatorThread::sendProgressSignal(int numHashes, int numPieces)
+void TorrentCreatorThread::sendProgressSignal(int currentPieceIdx, int totalPieces)
{
- emit updateProgress(static_cast((numHashes * 100.) / numPieces));
+ emit updateProgress(static_cast((currentPieceIdx * 100.) / totalPieces));
}
void TorrentCreatorThread::run()
{
+ const QString creatorStr("qBittorrent " QBT_VERSION);
+
emit updateProgress(0);
- QString creator_str("qBittorrent " QBT_VERSION);
try {
libt::file_storage fs;
// Adding files to the torrent
- libt::add_files(fs, Utils::Fs::toNativePath(m_inputPath).toStdString(), fileFilter);
+ libt::add_files(fs, Utils::Fs::toNativePath(m_params.inputPath).toStdString(), fileFilter);
if (isInterruptionRequested()) return;
- libt::create_torrent t(fs, m_pieceSize);
+ libt::create_torrent newTorrent(fs, m_params.pieceSize);
// Add url seeds
- foreach (const QString &seed, m_urlSeeds)
- t.add_url_seed(seed.trimmed().toStdString());
+ foreach (QString seed, m_params.urlSeeds) {
+ seed = seed.trimmed();
+ if (!seed.isEmpty())
+ newTorrent.add_url_seed(seed.toStdString());
+ }
int tier = 0;
- bool newline = false;
- foreach (const QString &tracker, m_trackers) {
- if (tracker.isEmpty()) {
- if (newline)
- continue;
+ foreach (const QString &tracker, m_params.trackers) {
+ if (tracker.isEmpty())
++tier;
- newline = true;
- continue;
- }
- t.add_tracker(tracker.trimmed().toStdString(), tier);
- newline = false;
+ else
+ newTorrent.add_tracker(tracker.trimmed().toStdString(), tier);
}
if (isInterruptionRequested()) return;
// calculate the hash for all pieces
- const QString parentPath = Utils::Fs::branchPath(m_inputPath) + "/";
- libt::set_piece_hashes(t, Utils::Fs::toNativePath(parentPath).toStdString(), boost::bind(&TorrentCreatorThread::sendProgressSignal, this, _1, t.num_pieces()));
+ const QString parentPath = Utils::Fs::branchPath(m_params.inputPath) + "/";
+ libt::set_piece_hashes(newTorrent, Utils::Fs::toNativePath(parentPath).toStdString()
+ , [this, &newTorrent](const int n) { sendProgressSignal(n, newTorrent.num_pieces()); });
// Set qBittorrent as creator and add user comment to
// torrent_info structure
- t.set_creator(creator_str.toUtf8().constData());
- t.set_comment(m_comment.toUtf8().constData());
+ newTorrent.set_creator(creatorStr.toUtf8().constData());
+ newTorrent.set_comment(m_params.comment.toUtf8().constData());
// Is private ?
- t.set_priv(m_private);
+ newTorrent.set_priv(m_params.isPrivate);
+
+ if (isInterruptionRequested()) return;
+
+ libt::entry entry = newTorrent.generate();
+
+ // add source field
+ if (!m_params.source.isEmpty())
+ entry["info"]["source"] = m_params.source.toStdString();
if (isInterruptionRequested()) return;
- // create the torrent and print it to out
- qDebug("Saving to %s", qUtf8Printable(m_savePath));
+ // create the torrent
+ std::ofstream outfile(
#ifdef _MSC_VER
- wchar_t *savePathW = new wchar_t[m_savePath.length() + 1];
- int len = Utils::Fs::toNativePath(m_savePath).toWCharArray(savePathW);
- savePathW[len] = L'\0';
- std::ofstream outfile(savePathW, std::ios_base::out | std::ios_base::binary);
- delete[] savePathW;
+ Utils::Fs::toNativePath(m_params.savePath).toStdWString().c_str()
#else
- std::ofstream outfile(Utils::Fs::toNativePath(m_savePath).toLocal8Bit().constData(), std::ios_base::out | std::ios_base::binary);
+ Utils::Fs::toNativePath(m_params.savePath).toUtf8().constData()
#endif
+ , (std::ios_base::out | std::ios_base::binary | std::ios_base::trunc));
if (outfile.fail())
- throw std::exception();
+ throw std::runtime_error(tr("create new torrent file failed").toStdString());
if (isInterruptionRequested()) return;
- libt::bencode(std::ostream_iterator(outfile), t.generate());
+ libt::bencode(std::ostream_iterator(outfile), entry);
outfile.close();
emit updateProgress(100);
- emit creationSuccess(m_savePath, parentPath);
+ emit creationSuccess(m_params.savePath, parentPath);
}
- catch (std::exception& e) {
- emit creationFailure(QString::fromStdString(e.what()));
+ catch (const std::exception &e) {
+ emit creationFailure(e.what());
}
}
diff --git a/src/base/bittorrent/torrentcreatorthread.h b/src/base/bittorrent/torrentcreatorthread.h
index 25d8d83ed9ff..58785cfa23e6 100644
--- a/src/base/bittorrent/torrentcreatorthread.h
+++ b/src/base/bittorrent/torrentcreatorthread.h
@@ -36,16 +36,27 @@
namespace BitTorrent
{
+ struct TorrentCreatorParams
+ {
+ bool isPrivate;
+ int pieceSize;
+ QString inputPath;
+ QString savePath;
+ QString comment;
+ QString source;
+ QStringList trackers;
+ QStringList urlSeeds;
+ };
+
class TorrentCreatorThread : public QThread
{
Q_OBJECT
public:
- TorrentCreatorThread(QObject *parent = 0);
+ TorrentCreatorThread(QObject *parent = nullptr);
~TorrentCreatorThread();
- void create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
- const QStringList &urlSeeds, const QString &comment, bool isPrivate, int pieceSize);
+ void create(const TorrentCreatorParams ¶ms);
static int calculateTotalPieces(const QString &inputPath, const int pieceSize);
@@ -58,15 +69,9 @@ namespace BitTorrent
void updateProgress(int progress);
private:
- void sendProgressSignal(int numHashes, int numPieces);
+ void sendProgressSignal(int currentPieceIdx, int totalPieces);
- QString m_inputPath;
- QString m_savePath;
- QStringList m_trackers;
- QStringList m_urlSeeds;
- QString m_comment;
- bool m_private;
- int m_pieceSize;
+ TorrentCreatorParams m_params;
};
}
diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp
index f71a2534e621..8193fcc0763e 100644
--- a/src/base/bittorrent/torrenthandle.cpp
+++ b/src/base/bittorrent/torrenthandle.cpp
@@ -156,6 +156,8 @@ const int TorrentHandle::MAX_SEEDING_TIME = 525600;
// The following can be removed after one or two libtorrent releases on each branch.
namespace
{
+ const char i18nContext[] = "TorrentHandle";
+
// new constructor is available
template::value, int>::type = 0>
T makeTorrentCreator(const libtorrent::torrent_info & ti)
@@ -1469,7 +1471,7 @@ void TorrentHandle::handleStorageMovedFailedAlert(libtorrent::storage_moved_fail
return;
}
- Logger::instance()->addMessage(tr("Could not move torrent: '%1'. Reason: %2")
+ LogMsg(QCoreApplication::translate(i18nContext, "Could not move torrent: '%1'. Reason: %2")
.arg(name()).arg(QString::fromStdString(p->message())), Log::CRITICAL);
m_moveStorageInfo.newPath.clear();
@@ -1647,13 +1649,13 @@ void TorrentHandle::handleFastResumeRejectedAlert(libtorrent::fastresume_rejecte
updateStatus();
if (p->error.value() == libt::errors::mismatching_file_size) {
// Mismatching file size (files were probably moved)
- logger->addMessage(tr("File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL);
+ logger->addMessage(QCoreApplication::translate(i18nContext, "File sizes mismatch for torrent '%1', pausing it.").arg(name()), Log::CRITICAL);
m_hasMissingFiles = true;
if (!isPaused())
pause();
}
else {
- logger->addMessage(tr("Fast resume data was rejected for torrent '%1'. Reason: %2. Checking again...")
+ logger->addMessage(QCoreApplication::translate(i18nContext, "Fast resume data was rejected for torrent '%1'. Reason: %2. Checking again...")
.arg(name()).arg(QString::fromStdString(p->message())), Log::CRITICAL);
}
}
diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp
index b09cf7ae06bc..c02c736dcfc5 100644
--- a/src/base/preferences.cpp
+++ b/src/base/preferences.cpp
@@ -35,6 +35,7 @@
#include
#include
#include
+#include
#include
#include
@@ -487,13 +488,17 @@ QList Preferences::getWebUiAuthSubnetWhitelist() const
return subnets;
}
-void Preferences::setWebUiAuthSubnetWhitelist(const QList &subnets)
+void Preferences::setWebUiAuthSubnetWhitelist(QStringList subnets)
{
- QStringList subnetsStringList;
- for (const Utils::Net::Subnet &subnet : subnets)
- subnetsStringList.append(Utils::Net::subnetToString(subnet));
+ QMutableListIterator i(subnets);
+ while (i.hasNext()) {
+ bool ok = false;
+ const Utils::Net::Subnet subnet = Utils::Net::parseSubnet(i.next().trimmed(), &ok);
+ if (!ok)
+ i.remove();
+ }
- setValue("Preferences/WebUI/AuthSubnetWhitelist", subnetsStringList);
+ setValue("Preferences/WebUI/AuthSubnetWhitelist", subnets);
}
QString Preferences::getServerDomains() const
@@ -1226,9 +1231,9 @@ void Preferences::setMainLastDir(const QString &path)
setValue("MainWindowLastDir", path);
}
-QSize Preferences::getPrefSize(const QSize &defaultSize) const
+QSize Preferences::getPrefSize() const
{
- return value("Preferences/State/size", defaultSize).toSize();
+ return value("Preferences/State/size").toSize();
}
void Preferences::setPrefSize(const QSize &size)
@@ -1306,9 +1311,9 @@ void Preferences::setPropTrackerListState(const QByteArray &state)
setValue("TorrentProperties/Trackers/qt5/TrackerListState", state);
}
-QSize Preferences::getRssGeometrySize(const QSize &defaultSize) const
+QSize Preferences::getRssGeometrySize() const
{
- return value("RssFeedDownloader/geometrySize", defaultSize).toSize();
+ return value("RssFeedDownloader/geometrySize").toSize();
}
void Preferences::setRssGeometrySize(const QSize &geometry)
diff --git a/src/base/preferences.h b/src/base/preferences.h
index a26af3775b3e..40e408a5ffea 100644
--- a/src/base/preferences.h
+++ b/src/base/preferences.h
@@ -191,7 +191,7 @@ class Preferences: public QObject
bool isWebUiAuthSubnetWhitelistEnabled() const;
void setWebUiAuthSubnetWhitelistEnabled(bool enabled);
QList getWebUiAuthSubnetWhitelist() const;
- void setWebUiAuthSubnetWhitelist(const QList &subnets);
+ void setWebUiAuthSubnetWhitelist(QStringList subnets);
QString getWebUiUsername() const;
void setWebUiUsername(const QString &username);
QString getWebUiPassword() const;
@@ -303,7 +303,7 @@ class Preferences: public QObject
void setMainVSplitterState(const QByteArray &state);
QString getMainLastDir() const;
void setMainLastDir(const QString &path);
- QSize getPrefSize(const QSize &defaultSize) const;
+ QSize getPrefSize() const;
void setPrefSize(const QSize &size);
QStringList getPrefHSplitterSizes() const;
void setPrefHSplitterSizes(const QStringList &sizes);
@@ -319,7 +319,7 @@ class Preferences: public QObject
void setPropVisible(const bool visible);
QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state);
- QSize getRssGeometrySize(const QSize &defaultSize) const;
+ QSize getRssGeometrySize() const;
void setRssGeometrySize(const QSize &geometry);
QByteArray getRssHSplitterSizes() const;
void setRssHSplitterSizes(const QByteArray &sizes);
diff --git a/src/base/rss/rss_autodownloader.cpp b/src/base/rss/rss_autodownloader.cpp
index 438509bc8624..188658f64b93 100644
--- a/src/base/rss/rss_autodownloader.cpp
+++ b/src/base/rss/rss_autodownloader.cpp
@@ -424,6 +424,8 @@ bool AutoDownloader::isProcessingEnabled() const
void AutoDownloader::resetProcessingQueue()
{
m_processingQueue.clear();
+ if (!m_processingEnabled) return;
+
foreach (Article *article, Session::instance()->rootFolder()->articles()) {
if (!article->isRead() && !article->torrentUrl().isEmpty())
addJobForArticle(article);
diff --git a/src/base/rss/rss_session.cpp b/src/base/rss/rss_session.cpp
index a3cac71f11f0..d2565571e738 100644
--- a/src/base/rss/rss_session.cpp
+++ b/src/base/rss/rss_session.cpp
@@ -102,6 +102,27 @@ Session::Session()
m_refreshTimer.start(m_refreshInterval * MsecsPerMin);
refresh();
}
+
+ // Remove legacy/corrupted settings
+ // (at least on Windows, QSettings is case-insensitive and it can get
+ // confused when asked about settings that differ only in their case)
+ auto settingsStorage = SettingsStorage::instance();
+ settingsStorage->removeValue("Rss/streamList");
+ settingsStorage->removeValue("Rss/streamAlias");
+ settingsStorage->removeValue("Rss/open_folders");
+ settingsStorage->removeValue("Rss/qt5/splitter_h");
+ settingsStorage->removeValue("Rss/qt5/splitterMain");
+ settingsStorage->removeValue("Rss/hosts_cookies");
+ settingsStorage->removeValue("RSS/streamList");
+ settingsStorage->removeValue("RSS/streamAlias");
+ settingsStorage->removeValue("RSS/open_folders");
+ settingsStorage->removeValue("RSS/qt5/splitter_h");
+ settingsStorage->removeValue("RSS/qt5/splitterMain");
+ settingsStorage->removeValue("RSS/hosts_cookies");
+ settingsStorage->removeValue("Rss/Session/EnableProcessing");
+ settingsStorage->removeValue("Rss/Session/RefreshInterval");
+ settingsStorage->removeValue("Rss/Session/MaxArticlesPerFeed");
+ settingsStorage->removeValue("Rss/AutoDownloader/EnableProcessing");
}
Session::~Session()
@@ -295,20 +316,6 @@ void Session::loadFolder(const QJsonObject &jsonObj, Folder *folder)
void Session::loadLegacy()
{
- struct LegacySettingsDeleter
- {
- ~LegacySettingsDeleter()
- {
- auto settingsStorage = SettingsStorage::instance();
- settingsStorage->removeValue("Rss/streamList");
- settingsStorage->removeValue("Rss/streamAlias");
- settingsStorage->removeValue("Rss/open_folders");
- settingsStorage->removeValue("Rss/qt5/splitter_h");
- settingsStorage->removeValue("Rss/qt5/splitterMain");
- settingsStorage->removeValue("Rss/hosts_cookies");
- }
- } legacySettingsDeleter;
-
const QStringList legacyFeedPaths = SettingsStorage::instance()->loadValue("Rss/streamList").toStringList();
const QStringList feedAliases = SettingsStorage::instance()->loadValue("Rss/streamAlias").toStringList();
if (legacyFeedPaths.size() != feedAliases.size()) {
diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp
index 65d4ea85afdf..6fdfa0ef1ed9 100644
--- a/src/base/utils/misc.cpp
+++ b/src/base/utils/misc.cpp
@@ -632,19 +632,6 @@ void Utils::Misc::openFolderSelect(const QString &absolutePath)
#endif
}
-QSize Utils::Misc::smallIconSize()
-{
- // Get DPI scaled icon size (device-dependent), see QT source
- int s = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
- return QSize(s, s);
-}
-
-QSize Utils::Misc::largeIconSize()
-{
- // Get DPI scaled icon size (device-dependent), see QT source
- int s = QApplication::style()->pixelMetric(QStyle::PM_LargeIconSize);
- return QSize(s, s);
-}
#endif // DISABLE_GUI
QString Utils::Misc::osName()
diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h
index cf733e9a75f4..157b30113ed8 100644
--- a/src/base/utils/misc.h
+++ b/src/base/utils/misc.h
@@ -103,8 +103,6 @@ namespace Utils
void openFolderSelect(const QString& absolutePath);
QPoint screenCenter(const QWidget *w);
- QSize smallIconSize();
- QSize largeIconSize();
#endif
#ifdef Q_OS_WIN
diff --git a/src/base/utils/string.cpp b/src/base/utils/string.cpp
index a7a58edf5bf2..c2a592b9ce87 100644
--- a/src/base/utils/string.cpp
+++ b/src/base/utils/string.cpp
@@ -85,7 +85,10 @@ namespace
const QChar leftChar = (m_caseSensitivity == Qt::CaseSensitive) ? left[posL] : left[posL].toLower();
const QChar rightChar = (m_caseSensitivity == Qt::CaseSensitive) ? right[posR] : right[posR].toLower();
- if (leftChar == rightChar) {
+ // Compare only non-digits.
+ // Numbers should be compared as a whole
+ // otherwise the string->int conversion can yield a wrong value
+ if ((leftChar == rightChar) && !leftChar.isDigit()) {
// compare next character
++posL;
++posR;
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 44148b4417ce..d7dfb2ca1917 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -74,6 +74,7 @@ transferlistfilterswidget.h
transferlistsortmodel.h
transferlistwidget.h
updownratiodlg.h
+utils.h
)
set(QBT_GUI_SOURCES
@@ -119,6 +120,7 @@ transferlistfilterswidget.cpp
transferlistsortmodel.cpp
transferlistwidget.cpp
updownratiodlg.cpp
+utils.cpp
)
if (APPLE)
diff --git a/src/gui/about.ui b/src/gui/about.ui
index 4b90eb3523ef..27581c0ca088 100644
--- a/src/gui/about.ui
+++ b/src/gui/about.ui
@@ -18,11 +18,7 @@
-
-
-
-
- :/icons/skin/qbittorrent32.png
-
-
+
-
@@ -57,11 +53,7 @@
-
-
-
- :/icons/skin/mascot.png
-
-
+
-
diff --git a/src/gui/about_imp.h b/src/gui/about_imp.h
index d693bfdd7d0e..0e14854efc43 100644
--- a/src/gui/about_imp.h
+++ b/src/gui/about_imp.h
@@ -31,10 +31,12 @@
#ifndef ABOUT_H
#define ABOUT_H
-#include "ui_about.h"
#include
+
#include "base/utils/misc.h"
#include "base/unicodestrings.h"
+#include "ui_about.h"
+#include "utils.h"
class about: public QDialog, private Ui::AboutDlg
{
@@ -53,13 +55,15 @@ class about: public QDialog, private Ui::AboutDlg
lb_name->setText("
qBittorrent " QBT_VERSION " (32-bit) (Enhanced Edition)
");
#endif
+ logo->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/qbittorrent32.png", this));
+
// About
QString aboutText = QString(
""
"%1\n\n"
"%2\n\n"
"
"
"
")
.arg(tr("An advanced BitTorrent client programmed in C++, based on Qt toolkit and libtorrent-rasterbar."))
- .arg(tr("Copyright %1 2006-2017 The qBittorrent project").arg(QString::fromUtf8(C_COPYRIGHT)))
+ .arg(tr("Copyright %1 2006-2018 The qBittorrent project").arg(QString::fromUtf8(C_COPYRIGHT)))
.arg(tr("Home Page:"))
.arg(tr("Forum:"))
.arg(tr("Bug Tracker:"))
@@ -75,6 +79,8 @@ class about: public QDialog, private Ui::AboutDlg
.arg(tr("Maintainer:"));
lb_about->setText(aboutText);
+ labelMascot->setPixmap(Utils::Gui::scaledPixmap(":/icons/skin/mascot.png", this));
+
// Thanks
QFile thanksfile(":/thanks.html");
if (thanksfile.open(QIODevice::ReadOnly | QIODevice::Text)) {
@@ -101,6 +107,7 @@ class about: public QDialog, private Ui::AboutDlg
label_12->setText(Utils::Misc::libtorrentVersionString());
label_13->setText(Utils::Misc::boostVersionString());
+ Utils::Gui::resize(this);
show();
}
};
diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp
index 39f430363a62..4f2c7250c03e 100644
--- a/src/gui/addnewtorrentdialog.cpp
+++ b/src/gui/addnewtorrentdialog.cpp
@@ -28,36 +28,38 @@
* Contact : chris@qbittorrent.org
*/
+#include "addnewtorrentdialog.h"
+
#include
-#include
#include
-#include
-#include
#include
+#include
#include
+#include
+#include
+#include "autoexpandabledialog.h"
+#include "base/bittorrent/magneturi.h"
+#include "base/bittorrent/session.h"
+#include "base/bittorrent/torrenthandle.h"
+#include "base/bittorrent/torrentinfo.h"
+#include "base/net/downloadhandler.h"
+#include "base/net/downloadmanager.h"
#include "base/preferences.h"
#include "base/settingsstorage.h"
#include "base/settingvalue.h"
-#include "base/net/downloadmanager.h"
-#include "base/net/downloadhandler.h"
-#include "base/bittorrent/session.h"
-#include "base/bittorrent/magneturi.h"
-#include "base/bittorrent/torrentinfo.h"
-#include "base/bittorrent/torrenthandle.h"
+#include "base/torrentfileguard.h"
+#include "base/unicodestrings.h"
#include "base/utils/fs.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
-#include "base/torrentfileguard.h"
-#include "base/unicodestrings.h"
#include "guiiconprovider.h"
-#include "autoexpandabledialog.h"
#include "messageboxraised.h"
#include "proplistdelegate.h"
-#include "torrentcontentmodel.h"
#include "torrentcontentfiltermodel.h"
+#include "torrentcontentmodel.h"
#include "ui_addnewtorrentdialog.h"
-#include "addnewtorrentdialog.h"
+#include "utils.h"
namespace
{
@@ -212,10 +214,11 @@ CachedSettingValue &AddNewTorrentDialog::savePathHistoryLengthSetting()
void AddNewTorrentDialog::loadState()
{
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
- int width = settings()->loadValue(KEY_WIDTH, -1).toInt();
- QSize geo = size();
- geo.setWidth(width);
- resize(geo);
+
+ const QSize newSize = Utils::Gui::scaledSize(this, size());
+ const int width = settings()->loadValue(KEY_WIDTH, newSize.width()).toInt();
+ const int height = newSize.height();
+ resize(width, height);
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
}
diff --git a/src/gui/autoexpandabledialog.cpp b/src/gui/autoexpandabledialog.cpp
index 590989326bb1..c5e9752110ad 100644
--- a/src/gui/autoexpandabledialog.cpp
+++ b/src/gui/autoexpandabledialog.cpp
@@ -32,6 +32,7 @@
#include "mainwindow.h"
#include "ui_autoexpandabledialog.h"
+#include "utils.h"
AutoExpandableDialog::AutoExpandableDialog(QWidget *parent)
: QDialog(parent)
@@ -68,30 +69,29 @@ QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, con
void AutoExpandableDialog::showEvent(QShowEvent *e)
{
// Overriding showEvent is required for consistent UI with fixed size under custom DPI
- // Show dialog
QDialog::showEvent(e);
- // and resize textbox to fit the text
- // NOTE: For some strange reason QFontMetrics gets more accurate
- // when called from showEvent. Only 6 symbols off instead of 11 symbols off.
- int textW = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
- int wd = textW;
+ // Show dialog and resize textbox to fit the text
+ // NOTE: For unknown reason QFontMetrics gets more accurate when called from showEvent.
+ int wd = m_ui->textEdit->fontMetrics().width(m_ui->textEdit->text()) + 4;
if (!windowTitle().isEmpty()) {
- int w = fontMetrics().width(windowTitle());
- if (w > wd)
- wd = w;
+ // not really the font metrics in window title, so we enlarge it a bit,
+ // including the small icon and close button width
+ int w = fontMetrics().width(windowTitle()) * 1.8;
+ wd = std::max(wd, w);
}
if (!m_ui->textLabel->text().isEmpty()) {
int w = m_ui->textLabel->fontMetrics().width(m_ui->textLabel->text());
- if (w > wd)
- wd = w;
+ wd = std::max(wd, w);
}
// Now resize the dialog to fit the contents
// max width of text from either of: label, title, textedit
// If the value is less than dialog default size, default size is used
- if (wd > width())
- resize(width() - m_ui->verticalLayout->sizeHint().width() + wd, height());
+ if (wd > width()) {
+ QSize size = {width() - m_ui->verticalLayout->sizeHint().width() + wd, height()};
+ Utils::Gui::resize(this, size);
+ }
}
diff --git a/src/gui/banlistoptions.cpp b/src/gui/banlistoptions.cpp
index ee009e854e83..71a1be2dddf0 100644
--- a/src/gui/banlistoptions.cpp
+++ b/src/gui/banlistoptions.cpp
@@ -36,6 +36,7 @@
#include "base/bittorrent/session.h"
#include "base/utils/net.h"
#include "ui_banlistoptions.h"
+#include "utils.h"
BanListOptions::BanListOptions(QWidget *parent)
: QDialog(parent)
@@ -52,6 +53,8 @@ BanListOptions::BanListOptions(QWidget *parent)
m_ui->bannedIPList->setModel(m_sortFilter);
m_ui->bannedIPList->sortByColumn(0, Qt::AscendingOrder);
m_ui->buttonBanIP->setEnabled(false);
+
+ Utils::Gui::resize(this);
}
BanListOptions::~BanListOptions()
diff --git a/src/gui/categoryfilterproxymodel.cpp b/src/gui/categoryfilterproxymodel.cpp
index 9c7a724b7da3..d9ba958ca027 100644
--- a/src/gui/categoryfilterproxymodel.cpp
+++ b/src/gui/categoryfilterproxymodel.cpp
@@ -54,8 +54,6 @@ bool CategoryFilterProxyModel::lessThan(const QModelIndex &left, const QModelInd
int result = Utils::String::naturalCompare(left.data().toString(), right.data().toString()
, Qt::CaseInsensitive);
- if (result != 0)
- return (result < 0);
- return (left < right);
+ return (result < 0);
}
diff --git a/src/gui/categoryfilterwidget.cpp b/src/gui/categoryfilterwidget.cpp
index 52669d221de2..efba7085462d 100644
--- a/src/gui/categoryfilterwidget.cpp
+++ b/src/gui/categoryfilterwidget.cpp
@@ -35,11 +35,11 @@
#include
#include "base/bittorrent/session.h"
-#include "base/utils/misc.h"
#include "categoryfiltermodel.h"
#include "categoryfilterproxymodel.h"
#include "guiiconprovider.h"
#include "torrentcategorydialog.h"
+#include "utils.h"
namespace
{
@@ -70,7 +70,7 @@ CategoryFilterWidget::CategoryFilterWidget(QWidget *parent)
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
setUniformRowHeights(true);
setHeaderHidden(true);
- setIconSize(Utils::Misc::smallIconSize());
+ setIconSize(Utils::Gui::smallIconSize());
#ifdef Q_OS_MAC
setAttribute(Qt::WA_MacShowFocusRect, false);
#endif
diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp
index ee6004161cc7..da46fa7c8101 100644
--- a/src/gui/cookiesdialog.cpp
+++ b/src/gui/cookiesdialog.cpp
@@ -35,6 +35,7 @@
#include "cookiesmodel.h"
#include "guiiconprovider.h"
#include "ui_cookiesdialog.h"
+#include "utils.h"
#define SETTINGS_KEY(name) "CookiesDialog/" name
const QString KEY_SIZE = SETTINGS_KEY("Size");
@@ -50,6 +51,8 @@ CookiesDialog::CookiesDialog(QWidget *parent)
setWindowIcon(GuiIconProvider::instance()->getIcon("preferences-web-browser-cookies"));
m_ui->buttonAdd->setIcon(GuiIconProvider::instance()->getIcon("list-add"));
m_ui->buttonDelete->setIcon(GuiIconProvider::instance()->getIcon("list-remove"));
+ m_ui->buttonAdd->setIconSize(Utils::Gui::mediumIconSize());
+ m_ui->buttonDelete->setIconSize(Utils::Gui::mediumIconSize());
m_ui->treeView->setModel(m_cookiesModel);
if (m_cookiesModel->rowCount() > 0)
@@ -57,7 +60,7 @@ CookiesDialog::CookiesDialog(QWidget *parent)
m_cookiesModel->index(0, 0),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
- resize(SettingsStorage::instance()->loadValue(KEY_SIZE, size()).toSize());
+ Utils::Gui::resize(this, SettingsStorage::instance()->loadValue(KEY_SIZE).toSize());
m_ui->treeView->header()->restoreState(
SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray());
}
diff --git a/src/gui/cookiesdialog.ui b/src/gui/cookiesdialog.ui
index 0f08a69d991d..e9d9a768a3e9 100644
--- a/src/gui/cookiesdialog.ui
+++ b/src/gui/cookiesdialog.ui
@@ -49,12 +49,6 @@
-
-
- 20
- 20
-
-
-
@@ -78,12 +72,6 @@
-
-
- 20
- 20
-
-
-
diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h
index 37e7acde1a5b..b369891e0183 100644
--- a/src/gui/deletionconfirmationdlg.h
+++ b/src/gui/deletionconfirmationdlg.h
@@ -33,11 +33,13 @@
#include
#include
-#include "ui_confirmdeletiondlg.h"
+
#include "base/preferences.h"
#include "base/utils/misc.h"
#include "base/utils/string.h"
#include "guiiconprovider.h"
+#include "ui_confirmdeletiondlg.h"
+#include "utils.h"
class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
Q_OBJECT
@@ -50,13 +52,17 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
else
label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size)));
// Icons
- lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height()));
- lbl_warn->setFixedWidth(lbl_warn->height());
+ const QSize iconSize = Utils::Gui::largeIconSize();
+ lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(iconSize));
+ lbl_warn->setFixedWidth(iconSize.width());
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
+ rememberBtn->setIconSize(Utils::Gui::mediumIconSize());
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
+
+ Utils::Gui::resize(this);
}
bool shouldDeleteLocalFiles() const {
diff --git a/src/gui/downloadfromurldlg.h b/src/gui/downloadfromurldlg.h
index 9adbb79360fa..c422b9975844 100644
--- a/src/gui/downloadfromurldlg.h
+++ b/src/gui/downloadfromurldlg.h
@@ -40,6 +40,7 @@
#include
#include "ui_downloadfromurldlg.h"
+#include "utils.h"
class downloadFromURL : public QDialog, private Ui::downloadFromURL
{
@@ -82,6 +83,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL
if (clip_txt_list_cleaned.size() > 0)
textUrls->setText(clip_txt_list_cleaned.join("\n"));
+ Utils::Gui::resize(this);
show();
}
diff --git a/src/gui/fspathedit.cpp b/src/gui/fspathedit.cpp
index b7889763a13e..2f9b0ee7009e 100644
--- a/src/gui/fspathedit.cpp
+++ b/src/gui/fspathedit.cpp
@@ -30,6 +30,7 @@
#include
#include
+#include
#include
#include
#include
@@ -40,6 +41,7 @@
namespace
{
+ const char i18nContext[] = "FileSystemPathEdit";
struct TrStringWithComment
{
const char *source;
@@ -47,18 +49,18 @@ namespace
QString tr() const
{
- return QObject::tr(source, comment);
+ return QCoreApplication::translate(i18nContext, source, comment);
}
};
constexpr TrStringWithComment browseButtonBriefText =
- QT_TRANSLATE_NOOP3("FileSystemPathEdit", "...", "Launch file dialog button text (brief)");
+ QT_TRANSLATE_NOOP3(i18nContext, "...", "Launch file dialog button text (brief)");
constexpr TrStringWithComment browseButtonFullText =
- QT_TRANSLATE_NOOP3("FileSystemPathEdit", "&Browse...", "Launch file dialog button text (full)");
+ QT_TRANSLATE_NOOP3(i18nContext, "&Browse...", "Launch file dialog button text (full)");
constexpr TrStringWithComment defaultDialogCaptionForFile =
- QT_TRANSLATE_NOOP3("FileSystemPathEdit", "Choose a file", "Caption for file open/save dialog");
+ QT_TRANSLATE_NOOP3(i18nContext, "Choose a file", "Caption for file open/save dialog");
constexpr TrStringWithComment defaultDialogCaptionForDirectory =
- QT_TRANSLATE_NOOP3("FileSystemPathEdit", "Choose a folder", "Caption for directory open dialog");
+ QT_TRANSLATE_NOOP3(i18nContext, "Choose a folder", "Caption for directory open dialog");
}
class FileSystemPathEdit::FileSystemPathEditPrivate
@@ -154,7 +156,9 @@ void FileSystemPathEdit::FileSystemPathEditPrivate::modeChanged()
switch (m_mode) {
case FileSystemPathEdit::Mode::FileOpen:
case FileSystemPathEdit::Mode::FileSave:
- pixmap = QStyle::SP_DialogOpenButton;
+#ifdef Q_OS_WIN
+ pixmap = QStyle::SP_DirOpenIcon;
+#endif
showDirsOnly = false;
break;
case FileSystemPathEdit::Mode::DirectoryOpen:
diff --git a/src/gui/gpl.html b/src/gui/gpl.html
index 4400ed8e1ad2..cec3fa8b9550 100644
--- a/src/gui/gpl.html
+++ b/src/gui/gpl.html
@@ -426,6 +426,92 @@