X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchannellistdlg.cpp;h=de872a740b84114fb61df566e7854355837dbd3f;hp=d49e34cf40f02fce087443a1d205bb042bf09a61;hb=158443f71d48215eea8b47b836b61afd77654b78;hpb=0a43227b8cd44625f4881cc1545d42c8c8a4876c diff --git a/src/qtui/channellistdlg.cpp b/src/qtui/channellistdlg.cpp index d49e34cf..de872a74 100644 --- a/src/qtui/channellistdlg.cpp +++ b/src/qtui/channellistdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -22,26 +22,23 @@ #include #include -#include #include #include "client.h" #include "clientirclisthelper.h" +#include "icon.h" ChannelListDlg::ChannelListDlg(QWidget *parent) : QDialog(parent), - _listFinished(true), _ircListModel(this), - _sortFilter(this), - _simpleModeSpacer(0), - _advancedMode(false) + _sortFilter(this) { _sortFilter.setSourceModel(&_ircListModel); _sortFilter.setFilterCaseSensitivity(Qt::CaseInsensitive); _sortFilter.setFilterKeyColumn(-1); ui.setupUi(this); - ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-rename").pixmap(22)); + ui.advancedModeLabel->setPixmap(icon::get("edit-rename").pixmap(22)); ui.channelListView->setSelectionBehavior(QAbstractItemView::SelectRows); ui.channelListView->setSelectionMode(QAbstractItemView::SingleSelection); @@ -49,12 +46,14 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) ui.channelListView->setTabKeyNavigation(false); ui.channelListView->setModel(&_sortFilter); ui.channelListView->setSortingEnabled(true); + // Sort A-Z by default + ui.channelListView->sortByColumn(0, Qt::AscendingOrder); ui.channelListView->verticalHeader()->hide(); ui.channelListView->horizontalHeader()->setStretchLastSection(true); ui.searchChannelsButton->setAutoDefault(false); - setWindowIcon(QIcon::fromTheme("format-list-unordered")); + setWindowIcon(icon::get("format-list-unordered")); connect(ui.advancedModeLabel, SIGNAL(clicked()), this, SLOT(toggleMode())); connect(ui.searchChannelsButton, SIGNAL(clicked()), this, SLOT(requestSearch())); @@ -70,6 +69,9 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) enableQuery(true); showFilterLine(false); showErrors(false); + + // Set initial input focus + updateInputFocus(); } @@ -84,8 +86,22 @@ void ChannelListDlg::setNetwork(NetworkId netId) } +void ChannelListDlg::setChannelFilters(const QString &channelFilters) +{ + // Enable advanced mode if searching + setAdvancedMode(!channelFilters.isEmpty()); + // Set channel search text after setting advanced mode so it's not cleared + ui.channelNameLineEdit->setText(channelFilters.trimmed()); +} + + void ChannelListDlg::requestSearch() { + if (!_netId.isValid()) { + // No valid network set yet + return; + } + _listFinished = false; enableQuery(false); showErrors(false); @@ -104,6 +120,8 @@ void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringLis showFilterLine(!channelList.isEmpty()); _ircListModel.setChannelList(channelList); enableQuery(_listFinished); + // Reset input focus since UI changed + updateInputFocus(); } @@ -130,16 +148,16 @@ void ChannelListDlg::setAdvancedMode(bool advanced) if (_simpleModeSpacer) { ui.searchLayout->removeItem(_simpleModeSpacer); delete _simpleModeSpacer; - _simpleModeSpacer = 0; + _simpleModeSpacer = nullptr; } - ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-clear-locationbar-rtl", QIcon::fromTheme("edit-clear")).pixmap(16)); + ui.advancedModeLabel->setPixmap(icon::get("edit-clear-locationbar-rtl").pixmap(16)); } else { if (!_simpleModeSpacer) { _simpleModeSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); ui.searchLayout->insertSpacerItem(0, _simpleModeSpacer); } - ui.advancedModeLabel->setPixmap(QIcon::fromTheme("edit-rename").pixmap(16)); + ui.advancedModeLabel->setPixmap(icon::get("edit-rename").pixmap(16)); } ui.channelNameLineEdit->clear(); @@ -148,6 +166,18 @@ void ChannelListDlg::setAdvancedMode(bool advanced) } +void ChannelListDlg::updateInputFocus() +{ + // Update keyboard focus to match what options are available. Prioritize the channel name + // editor as one likely won't need to filter when already limiting the list. + if (ui.channelNameLineEdit->isVisible()) { + ui.channelNameLineEdit->setFocus(); + } else if (ui.filterLineEdit->isVisible()) { + ui.filterLineEdit->setFocus(); + } +} + + void ChannelListDlg::showErrors(bool show) { if (!show) {