X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fqtui%2Fchannellistdlg.cpp;h=d575dc7bcde08a36a72793961bb557f73a169e00;hb=c015fbf8afaf64fbb5a8e2122e2a1ecf0325b1a1;hp=f8b70284a40b12605c8a68e298fe4d6dfef2f6ba;hpb=8e93326fd70af3c0accc599770796619ef3cee6e;p=quassel.git diff --git a/src/qtui/channellistdlg.cpp b/src/qtui/channellistdlg.cpp index f8b70284..d575dc7b 100644 --- a/src/qtui/channellistdlg.cpp +++ b/src/qtui/channellistdlg.cpp @@ -49,6 +49,8 @@ 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); @@ -70,6 +72,9 @@ ChannelListDlg::ChannelListDlg(QWidget *parent) enableQuery(true); showFilterLine(false); showErrors(false); + + // Set initial input focus + updateInputFocus(); } @@ -95,6 +100,11 @@ void ChannelListDlg::setChannelFilters(const QString &channelFilters) void ChannelListDlg::requestSearch() { + if (!_netId.isValid()) { + // No valid network set yet + return; + } + _listFinished = false; enableQuery(false); showErrors(false); @@ -113,6 +123,8 @@ void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringLis showFilterLine(!channelList.isEmpty()); _ircListModel.setChannelList(channelList); enableQuery(_listFinished); + // Reset input focus since UI changed + updateInputFocus(); } @@ -157,6 +169,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) {