mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Improve coding style
This commit is contained in:
@@ -63,7 +63,8 @@ namespace
|
||||
{
|
||||
QString statusIconName(SearchJobWidget::Status st)
|
||||
{
|
||||
switch (st) {
|
||||
switch (st)
|
||||
{
|
||||
case SearchJobWidget::Status::Ongoing:
|
||||
return QLatin1String("task-ongoing");
|
||||
case SearchJobWidget::Status::Finished:
|
||||
@@ -148,14 +149,16 @@ SearchWidget::SearchWidget(MainWindow *mainWindow)
|
||||
|
||||
bool SearchWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if (object == m_ui->tabWidget->tabBar()) {
|
||||
if (object == m_ui->tabWidget->tabBar())
|
||||
{
|
||||
// Close tabs when middle-clicked
|
||||
if (event->type() != QEvent::MouseButtonRelease)
|
||||
return false;
|
||||
|
||||
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||
const int tabIndex = m_ui->tabWidget->tabBar()->tabAt(mouseEvent->pos());
|
||||
if ((mouseEvent->button() == Qt::MiddleButton) && (tabIndex >= 0)) {
|
||||
if ((mouseEvent->button() == Qt::MiddleButton) && (tabIndex >= 0))
|
||||
{
|
||||
closeTab(tabIndex);
|
||||
return true;
|
||||
}
|
||||
@@ -175,7 +178,8 @@ void SearchWidget::fillCatCombobox()
|
||||
tmpList << qMakePair(SearchPluginManager::categoryFullName(cat), cat);
|
||||
std::sort(tmpList.begin(), tmpList.end(), [](const QStrPair &l, const QStrPair &r) { return (QString::localeAwareCompare(l.first, r.first) < 0); });
|
||||
|
||||
for (const QStrPair &p : asConst(tmpList)) {
|
||||
for (const QStrPair &p : asConst(tmpList))
|
||||
{
|
||||
qDebug("Supported category: %s", qUtf8Printable(p.second));
|
||||
m_ui->comboCategory->addItem(p.first, p.second);
|
||||
}
|
||||
@@ -216,14 +220,16 @@ QString SearchWidget::selectedPlugin() const
|
||||
|
||||
void SearchWidget::selectActivePage()
|
||||
{
|
||||
if (SearchPluginManager::instance()->allPlugins().isEmpty()) {
|
||||
if (SearchPluginManager::instance()->allPlugins().isEmpty())
|
||||
{
|
||||
m_ui->stackedPages->setCurrentWidget(m_ui->emptyPage);
|
||||
m_ui->lineEditSearchPattern->setEnabled(false);
|
||||
m_ui->comboCategory->setEnabled(false);
|
||||
m_ui->selectPlugin->setEnabled(false);
|
||||
m_ui->searchButton->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_ui->stackedPages->setCurrentWidget(m_ui->searchPage);
|
||||
m_ui->lineEditSearchPattern->setEnabled(true);
|
||||
m_ui->comboCategory->setEnabled(true);
|
||||
@@ -254,11 +260,13 @@ void SearchWidget::selectMultipleBox(int index)
|
||||
|
||||
void SearchWidget::toggleFocusBetweenLineEdits()
|
||||
{
|
||||
if (m_ui->lineEditSearchPattern->hasFocus() && m_currentSearchTab) {
|
||||
if (m_ui->lineEditSearchPattern->hasFocus() && m_currentSearchTab)
|
||||
{
|
||||
m_currentSearchTab->lineEditSearchResultsFilter()->setFocus();
|
||||
m_currentSearchTab->lineEditSearchResultsFilter()->selectAll();
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
m_ui->lineEditSearchPattern->setFocus();
|
||||
m_ui->lineEditSearchPattern->selectAll();
|
||||
}
|
||||
@@ -284,14 +292,17 @@ void SearchWidget::giveFocusToSearchInput()
|
||||
// Function called when we click on search button
|
||||
void SearchWidget::on_searchButton_clicked()
|
||||
{
|
||||
if (!Utils::ForeignApps::pythonInfo().isValid()) {
|
||||
if (!Utils::ForeignApps::pythonInfo().isValid())
|
||||
{
|
||||
m_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Please install Python to use the Search Engine."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_activeSearchTab) {
|
||||
if (m_activeSearchTab)
|
||||
{
|
||||
m_activeSearchTab->cancelSearch();
|
||||
if (!m_isNewQueryString) {
|
||||
if (!m_isNewQueryString)
|
||||
{
|
||||
m_ui->searchButton->setText(tr("Search"));
|
||||
return;
|
||||
}
|
||||
@@ -301,7 +312,8 @@ void SearchWidget::on_searchButton_clicked()
|
||||
|
||||
const QString pattern = m_ui->lineEditSearchPattern->text().trimmed();
|
||||
// No search pattern entered
|
||||
if (pattern.isEmpty()) {
|
||||
if (pattern.isEmpty())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
||||
return;
|
||||
}
|
||||
@@ -344,10 +356,12 @@ void SearchWidget::tabStatusChanged(QWidget *tab)
|
||||
m_ui->tabWidget->setTabIcon(tabIndex, UIThemeManager::instance()->getIcon(
|
||||
statusIconName(static_cast<SearchJobWidget *>(tab)->status())));
|
||||
|
||||
if ((tab == m_activeSearchTab) && (m_activeSearchTab->status() != SearchJobWidget::Status::Ongoing)) {
|
||||
if ((tab == m_activeSearchTab) && (m_activeSearchTab->status() != SearchJobWidget::Status::Ongoing))
|
||||
{
|
||||
Q_ASSERT(m_activeSearchTab->status() != SearchJobWidget::Status::Ongoing);
|
||||
|
||||
if (m_mainWindow->isNotificationsEnabled() && (m_mainWindow->currentTabWidget() != this)) {
|
||||
if (m_mainWindow->isNotificationsEnabled() && (m_mainWindow->currentTabWidget() != this))
|
||||
{
|
||||
if (m_activeSearchTab->status() == SearchJobWidget::Status::Error)
|
||||
m_mainWindow->showNotificationBaloon(tr("Search Engine"), tr("Search has failed"));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user