mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Fix issues related to tab order in main window
Make sure the search input has focus when switching to the search tab
This commit is contained in:
parent
51068294f1
commit
bceb00d35f
7 changed files with 30 additions and 16 deletions
28
src/GUI.cpp
28
src/GUI.cpp
|
@ -345,10 +345,18 @@ void GUI::on_actionBugReport_triggered() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::tab_changed(int new_tab) {
|
void GUI::tab_changed(int new_tab) {
|
||||||
if(new_tab == TAB_TRANSFER) {
|
Q_UNUSED(new_tab);
|
||||||
|
// We cannot rely on the index new_tab
|
||||||
|
// because the tab order is undetermined now
|
||||||
|
if(tabs->currentWidget() == vSplitter) {
|
||||||
qDebug("Changed tab to transfer list, refreshing the list");
|
qDebug("Changed tab to transfer list, refreshing the list");
|
||||||
transferList->refreshList();
|
transferList->refreshList();
|
||||||
properties->loadDynamicData();
|
properties->loadDynamicData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(tabs->currentWidget() == searchEngine) {
|
||||||
|
qDebug("Changed tab to search engine, giving focus to search input");
|
||||||
|
searchEngine->giveFocusToSearchInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,15 +409,17 @@ void GUI::createKeyboardShortcuts() {
|
||||||
|
|
||||||
// Keyboard shortcuts slots
|
// Keyboard shortcuts slots
|
||||||
void GUI::displayTransferTab() const {
|
void GUI::displayTransferTab() const {
|
||||||
tabs->setCurrentIndex(TAB_TRANSFER);
|
tabs->setCurrentWidget(transferList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::displaySearchTab() const {
|
void GUI::displaySearchTab() const {
|
||||||
tabs->setCurrentIndex(TAB_SEARCH);
|
if(searchEngine)
|
||||||
|
tabs->setCurrentWidget(searchEngine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::displayRSSTab() const {
|
void GUI::displayRSSTab() const {
|
||||||
tabs->setCurrentIndex(TAB_RSS);
|
if(rssWidget)
|
||||||
|
tabs->setCurrentWidget(rssWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of keyboard shortcuts slots
|
// End of keyboard shortcuts slots
|
||||||
|
@ -509,10 +519,12 @@ void GUI::on_actionExit_triggered() {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GUI::getCurrentTabIndex() const {
|
QWidget* GUI::getCurrentTabWidget() const {
|
||||||
if(isMinimized() || !isVisible())
|
if(isMinimized() || !isVisible())
|
||||||
return -1;
|
return 0;
|
||||||
return tabs->currentIndex();
|
if(tabs->currentIndex() == 0)
|
||||||
|
return transferList;
|
||||||
|
return tabs->currentWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::setTabText(int index, QString text) const {
|
void GUI::setTabText(int index, QString text) const {
|
||||||
|
@ -551,7 +563,7 @@ void GUI::on_actionAbout_triggered() {
|
||||||
|
|
||||||
void GUI::showEvent(QShowEvent *e) {
|
void GUI::showEvent(QShowEvent *e) {
|
||||||
qDebug("** Show Event **");
|
qDebug("** Show Event **");
|
||||||
if(getCurrentTabIndex() == TAB_TRANSFER) {
|
if(getCurrentTabWidget() == transferList) {
|
||||||
qDebug("-> Refreshing transfer list");
|
qDebug("-> Refreshing transfer list");
|
||||||
transferList->refreshList();
|
transferList->refreshList();
|
||||||
properties->loadDynamicData();
|
properties->loadDynamicData();
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
|
|
||||||
|
|
||||||
class Bittorrent;
|
class Bittorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class downloadFromURL;
|
class downloadFromURL;
|
||||||
|
@ -68,7 +66,7 @@ public:
|
||||||
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
||||||
~GUI();
|
~GUI();
|
||||||
// Methods
|
// Methods
|
||||||
int getCurrentTabIndex() const;
|
QWidget* getCurrentTabWidget() const;
|
||||||
TransferListWidget* getTransferList() const { return transferList; }
|
TransferListWidget* getTransferList() const { return transferList; }
|
||||||
QMenu* getTrayIconMenu();
|
QMenu* getTrayIconMenu();
|
||||||
|
|
||||||
|
|
|
@ -2089,7 +2089,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
|
||||||
QString hash;
|
QString hash;
|
||||||
#if LIBTORRENT_VERSION_MINOR > 14
|
#if LIBTORRENT_VERSION_MINOR > 14
|
||||||
hash = misc::toQString(p->info_hash);
|
hash = misc::toQString(p->info_hash);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Unfortunately libtorrent v0.14 does not provide the hash,
|
// Unfortunately libtorrent v0.14 does not provide the hash,
|
||||||
// only the torrent handle that is often invalid when it arrives
|
// only the torrent handle that is often invalid when it arrives
|
||||||
|
|
|
@ -327,7 +327,7 @@ void PropertiesWidget::reloadPreferences() {
|
||||||
|
|
||||||
void PropertiesWidget::loadDynamicData() {
|
void PropertiesWidget::loadDynamicData() {
|
||||||
// Refresh only if the torrent handle is valid and if visible
|
// Refresh only if the torrent handle is valid and if visible
|
||||||
if(!h.is_valid() || main_window->getCurrentTabIndex() != TAB_TRANSFER || state != VISIBLE) return;
|
if(!h.is_valid() || main_window->getCurrentTabWidget() != transferList || state != VISIBLE) return;
|
||||||
try {
|
try {
|
||||||
// Transfer infos
|
// Transfer infos
|
||||||
if(stackedProperties->currentIndex() == MAIN_TAB) {
|
if(stackedProperties->currentIndex() == MAIN_TAB) {
|
||||||
|
|
|
@ -277,6 +277,10 @@ void SearchEngine::searchTextEdited(QString) {
|
||||||
search_button->setText(tr("Search"));
|
search_button->setText(tr("Search"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchEngine::giveFocusToSearchInput() {
|
||||||
|
search_pattern->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
// Function called when we click on search button
|
// Function called when we click on search button
|
||||||
void SearchEngine::on_search_button_clicked(){
|
void SearchEngine::on_search_button_clicked(){
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
@ -549,7 +553,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
|
||||||
}
|
}
|
||||||
QIniSettings settings("qBittorrent", "qBittorrent");
|
QIniSettings settings("qBittorrent", "qBittorrent");
|
||||||
bool useNotificationBalloons = settings.value("Preferences/General/NotificationBaloons", true).toBool();
|
bool useNotificationBalloons = settings.value("Preferences/General/NotificationBaloons", true).toBool();
|
||||||
if(useNotificationBalloons && parent->getCurrentTabIndex() != TAB_SEARCH) {
|
if(useNotificationBalloons && parent->getCurrentTabWidget() != this) {
|
||||||
parent->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
parent->showNotificationBaloon(tr("Search Engine"), tr("Search has finished"));
|
||||||
}
|
}
|
||||||
if(exitcode){
|
if(exitcode){
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void on_download_button_clicked();
|
void on_download_button_clicked();
|
||||||
void downloadTorrent(QString engine_url, QString torrent_url);
|
void downloadTorrent(QString engine_url, QString torrent_url);
|
||||||
|
void giveFocusToSearchInput();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// Search slots
|
// Search slots
|
||||||
|
|
|
@ -486,7 +486,7 @@ void TransferListWidget::refreshList(bool force) {
|
||||||
// Stop updating the display
|
// Stop updating the display
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
// Refresh only if displayed
|
// Refresh only if displayed
|
||||||
if(!force && main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
|
if(!force && main_window->getCurrentTabWidget() != this) return;
|
||||||
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0, nb_paused = 0;
|
unsigned int nb_downloading = 0, nb_seeding=0, nb_active=0, nb_inactive = 0, nb_paused = 0;
|
||||||
if(BTSession->getSession()->get_torrents().size() != (uint)listModel->rowCount()) {
|
if(BTSession->getSession()->get_torrents().size() != (uint)listModel->rowCount()) {
|
||||||
// Oups, we have torrents that are not displayed, fix this
|
// Oups, we have torrents that are not displayed, fix this
|
||||||
|
@ -695,7 +695,7 @@ void TransferListWidget::pauseAllTorrents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::deleteSelectedTorrents() {
|
void TransferListWidget::deleteSelectedTorrents() {
|
||||||
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
|
if(main_window->getCurrentTabWidget() != this) return;
|
||||||
const QStringList& hashes = getSelectedTorrentsHashes();
|
const QStringList& hashes = getSelectedTorrentsHashes();
|
||||||
if(!hashes.empty()) {
|
if(!hashes.empty()) {
|
||||||
bool delete_local_files = false;
|
bool delete_local_files = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue