add icon to indicate the read/edit mode of tab

Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
Le Tan 2016-12-24 09:32:05 +08:00
parent d4fe99b8bb
commit b14d15e266
4 changed files with 37 additions and 8 deletions

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g>
<rect x="178.846" y="92.087" transform="matrix(-0.7071 -0.7071 0.7071 -0.7071 224.3476 631.1498)" width="128.085" height="354.049"/>
<path d="M471.723,88.393l-48.115-48.114c-11.723-11.724-31.558-10.896-44.304,1.85l-45.202,45.203l90.569,90.568l45.202-45.202
C482.616,119.952,483.445,100.116,471.723,88.393z"/>
<polygon points="64.021,363.252 32,480 148.737,447.979 "/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 876 B

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g>
<path d="M112,64v16v320h16V80h304v337.143c0,8.205-6.652,14.857-14.857,14.857H94.857C86.652,432,80,425.348,80,417.143V128h16v-16
H64v305.143C64,434.157,77.843,448,94.857,448h322.285C434.157,448,448,434.157,448,417.143V64H112z"/>
<rect x="160" y="112" width="128" height="16"/>
<rect x="160" y="192" width="240" height="16"/>
<rect x="160" y="272" width="192" height="16"/>
<rect x="160" y="352" width="240" height="16"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 927 B

View File

@ -94,8 +94,8 @@ void VEditWindow::removeEditTab(int p_index)
int VEditWindow::insertEditTab(int p_index, VFile *p_file, QWidget *p_page) int VEditWindow::insertEditTab(int p_index, VFile *p_file, QWidget *p_page)
{ {
int idx = insertTab(p_index, p_page, p_file->getName()); int idx = insertTab(p_index, p_page, p_file->getName());
QTabBar *tabs = tabBar(); setTabToolTip(idx, generateTooltip(p_file));
tabs->setTabToolTip(idx, generateTooltip(p_file)); setTabIcon(idx, QIcon(":/resources/icons/reading.svg"));
return idx; return idx;
} }
@ -293,9 +293,10 @@ void VEditWindow::noticeTabStatus(int p_index)
bool editMode = editor->getIsEditMode(); bool editMode = editor->getIsEditMode();
// Update tab text // Update tab text
QTabBar *tabs = tabBar(); setTabText(p_index, generateTabText(file->getName(), file->isModified()));
tabs->setTabText(p_index, generateTabText(file->getName(), file->isModified())); setTabToolTip(p_index, generateTooltip(file));
tabs->setTabToolTip(p_index, generateTooltip(file)); setTabIcon(p_index, editMode ? QIcon(":/resources/icons/editing.svg") :
QIcon(":/resources/icons/reading.svg"));
emit tabStatusChanged(file, editor, editMode); emit tabStatusChanged(file, editor, editMode);
} }
@ -387,12 +388,11 @@ void VEditWindow::updateTabListMenu()
} }
int curTab = currentIndex(); int curTab = currentIndex();
QTabBar *tabbar = tabBar(); int nrTab = count();
int nrTab = tabbar->count();
for (int i = 0; i < nrTab; ++i) { for (int i = 0; i < nrTab; ++i) {
VEditTab *editor = getTab(i); VEditTab *editor = getTab(i);
QPointer<VFile> file = editor->getFile(); QPointer<VFile> file = editor->getFile();
QAction *action = new QAction(tabbar->tabText(i), tabListAct); QAction *action = new QAction(tabIcon(i), tabText(i), tabListAct);
action->setStatusTip(generateTooltip(file)); action->setStatusTip(generateTooltip(file));
action->setData(QVariant::fromValue(file)); action->setData(QVariant::fromValue(file));
if (i == curTab) { if (i == curTab) {

View File

@ -74,5 +74,7 @@
<file>resources/icons/vnote.png</file> <file>resources/icons/vnote.png</file>
<file>resources/icons/insert_image.svg</file> <file>resources/icons/insert_image.svg</file>
<file>resources/icons/import_note.svg</file> <file>resources/icons/import_note.svg</file>
<file>resources/icons/editing.svg</file>
<file>resources/icons/reading.svg</file>
</qresource> </qresource>
</RCC> </RCC>