Merge pull request #4995 from Chocobo1/border

Search UI tweaks
This commit is contained in:
sledgehammer999 2016-04-13 07:11:31 -05:00
commit 32490f1ef6
7 changed files with 135 additions and 100 deletions

View file

@ -310,6 +310,11 @@ QString SearchEngine::categoryFullName(const QString &categoryName)
return tr(m_categoryNames.value(categoryName).toUtf8().constData()); return tr(m_categoryNames.value(categoryName).toUtf8().constData());
} }
QString SearchEngine::pluginFullName(const QString &pluginName)
{
return pluginInfo(pluginName) ? pluginInfo(pluginName)->fullName : QString();
}
QString SearchEngine::pluginsLocation() QString SearchEngine::pluginsLocation()
{ {
return QString("%1/engines").arg(engineLocation()); return QString("%1/engines").arg(engineLocation());

View file

@ -88,6 +88,7 @@ public:
static qreal getPluginVersion(QString filePath); static qreal getPluginVersion(QString filePath);
static QString categoryFullName(const QString &categoryName); static QString categoryFullName(const QString &categoryName);
QString pluginFullName(const QString &pluginName);
static QString pluginsLocation(); static QString pluginsLocation();
signals: signals:

View file

@ -16,7 +16,7 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Search plugins</string> <string>Search plugins</string>
</property> </property>
<layout class="QVBoxLayout"> <layout class="QVBoxLayout" name="pluginSelectLayout">
<item> <item>
<widget class="QLabel" name="lbl_plugins"> <widget class="QLabel" name="lbl_plugins">
<property name="font"> <property name="font">
@ -82,16 +82,13 @@
<property name="text"> <property name="text">
<string>You can get new search engine plugins here: &lt;a href=&quot;http://plugins.qbittorrent.org&quot;&gt;http://plugins.qbittorrent.org&lt;/a&gt;</string> <string>You can get new search engine plugins here: &lt;a href=&quot;http://plugins.qbittorrent.org&quot;&gt;http://plugins.qbittorrent.org&lt;/a&gt;</string>
</property> </property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout"> <layout class="QHBoxLayout" name="layout1">
<item> <item>
<widget class="QPushButton" name="installButton"> <widget class="QPushButton" name="installButton">
<property name="text"> <property name="text">

View file

@ -1,7 +1,8 @@
<ui version="4.0" > <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PluginSourceDlg</class> <class>PluginSourceDlg</class>
<widget class="QDialog" name="PluginSourceDlg" > <widget class="QDialog" name="PluginSourceDlg">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
@ -9,36 +10,36 @@
<height>76</height> <height>76</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>Plugin source</string> <string>Plugin source</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" name="pluginSourceLayout">
<item> <item>
<widget class="QLabel" name="source_lbl" > <widget class="QLabel" name="source_lbl">
<property name="font" > <property name="font">
<font> <font>
<weight>75</weight> <weight>75</weight>
<bold>true</bold> <bold>true</bold>
<underline>true</underline> <underline>true</underline>
</font> </font>
</property> </property>
<property name="text" > <property name="text">
<string>Search plugin source:</string> <string>Search plugin source:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" name="layout1">
<item> <item>
<widget class="QPushButton" name="localButton" > <widget class="QPushButton" name="localButton">
<property name="text" > <property name="text">
<string>Local file</string> <string>Local file</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="urlButton" > <widget class="QPushButton" name="urlButton">
<property name="text" > <property name="text">
<string>Web link</string> <string>Web link</string>
</property> </property>
</widget> </widget>

View file

@ -61,7 +61,6 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "addnewtorrentdialog.h" #include "addnewtorrentdialog.h"
#include "guiiconprovider.h" #include "guiiconprovider.h"
#include "lineedit.h"
#include "pluginselectdlg.h" #include "pluginselectdlg.h"
#include "searchsortmodel.h" #include "searchsortmodel.h"
#include "searchtab.h" #include "searchtab.h"
@ -78,13 +77,8 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
{ {
setupUi(this); setupUi(this);
m_searchPattern = new LineEdit(this);
searchBarLayout->insertWidget(0, m_searchPattern);
connect(m_searchPattern, SIGNAL(returnPressed()), searchButton, SLOT(click()));
QString searchPatternHint; QString searchPatternHint;
QTextStream stream(&searchPatternHint, QIODevice::WriteOnly); QTextStream stream(&searchPatternHint, QIODevice::WriteOnly);
stream << "<html><head/><body><p>" stream << "<html><head/><body><p>"
<< tr("A phrase to search for.") << "<br>" << tr("A phrase to search for.") << "<br>"
<< tr("Spaces in a search term may be protected by double quotes.") << 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" "Search phrase example, illustrates quotes usage, double quoted"
"pair of space delimited words, the whole pair is highlighted") "pair of space delimited words, the whole pair is highlighted")
<< "</p></body></html>" << flush; << "</p></body></html>" << flush;
m_searchPattern->setToolTip(searchPatternHint); m_searchPattern->setToolTip(searchPatternHint);
// Icons // Icons
@ -108,7 +101,6 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl")); goToDescBtn->setIcon(GuiIconProvider::instance()->getIcon("application-x-mswinurl"));
pluginsButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network")); pluginsButton->setIcon(GuiIconProvider::instance()->getIcon("preferences-system-network"));
copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy")); copyURLBtn->setIcon(GuiIconProvider::instance()->getIcon("edit-copy"));
tabWidget->setTabsClosable(true);
connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); connect(tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
m_searchEngine = new SearchEngine; m_searchEngine = new SearchEngine;
@ -122,28 +114,45 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
fillCatCombobox(); fillCatCombobox();
fillPluginComboBox(); fillPluginComboBox();
connect(m_searchPattern, SIGNAL(returnPressed()), searchButton, SLOT(click()));
connect(m_searchPattern, SIGNAL(textEdited(QString)), this, SLOT(searchTextEdited(QString))); 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() void SearchWidget::fillCatCombobox()
{ {
comboCategory->clear(); comboCategory->clear();
comboCategory->addItem(SearchEngine::categoryFullName("all"), QVariant("all")); comboCategory->addItem(SearchEngine::categoryFullName("all"), QVariant("all"));
foreach (QString cat, m_searchEngine->supportedCategories()) { comboCategory->insertSeparator(1);
qDebug("Supported category: %s", qPrintable(cat));
comboCategory->addItem(SearchEngine::categoryFullName(cat), QVariant(cat)); using QStrPair = QPair<QString, QString>;
QList<QStrPair> 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() void SearchWidget::fillPluginComboBox()
{ {
selectPlugin->clear(); selectPlugin->clear();
selectPlugin->addItem(tr("All enabled"), QVariant("enabled"));
selectPlugin->addItem(tr("All plugins"), QVariant("all")); selectPlugin->addItem(tr("All plugins"), QVariant("all"));
foreach (QString name, m_searchEngine->enabledPlugins()) selectPlugin->addItem(tr("Only enabled"), QVariant("enabled"));
selectPlugin->addItem(name, QVariant(name)); selectPlugin->addItem(tr("Select..."), QVariant("multi"));
selectPlugin->addItem(tr("Multiple..."), QVariant("multi")); selectPlugin->insertSeparator(3);
using QStrPair = QPair<QString, QString>;
QList<QStrPair> 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 QString SearchWidget::selectedCategory() const
@ -190,9 +199,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(); on_pluginsButton_clicked();
} }

View file

@ -38,7 +38,6 @@
#include "ui_searchwidget.h" #include "ui_searchwidget.h"
class MainWindow; class MainWindow;
class LineEdit;
class SearchEngine; class SearchEngine;
struct SearchResult; struct SearchResult;
class SearchTab; class SearchTab;
@ -71,7 +70,7 @@ private slots:
void searchStarted(); void searchStarted();
void searchFinished(bool cancelled); void searchFinished(bool cancelled);
void searchFailed(); void searchFailed();
void selectMultipleBox(const QString &text); void selectMultipleBox(int index);
void addTorrentToSession(const QString &source); void addTorrentToSession(const QString &source);
@ -84,7 +83,6 @@ private:
QString selectedCategory() const; QString selectedCategory() const;
QString selectedPlugin() const; QString selectedPlugin() const;
LineEdit *m_searchPattern;
SearchEngine *m_searchEngine; SearchEngine *m_searchEngine;
QPointer<SearchTab> m_currentSearchTab; // Selected tab QPointer<SearchTab> m_currentSearchTab; // Selected tab
QPointer<SearchTab> m_activeSearchTab; // Tab with running search QPointer<SearchTab> m_activeSearchTab; // Tab with running search

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1382</width> <width>843</width>
<height>669</height> <height>669</height>
</rect> </rect>
</property> </property>
@ -17,13 +17,36 @@
<item> <item>
<layout class="QHBoxLayout" name="searchBarLayout"> <layout class="QHBoxLayout" name="searchBarLayout">
<item> <item>
<widget class="QComboBox" name="comboCategory"/> <widget class="LineEdit" name="m_searchPattern"/>
</item> </item>
<item> <item>
<widget class="QComboBox" name="selectPlugin"/> <widget class="QComboBox" name="comboCategory">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="selectPlugin">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QPushButton" name="searchButton"> <widget class="QPushButton" name="searchButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text"> <property name="text">
<string>Search</string> <string>Search</string>
</property> </property>
@ -33,74 +56,74 @@
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy"> <property name="tabsClosable">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding"> <bool>true</bool>
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QVBoxLayout"> <layout class="QHBoxLayout" name="layout2">
<item> <item>
<layout class="QHBoxLayout"> <widget class="QPushButton" name="downloadButton">
<item> <property name="enabled">
<widget class="QPushButton" name="downloadButton"> <bool>false</bool>
<property name="enabled"> </property>
<bool>false</bool> <property name="text">
</property> <string>Download</string>
<property name="text"> </property>
<string>Download</string> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QPushButton" name="goToDescBtn">
<item> <property name="enabled">
<widget class="QPushButton" name="goToDescBtn"> <bool>false</bool>
<property name="enabled"> </property>
<bool>false</bool> <property name="text">
</property> <string>Go to description page</string>
<property name="text"> </property>
<string>Go to description page</string> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QPushButton" name="copyURLBtn">
<item> <property name="enabled">
<widget class="QPushButton" name="copyURLBtn"> <bool>false</bool>
<property name="enabled"> </property>
<bool>false</bool> <property name="text">
</property> <string>Copy description page URL</string>
<property name="text"> </property>
<string>Copy description page URL</string> </widget>
</property> </item>
</widget> <item>
</item> <spacer name="spacer2">
<item> <property name="orientation">
<spacer> <enum>Qt::Horizontal</enum>
<property name="orientation"> </property>
<enum>Qt::Horizontal</enum> <property name="sizeHint" stdset="0">
</property> <size>
<property name="sizeHint" stdset="0"> <width>0</width>
<size> <height>0</height>
<width>601</width> </size>
<height>20</height> </property>
</size> </spacer>
</property> </item>
</spacer> <item>
</item> <widget class="QPushButton" name="pluginsButton">
<item> <property name="text">
<widget class="QPushButton" name="pluginsButton"> <string>Search plugins...</string>
<property name="text"> </property>
<string>Search plugins...</string> </widget>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>LineEdit</class>
<extends>QLineEdit</extends>
<header>lineedit.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>