add abck tab icon

This commit is contained in:
Le Tan 2022-08-24 20:16:12 +08:00
parent 08c597513c
commit 2a91577521
3 changed files with 32 additions and 4 deletions

View File

@ -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

View File

@ -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. if (m_buffer) {
return QIcon(); return m_buffer->isModified() ? s_modifiedIcon : s_savedIcon;
} else {
return s_savedIcon;
}
} }
QString ViewWindow::getName() const QString ViewWindow::getName() const

View File

@ -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