@ -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_W S_MAC
# ifdef Q_O S_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_W S_MAC)
# if defined(Q_OS_WIN) || defined(Q_O S_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_W S_MAC
# ifdef Q_O S_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_W S_MAC)
# if defined(Q_OS_WIN) || defined(Q_O S_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_W S_MAC
# ifdef Q_O S_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_W S_WIN
# ifdef Q_O S_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. \n Do 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. \n Do 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_W S_MAC
# ifdef Q_O S_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_W S_MAC
# ifdef Q_O S_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_W S_MAC
# ifdef Q_O S_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_W S_MAC
# ifdef Q_O S_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_W S_MAC)
# if defined(Q_OS_WIN) || defined(Q_O S_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_W S_MAC)
# if defined(Q_OS_WIN) || defined(Q_O S_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_W S_MAC)
# if defined(Q_OS_WIN) || defined(Q_O S_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 ) ;