소스 검색

small fixes about panel

1. Focus to the input when activating the Search panel;
2. Expand content area won't activate all the panels.
Le Tan 4 년 전
부모
커밋
8955afae66
2개의 변경된 파일23개의 추가작업 그리고 3개의 파일을 삭제
  1. 22 3
      src/widgets/mainwindow.cpp
  2. 1 0
      src/widgets/searchpanel.cpp

+ 22 - 3
src/widgets/mainwindow.cpp

@@ -18,6 +18,7 @@
 #include <QSystemTrayIcon>
 #include <QWindowStateChangeEvent>
 #include <QTimer>
+#include <QBitArray>
 
 #include "toolbox.h"
 #include "notebookexplorer.h"
@@ -478,9 +479,27 @@ void MainWindow::resetStateAndGeometry()
 
 void MainWindow::setContentAreaExpanded(bool p_expanded)
 {
-    for (auto dock : m_docks) {
-        if (!dock->isFloating()) {
-            dock->setVisible(!p_expanded);
+    static QBitArray dockStateCache(m_docks.size(), false);
+
+    if (p_expanded) {
+        // Store the state and hide.
+        for (int i = 0; i < m_docks.size(); ++i) {
+            if (m_docks[i]->isFloating()) {
+                dockStateCache[i] = true;
+                continue;
+            }
+
+            dockStateCache[i] = m_docks[i]->isVisible();
+            m_docks[i]->setVisible(false);
+        }
+    } else {
+        // Restore the state.
+        for (int i = 0; i < m_docks.size(); ++i) {
+            if (m_docks[i]->isFloating()) {
+                continue;
+            }
+
+            m_docks[i]->setVisible(dockStateCache[i]);
         }
     }
 }

+ 1 - 0
src/widgets/searchpanel.cpp

@@ -79,6 +79,7 @@ void SearchPanel::setupUI()
     m_keywordComboBox->setLineEdit(WidgetsFactory::createLineEdit(mainWidget));
     m_keywordComboBox->lineEdit()->setProperty(PropertyDefs::c_embeddedLineEdit, true);
     m_keywordComboBox->completer()->setCaseSensitivity(Qt::CaseSensitive);
+    setFocusProxy(m_keywordComboBox);
     connect(m_keywordComboBox->lineEdit(), &QLineEdit::returnPressed,
             this, [this]() {
                 m_searchBtn->animateClick();