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());
}
QString SearchEngine::pluginFullName(const QString &pluginName)
{
return pluginInfo(pluginName) ? pluginInfo(pluginName)->fullName : QString();
}
QString SearchEngine::pluginsLocation()
{
return QString("%1/engines").arg(engineLocation());

View File

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

View File

@ -16,7 +16,7 @@
<property name="windowTitle">
<string>Search plugins</string>
</property>
<layout class="QVBoxLayout">
<layout class="QVBoxLayout" name="pluginSelectLayout">
<item>
<widget class="QLabel" name="lbl_plugins">
<property name="font">
@ -82,16 +82,13 @@
<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>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<layout class="QHBoxLayout" name="layout1">
<item>
<widget class="QPushButton" name="installButton">
<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>
<widget class="QDialog" name="PluginSourceDlg" >
<property name="geometry" >
<widget class="QDialog" name="PluginSourceDlg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
@ -9,36 +10,36 @@
<height>76</height>
</rect>
</property>
<property name="windowTitle" >
<property name="windowTitle">
<string>Plugin source</string>
</property>
<layout class="QVBoxLayout" >
<layout class="QVBoxLayout" name="pluginSourceLayout">
<item>
<widget class="QLabel" name="source_lbl" >
<property name="font" >
<widget class="QLabel" name="source_lbl">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
<underline>true</underline>
</font>
</property>
<property name="text" >
<property name="text">
<string>Search plugin source:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<layout class="QHBoxLayout" name="layout1">
<item>
<widget class="QPushButton" name="localButton" >
<property name="text" >
<widget class="QPushButton" name="localButton">
<property name="text">
<string>Local file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="urlButton" >
<property name="text" >
<widget class="QPushButton" name="urlButton">
<property name="text">
<string>Web link</string>
</property>
</widget>

View File

@ -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 << "<html><head/><body><p>"
<< tr("A phrase to search for.") << "<br>"
<< 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")
<< "</p></body></html>" << flush;
m_searchPattern->setToolTip(searchPatternHint);
// Icons
@ -108,7 +101,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;
@ -122,28 +114,45 @@ 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(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<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()
{
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<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
@ -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();
}

View File

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

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1382</width>
<width>843</width>
<height>669</height>
</rect>
</property>
@ -17,13 +17,36 @@
<item>
<layout class="QHBoxLayout" name="searchBarLayout">
<item>
<widget class="QComboBox" name="comboCategory"/>
<widget class="LineEdit" name="m_searchPattern"/>
</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>
<widget class="QPushButton" name="searchButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Search</string>
</property>
@ -33,18 +56,13 @@
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
<property name="tabsClosable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout">
<item>
<layout class="QHBoxLayout">
<layout class="QHBoxLayout" name="layout2">
<item>
<widget class="QPushButton" name="downloadButton">
<property name="enabled">
@ -76,14 +94,14 @@
</widget>
</item>
<item>
<spacer>
<spacer name="spacer2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>601</width>
<height>20</height>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
@ -98,9 +116,14 @@
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>LineEdit</class>
<extends>QLineEdit</extends>
<header>lineedit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>