Some work about adaptive color scheme for Web UI (PR #19901)
http://[316:c51a:62a3:8b9::4]/d4708/qBittorrent/src/branch/adaptive-webui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1261 lines
47 KiB
1261 lines
47 KiB
18 years ago
|
/*
|
||
|
* Bittorrent Client using Qt4 and libtorrent.
|
||
18 years ago
|
* Copyright (C) 2006 Christophe Dumez
|
||
18 years ago
|
*
|
||
18 years ago
|
* This program is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU General Public License
|
||
|
* as published by the Free Software Foundation; either version 2
|
||
|
* of the License, or (at your option) any later version.
|
||
18 years ago
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
18 years ago
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
16 years ago
|
* In addition, as a special exception, the copyright holders give permission to
|
||
|
* link this program with the OpenSSL project's "OpenSSL" library (or with
|
||
|
* modified versions of it that use the same license as the "OpenSSL" library),
|
||
|
* and distribute the linked executables. You must obey the GNU General Public
|
||
|
* License in all respects for all of the code used other than "OpenSSL". If you
|
||
|
* modify file(s), you may extend this exception to your version of the file(s),
|
||
|
* but you are not obligated to do so. If you do not wish to do so, delete this
|
||
|
* exception statement from your version.
|
||
|
*
|
||
18 years ago
|
* Contact : chris@qbittorrent.org
|
||
18 years ago
|
*/
|
||
15 years ago
|
#ifdef WITH_LIBNOTIFY
|
||
|
#include <glib.h>
|
||
|
#include <unistd.h>
|
||
|
#include <libnotify/notify.h>
|
||
|
#endif
|
||
|
|
||
18 years ago
|
#include <QFileDialog>
|
||
14 years ago
|
#include <QFileSystemWatcher>
|
||
18 years ago
|
#include <QMessageBox>
|
||
|
#include <QTimer>
|
||
18 years ago
|
#include <QDesktopServices>
|
||
17 years ago
|
#include <QStatusBar>
|
||
15 years ago
|
#include <QClipboard>
|
||
18 years ago
|
#include <QCloseEvent>
|
||
18 years ago
|
#include <QShortcut>
|
||
14 years ago
|
#include <QScrollBar>
|
||
18 years ago
|
|
||
14 years ago
|
#include "mainwindow.h"
|
||
15 years ago
|
#include "transferlistwidget.h"
|
||
18 years ago
|
#include "misc.h"
|
||
14 years ago
|
#include "torrentcreatordlg.h"
|
||
15 years ago
|
#include "downloadfromurldlg.h"
|
||
|
#include "torrentadditiondlg.h"
|
||
|
#include "searchengine.h"
|
||
18 years ago
|
#include "rss_imp.h"
|
||
14 years ago
|
#include "qbtsession.h"
|
||
18 years ago
|
#include "about_imp.h"
|
||
15 years ago
|
#include "trackerlogin.h"
|
||
18 years ago
|
#include "options_imp.h"
|
||
15 years ago
|
#include "speedlimitdlg.h"
|
||
15 years ago
|
#include "preferences.h"
|
||
16 years ago
|
#include "console_imp.h"
|
||
15 years ago
|
#include "trackerlist.h"
|
||
|
#include "peerlistwidget.h"
|
||
15 years ago
|
#include "torrentpersistentdata.h"
|
||
|
#include "transferlistfilterswidget.h"
|
||
15 years ago
|
#include "propertieswidget.h"
|
||
15 years ago
|
#include "statusbar.h"
|
||
15 years ago
|
#include "hidabletabwidget.h"
|
||
15 years ago
|
#include "qinisettings.h"
|
||
14 years ago
|
#include "torrentimportdlg.h"
|
||
14 years ago
|
#include "rsssettings.h"
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
|
#include "qmacapplication.h"
|
||
15 years ago
|
void qt_mac_set_dock_menu(QMenu *menu);
|
||
15 years ago
|
#endif
|
||
14 years ago
|
#include "lineedit.h"
|
||
14 years ago
|
#include "sessionapplication.h"
|
||
14 years ago
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||
|
#include "programupdater.h"
|
||
|
#endif
|
||
18 years ago
|
|
||
17 years ago
|
using namespace libtorrent;
|
||
|
|
||
15 years ago
|
#define TIME_TRAY_BALLOON 5000
|
||
|
|
||
18 years ago
|
/*****************************************************
|
||
|
* *
|
||
|
* GUI *
|
||
|
* *
|
||
|
*****************************************************/
|
||
|
|
||
|
// Constructor
|
||
14 years ago
|
MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), force_exit(false) {
|
||
18 years ago
|
setupUi(this);
|
||
14 years ago
|
ui_locked = Preferences::isUILocked();
|
||
15 years ago
|
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
|
||
15 years ago
|
displaySpeedInTitle = Preferences::speedInTitleBar();
|
||
14 years ago
|
// Clean exit on log out
|
||
|
connect(static_cast<SessionApplication*>(qApp), SIGNAL(sessionIsShuttingDown()), this, SLOT(deleteBTSession()));
|
||
18 years ago
|
// Setting icons
|
||
16 years ago
|
this->setWindowIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")));
|
||
18 years ago
|
actionOpen->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/open.png")));
|
||
|
actionExit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/exit.png")));
|
||
|
actionDownload_from_URL->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/url.png")));
|
||
|
actionOptions->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/settings.png")));
|
||
|
actionAbout->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/info.png")));
|
||
16 years ago
|
actionWebsite->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent32.png")));
|
||
16 years ago
|
actionBugReport->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/bug.png")));
|
||
18 years ago
|
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png")));
|
||
|
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png")));
|
||
|
actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
|
||
|
actionPause_All->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause_all.png")));
|
||
|
actionStart_All->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play_all.png")));
|
||
|
actionClearLog->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
|
||
|
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
|
||
18 years ago
|
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
||
15 years ago
|
actionSet_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/download.png")));
|
||
18 years ago
|
actionSet_global_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png")));
|
||
15 years ago
|
actionSet_global_download_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/download.png")));
|
||
18 years ago
|
actionDocumentation->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/qb_question.png")));
|
||
14 years ago
|
actionLock_qBittorrent->setIcon(QIcon(QString::fromUtf8(":/Icons/oxygen/encrypted32.png")));
|
||
14 years ago
|
lockMenu = new QMenu();
|
||
14 years ago
|
QAction *defineUiLockPasswdAct = lockMenu->addAction(tr("Set the password..."));
|
||
|
connect(defineUiLockPasswdAct, SIGNAL(triggered()), this, SLOT(defineUILockPassword()));
|
||
|
actionLock_qBittorrent->setMenu(lockMenu);
|
||
16 years ago
|
prioSeparator = toolBar->insertSeparator(actionDecreasePriority);
|
||
|
prioSeparator2 = menu_Edit->insertSeparator(actionDecreasePriority);
|
||
|
prioSeparator->setVisible(false);
|
||
|
prioSeparator2->setVisible(false);
|
||
18 years ago
|
actionCreate_torrent->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/new.png")));
|
||
|
// Fix Tool bar layout
|
||
|
toolBar->layout()->setSpacing(7);
|
||
15 years ago
|
// Creating Bittorrent session
|
||
14 years ago
|
BTSession = QBtSession::instance();
|
||
16 years ago
|
connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&, QString)), this, SLOT(fullDiskError(QTorrentHandle&, QString)));
|
||
17 years ago
|
connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&)));
|
||
17 years ago
|
connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&)));
|
||
18 years ago
|
connect(BTSession, SIGNAL(newDownloadedTorrent(QString, QString)), this, SLOT(processDownloadedFiles(QString, QString)));
|
||
|
connect(BTSession, SIGNAL(downloadFromUrlFailure(QString, QString)), this, SLOT(handleDownloadFromUrlFailure(QString, QString)));
|
||
15 years ago
|
connect(BTSession, SIGNAL(alternativeSpeedsModeChanged(bool)), this, SLOT(updateAltSpeedsBtn(bool)));
|
||
15 years ago
|
connect(BTSession, SIGNAL(recursiveTorrentDownloadPossible(QTorrentHandle&)), this, SLOT(askRecursiveTorrentDownloadConfirmation(QTorrentHandle&)));
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
15 years ago
|
connect(static_cast<QMacApplication*>(qApp), SIGNAL(newFileOpenMacEvent(QString)), this, SLOT(processParams(QString)));
|
||
15 years ago
|
#endif
|
||
15 years ago
|
|
||
17 years ago
|
qDebug("create tabWidget");
|
||
15 years ago
|
tabs = new HidableTabWidget();
|
||
15 years ago
|
connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tab_changed(int)));
|
||
15 years ago
|
vSplitter = new QSplitter(Qt::Horizontal);
|
||
15 years ago
|
//vSplitter->setChildrenCollapsible(false);
|
||
15 years ago
|
hSplitter = new QSplitter(Qt::Vertical);
|
||
15 years ago
|
hSplitter->setChildrenCollapsible(false);
|
||
15 years ago
|
|
||
15 years ago
|
// Transfer List tab
|
||
15 years ago
|
transferList = new TransferListWidget(hSplitter, this, BTSession);
|
||
14 years ago
|
properties = new PropertiesWidget(hSplitter, this, transferList);
|
||
15 years ago
|
transferListFilters = new TransferListFiltersWidget(vSplitter, transferList);
|
||
15 years ago
|
hSplitter->addWidget(transferList);
|
||
|
hSplitter->addWidget(properties);
|
||
15 years ago
|
vSplitter->addWidget(transferListFilters);
|
||
15 years ago
|
vSplitter->addWidget(hSplitter);
|
||
15 years ago
|
vSplitter->setCollapsible(0, true);
|
||
|
vSplitter->setCollapsible(1, false);
|
||
15 years ago
|
tabs->addTab(vSplitter, QIcon(QString::fromUtf8(":/Icons/oxygen/folder-remote.png")), tr("Transfers"));
|
||
15 years ago
|
connect(transferList, SIGNAL(torrentStatusUpdate(uint,uint,uint,uint,uint)), this, SLOT(updateNbTorrents(uint,uint,uint,uint,uint)));
|
||
16 years ago
|
vboxLayout->addWidget(tabs);
|
||
15 years ago
|
|
||
14 years ago
|
// Name filter
|
||
|
search_filter = new LineEdit();
|
||
14 years ago
|
QAction *separatorBFSearch = toolBar->insertSeparator(actionLock_qBittorrent);
|
||
|
toolBar->insertWidget(separatorBFSearch, search_filter);
|
||
14 years ago
|
search_filter->setFixedWidth(200);
|
||
|
connect(search_filter, SIGNAL(textChanged(QString)), transferList, SLOT(applyNameFilter(QString)));
|
||
|
|
||
15 years ago
|
// Transfer list slots
|
||
|
connect(actionStart, SIGNAL(triggered()), transferList, SLOT(startSelectedTorrents()));
|
||
|
connect(actionStart_All, SIGNAL(triggered()), transferList, SLOT(startAllTorrents()));
|
||
|
connect(actionPause, SIGNAL(triggered()), transferList, SLOT(pauseSelectedTorrents()));
|
||
|
connect(actionPause_All, SIGNAL(triggered()), transferList, SLOT(pauseAllTorrents()));
|
||
|
connect(actionDelete, SIGNAL(triggered()), transferList, SLOT(deleteSelectedTorrents()));
|
||
|
connect(actionIncreasePriority, SIGNAL(triggered()), transferList, SLOT(increasePrioSelectedTorrents()));
|
||
|
connect(actionDecreasePriority, SIGNAL(triggered()), transferList, SLOT(decreasePrioSelectedTorrents()));
|
||
|
|
||
16 years ago
|
// Configure BT session according to options
|
||
15 years ago
|
loadPreferences(false);
|
||
15 years ago
|
|
||
15 years ago
|
// Start connection checking timer
|
||
15 years ago
|
guiUpdater = new QTimer(this);
|
||
|
connect(guiUpdater, SIGNAL(timeout()), this, SLOT(updateGUI()));
|
||
|
guiUpdater->start(2000);
|
||
15 years ago
|
// Accept drag 'n drops
|
||
|
setAcceptDrops(true);
|
||
|
createKeyboardShortcuts();
|
||
15 years ago
|
// Create status bar
|
||
14 years ago
|
status_bar = new StatusBar(QMainWindow::statusBar());
|
||
14 years ago
|
connect(status_bar->connectionStatusButton(), SIGNAL(clicked()), SLOT(showConnectionSettings()));
|
||
15 years ago
|
connect(actionUse_alternative_speed_limits, SIGNAL(triggered()), status_bar, SLOT(toggleAlternativeSpeeds()));
|
||
15 years ago
|
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
|
setUnifiedTitleAndToolBarOnMac(true);
|
||
|
#endif
|
||
|
|
||
15 years ago
|
// View settings
|
||
|
actionTop_tool_bar->setChecked(Preferences::isToolbarDisplayed());
|
||
|
actionSpeed_in_title_bar->setChecked(Preferences::speedInTitleBar());
|
||
14 years ago
|
actionRSS_Reader->setChecked(RssSettings::isRSSEnabled());
|
||
15 years ago
|
actionSearch_engine->setChecked(Preferences::isSearchEnabled());
|
||
15 years ago
|
displaySearchTab(actionSearch_engine->isChecked());
|
||
|
displayRSSTab(actionRSS_Reader->isChecked());
|
||
14 years ago
|
actionShutdown_when_downloads_complete->setChecked(Preferences::shutdownWhenDownloadsComplete());
|
||
14 years ago
|
actionShutdown_qBittorrent_when_downloads_complete->setChecked(Preferences::shutdownqBTWhenDownloadsComplete());
|
||
15 years ago
|
|
||
15 years ago
|
show();
|
||
15 years ago
|
|
||
|
// Load Window state and sizes
|
||
|
readSettings();
|
||
15 years ago
|
properties->readSettings();
|
||
15 years ago
|
|
||
15 years ago
|
// Limit status filters list height
|
||
14 years ago
|
transferListFilters->getStatusFilters()->updateHeight();
|
||
15 years ago
|
|
||
14 years ago
|
if(ui_locked) {
|
||
|
hide();
|
||
|
} else {
|
||
|
if(Preferences::startMinimized())
|
||
|
showMinimized();
|
||
15 years ago
|
}
|
||
15 years ago
|
|
||
14 years ago
|
// Start watching the executable for updates
|
||
|
executable_watcher = new QFileSystemWatcher();
|
||
|
connect(executable_watcher, SIGNAL(fileChanged(QString)), this, SLOT(notifyOfUpdate(QString)));
|
||
|
executable_watcher->addPath(qApp->applicationFilePath());
|
||
|
|
||
14 years ago
|
// Resume unfinished torrents
|
||
|
BTSession->startUpTorrents();
|
||
|
// Add torrent given on command line
|
||
|
processParams(torrentCmdLine);
|
||
|
|
||
15 years ago
|
qDebug("GUI Built");
|
||
15 years ago
|
#ifdef Q_WS_WIN
|
||
15 years ago
|
if(!Preferences::neverCheckFileAssoc() && !Preferences::isFileAssocOk()) {
|
||
15 years ago
|
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?"),
|
||
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
|
||
|
Preferences::setFileAssoc();
|
||
|
} else {
|
||
|
Preferences::setNeverCheckFileAssoc();
|
||
|
}
|
||
15 years ago
|
}
|
||
|
#endif
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
|
qt_mac_set_dock_menu(getTrayIconMenu());
|
||
|
#endif
|
||
14 years ago
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||
|
// Check for update
|
||
|
ProgramUpdater *updater = new ProgramUpdater(this);
|
||
|
connect(updater, SIGNAL(updateCheckFinished(bool, QString)), SLOT(handleUpdateCheckFinished(bool, QString)));
|
||
|
updater->checkForUpdates();
|
||
|
#endif
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::deleteBTSession() {
|
||
14 years ago
|
guiUpdater->stop();
|
||
|
status_bar->stopTimer();
|
||
|
if(BTSession) {
|
||
|
delete BTSession;
|
||
|
BTSession = 0;
|
||
|
}
|
||
|
QTimer::singleShot(0, this, SLOT(close()));
|
||
|
}
|
||
|
|
||
15 years ago
|
// Destructor
|
||
14 years ago
|
MainWindow::~MainWindow() {
|
||
15 years ago
|
qDebug("GUI destruction");
|
||
|
hide();
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
|
// Workaround to avoid bug http://bugreports.qt.nokia.com/browse/QTBUG-7305
|
||
15 years ago
|
setUnifiedTitleAndToolBarOnMac(false);
|
||
15 years ago
|
#endif
|
||
15 years ago
|
// Some saving
|
||
|
properties->saveSettings();
|
||
|
disconnect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tab_changed(int)));
|
||
15 years ago
|
// Delete other GUI objects
|
||
14 years ago
|
if(executable_watcher)
|
||
|
delete executable_watcher;
|
||
15 years ago
|
delete status_bar;
|
||
14 years ago
|
delete search_filter;
|
||
15 years ago
|
delete transferList;
|
||
|
delete guiUpdater;
|
||
14 years ago
|
delete lockMenu;
|
||
15 years ago
|
if(createTorrentDlg)
|
||
|
delete createTorrentDlg;
|
||
|
if(console)
|
||
15 years ago
|
delete console;
|
||
15 years ago
|
if(aboutDlg)
|
||
|
delete aboutDlg;
|
||
15 years ago
|
if(options)
|
||
|
delete options;
|
||
15 years ago
|
if(downloadFromURLDialog)
|
||
|
delete downloadFromURLDialog;
|
||
15 years ago
|
if(rssWidget)
|
||
15 years ago
|
delete rssWidget;
|
||
15 years ago
|
if(searchEngine)
|
||
|
delete searchEngine;
|
||
15 years ago
|
delete transferListFilters;
|
||
15 years ago
|
delete properties;
|
||
|
delete hSplitter;
|
||
15 years ago
|
delete vSplitter;
|
||
15 years ago
|
if(systrayCreator) {
|
||
|
delete systrayCreator;
|
||
|
}
|
||
15 years ago
|
if(systrayIcon) {
|
||
|
delete systrayIcon;
|
||
15 years ago
|
}
|
||
|
if(myTrayIconMenu) {
|
||
15 years ago
|
delete myTrayIconMenu;
|
||
|
}
|
||
|
delete tabs;
|
||
|
// Keyboard shortcuts
|
||
|
delete switchSearchShortcut;
|
||
|
delete switchSearchShortcut2;
|
||
15 years ago
|
delete switchTransferShortcut;
|
||
15 years ago
|
delete switchRSSShortcut;
|
||
15 years ago
|
// Delete BTSession objects
|
||
14 years ago
|
qDebug("Deleting BTSession");
|
||
14 years ago
|
QBtSession::drop();
|
||
15 years ago
|
// May freeze for a few seconds after the next line
|
||
|
// because the Bittorrent session proxy will
|
||
|
// actually be deleted now and destruction
|
||
|
// becomes synchronous
|
||
|
qDebug("Exiting GUI destructor...");
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::defineUILockPassword() {
|
||
14 years ago
|
QString old_pass_md5 = Preferences::getUILockPasswordMD5();
|
||
|
if(old_pass_md5.isNull()) old_pass_md5 = "";
|
||
|
bool ok = false;
|
||
14 years ago
|
QString new_clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, old_pass_md5, &ok);
|
||
14 years ago
|
if(ok) {
|
||
|
if(new_clear_password != old_pass_md5) {
|
||
|
Preferences::setUILockPassword(new_clear_password);
|
||
|
}
|
||
|
QMessageBox::information(this, tr("Password update"), tr("The UI lock password has been successfully updated"));
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionLock_qBittorrent_triggered() {
|
||
14 years ago
|
// Check if there is a password
|
||
|
if(Preferences::getUILockPasswordMD5().isEmpty()) {
|
||
|
// Ask for a password
|
||
|
bool ok = false;
|
||
14 years ago
|
QString clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok);
|
||
14 years ago
|
if(!ok) return;
|
||
|
Preferences::setUILockPassword(clear_password);
|
||
|
}
|
||
|
// Lock the interface
|
||
|
ui_locked = true;
|
||
|
Preferences::setUILocked(true);
|
||
14 years ago
|
myTrayIconMenu->setEnabled(false);
|
||
14 years ago
|
hide();
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::displayRSSTab(bool enable) {
|
||
15 years ago
|
if(enable) {
|
||
|
// RSS tab
|
||
15 years ago
|
if(!rssWidget) {
|
||
14 years ago
|
rssWidget = new RSSImp(tabs);
|
||
15 years ago
|
int index_tab = tabs->addTab(rssWidget, tr("RSS"));
|
||
|
tabs->setTabIcon(index_tab, QIcon(QString::fromUtf8(":/Icons/rss32.png")));
|
||
15 years ago
|
}
|
||
15 years ago
|
tabs->showTabBar(true);
|
||
15 years ago
|
} else {
|
||
15 years ago
|
if(rssWidget) {
|
||
17 years ago
|
delete rssWidget;
|
||
15 years ago
|
}
|
||
15 years ago
|
if(!searchEngine)
|
||
|
tabs->showTabBar(false);
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::displaySearchTab(bool enable) {
|
||
15 years ago
|
if(enable) {
|
||
|
// RSS tab
|
||
|
if(!searchEngine) {
|
||
14 years ago
|
searchEngine = new SearchEngine(this);
|
||
15 years ago
|
tabs->insertTab(1, searchEngine, QIcon(QString::fromUtf8(":/Icons/oxygen/edit-find.png")), tr("Search"));
|
||
|
}
|
||
15 years ago
|
tabs->showTabBar(true);
|
||
15 years ago
|
} else {
|
||
|
if(searchEngine) {
|
||
|
delete searchEngine;
|
||
|
}
|
||
15 years ago
|
if(!rssWidget)
|
||
|
tabs->showTabBar(false);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::updateNbTorrents(unsigned int nb_downloading, unsigned int nb_seeding, unsigned int nb_active, unsigned int nb_inactive, unsigned int nb_paused) {
|
||
15 years ago
|
Q_UNUSED(nb_downloading);
|
||
|
Q_UNUSED(nb_seeding);
|
||
15 years ago
|
Q_UNUSED(nb_paused);
|
||
15 years ago
|
tabs->setTabText(0, tr("Transfers (%1)").arg(QString::number(nb_inactive+nb_active)));
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionWebsite_triggered() const {
|
||
15 years ago
|
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://www.qbittorrent.org")));
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionDocumentation_triggered() const {
|
||
15 years ago
|
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://doc.qbittorrent.org")));
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionBugReport_triggered() const {
|
||
15 years ago
|
QDesktopServices::openUrl(QUrl(QString::fromUtf8("http://bugs.qbittorrent.org")));
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::tab_changed(int new_tab) {
|
||
15 years ago
|
Q_UNUSED(new_tab);
|
||
|
// We cannot rely on the index new_tab
|
||
|
// because the tab order is undetermined now
|
||
|
if(tabs->currentWidget() == vSplitter) {
|
||
15 years ago
|
qDebug("Changed tab to transfer list, refreshing the list");
|
||
|
transferList->refreshList();
|
||
|
properties->loadDynamicData();
|
||
15 years ago
|
return;
|
||
|
}
|
||
|
if(tabs->currentWidget() == searchEngine) {
|
||
|
qDebug("Changed tab to search engine, giving focus to search input");
|
||
|
searchEngine->giveFocusToSearchInput();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::writeSettings() {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
settings.beginGroup(QString::fromUtf8("MainWindow"));
|
||
15 years ago
|
settings.setValue("geometry", saveGeometry());
|
||
15 years ago
|
// Splitter size
|
||
|
QStringList sizes_str;
|
||
|
sizes_str << QString::number(vSplitter->sizes().first());
|
||
|
sizes_str << QString::number(vSplitter->sizes().last());
|
||
|
settings.setValue(QString::fromUtf8("vSplitterSizes"), sizes_str);
|
||
15 years ago
|
settings.endGroup();
|
||
|
}
|
||
|
|
||
|
// called when a torrent has finished
|
||
14 years ago
|
void MainWindow::finishedTorrent(QTorrentHandle& h) const {
|
||
15 years ago
|
if(!TorrentPersistentData::isSeed(h.hash()))
|
||
|
showNotificationBaloon(tr("Download completion"), tr("%1 has finished downloading.", "e.g: xxx.avi has finished downloading.").arg(h.name()));
|
||
15 years ago
|
}
|
||
|
|
||
|
// Notification when disk is full
|
||
14 years ago
|
void MainWindow::fullDiskError(QTorrentHandle& h, QString msg) const {
|
||
15 years ago
|
if(!h.is_valid()) return;
|
||
|
showNotificationBaloon(tr("I/O Error", "i.e: Input/Output Error"), tr("An I/O error occured for torrent %1.\n Reason: %2", "e.g: An error occured for torrent xxx.avi.\n Reason: disk is full.").arg(h.name()).arg(msg));
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::createKeyboardShortcuts() {
|
||
15 years ago
|
actionCreate_torrent->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+N")));
|
||
|
actionOpen->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+O")));
|
||
|
actionExit->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Q")));
|
||
15 years ago
|
switchTransferShortcut = new QShortcut(QKeySequence(tr("Alt+1", "shortcut to switch to first tab")), this);
|
||
|
connect(switchTransferShortcut, SIGNAL(activated()), this, SLOT(displayTransferTab()));
|
||
15 years ago
|
switchSearchShortcut = new QShortcut(QKeySequence(tr("Alt+2", "shortcut to switch to third tab")), this);
|
||
15 years ago
|
connect(switchSearchShortcut, SIGNAL(activated()), this, SLOT(displaySearchTab()));
|
||
|
switchSearchShortcut2 = new QShortcut(QKeySequence(tr("Ctrl+F", "shortcut to switch to search tab")), this);
|
||
|
connect(switchSearchShortcut2, SIGNAL(activated()), this, SLOT(displaySearchTab()));
|
||
15 years ago
|
switchRSSShortcut = new QShortcut(QKeySequence(tr("Alt+3", "shortcut to switch to fourth tab")), this);
|
||
15 years ago
|
connect(switchRSSShortcut, SIGNAL(activated()), this, SLOT(displayRSSTab()));
|
||
15 years ago
|
actionDocumentation->setShortcut(QKeySequence("F1"));
|
||
15 years ago
|
actionOptions->setShortcut(QKeySequence(QString::fromUtf8("Alt+O")));
|
||
|
actionDelete->setShortcut(QKeySequence(QString::fromUtf8("Del")));
|
||
|
actionStart->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+S")));
|
||
|
actionStart_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+S")));
|
||
|
actionPause->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+P")));
|
||
|
actionPause_All->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+Shift+P")));
|
||
|
actionDecreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl+-")));
|
||
|
actionIncreasePriority->setShortcut(QKeySequence(QString::fromUtf8("Ctrl++")));
|
||
|
}
|
||
|
|
||
|
// Keyboard shortcuts slots
|
||
14 years ago
|
void MainWindow::displayTransferTab() const {
|
||
15 years ago
|
tabs->setCurrentWidget(transferList);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::displaySearchTab() const {
|
||
15 years ago
|
if(searchEngine)
|
||
|
tabs->setCurrentWidget(searchEngine);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::displayRSSTab() const {
|
||
15 years ago
|
if(rssWidget)
|
||
|
tabs->setCurrentWidget(rssWidget);
|
||
15 years ago
|
}
|
||
|
|
||
|
// End of keyboard shortcuts slots
|
||
|
|
||
14 years ago
|
void MainWindow::readSettings() {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
settings.beginGroup(QString::fromUtf8("MainWindow"));
|
||
15 years ago
|
restoreGeometry(settings.value("geometry").toByteArray());
|
||
15 years ago
|
const QStringList sizes_str = settings.value("vSplitterSizes", QStringList()).toStringList();
|
||
15 years ago
|
// Splitter size
|
||
|
QList<int> sizes;
|
||
|
if(sizes_str.size() == 2) {
|
||
|
sizes << sizes_str.first().toInt();
|
||
|
sizes << sizes_str.last().toInt();
|
||
|
} else {
|
||
|
qDebug("Default splitter size");
|
||
|
sizes << 120;
|
||
|
sizes << vSplitter->width()-120;
|
||
|
}
|
||
|
vSplitter->setSizes(sizes);
|
||
15 years ago
|
settings.endGroup();
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::balloonClicked() {
|
||
15 years ago
|
if(isHidden()) {
|
||
|
show();
|
||
|
if(isMinimized()) {
|
||
|
showNormal();
|
||
16 years ago
|
}
|
||
15 years ago
|
raise();
|
||
|
activateWindow();
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::askRecursiveTorrentDownloadConfirmation(QTorrentHandle &h) {
|
||
15 years ago
|
if(Preferences::recursiveDownloadDisabled()) return;
|
||
|
QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent %1 contains torrent files, do you want to proceed with their download?").arg(h.name()));
|
||
|
QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
|
||
|
/*QPushButton *no = */confirmBox.addButton(tr("No"), QMessageBox::NoRole);
|
||
14 years ago
|
QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole);
|
||
|
confirmBox.exec();
|
||
|
if(confirmBox.clickedButton() == 0) return;
|
||
|
if(confirmBox.clickedButton() == yes) {
|
||
|
BTSession->recursiveTorrentDownload(h);
|
||
|
return;
|
||
|
}
|
||
|
if(confirmBox.clickedButton() == never) {
|
||
|
Preferences::disableRecursiveDownload();
|
||
|
}
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const{
|
||
15 years ago
|
// Display a message box
|
||
14 years ago
|
showNotificationBaloon(tr("Url download error"), tr("Couldn't download file at url: %1, reason: %2.").arg(url).arg(reason));
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionSet_global_upload_limit_triggered() {
|
||
15 years ago
|
qDebug("actionSet_global_upload_limit_triggered");
|
||
15 years ago
|
bool ok;
|
||
15 years ago
|
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Upload Speed Limit"), BTSession->getSession()->upload_rate_limit());
|
||
15 years ago
|
if(ok) {
|
||
|
qDebug("Setting global upload rate limit to %.1fKb/s", new_limit/1024.);
|
||
|
BTSession->getSession()->set_upload_rate_limit(new_limit);
|
||
|
if(new_limit <= 0)
|
||
|
Preferences::setGlobalUploadLimit(-1);
|
||
|
else
|
||
|
Preferences::setGlobalUploadLimit(new_limit/1024.);
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionShow_console_triggered() {
|
||
15 years ago
|
if(!console) {
|
||
14 years ago
|
console = new consoleDlg(this);
|
||
15 years ago
|
} else {
|
||
|
console->setFocus();
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionSet_global_download_limit_triggered() {
|
||
15 years ago
|
qDebug("actionSet_global_download_limit_triggered");
|
||
15 years ago
|
bool ok;
|
||
15 years ago
|
const long new_limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Global Download Speed Limit"), BTSession->getSession()->download_rate_limit());
|
||
15 years ago
|
if(ok) {
|
||
|
qDebug("Setting global download rate limit to %.1fKb/s", new_limit/1024.);
|
||
|
BTSession->getSession()->set_download_rate_limit(new_limit);
|
||
|
if(new_limit <= 0)
|
||
|
Preferences::setGlobalDownloadLimit(-1);
|
||
|
else
|
||
|
Preferences::setGlobalDownloadLimit(new_limit/1024.);
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
// Necessary if we want to close the window
|
||
|
// in one time if "close to systray" is enabled
|
||
14 years ago
|
void MainWindow::on_actionExit_triggered() {
|
||
15 years ago
|
force_exit = true;
|
||
|
close();
|
||
|
}
|
||
|
|
||
14 years ago
|
QWidget* MainWindow::getCurrentTabWidget() const {
|
||
15 years ago
|
if(isMinimized() || !isVisible())
|
||
15 years ago
|
return 0;
|
||
|
if(tabs->currentIndex() == 0)
|
||
|
return transferList;
|
||
|
return tabs->currentWidget();
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::setTabText(int index, QString text) const {
|
||
15 years ago
|
tabs->setTabText(index, text);
|
||
|
}
|
||
|
|
||
14 years ago
|
bool MainWindow::unlockUI() {
|
||
14 years ago
|
bool ok = false;
|
||
|
QString clear_password = QInputDialog::getText(this, tr("UI lock password"), tr("Please type the UI lock password:"), QLineEdit::Password, "", &ok);
|
||
|
if(!ok) return false;
|
||
|
QString real_pass_md5 = Preferences::getUILockPasswordMD5();
|
||
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
||
|
md5.addData(clear_password.toLocal8Bit());
|
||
|
QString password_md5 = md5.result().toHex();
|
||
|
if(real_pass_md5 == password_md5) {
|
||
|
ui_locked = false;
|
||
|
Preferences::setUILocked(false);
|
||
14 years ago
|
myTrayIconMenu->setEnabled(true);
|
||
14 years ago
|
return true;
|
||
|
}
|
||
|
QMessageBox::warning(this, tr("Invalid password"), tr("The password is invalid"));
|
||
|
return false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::notifyOfUpdate(QString) {
|
||
14 years ago
|
// Show restart message
|
||
|
status_bar->showRestartRequired();
|
||
|
// Delete the executable watcher
|
||
|
delete executable_watcher;
|
||
|
executable_watcher = 0;
|
||
|
}
|
||
|
|
||
15 years ago
|
// Toggle Main window visibility
|
||
14 years ago
|
void MainWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e) {
|
||
15 years ago
|
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick) {
|
||
15 years ago
|
if(isHidden()) {
|
||
14 years ago
|
if(ui_locked) {
|
||
|
// Ask for UI lock password
|
||
|
if(!unlockUI())
|
||
|
return;
|
||
|
}
|
||
18 years ago
|
show();
|
||
17 years ago
|
if(isMinimized()) {
|
||
15 years ago
|
if(isMaximized()) {
|
||
|
showMaximized();
|
||
|
}else{
|
||
|
showNormal();
|
||
|
}
|
||
18 years ago
|
}
|
||
|
raise();
|
||
|
activateWindow();
|
||
15 years ago
|
}else{
|
||
|
hide();
|
||
15 years ago
|
}
|
||
18 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
// Display About Dialog
|
||
14 years ago
|
void MainWindow::on_actionAbout_triggered() {
|
||
15 years ago
|
//About dialog
|
||
15 years ago
|
if(aboutDlg) {
|
||
|
aboutDlg->setFocus();
|
||
|
} else {
|
||
|
aboutDlg = new about(this);
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::showEvent(QShowEvent *e) {
|
||
15 years ago
|
qDebug("** Show Event **");
|
||
15 years ago
|
if(getCurrentTabWidget() == transferList) {
|
||
15 years ago
|
qDebug("-> Refreshing transfer list");
|
||
|
transferList->refreshList();
|
||
|
properties->loadDynamicData();
|
||
|
}
|
||
15 years ago
|
e->accept();
|
||
|
}
|
||
|
|
||
|
// Called when we close the program
|
||
14 years ago
|
void MainWindow::closeEvent(QCloseEvent *e) {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
const bool goToSystrayOnExit = settings.value(QString::fromUtf8("Preferences/General/CloseToTray"), false).toBool();
|
||
15 years ago
|
if(!force_exit && systrayIcon && goToSystrayOnExit && !this->isHidden()) {
|
||
15 years ago
|
hide();
|
||
|
e->accept();
|
||
|
return;
|
||
18 years ago
|
}
|
||
14 years ago
|
if(settings.value(QString::fromUtf8("Preferences/General/ExitConfirm"), true).toBool() && BTSession && BTSession->hasActiveTorrents()) {
|
||
15 years ago
|
if(e->spontaneous() || force_exit) {
|
||
15 years ago
|
if(!isVisible())
|
||
|
show();
|
||
15 years ago
|
QMessageBox confirmBox(QMessageBox::Question, tr("Exiting qBittorrent"),
|
||
15 years ago
|
tr("Some files are currently transferring.\nAre you sure you want to quit qBittorrent?"),
|
||
|
QMessageBox::NoButton, this);
|
||
15 years ago
|
QPushButton *noBtn = confirmBox.addButton(tr("No"), QMessageBox::NoRole);
|
||
|
QPushButton *yesBtn = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole);
|
||
|
QPushButton *alwaysBtn = confirmBox.addButton(tr("Always"), QMessageBox::YesRole);
|
||
|
confirmBox.setDefaultButton(yesBtn);
|
||
|
confirmBox.exec();
|
||
|
if(!confirmBox.clickedButton() || confirmBox.clickedButton() == noBtn) {
|
||
|
// Cancel exit
|
||
15 years ago
|
e->ignore();
|
||
|
force_exit = false;
|
||
|
return;
|
||
15 years ago
|
}
|
||
15 years ago
|
if(confirmBox.clickedButton() == alwaysBtn) {
|
||
|
// Remember choice
|
||
|
Preferences::setConfirmOnExit(false);
|
||
|
}
|
||
17 years ago
|
}
|
||
|
}
|
||
15 years ago
|
hide();
|
||
15 years ago
|
if(systrayIcon) {
|
||
15 years ago
|
// Hide tray icon
|
||
15 years ago
|
systrayIcon->hide();
|
||
17 years ago
|
}
|
||
15 years ago
|
// Save window size, columns size
|
||
|
writeSettings();
|
||
|
// Accept exit
|
||
|
e->accept();
|
||
|
qApp->exit();
|
||
|
}
|
||
|
|
||
|
// Display window to create a torrent
|
||
14 years ago
|
void MainWindow::on_actionCreate_torrent_triggered() {
|
||
15 years ago
|
if(createTorrentDlg) {
|
||
|
createTorrentDlg->setFocus();
|
||
|
} else {
|
||
14 years ago
|
createTorrentDlg = new TorrentCreatorDlg(this);
|
||
15 years ago
|
connect(createTorrentDlg, SIGNAL(torrent_to_seed(QString)), this, SLOT(addTorrent(QString)));
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
bool MainWindow::event(QEvent * e) {
|
||
15 years ago
|
switch(e->type()) {
|
||
|
case QEvent::WindowStateChange: {
|
||
14 years ago
|
qDebug("Window change event");
|
||
|
//Now check to see if the window is minimised
|
||
|
if(isMinimized()) {
|
||
|
qDebug("minimisation");
|
||
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
|
if(systrayIcon && settings.value(QString::fromUtf8("Preferences/General/MinimizeToTray"), false).toBool()) {
|
||
|
qDebug("Has active window: %d", (int)(qApp->activeWindow() != 0));
|
||
|
// Check if there is a modal window
|
||
|
bool has_modal_window = false;
|
||
|
foreach (QWidget *widget, QApplication::allWidgets()) {
|
||
|
if(widget->isModal()) {
|
||
|
has_modal_window = true;
|
||
|
break;
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
14 years ago
|
// Iconify if there is no modal window
|
||
|
if(!has_modal_window) {
|
||
|
qDebug("Minimize to Tray enabled, hiding!");
|
||
|
e->accept();
|
||
|
QTimer::singleShot(0, this, SLOT(hide()));
|
||
|
return true;
|
||
|
}
|
||
18 years ago
|
}
|
||
|
}
|
||
14 years ago
|
break;
|
||
|
}
|
||
15 years ago
|
#ifdef Q_WS_MAC
|
||
|
case QEvent::ToolBarChange: {
|
||
14 years ago
|
qDebug("MAC: Received a toolbar change event!");
|
||
|
bool ret = QMainWindow::event(e);
|
||
15 years ago
|
|
||
14 years ago
|
qDebug("MAC: new toolbar visibility is %d", !actionTop_tool_bar->isChecked());
|
||
|
actionTop_tool_bar->toggle();
|
||
|
Preferences::setToolbarDisplayed(actionTop_tool_bar->isChecked());
|
||
|
return ret;
|
||
|
}
|
||
15 years ago
|
#endif
|
||
|
default:
|
||
|
break;
|
||
18 years ago
|
}
|
||
15 years ago
|
return QMainWindow::event(e);
|
||
|
}
|
||
|
|
||
|
// Action executed when a file is dropped
|
||
14 years ago
|
void MainWindow::dropEvent(QDropEvent *event) {
|
||
15 years ago
|
event->acceptProposedAction();
|
||
|
QStringList files;
|
||
|
if(event->mimeData()->hasUrls()) {
|
||
15 years ago
|
const QList<QUrl> urls = event->mimeData()->urls();
|
||
15 years ago
|
foreach(const QUrl &url, urls) {
|
||
15 years ago
|
const QString tmp = url.toString().trimmed();
|
||
15 years ago
|
if(!tmp.isEmpty())
|
||
|
files << url.toString();
|
||
|
}
|
||
|
} else {
|
||
|
files = event->mimeData()->text().split(QString::fromUtf8("\n"));
|
||
|
}
|
||
|
// Add file to download list
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||
15 years ago
|
foreach(QString file, files) {
|
||
15 years ago
|
#ifdef Q_WS_WIN
|
||
|
file = file.trimmed().replace(QString::fromUtf8("file:///"), QString::fromUtf8(""), Qt::CaseInsensitive);
|
||
|
#else
|
||
15 years ago
|
file = file.trimmed().replace(QString::fromUtf8("file://"), QString::fromUtf8(""), Qt::CaseInsensitive);
|
||
15 years ago
|
#endif
|
||
15 years ago
|
qDebug("Dropped file %s on download list", file.toLocal8Bit().data());
|
||
|
if(file.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||
|
BTSession->downloadFromUrl(file);
|
||
|
continue;
|
||
|
}
|
||
15 years ago
|
if(file.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||
|
qDebug("Converting bc link to magnet link");
|
||
|
file = misc::bcLinkToMagnet(file);
|
||
|
}
|
||
15 years ago
|
if(file.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||
|
// FIXME: Possibly skipped torrent addition dialog
|
||
|
BTSession->addMagnetUri(file);
|
||
|
continue;
|
||
15 years ago
|
}
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoad(file);
|
||
|
}else{
|
||
|
BTSession->addTorrent(file);
|
||
17 years ago
|
}
|
||
18 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
// Decode if we accept drag 'n drop or not
|
||
14 years ago
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event) {
|
||
15 years ago
|
foreach(const QString &mime, event->mimeData()->formats()){
|
||
|
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
||
|
}
|
||
15 years ago
|
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
||
|
event->acceptProposedAction();
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
/*****************************************************
|
||
|
* *
|
||
|
* Torrent *
|
||
|
* *
|
||
|
*****************************************************/
|
||
|
|
||
|
// Display a dialog to allow user to add
|
||
|
// torrents to download list
|
||
14 years ago
|
void MainWindow::on_actionOpen_triggered() {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
// Open File Open Dialog
|
||
|
// Note: it is possible to select more than one file
|
||
15 years ago
|
const QStringList pathsList = QFileDialog::getOpenFileNames(0,
|
||
14 years ago
|
tr("Open Torrent Files"), settings.value(QString::fromUtf8("MainWindowLastDir"), QDir::homePath()).toString(),
|
||
|
tr("Torrent Files")+QString::fromUtf8(" (*.torrent)"));
|
||
15 years ago
|
if(!pathsList.empty()) {
|
||
15 years ago
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||
|
const uint listSize = pathsList.size();
|
||
|
for(uint i=0; i<listSize; ++i) {
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoad(pathsList.at(i));
|
||
15 years ago
|
}else{
|
||
15 years ago
|
BTSession->addTorrent(pathsList.at(i));
|
||
15 years ago
|
}
|
||
18 years ago
|
}
|
||
15 years ago
|
// Save last dir to remember it
|
||
|
QStringList top_dir = pathsList.at(0).split(QDir::separator());
|
||
|
top_dir.removeLast();
|
||
|
settings.setValue(QString::fromUtf8("MainWindowLastDir"), top_dir.join(QDir::separator()));
|
||
18 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
// As program parameters, we can get paths or urls.
|
||
|
// This function parse the parameters and call
|
||
|
// the right addTorrent function, considering
|
||
|
// the parameter type.
|
||
14 years ago
|
void MainWindow::processParams(const QString& params_str) {
|
||
15 years ago
|
processParams(params_str.split("|", QString::SkipEmptyParts));
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::processParams(const QStringList& params) {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||
15 years ago
|
foreach(QString param, params) {
|
||
|
param = param.trimmed();
|
||
|
if(param.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || param.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||
|
BTSession->downloadFromUrl(param);
|
||
|
}else{
|
||
15 years ago
|
if(param.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||
|
qDebug("Converting bc link to magnet link");
|
||
|
param = misc::bcLinkToMagnet(param);
|
||
|
}
|
||
15 years ago
|
if(param.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoadMagnetURI(param);
|
||
|
} else {
|
||
|
BTSession->addMagnetUri(param);
|
||
|
}
|
||
15 years ago
|
} else {
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoad(param);
|
||
15 years ago
|
}else{
|
||
15 years ago
|
BTSession->addTorrent(param);
|
||
15 years ago
|
}
|
||
18 years ago
|
}
|
||
18 years ago
|
}
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::addTorrent(QString path) {
|
||
15 years ago
|
BTSession->addTorrent(path);
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::processDownloadedFiles(QString path, QString url) {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoad(path, url);
|
||
|
}else{
|
||
|
BTSession->addTorrent(path, false, url);
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::optionsSaved() {
|
||
15 years ago
|
loadPreferences();
|
||
|
}
|
||
|
|
||
15 years ago
|
// Load program preferences
|
||
14 years ago
|
void MainWindow::loadPreferences(bool configure_session) {
|
||
15 years ago
|
BTSession->addConsoleMessage(tr("Options were saved successfully."));
|
||
15 years ago
|
const bool newSystrayIntegration = Preferences::systrayIntegration();
|
||
14 years ago
|
actionLock_qBittorrent->setEnabled(newSystrayIntegration);
|
||
15 years ago
|
if(newSystrayIntegration != (systrayIcon!=0)) {
|
||
15 years ago
|
if(newSystrayIntegration) {
|
||
|
// create the trayicon
|
||
15 years ago
|
if(!QSystemTrayIcon::isSystemTrayAvailable()) {
|
||
|
if(!configure_session) { // Program startup
|
||
|
systrayCreator = new QTimer(this);
|
||
|
connect(systrayCreator, SIGNAL(timeout()), this, SLOT(createSystrayDelayed()));
|
||
|
systrayCreator->setSingleShot(true);
|
||
|
systrayCreator->start(2000);
|
||
|
qDebug("Info: System tray is unavailable, trying again later.");
|
||
|
} else {
|
||
|
qDebug("Warning: System tray is unavailable.");
|
||
|
}
|
||
|
} else {
|
||
|
createTrayIcon();
|
||
|
}
|
||
15 years ago
|
} else {
|
||
|
// Destroy trayicon
|
||
15 years ago
|
delete systrayIcon;
|
||
15 years ago
|
delete myTrayIconMenu;
|
||
|
}
|
||
|
}
|
||
15 years ago
|
// General
|
||
15 years ago
|
if(Preferences::isToolbarDisplayed()) {
|
||
15 years ago
|
toolBar->setVisible(true);
|
||
|
toolBar->layout()->setSpacing(7);
|
||
|
} else {
|
||
14 years ago
|
// Clear search filter before hiding the top toolbar
|
||
|
search_filter->clear();
|
||
15 years ago
|
toolBar->setVisible(false);
|
||
|
}
|
||
15 years ago
|
const uint new_refreshInterval = Preferences::getRefreshInterval();
|
||
15 years ago
|
transferList->setRefreshInterval(new_refreshInterval);
|
||
15 years ago
|
transferList->setAlternatingRowColors(Preferences::useAlternatingRowColors());
|
||
15 years ago
|
properties->getFilesList()->setAlternatingRowColors(Preferences::useAlternatingRowColors());
|
||
|
properties->getTrackerList()->setAlternatingRowColors(Preferences::useAlternatingRowColors());
|
||
|
properties->getPeerList()->setAlternatingRowColors(Preferences::useAlternatingRowColors());
|
||
15 years ago
|
// Queueing System
|
||
15 years ago
|
if(Preferences::isQueueingSystemEnabled()) {
|
||
14 years ago
|
if(!actionDecreasePriority->isVisible()) {
|
||
15 years ago
|
transferList->hidePriorityColumn(false);
|
||
15 years ago
|
actionDecreasePriority->setVisible(true);
|
||
|
actionIncreasePriority->setVisible(true);
|
||
|
prioSeparator->setVisible(true);
|
||
|
prioSeparator2->setVisible(true);
|
||
15 years ago
|
toolBar->layout()->setSpacing(7);
|
||
|
}
|
||
15 years ago
|
} else {
|
||
14 years ago
|
if(actionDecreasePriority->isVisible()) {
|
||
15 years ago
|
transferList->hidePriorityColumn(true);
|
||
15 years ago
|
actionDecreasePriority->setVisible(false);
|
||
|
actionIncreasePriority->setVisible(false);
|
||
|
prioSeparator->setVisible(false);
|
||
|
prioSeparator2->setVisible(false);
|
||
|
toolBar->layout()->setSpacing(7);
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
15 years ago
|
|
||
15 years ago
|
// Torrent properties
|
||
|
properties->reloadPreferences();
|
||
|
|
||
15 years ago
|
if(configure_session)
|
||
|
BTSession->configureSession();
|
||
|
|
||
|
qDebug("GUI settings loaded");
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::addUnauthenticatedTracker(const QPair<QTorrentHandle,QString> &tracker) {
|
||
15 years ago
|
// Trackers whose authentication was cancelled
|
||
|
if(unauthenticated_trackers.indexOf(tracker) < 0) {
|
||
|
unauthenticated_trackers << tracker;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Called when a tracker requires authentication
|
||
14 years ago
|
void MainWindow::trackerAuthenticationRequired(QTorrentHandle& h) {
|
||
15 years ago
|
if(unauthenticated_trackers.indexOf(QPair<QTorrentHandle,QString>(h, h.current_tracker())) < 0) {
|
||
|
// Tracker login
|
||
|
new trackerLogin(this, h);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Check connection status and display right icon
|
||
14 years ago
|
void MainWindow::updateGUI() {
|
||
15 years ago
|
// update global informations
|
||
15 years ago
|
if(systrayIcon) {
|
||
14 years ago
|
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
|
||
15 years ago
|
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
|
||
|
html += tr("qBittorrent");
|
||
|
html += "</div>";
|
||
|
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||
15 years ago
|
html += "<img src=':/Icons/skin/download.png'/> "+tr("DL speed: %1 KiB/s", "e.g: Download speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1));
|
||
15 years ago
|
html += "</div>";
|
||
|
html += "<div style='vertical-align: baseline; height: 18px;'>";
|
||
15 years ago
|
html += "<img src=':/Icons/skin/seeding.png'/> "+tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1));
|
||
15 years ago
|
html += "</div>";
|
||
15 years ago
|
#else
|
||
|
// OSes such as Windows do not support html here
|
||
|
QString html =tr("DL speed: %1 KiB/s", "e.g: Download speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1));
|
||
|
html += "\n";
|
||
|
html += tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1));
|
||
16 years ago
|
#endif
|
||
15 years ago
|
systrayIcon->setToolTip(html); // tray icon
|
||
18 years ago
|
}
|
||
15 years ago
|
if(displaySpeedInTitle) {
|
||
15 years ago
|
setWindowTitle(tr("qBittorrent %1 (Down: %2/s, Up: %3/s)", "%1 is qBittorrent version").arg(QString::fromUtf8(VERSION)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_download_rate)).arg(misc::friendlyUnit(BTSession->getSessionStatus().payload_upload_rate)));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::showNotificationBaloon(QString title, QString msg) const {
|
||
15 years ago
|
if(!Preferences::useProgramNotification()) return;
|
||
15 years ago
|
#ifdef WITH_LIBNOTIFY
|
||
15 years ago
|
if (notify_init ("summary-body")) {
|
||
|
NotifyNotification* notification;
|
||
14 years ago
|
|
||
|
notification = notify_notification_new (qPrintable(title), qPrintable(msg), "qbittorrent"
|
||
|
#if !defined(NOTIFY_VERSION_MINOR) || (NOTIFY_VERSION_MAJOR == 0 && NOTIFY_VERSION_MINOR < 7)
|
||
|
, 0
|
||
|
#endif
|
||
|
);
|
||
15 years ago
|
gboolean success = notify_notification_show (notification, NULL);
|
||
|
g_object_unref(G_OBJECT(notification));
|
||
|
notify_uninit ();
|
||
|
if(success) {
|
||
|
return;
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
15 years ago
|
#endif
|
||
15 years ago
|
if(systrayIcon && QSystemTrayIcon::supportsMessages())
|
||
|
systrayIcon->showMessage(title, msg, QSystemTrayIcon::Information, TIME_TRAY_BALLOON);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
/*****************************************************
|
||
18 years ago
|
* *
|
||
|
* Utils *
|
||
|
* *
|
||
|
*****************************************************/
|
||
15 years ago
|
|
||
14 years ago
|
void MainWindow::downloadFromURLList(const QStringList& url_list) {
|
||
15 years ago
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||
15 years ago
|
const bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||
15 years ago
|
foreach(QString url, url_list) {
|
||
|
if(url.startsWith("bc://bt/", Qt::CaseInsensitive)) {
|
||
|
qDebug("Converting bc link to magnet link");
|
||
|
url = misc::bcLinkToMagnet(url);
|
||
|
}
|
||
15 years ago
|
if(url.startsWith("magnet:", Qt::CaseInsensitive)) {
|
||
15 years ago
|
if(useTorrentAdditionDialog) {
|
||
14 years ago
|
torrentAdditionDialog *dialog = new torrentAdditionDialog(this);
|
||
15 years ago
|
dialog->showLoadMagnetURI(url);
|
||
|
} else {
|
||
|
BTSession->addMagnetUri(url);
|
||
|
}
|
||
15 years ago
|
} else {
|
||
|
BTSession->downloadFromUrl(url);
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
|
/*****************************************************
|
||
18 years ago
|
* *
|
||
|
* Options *
|
||
|
* *
|
||
|
*****************************************************/
|
||
15 years ago
|
|
||
14 years ago
|
void MainWindow::createSystrayDelayed() {
|
||
15 years ago
|
static int timeout = 20;
|
||
15 years ago
|
if(QSystemTrayIcon::isSystemTrayAvailable()) {
|
||
|
// Ok, systray integration is now supported
|
||
|
// Create systray icon
|
||
|
createTrayIcon();
|
||
|
delete systrayCreator;
|
||
|
} else {
|
||
|
if(timeout) {
|
||
|
// Retry a bit later
|
||
15 years ago
|
systrayCreator->start(2000);
|
||
15 years ago
|
--timeout;
|
||
17 years ago
|
} else {
|
||
15 years ago
|
// Timed out, apparently system really does not
|
||
|
// support systray icon
|
||
|
delete systrayCreator;
|
||
15 years ago
|
// Disable it in program preferences to
|
||
|
// avoid trying at earch startup
|
||
|
Preferences::setSystrayIntegration(false);
|
||
17 years ago
|
}
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::updateAltSpeedsBtn(bool alternative) {
|
||
15 years ago
|
actionUse_alternative_speed_limits->setChecked(alternative);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
QMenu* MainWindow::getTrayIconMenu() {
|
||
15 years ago
|
if(myTrayIconMenu)
|
||
|
return myTrayIconMenu;
|
||
15 years ago
|
// Tray icon Menu
|
||
|
myTrayIconMenu = new QMenu(this);
|
||
|
myTrayIconMenu->addAction(actionOpen);
|
||
|
myTrayIconMenu->addAction(actionDownload_from_URL);
|
||
|
myTrayIconMenu->addSeparator();
|
||
15 years ago
|
updateAltSpeedsBtn(Preferences::isAltBandwidthEnabled());
|
||
15 years ago
|
actionUse_alternative_speed_limits->setChecked(Preferences::isAltBandwidthEnabled());
|
||
15 years ago
|
myTrayIconMenu->addAction(actionUse_alternative_speed_limits);
|
||
15 years ago
|
myTrayIconMenu->addAction(actionSet_global_download_limit);
|
||
|
myTrayIconMenu->addAction(actionSet_global_upload_limit);
|
||
|
myTrayIconMenu->addSeparator();
|
||
|
myTrayIconMenu->addAction(actionStart_All);
|
||
|
myTrayIconMenu->addAction(actionPause_All);
|
||
|
myTrayIconMenu->addSeparator();
|
||
|
myTrayIconMenu->addAction(actionExit);
|
||
14 years ago
|
if(ui_locked)
|
||
|
myTrayIconMenu->setEnabled(false);
|
||
15 years ago
|
return myTrayIconMenu;
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::createTrayIcon() {
|
||
15 years ago
|
// Tray icon
|
||
|
#ifdef Q_WS_WIN
|
||
|
systrayIcon = new QSystemTrayIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent16.png")), this);
|
||
|
#else
|
||
|
systrayIcon = new QSystemTrayIcon(QIcon(QString::fromUtf8(":/Icons/skin/qbittorrent22.png")), this);
|
||
|
#endif
|
||
|
|
||
|
systrayIcon->setContextMenu(getTrayIconMenu());
|
||
15 years ago
|
connect(systrayIcon, SIGNAL(messageClicked()), this, SLOT(balloonClicked()));
|
||
15 years ago
|
// End of Icon Menu
|
||
15 years ago
|
connect(systrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleVisibility(QSystemTrayIcon::ActivationReason)));
|
||
|
systrayIcon->show();
|
||
15 years ago
|
}
|
||
|
|
||
|
// Display Program Options
|
||
14 years ago
|
void MainWindow::on_actionOptions_triggered() {
|
||
15 years ago
|
if(options) {
|
||
15 years ago
|
// Get focus
|
||
|
options->setFocus();
|
||
15 years ago
|
} else {
|
||
|
options = new options_imp(this);
|
||
|
connect(options, SIGNAL(status_changed()), this, SLOT(optionsSaved()));
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionTop_tool_bar_triggered() {
|
||
15 years ago
|
bool is_visible = static_cast<QAction*>(sender())->isChecked();
|
||
|
toolBar->setVisible(is_visible);
|
||
|
Preferences::setToolbarDisplayed(is_visible);
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionShutdown_when_downloads_complete_triggered() {
|
||
14 years ago
|
bool is_checked = static_cast<QAction*>(sender())->isChecked();
|
||
|
Preferences::setShutdownWhenDownloadsComplete(is_checked);
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionShutdown_qBittorrent_when_downloads_complete_triggered() {
|
||
14 years ago
|
bool is_checked = static_cast<QAction*>(sender())->isChecked();
|
||
|
Preferences::setShutdownqBTWhenDownloadsComplete(is_checked);
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionSpeed_in_title_bar_triggered() {
|
||
15 years ago
|
displaySpeedInTitle = static_cast<QAction*>(sender())->isChecked();
|
||
|
Preferences::showSpeedInTitleBar(displaySpeedInTitle);
|
||
|
if(displaySpeedInTitle)
|
||
|
updateGUI();
|
||
|
else
|
||
|
setWindowTitle(tr("qBittorrent %1", "e.g: qBittorrent v0.x").arg(QString::fromUtf8(VERSION)));
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_actionRSS_Reader_triggered() {
|
||
14 years ago
|
RssSettings::setRSSEnabled(actionRSS_Reader->isChecked());
|
||
15 years ago
|
displayRSSTab(actionRSS_Reader->isChecked());
|
||
|
}
|
||
15 years ago
|
|
||
14 years ago
|
void MainWindow::on_actionSearch_engine_triggered() {
|
||
15 years ago
|
Preferences::setSearchEnabled(actionSearch_engine->isChecked());
|
||
|
displaySearchTab(actionSearch_engine->isChecked());
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::on_action_Import_Torrent_triggered()
|
||
14 years ago
|
{
|
||
14 years ago
|
TorrentImportDlg::importTorrent();
|
||
14 years ago
|
}
|
||
|
|
||
15 years ago
|
/*****************************************************
|
||
18 years ago
|
* *
|
||
|
* HTTP Downloader *
|
||
|
* *
|
||
|
*****************************************************/
|
||
15 years ago
|
|
||
|
// Display an input dialog to prompt user for
|
||
|
// an url
|
||
14 years ago
|
void MainWindow::on_actionDownload_from_URL_triggered() {
|
||
15 years ago
|
if(!downloadFromURLDialog) {
|
||
|
downloadFromURLDialog = new downloadFromURL(this);
|
||
|
connect(downloadFromURLDialog, SIGNAL(urlsReadyToBeDownloaded(const QStringList&)), this, SLOT(downloadFromURLList(const QStringList&)));
|
||
|
}
|
||
15 years ago
|
}
|
||
15 years ago
|
|
||
14 years ago
|
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||
|
|
||
|
void GUI::handleUpdateCheckFinished(bool update_available, QString new_version)
|
||
|
{
|
||
|
if(update_available) {
|
||
|
if(QMessageBox::question(this, tr("A newer version is available"),
|
||
|
tr("A newer version of qBittorrent is available on Sourceforge.\nWould you like to update qBittorrent to version %1?").arg(new_version),
|
||
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) {
|
||
|
// The user want to update, let's download the update
|
||
|
ProgramUpdater* updater = dynamic_cast<ProgramUpdater*>(sender());
|
||
|
connect(updater, SIGNAL(updateInstallFinished(QString)), SLOT(handleUpdateInstalled(QString)));
|
||
|
updater->updateProgram();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
sender()->deleteLater();
|
||
|
}
|
||
|
|
||
|
void GUI::handleUpdateInstalled(QString error_msg)
|
||
|
{
|
||
|
if(!error_msg.isEmpty()) {
|
||
|
QMessageBox::critical(this, tr("Impossible to update qBittorrent"), tr("qBittorrent failed to update, reason: %1").arg(error_msg));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endif
|
||
14 years ago
|
|
||
14 years ago
|
void MainWindow::on_actionDonate_money_triggered()
|
||
14 years ago
|
{
|
||
14 years ago
|
QDesktopServices::openUrl(QUrl("http://sourceforge.net/donate/index.php?group_id=163414"));
|
||
|
}
|
||
|
|
||
14 years ago
|
void MainWindow::showConnectionSettings()
|
||
14 years ago
|
{
|
||
|
on_actionOptions_triggered();
|
||
|
options->showConnectionTab();
|
||
14 years ago
|
}
|