mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
- Code cleanup using autoconnect slots
This commit is contained in:
parent
216e9a9785
commit
b198494900
51
src/GUI.cpp
51
src/GUI.cpp
@ -149,27 +149,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
downloadList->header()->setClickable(true);
|
downloadList->header()->setClickable(true);
|
||||||
downloadList->header()->setSortIndicatorShown(true);
|
downloadList->header()->setSortIndicatorShown(true);
|
||||||
// Connecting Actions to slots
|
// Connecting Actions to slots
|
||||||
connect(actionExit, SIGNAL(triggered()), this, SLOT(forceExit()));
|
|
||||||
connect(actionOpen, SIGNAL(triggered()), this, SLOT(askForTorrents()));
|
|
||||||
connect(actionDelete_Permanently, SIGNAL(triggered()), this, SLOT(deletePermanently()));
|
|
||||||
connect(actionDelete, SIGNAL(triggered()), this, SLOT(deleteSelection()));
|
|
||||||
connect(actionOptions, SIGNAL(triggered()), this, SLOT(showOptions()));
|
|
||||||
connect(actionDownload_from_URL, SIGNAL(triggered()), this, SLOT(askForTorrentUrl()));
|
|
||||||
connect(actionPause, SIGNAL(triggered()), this, SLOT(pauseSelection()));
|
|
||||||
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
|
|
||||||
connect(actionStart, SIGNAL(triggered()), this, SLOT(startSelection()));
|
|
||||||
connect(actionPause_All, SIGNAL(triggered()), this, SLOT(pauseAll()));
|
|
||||||
connect(actionStart_All, SIGNAL(triggered()), this, SLOT(resumeAll()));
|
|
||||||
connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAbout()));
|
|
||||||
connect(actionCreate_torrent, SIGNAL(triggered()), this, SLOT(showCreateWindow()));
|
|
||||||
connect(actionClearLog, SIGNAL(triggered()), this, SLOT(clearLog()));
|
|
||||||
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(togglePausedState(const QModelIndex&)));
|
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(togglePausedState(const QModelIndex&)));
|
||||||
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
|
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
|
||||||
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
|
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
|
||||||
connect(actionWebsite, SIGNAL(triggered()), this, SLOT(openqBTHomepage()));
|
|
||||||
connect(actionBugReport, SIGNAL(triggered()), this, SLOT(openqBTBugTracker()));
|
|
||||||
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayGUIMenu(const QPoint&)));
|
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayGUIMenu(const QPoint&)));
|
||||||
connect(actionPreview_file, SIGNAL(triggered()), this, SLOT(previewFileSelection()));
|
|
||||||
connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&)));
|
connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&)));
|
||||||
// Create tray icon
|
// Create tray icon
|
||||||
if (QSystemTrayIcon::isSystemTrayAvailable()){
|
if (QSystemTrayIcon::isSystemTrayAvailable()){
|
||||||
@ -225,11 +208,11 @@ GUI::~GUI(){
|
|||||||
delete connecStatusLblIcon;
|
delete connecStatusLblIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::openqBTHomepage(){
|
void GUI::on_actionWebsite_triggered(){
|
||||||
QDesktopServices::openUrl(QUrl("http://www.qbittorrent.org"));
|
QDesktopServices::openUrl(QUrl("http://www.qbittorrent.org"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::openqBTBugTracker(){
|
void GUI::on_actionBugReport_triggered(){
|
||||||
QDesktopServices::openUrl(QUrl("http://bugs.qbittorrent.org"));
|
QDesktopServices::openUrl(QUrl("http://bugs.qbittorrent.org"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +294,7 @@ void GUI::togglePausedState(const QModelIndex& index){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::previewFileSelection(){
|
void GUI::on_actionPreview_file_triggered(){
|
||||||
if(tabs->currentIndex() > 1) return;
|
if(tabs->currentIndex() > 1) return;
|
||||||
bool inDownloadList = true;
|
bool inDownloadList = true;
|
||||||
if(tabs->currentIndex() != 0)
|
if(tabs->currentIndex() != 0)
|
||||||
@ -375,7 +358,7 @@ void GUI::displayDLListMenu(const QPoint& pos){
|
|||||||
|
|
||||||
// Necessary if we want to close the window
|
// Necessary if we want to close the window
|
||||||
// in one time if "close to systray" is enabled
|
// in one time if "close to systray" is enabled
|
||||||
void GUI::forceExit(){
|
void GUI::on_actionExit_triggered(){
|
||||||
force_exit = true;
|
force_exit = true;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -415,7 +398,7 @@ void GUI::selectGivenRow(const QModelIndex& index){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::clearLog(){
|
void GUI::on_actionClearLog_triggered(){
|
||||||
infoBar->clear();
|
infoBar->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +644,7 @@ bool GUI::loadColWidthDLList(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display About Dialog
|
// Display About Dialog
|
||||||
void GUI::showAbout(){
|
void GUI::on_actionAbout_triggered(){
|
||||||
//About dialog
|
//About dialog
|
||||||
aboutdlg = new about(this);
|
aboutdlg = new about(this);
|
||||||
}
|
}
|
||||||
@ -704,7 +687,7 @@ void GUI::closeEvent(QCloseEvent *e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display window to create a torrent
|
// Display window to create a torrent
|
||||||
void GUI::showCreateWindow(){
|
void GUI::on_actionCreate_torrent_triggered(){
|
||||||
createWindow = new createtorrent(this);
|
createWindow = new createtorrent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -754,7 +737,7 @@ void GUI::dragEnterEvent(QDragEnterEvent *event){
|
|||||||
|
|
||||||
// Display a dialog to allow user to add
|
// Display a dialog to allow user to add
|
||||||
// torrents to download list
|
// torrents to download list
|
||||||
void GUI::askForTorrents(){
|
void GUI::on_actionOpen_triggered(){
|
||||||
QStringList pathsList;
|
QStringList pathsList;
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
// Open File Open Dialog
|
// Open File Open Dialog
|
||||||
@ -783,7 +766,7 @@ void GUI::askForTorrents(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete from download list AND from hard drive
|
// delete from download list AND from hard drive
|
||||||
void GUI::deletePermanently(){
|
void GUI::on_actionDelete_Permanently_triggered(){
|
||||||
if(tabs->currentIndex() > 1) return;
|
if(tabs->currentIndex() > 1) return;
|
||||||
QModelIndexList selectedIndexes;
|
QModelIndexList selectedIndexes;
|
||||||
bool inDownloadList = true;
|
bool inDownloadList = true;
|
||||||
@ -854,7 +837,7 @@ void GUI::deletePermanently(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// delete selected items in the list
|
// delete selected items in the list
|
||||||
void GUI::deleteSelection(){
|
void GUI::on_actionDelete_triggered(){
|
||||||
if(tabs->currentIndex() > 1) return;
|
if(tabs->currentIndex() > 1) return;
|
||||||
QModelIndexList selectedIndexes;
|
QModelIndexList selectedIndexes;
|
||||||
bool inDownloadList = true;
|
bool inDownloadList = true;
|
||||||
@ -1130,7 +1113,7 @@ void GUI::configureSession(bool deleteOptions){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pause All Downloads in DL list
|
// Pause All Downloads in DL list
|
||||||
void GUI::pauseAll(){
|
void GUI::on_actionPause_All_triggered(){
|
||||||
QString fileHash;
|
QString fileHash;
|
||||||
// Pause all torrents
|
// Pause all torrents
|
||||||
BTSession.pauseAllTorrents();
|
BTSession.pauseAllTorrents();
|
||||||
@ -1154,7 +1137,7 @@ void GUI::pauseAll(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pause selected items in the list
|
// pause selected items in the list
|
||||||
void GUI::pauseSelection(){
|
void GUI::on_actionPause_triggered(){
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
foreach(index, selectedIndexes){
|
foreach(index, selectedIndexes){
|
||||||
@ -1180,7 +1163,7 @@ void GUI::pauseSelection(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resume All Downloads in DL list
|
// Resume All Downloads in DL list
|
||||||
void GUI::resumeAll(){
|
void GUI::on_actionStart_All_triggered(){
|
||||||
QString fileHash;
|
QString fileHash;
|
||||||
// Pause all torrents
|
// Pause all torrents
|
||||||
BTSession.resumeAllTorrents();
|
BTSession.resumeAllTorrents();
|
||||||
@ -1198,7 +1181,7 @@ void GUI::resumeAll(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start selected items in the list
|
// start selected items in the list
|
||||||
void GUI::startSelection(){
|
void GUI::on_actionStart_triggered(){
|
||||||
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
|
||||||
QModelIndex index;
|
QModelIndex index;
|
||||||
foreach(index, selectedIndexes){
|
foreach(index, selectedIndexes){
|
||||||
@ -1229,7 +1212,7 @@ void GUI::addUnauthenticatedTracker(QPair<torrent_handle,std::string> tracker){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// display properties of selected items
|
// display properties of selected items
|
||||||
void GUI::propertiesSelection(){
|
void GUI::on_actionTorrent_Properties_triggered(){
|
||||||
if(tabs->currentIndex() > 1) return;
|
if(tabs->currentIndex() > 1) return;
|
||||||
if(tabs->currentIndex() == 1){
|
if(tabs->currentIndex() == 1){
|
||||||
finishedTorrentTab->propertiesSelection();
|
finishedTorrentTab->propertiesSelection();
|
||||||
@ -1410,7 +1393,7 @@ void GUI::createTrayIcon(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display Program Options
|
// Display Program Options
|
||||||
void GUI::showOptions(){
|
void GUI::on_actionOptions_triggered(){
|
||||||
options = new options_imp(this);
|
options = new options_imp(this);
|
||||||
connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool)));
|
connect(options, SIGNAL(status_changed(const QString&, bool)), this, SLOT(OptionsSaved(const QString&, bool)));
|
||||||
options->show();
|
options->show();
|
||||||
@ -1443,7 +1426,7 @@ void GUI::OptionsSaved(const QString& info, bool deleteOptions){
|
|||||||
|
|
||||||
// Display an input dialog to prompt user for
|
// Display an input dialog to prompt user for
|
||||||
// an url
|
// an url
|
||||||
void GUI::askForTorrentUrl(){
|
void GUI::on_actionDownload_from_URL_triggered(){
|
||||||
downloadFromURLDialog = new downloadFromURL(this);
|
downloadFromURLDialog = new downloadFromURL(this);
|
||||||
connect(downloadFromURLDialog, SIGNAL(downloadFinished(QString, QString, int, QString)), &BTSession, SLOT(processDownloadedFile(QString, QString, int, QString)));
|
connect(downloadFromURLDialog, SIGNAL(downloadFinished(QString, QString, int, QString)), &BTSession, SLOT(processDownloadedFile(QString, QString, int, QString)));
|
||||||
}
|
}
|
||||||
|
34
src/GUI.h
34
src/GUI.h
@ -98,13 +98,13 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void dropEvent(QDropEvent *event);
|
void dropEvent(QDropEvent *event);
|
||||||
void dragEnterEvent(QDragEnterEvent *event);
|
void dragEnterEvent(QDragEnterEvent *event);
|
||||||
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
|
||||||
void showAbout();
|
void on_actionAbout_triggered();
|
||||||
void setInfoBar(const QString& info, const QString& color="black");
|
void setInfoBar(const QString& info, const QString& color="black");
|
||||||
void updateDlList(bool force=false);
|
void updateDlList(bool force=false);
|
||||||
void showCreateWindow();
|
void on_actionCreate_torrent_triggered();
|
||||||
void clearLog();
|
void on_actionClearLog_triggered();
|
||||||
void openqBTHomepage();
|
void on_actionWebsite_triggered();
|
||||||
void openqBTBugTracker();
|
void on_actionBugReport_triggered();
|
||||||
void readParamsOnSocket();
|
void readParamsOnSocket();
|
||||||
void acceptConnection();
|
void acceptConnection();
|
||||||
void saveColWidthDLList() const;
|
void saveColWidthDLList() const;
|
||||||
@ -117,24 +117,24 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void togglePausedState(const QModelIndex& index);
|
void togglePausedState(const QModelIndex& index);
|
||||||
void displayInfoBarMenu(const QPoint& pos);
|
void displayInfoBarMenu(const QPoint& pos);
|
||||||
void displayGUIMenu(const QPoint& pos);
|
void displayGUIMenu(const QPoint& pos);
|
||||||
void previewFileSelection();
|
void on_actionPreview_file_triggered();
|
||||||
void previewFile(const QString& filePath);
|
void previewFile(const QString& filePath);
|
||||||
void cleanTempPreviewFile(int, QProcess::ExitStatus);
|
void cleanTempPreviewFile(int, QProcess::ExitStatus);
|
||||||
void balloonClicked();
|
void balloonClicked();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void readSettings();
|
void readSettings();
|
||||||
void forceExit();
|
void on_actionExit_triggered();
|
||||||
void createTrayIcon();
|
void createTrayIcon();
|
||||||
// Torrent actions
|
// Torrent actions
|
||||||
void showProperties(const QModelIndex &index);
|
void showProperties(const QModelIndex &index);
|
||||||
void propertiesSelection();
|
void on_actionTorrent_Properties_triggered();
|
||||||
void pauseSelection();
|
void on_actionPause_triggered();
|
||||||
void pauseAll();
|
void on_actionPause_All_triggered();
|
||||||
void startSelection();
|
void on_actionStart_triggered();
|
||||||
void resumeAll();
|
void on_actionStart_All_triggered();
|
||||||
void askForTorrents();
|
void on_actionOpen_triggered();
|
||||||
void deletePermanently();
|
void on_actionDelete_Permanently_triggered();
|
||||||
void deleteSelection();
|
void on_actionDelete_triggered();
|
||||||
void checkConnectionStatus();
|
void checkConnectionStatus();
|
||||||
void configureSession(bool deleteOptions);
|
void configureSession(bool deleteOptions);
|
||||||
void processParams(const QStringList& params);
|
void processParams(const QStringList& params);
|
||||||
@ -146,10 +146,10 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
// Utils slots
|
// Utils slots
|
||||||
void setRowColor(int row, const QString& color);
|
void setRowColor(int row, const QString& color);
|
||||||
// Options slots
|
// Options slots
|
||||||
void showOptions();
|
void on_actionOptions_triggered();
|
||||||
void OptionsSaved(const QString& info, bool deleteOptions);
|
void OptionsSaved(const QString& info, bool deleteOptions);
|
||||||
// HTTP slots
|
// HTTP slots
|
||||||
void askForTorrentUrl();
|
void on_actionDownload_from_URL_triggered();
|
||||||
#ifndef NO_UPNP
|
#ifndef NO_UPNP
|
||||||
void displayNoUPnPWanServiceDetected();
|
void displayNoUPnPWanServiceDetected();
|
||||||
void displayUPnPWanServiceDetected();
|
void displayUPnPWanServiceDetected();
|
||||||
|
Loading…
Reference in New Issue
Block a user