Browse Source

Fix issues related to tab order in main window

Make sure the search input has focus when switching to the search tab
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
bceb00d35f
  1. 28
      src/GUI.cpp
  2. 4
      src/GUI.h
  3. 1
      src/bittorrent.cpp
  4. 2
      src/propertieswidget.cpp
  5. 6
      src/searchengine.cpp
  6. 1
      src/searchengine.h
  7. 4
      src/transferlistwidget.cpp

28
src/GUI.cpp

@ -345,10 +345,18 @@ void GUI::on_actionBugReport_triggered() const { @@ -345,10 +345,18 @@ void GUI::on_actionBugReport_triggered() const {
}
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");
transferList->refreshList();
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() { @@ -401,15 +409,17 @@ void GUI::createKeyboardShortcuts() {
// Keyboard shortcuts slots
void GUI::displayTransferTab() const {
tabs->setCurrentIndex(TAB_TRANSFER);
tabs->setCurrentWidget(transferList);
}
void GUI::displaySearchTab() const {
tabs->setCurrentIndex(TAB_SEARCH);
if(searchEngine)
tabs->setCurrentWidget(searchEngine);
}
void GUI::displayRSSTab() const {
tabs->setCurrentIndex(TAB_RSS);
if(rssWidget)
tabs->setCurrentWidget(rssWidget);
}
// End of keyboard shortcuts slots
@ -509,10 +519,12 @@ void GUI::on_actionExit_triggered() { @@ -509,10 +519,12 @@ void GUI::on_actionExit_triggered() {
close();
}
int GUI::getCurrentTabIndex() const {
QWidget* GUI::getCurrentTabWidget() const {
if(isMinimized() || !isVisible())
return -1;
return tabs->currentIndex();
return 0;
if(tabs->currentIndex() == 0)
return transferList;
return tabs->currentWidget();
}
void GUI::setTabText(int index, QString text) const {
@ -551,7 +563,7 @@ void GUI::on_actionAbout_triggered() { @@ -551,7 +563,7 @@ void GUI::on_actionAbout_triggered() {
void GUI::showEvent(QShowEvent *e) {
qDebug("** Show Event **");
if(getCurrentTabIndex() == TAB_TRANSFER) {
if(getCurrentTabWidget() == transferList) {
qDebug("-> Refreshing transfer list");
transferList->refreshList();
properties->loadDynamicData();

4
src/GUI.h

@ -37,8 +37,6 @@ @@ -37,8 +37,6 @@
#include "ui_mainwindow.h"
#include "qtorrenthandle.h"
enum TabIndex{TAB_TRANSFER, TAB_SEARCH, TAB_RSS};
class Bittorrent;
class QTimer;
class downloadFromURL;
@ -68,7 +66,7 @@ public: @@ -68,7 +66,7 @@ public:
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
~GUI();
// Methods
int getCurrentTabIndex() const;
QWidget* getCurrentTabWidget() const;
TransferListWidget* getTransferList() const { return transferList; }
QMenu* getTrayIconMenu();

1
src/bittorrent.cpp

@ -2089,7 +2089,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) { @@ -2089,7 +2089,6 @@ void Bittorrent::addConsoleMessage(QString msg, QString) {
QString hash;
#if LIBTORRENT_VERSION_MINOR > 14
hash = misc::toQString(p->info_hash);
#else
// Unfortunately libtorrent v0.14 does not provide the hash,
// only the torrent handle that is often invalid when it arrives

2
src/propertieswidget.cpp

@ -327,7 +327,7 @@ void PropertiesWidget::reloadPreferences() { @@ -327,7 +327,7 @@ void PropertiesWidget::reloadPreferences() {
void PropertiesWidget::loadDynamicData() {
// 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 {
// Transfer infos
if(stackedProperties->currentIndex() == MAIN_TAB) {

6
src/searchengine.cpp

@ -277,6 +277,10 @@ void SearchEngine::searchTextEdited(QString) { @@ -277,6 +277,10 @@ void SearchEngine::searchTextEdited(QString) {
search_button->setText(tr("Search"));
}
void SearchEngine::giveFocusToSearchInput() {
search_pattern->setFocus();
}
// Function called when we click on search button
void SearchEngine::on_search_button_clicked(){
#ifdef Q_WS_WIN
@ -549,7 +553,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){ @@ -549,7 +553,7 @@ void SearchEngine::searchFinished(int exitcode,QProcess::ExitStatus){
}
QIniSettings settings("qBittorrent", "qBittorrent");
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"));
}
if(exitcode){

1
src/searchengine.h

@ -104,6 +104,7 @@ public: @@ -104,6 +104,7 @@ public:
public slots:
void on_download_button_clicked();
void downloadTorrent(QString engine_url, QString torrent_url);
void giveFocusToSearchInput();
protected slots:
// Search slots

4
src/transferlistwidget.cpp

@ -486,7 +486,7 @@ void TransferListWidget::refreshList(bool force) { @@ -486,7 +486,7 @@ void TransferListWidget::refreshList(bool force) {
// Stop updating the display
setUpdatesEnabled(false);
// 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;
if(BTSession->getSession()->get_torrents().size() != (uint)listModel->rowCount()) {
// Oups, we have torrents that are not displayed, fix this
@ -695,7 +695,7 @@ void TransferListWidget::pauseAllTorrents() { @@ -695,7 +695,7 @@ void TransferListWidget::pauseAllTorrents() {
}
void TransferListWidget::deleteSelectedTorrents() {
if(main_window->getCurrentTabIndex() != TAB_TRANSFER) return;
if(main_window->getCurrentTabWidget() != this) return;
const QStringList& hashes = getSelectedTorrentsHashes();
if(!hashes.empty()) {
bool delete_local_files = false;

Loading…
Cancel
Save