qtui: Make the debug log a proper dialog
[quassel.git] / src / qtui / channellistdlg.cpp
index f8b7028..d575dc7 100644 (file)
@@ -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) {