瀏覽代碼

add abck tab icon

Le Tan 3 年之前
父節點
當前提交
2a91577521
共有 3 個文件被更改,包括 32 次插入4 次删除
  1. 2 2
      .github/workflows/ci-linux.yml
  2. 25 2
      src/widgets/viewwindow.cpp
  3. 5 0
      src/widgets/viewwindow.h

+ 2 - 2
.github/workflows/ci-linux.yml

@@ -45,12 +45,12 @@ jobs:
         uses: actions/cache@v1  # not v2!
         uses: actions/cache@v1  # not v2!
         with:
         with:
           path: ../Qt
           path: ../Qt
-          key: ${{ runner.os }}-QtCache-5.12-1
+          key: ${{ runner.os }}-QtCache-5.15
 
 
       - name: Install Qt
       - name: Install Qt
         uses: jurplel/install-qt-action@v2
         uses: jurplel/install-qt-action@v2
         with:
         with:
-          version: 5.12.12
+          version: 5.15.2
           target: desktop
           target: desktop
           modules: qtwebengine
           modules: qtwebengine
           tools: tools_openssl_x64,1.1.1-4,qt.tools.openssl.gcc_64
           tools: tools_openssl_x64,1.1.1-4,qt.tools.openssl.gcc_64

+ 25 - 2
src/widgets/viewwindow.cpp

@@ -41,11 +41,17 @@
 
 
 using namespace vnotex;
 using namespace vnotex;
 
 
+QIcon ViewWindow::s_savedIcon;
+
+QIcon ViewWindow::s_modifiedIcon;
+
 ViewWindow::ViewWindow(QWidget *p_parent)
 ViewWindow::ViewWindow(QWidget *p_parent)
     : QFrame(p_parent)
     : QFrame(p_parent)
 {
 {
     setupUI();
     setupUI();
 
 
+    initIcons();
+
     setupShortcuts();
     setupShortcuts();
 
 
     // Need to use this global-wise way, especially for the WebView.
     // Need to use this global-wise way, especially for the WebView.
@@ -96,6 +102,20 @@ void ViewWindow::setupUI()
     m_mainLayout->addLayout(m_bottomLayout, 0);
     m_mainLayout->addLayout(m_bottomLayout, 0);
 }
 }
 
 
+void ViewWindow::initIcons()
+{
+    if (!s_savedIcon.isNull()) {
+        return;
+    }
+
+    const auto &themeMgr = VNoteX::getInst().getThemeMgr();
+    const QString savedIconName("buffer.svg");
+    const QString unsavedIconFg("base#icon#warning#fg");
+    s_savedIcon = IconUtils::fetchIcon(themeMgr.getIconFile(savedIconName));
+    s_modifiedIcon = IconUtils::fetchIcon(themeMgr.getIconFile(savedIconName),
+                                          themeMgr.paletteColor(unsavedIconFg));
+}
+
 Buffer *ViewWindow::getBuffer() const
 Buffer *ViewWindow::getBuffer() const
 {
 {
     return m_buffer;
     return m_buffer;
@@ -174,8 +194,11 @@ void ViewWindow::detachFromBuffer(bool p_quiet)
 
 
 QIcon ViewWindow::getIcon() const
 QIcon ViewWindow::getIcon() const
 {
 {
-    // Unnecessary to provide an icon for the tab.
-    return QIcon();
+    if (m_buffer) {
+        return m_buffer->isModified() ? s_modifiedIcon : s_savedIcon;
+    } else {
+        return s_savedIcon;
+    }
 }
 }
 
 
 QString ViewWindow::getName() const
 QString ViewWindow::getName() const

+ 5 - 0
src/widgets/viewwindow.h

@@ -283,6 +283,8 @@ namespace vnotex
 
 
         void setupUI();
         void setupUI();
 
 
+        void initIcons();
+
         void setupShortcuts();
         void setupShortcuts();
 
 
         void discardChangesAndRead();
         void discardChangesAndRead();
@@ -376,6 +378,9 @@ namespace vnotex
         QActionGroup *m_imageHostActionGroup = nullptr;
         QActionGroup *m_imageHostActionGroup = nullptr;
 
 
         bool m_statusWidgetInBottomLayout = false;
         bool m_statusWidgetInBottomLayout = false;
+
+        static QIcon s_savedIcon;
+        static QIcon s_modifiedIcon;
     };
     };
 } // ns vnotex
 } // ns vnotex