1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-11 15:27:54 +00:00

Add "Show torrent options" double-click action

PR #15853.
Closes #15837.
This commit is contained in:
Vladimir Golovnev 2021-12-19 09:01:20 +03:00 committed by GitHub
parent aedd997604
commit 2fb0c86f1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 32 deletions

View File

@ -763,8 +763,8 @@ void OptionsDialog::saveOptions()
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked()); pref->setAutoRunConsoleEnabled(m_ui->autoRunConsole->isChecked());
#endif #endif
pref->setActionOnDblClOnTorrentDl(getActionOnDblClOnTorrentDl()); pref->setActionOnDblClOnTorrentDl(m_ui->actionTorrentDlOnDblClBox->currentData().toInt());
pref->setActionOnDblClOnTorrentFn(getActionOnDblClOnTorrentFn()); pref->setActionOnDblClOnTorrentFn(m_ui->actionTorrentFnOnDblClBox->currentData().toInt());
TorrentFileGuard::setAutoDeleteMode(!m_ui->deleteTorrentBox->isChecked() ? TorrentFileGuard::Never TorrentFileGuard::setAutoDeleteMode(!m_ui->deleteTorrentBox->isChecked() ? TorrentFileGuard::Never
: !m_ui->deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded : !m_ui->deleteCancelledTorrentBox->isChecked() ? TorrentFileGuard::IfAdded
: TorrentFileGuard::Always); : TorrentFileGuard::Always);
@ -1057,14 +1057,26 @@ void OptionsDialog::loadOptions()
#else #else
m_ui->autoRunConsole->hide(); m_ui->autoRunConsole->hide();
#endif #endif
intValue = pref->getActionOnDblClOnTorrentDl();
if (intValue >= m_ui->actionTorrentDlOnDblClBox->count()) m_ui->actionTorrentDlOnDblClBox->setItemData(0, TOGGLE_PAUSE);
intValue = 0; m_ui->actionTorrentDlOnDblClBox->setItemData(1, OPEN_DEST);
m_ui->actionTorrentDlOnDblClBox->setCurrentIndex(intValue); m_ui->actionTorrentDlOnDblClBox->setItemData(2, PREVIEW_FILE);
intValue = pref->getActionOnDblClOnTorrentFn(); m_ui->actionTorrentDlOnDblClBox->setItemData(3, SHOW_OPTIONS);
if (intValue >= m_ui->actionTorrentFnOnDblClBox->count()) m_ui->actionTorrentDlOnDblClBox->setItemData(4, NO_ACTION);
intValue = 1; int actionDownloading = pref->getActionOnDblClOnTorrentDl();
m_ui->actionTorrentFnOnDblClBox->setCurrentIndex(intValue); if ((actionDownloading < 0) || (actionDownloading >= m_ui->actionTorrentDlOnDblClBox->count()))
actionDownloading = TOGGLE_PAUSE;
m_ui->actionTorrentDlOnDblClBox->setCurrentIndex(m_ui->actionTorrentDlOnDblClBox->findData(actionDownloading));
m_ui->actionTorrentFnOnDblClBox->setItemData(0, TOGGLE_PAUSE);
m_ui->actionTorrentFnOnDblClBox->setItemData(1, OPEN_DEST);
m_ui->actionTorrentFnOnDblClBox->setItemData(2, PREVIEW_FILE);
m_ui->actionTorrentFnOnDblClBox->setItemData(3, SHOW_OPTIONS);
m_ui->actionTorrentFnOnDblClBox->setItemData(4, NO_ACTION);
int actionSeeding = pref->getActionOnDblClOnTorrentFn();
if ((actionSeeding < 0) || (actionSeeding >= m_ui->actionTorrentFnOnDblClBox->count()))
actionSeeding = OPEN_DEST;
m_ui->actionTorrentFnOnDblClBox->setCurrentIndex(m_ui->actionTorrentFnOnDblClBox->findData(actionSeeding));
// End Downloads preferences // End Downloads preferences
// Connection preferences // Connection preferences
@ -1643,22 +1655,6 @@ QString OptionsDialog::getFinishedTorrentExportDir() const
return {}; return {};
} }
// Return action on double-click on a downloading torrent set in options
int OptionsDialog::getActionOnDblClOnTorrentDl() const
{
if (m_ui->actionTorrentDlOnDblClBox->currentIndex() < 1)
return 0;
return m_ui->actionTorrentDlOnDblClBox->currentIndex();
}
// Return action on double-click on a finished torrent set in options
int OptionsDialog::getActionOnDblClOnTorrentFn() const
{
if (m_ui->actionTorrentFnOnDblClBox->currentIndex() < 1)
return 0;
return m_ui->actionTorrentFnOnDblClBox->currentIndex();
}
void OptionsDialog::on_addWatchedFolderButton_clicked() void OptionsDialog::on_addWatchedFolderButton_clicked()
{ {
Preferences *const pref = Preferences::instance(); Preferences *const pref = Preferences::instance();

View File

@ -40,10 +40,11 @@ class AdvancedSettings;
// actions on double-click on torrents // actions on double-click on torrents
enum DoubleClickAction enum DoubleClickAction
{ {
TOGGLE_PAUSE, TOGGLE_PAUSE = 0,
OPEN_DEST, OPEN_DEST = 1,
PREVIEW_FILE, PREVIEW_FILE = 2,
NO_ACTION NO_ACTION = 3,
SHOW_OPTIONS = 4
}; };
namespace Net namespace Net
@ -138,8 +139,6 @@ private:
QString getTorrentExportDir() const; QString getTorrentExportDir() const;
QString getFinishedTorrentExportDir() const; QString getFinishedTorrentExportDir() const;
QString askForExportDir(const QString &currentExportPath); QString askForExportDir(const QString &currentExportPath);
int getActionOnDblClOnTorrentDl() const;
int getActionOnDblClOnTorrentFn() const;
// Connection options // Connection options
int getPort() const; int getPort() const;
bool isUPnPEnabled() const; bool isUPnPEnabled() const;

View File

@ -313,6 +313,11 @@
<string>Preview file, otherwise open destination folder</string> <string>Preview file, otherwise open destination folder</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Show torrent options</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>No action</string> <string>No action</string>
@ -344,6 +349,11 @@
<string>Preview file, otherwise open destination folder</string> <string>Preview file, otherwise open destination folder</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>Show torrent options</string>
</property>
</item>
<item> <item>
<property name="text"> <property name="text">
<string>No action</string> <string>No action</string>

View File

@ -303,6 +303,9 @@ void TransferListWidget::torrentDoubleClicked()
case OPEN_DEST: case OPEN_DEST:
openDestinationFolder(torrent); openDestinationFolder(torrent);
break; break;
case SHOW_OPTIONS:
setTorrentOptions();
break;
} }
} }