X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchannellistdlg.cpp;h=d6dde67d1b482c94c28456f91a2a307ae61a8b90;hp=14a7e31c0068b08cb4bd3b14e63613a46256e36d;hb=efe1292ee3dffb7fe2f8cee2c4c2767cd53efb34;hpb=1cb02004ee5973b89368bd84f234d4652794690d diff --git a/src/qtui/channellistdlg.cpp b/src/qtui/channellistdlg.cpp index 14a7e31c..d6dde67d 100644 --- a/src/qtui/channellistdlg.cpp +++ b/src/qtui/channellistdlg.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2015 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,11 +22,11 @@ #include #include -#include #include #include "client.h" #include "clientirclisthelper.h" +#include "icon.h" ChannelListDlg::ChannelListDlg(QWidget *parent) : QDialog(parent), @@ -41,7 +41,7 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) _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 +49,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 +72,9 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) enableQuery(true); showFilterLine(false); showErrors(false); + + // Set initial input focus + updateInputFocus(); } @@ -84,6 +89,15 @@ 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() { _listFinished = false; @@ -104,6 +118,8 @@ void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringLis showFilterLine(!channelList.isEmpty()); _ircListModel.setChannelList(channelList); enableQuery(_listFinished); + // Reset input focus since UI changed + updateInputFocus(); } @@ -132,14 +148,14 @@ void ChannelListDlg::setAdvancedMode(bool advanced) delete _simpleModeSpacer; _simpleModeSpacer = 0; } - 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 +164,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) {