client: Set Channel List input focus, sort A-Z
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 22 Jun 2018 01:46:54 +0000 (20:46 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 12 Jul 2018 22:36:39 +0000 (00:36 +0200)
Set Channel List input focus to reasonable defaults.  When advanced
channel search is visible, focus it.  Otherwise, focus the channel
list filter box.

Sort channel list by name in ascending order by default.  Sort order
can be changed afterwards as before.

src/qtui/channellistdlg.cpp
src/qtui/channellistdlg.h

index f8b7028..d6dde67 100644 (file)
@@ -49,6 +49,8 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
     ui.channelListView->setTabKeyNavigation(false);
     ui.channelListView->setModel(&_sortFilter);
     ui.channelListView->setSortingEnabled(true);
     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.channelListView->verticalHeader()->hide();
     ui.channelListView->horizontalHeader()->setStretchLastSection(true);
 
@@ -70,6 +72,9 @@ ChannelListDlg::ChannelListDlg(QWidget *parent)
     enableQuery(true);
     showFilterLine(false);
     showErrors(false);
     enableQuery(true);
     showFilterLine(false);
     showErrors(false);
+
+    // Set initial input focus
+    updateInputFocus();
 }
 
 
 }
 
 
@@ -113,6 +118,8 @@ void ChannelListDlg::receiveChannelList(const NetworkId &netId, const QStringLis
     showFilterLine(!channelList.isEmpty());
     _ircListModel.setChannelList(channelList);
     enableQuery(_listFinished);
     showFilterLine(!channelList.isEmpty());
     _ircListModel.setChannelList(channelList);
     enableQuery(_listFinished);
+    // Reset input focus since UI changed
+    updateInputFocus();
 }
 
 
 }
 
 
@@ -157,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) {
 void ChannelListDlg::showErrors(bool show)
 {
     if (!show) {
index b818778..fbdb38f 100644 (file)
@@ -66,6 +66,11 @@ private:
     void enableQuery(bool enable);
     void setAdvancedMode(bool advanced);
 
     void enableQuery(bool enable);
     void setAdvancedMode(bool advanced);
 
+    /**
+     * Update the focus of input widgets according to dialog state
+     */
+    void updateInputFocus();
+
     Ui::ChannelListDlg ui;
 
     bool _listFinished;
     Ui::ChannelListDlg ui;
 
     bool _listFinished;