From 2d6669b88d2e022f9e1ff806d0072f9895df681a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 28 Mar 2016 18:22:01 +0800 Subject: [PATCH 1/4] [Search] minor cleanups --- src/gui/search/pluginselectdlg.ui | 7 +- src/gui/search/pluginsourcedlg.ui | 27 +++---- src/gui/search/searchwidget.cpp | 1 - src/gui/search/searchwidget.ui | 117 +++++++++++++++--------------- 4 files changed, 74 insertions(+), 78 deletions(-) diff --git a/src/gui/search/pluginselectdlg.ui b/src/gui/search/pluginselectdlg.ui index a87d23c6c..8f9ff31e8 100644 --- a/src/gui/search/pluginselectdlg.ui +++ b/src/gui/search/pluginselectdlg.ui @@ -16,7 +16,7 @@ Search plugins - + @@ -82,16 +82,13 @@ You can get new search engine plugins here: <a href="http://plugins.qbittorrent.org">http://plugins.qbittorrent.org</a> - - Qt::AutoText - true - + diff --git a/src/gui/search/pluginsourcedlg.ui b/src/gui/search/pluginsourcedlg.ui index a2ca22d95..9b0411e1d 100644 --- a/src/gui/search/pluginsourcedlg.ui +++ b/src/gui/search/pluginsourcedlg.ui @@ -1,7 +1,8 @@ - + + PluginSourceDlg - - + + 0 0 @@ -9,36 +10,36 @@ 76 - + Plugin source - + - - + + 75 true true - + Search plugin source: - + - - + + Local file - - + + Web link diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 63008b11d..e5c1ec796 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -108,7 +108,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl")); pluginsButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network")); copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy")); - tabWidget->setTabsClosable(true); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); m_searchEngine = new SearchEngine; diff --git a/src/gui/search/searchwidget.ui b/src/gui/search/searchwidget.ui index e3d539135..c2641f19e 100644 --- a/src/gui/search/searchwidget.ui +++ b/src/gui/search/searchwidget.ui @@ -6,7 +6,7 @@ 0 0 - 1382 + 843 669 @@ -24,6 +24,12 @@ + + + 0 + 0 + + Search @@ -33,69 +39,62 @@ - - - 0 - 1 - + + true - + - - - - - false - - - Download - - - - - - - false - - - Go to description page - - - - - - - false - - - Copy description page URL - - - - - - - Qt::Horizontal - - - - 601 - 20 - - - - - - - - Search plugins... - - - - + + + false + + + Download + + + + + + + false + + + Go to description page + + + + + + + false + + + Copy description page URL + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + + + Search plugins... + + From 231262ad8ec89d3c62ddf1dd96a55e3aac24b74e Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 28 Feb 2016 14:57:34 +0800 Subject: [PATCH 2/4] [Search] match combobox height to button height --- src/gui/search/searchwidget.ui | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui/search/searchwidget.ui b/src/gui/search/searchwidget.ui index c2641f19e..a4a8471ef 100644 --- a/src/gui/search/searchwidget.ui +++ b/src/gui/search/searchwidget.ui @@ -17,10 +17,24 @@ - + + + + 0 + 0 + + + - + + + + 0 + 0 + + + From a52f9d4ef9bcb904fef94718b8d620cd5434eeb4 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 29 Feb 2016 14:46:39 +0800 Subject: [PATCH 3/4] [Search] Add seperator for categories & plugins Sort categories & plugins entries Rename & reorder entries Use full name for plugins --- src/base/searchengine.cpp | 5 +++++ src/base/searchengine.h | 1 + src/gui/search/searchwidget.cpp | 37 ++++++++++++++++++++++++--------- src/gui/search/searchwidget.h | 2 +- 4 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/base/searchengine.cpp b/src/base/searchengine.cpp index 624f47d5a..e13f8ee51 100644 --- a/src/base/searchengine.cpp +++ b/src/base/searchengine.cpp @@ -295,6 +295,11 @@ QString SearchEngine::categoryFullName(const QString &categoryName) return tr(m_categoryNames.value(categoryName).toUtf8().constData()); } +QString SearchEngine::pluginFullName(const QString &pluginName) +{ + return pluginInfo(pluginName) ? pluginInfo(pluginName)->fullName : QString(); +} + QString SearchEngine::pluginsLocation() { return QString("%1/engines").arg(engineLocation()); diff --git a/src/base/searchengine.h b/src/base/searchengine.h index 084affdf3..009e59cda 100644 --- a/src/base/searchengine.h +++ b/src/base/searchengine.h @@ -86,6 +86,7 @@ public: static qreal getPluginVersion(QString filePath); static QString categoryFullName(const QString &categoryName); + QString pluginFullName(const QString &pluginName); static QString pluginsLocation(); signals: diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index e5c1ec796..a0908977c 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -121,27 +121,43 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) fillPluginComboBox(); connect(m_searchPattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); - connect(selectPlugin, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(selectMultipleBox(const QString &))); + connect(selectPlugin, SIGNAL(currentIndexChanged(int)), this, SLOT(selectMultipleBox(int))); } void SearchWidget::fillCatCombobox() { comboCategory->clear(); comboCategory->addItem(SearchEngine::categoryFullName("all"), QVariant("all")); - foreach (QString cat, m_searchEngine->supportedCategories()) { - qDebug("Supported category: %s", qPrintable(cat)); - comboCategory->addItem(SearchEngine::categoryFullName(cat), QVariant(cat)); + comboCategory->insertSeparator(1); + + using QStrPair = QPair; + QList tmpList; + foreach (const QString &cat, m_searchEngine->supportedCategories()) + tmpList << qMakePair(SearchEngine::categoryFullName(cat), cat); + std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } ); + + foreach (const QStrPair &p, tmpList) { + qDebug("Supported category: %s", qPrintable(p.second)); + comboCategory->addItem(p.first, QVariant(p.second)); } } void SearchWidget::fillPluginComboBox() { selectPlugin->clear(); - selectPlugin->addItem(tr("All enabled"), QVariant("enabled")); selectPlugin->addItem(tr("All plugins"), QVariant("all")); - foreach (QString name, m_searchEngine->enabledPlugins()) - selectPlugin->addItem(name, QVariant(name)); - selectPlugin->addItem(tr("Multiple..."), QVariant("multi")); + selectPlugin->addItem(tr("Only enabled"), QVariant("enabled")); + selectPlugin->addItem(tr("Select..."), QVariant("multi")); + selectPlugin->insertSeparator(3); + + using QStrPair = QPair; + QList tmpList; + foreach (const QString &name, m_searchEngine->enabledPlugins()) + tmpList << qMakePair(m_searchEngine->pluginFullName(name), name); + std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (l.first < r.first); } ); + + foreach (const QStrPair &p, tmpList) + selectPlugin->addItem(p.first, QVariant(p.second)); } QString SearchWidget::selectedCategory() const @@ -180,9 +196,10 @@ void SearchWidget::tab_changed(int t) } } -void SearchWidget::selectMultipleBox(const QString &text) +void SearchWidget::selectMultipleBox(int index) { - if (text == tr("Multiple...")) + Q_UNUSED(index); + if (selectedPlugin() == "multi") on_pluginsButton_clicked(); } diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index 0098b4b7c..b09dddd47 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -71,7 +71,7 @@ private slots: void searchStarted(); void searchFinished(bool cancelled); void searchFailed(); - void selectMultipleBox(const QString &text); + void selectMultipleBox(int index); void saveResultsColumnsWidth(); void fillCatCombobox(); From 216d98844be14f10f88de47608cb6068115f0975 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sat, 12 Mar 2016 20:04:03 +0800 Subject: [PATCH 4/4] Move m_searchPattern widget from code to .ui file --- src/gui/search/searchwidget.cpp | 8 +------- src/gui/search/searchwidget.h | 2 -- src/gui/search/searchwidget.ui | 10 ++++++++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index a0908977c..f52cb3a41 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -61,7 +61,6 @@ #include "mainwindow.h" #include "addnewtorrentdialog.h" #include "guiiconprovider.h" -#include "lineedit.h" #include "pluginselectdlg.h" #include "searchsortmodel.h" #include "searchtab.h" @@ -78,13 +77,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) { setupUi(this); - m_searchPattern = new LineEdit(this); - searchBarLayout->insertWidget(0, m_searchPattern); - connect(m_searchPattern, SIGNAL(returnPressed()), searchButton, SLOT(click())); - QString searchPatternHint; QTextStream stream(&searchPatternHint, QIODevice::WriteOnly); - stream << "

" << tr("A phrase to search for.") << "
" << tr("Spaces in a search term may be protected by double quotes.") @@ -99,7 +93,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) "Search phrase example, illustrates quotes usage, double quoted" "pair of space delimited words, the whole pair is highlighted") << "

" << flush; - m_searchPattern->setToolTip(searchPatternHint); // Icons @@ -120,6 +113,7 @@ SearchWidget::SearchWidget(MainWindow *mainWindow) fillCatCombobox(); fillPluginComboBox(); + connect(m_searchPattern, SIGNAL(returnPressed()), searchButton, SLOT(click())); connect(m_searchPattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); connect(selectPlugin, SIGNAL(currentIndexChanged(int)), this, SLOT(selectMultipleBox(int))); } diff --git a/src/gui/search/searchwidget.h b/src/gui/search/searchwidget.h index b09dddd47..4d8f74de6 100644 --- a/src/gui/search/searchwidget.h +++ b/src/gui/search/searchwidget.h @@ -38,7 +38,6 @@ #include "ui_searchwidget.h" class MainWindow; -class LineEdit; class SearchEngine; struct SearchResult; class SearchTab; @@ -82,7 +81,6 @@ private: QString selectedCategory() const; QString selectedPlugin() const; - LineEdit *m_searchPattern; SearchEngine *m_searchEngine; QPointer m_currentSearchTab; // Selected tab QPointer m_activeSearchTab; // Tab with running search diff --git a/src/gui/search/searchwidget.ui b/src/gui/search/searchwidget.ui index a4a8471ef..d3acb07f0 100644 --- a/src/gui/search/searchwidget.ui +++ b/src/gui/search/searchwidget.ui @@ -16,6 +16,9 @@ + + + @@ -114,6 +117,13 @@
+ + + LineEdit + QLineEdit +
lineedit.h
+
+