mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
update a more friendly toolbar
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
a6774fdf49
commit
ec7850685e
10
src/resources/icons/create_note_tb.svg
Normal file
10
src/resources/icons/create_note_tb.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?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" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<path d="M399.3,168.9c-0.7-2.9-2-5-3.5-6.8l-83.7-91.7c-1.9-2.1-4.1-3.1-6.6-4.4c-2.9-1.5-6.1-1.6-9.4-1.6H136.2
|
||||||
|
c-12.4,0-23.7,9.6-23.7,22.9v335.2c0,13.4,11.3,25.9,23.7,25.9h243.1c12.4,0,21.2-12.5,21.2-25.9V178.4
|
||||||
|
C400.5,174.8,400.1,172.2,399.3,168.9z M305.5,111l58,63.5h-58V111z M144.5,416.5v-320h129v81.7c0,14.8,13.4,28.3,28.1,28.3h66.9
|
||||||
|
v210H144.5z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 847 B |
9
src/resources/icons/discard_exit.svg
Normal file
9
src/resources/icons/discard_exit.svg
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?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">
|
||||||
|
<path d="M215.469,332.802l29.863,29.864L352,256L245.332,149.333l-29.863,29.865l55.469,55.469H64v42.666h205.864L215.469,332.802z
|
||||||
|
M405.334,64H106.666C83.198,64,64,83.198,64,106.666V192h42.666v-85.333h298.668v298.668H106.666V320H64v85.334
|
||||||
|
C64,428.802,83.198,448,106.666,448h298.668C428.802,448,448,428.802,448,405.334V106.666C448,83.198,428.802,64,405.334,64z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 849 B |
14
src/resources/icons/edit_note.svg
Normal file
14
src/resources/icons/edit_note.svg
Normal 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" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<path d="M442.8,99.6l-30.4-30.4c-7-6.9-18.2-6.9-25.1,0L355.5,101l55.5,55.5l31.8-31.7C449.7,117.7,449.7,106.5,442.8,99.6z"/>
|
||||||
|
<g>
|
||||||
|
<polygon points="346.1,110.5 174.1,288 160,352 224,337.9 400.6,164.9 "/>
|
||||||
|
</g>
|
||||||
|
<path d="M384,256v150c0,5.1-3.9,10.1-9.2,10.1s-269-0.1-269-0.1c-5.6,0-9.8-5.4-9.8-10s0-268,0-268c0-5,4.7-10,10.6-10H256l32-32
|
||||||
|
H87.4c-13,0-23.4,10.3-23.4,23.3v305.3c0,12.9,10.5,23.4,23.4,23.4h305.3c12.9,0,23.3-10.5,23.3-23.4V224L384,256z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 963 B |
10
src/resources/icons/save_exit.svg
Normal file
10
src/resources/icons/save_exit.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?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" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<path d="M461.6,109.6l-54.9-43.3c-1.7-1.4-3.8-2.4-6.2-2.4c-2.4,0-4.6,1-6.3,2.5L194.5,323c0,0-78.5-75.5-80.7-77.7
|
||||||
|
c-2.2-2.2-5.1-5.9-9.5-5.9c-4.4,0-6.4,3.1-8.7,5.4c-1.7,1.8-29.7,31.2-43.5,45.8c-0.8,0.9-1.3,1.4-2,2.1c-1.2,1.7-2,3.6-2,5.7
|
||||||
|
c0,2.2,0.8,4,2,5.7l2.8,2.6c0,0,139.3,133.8,141.6,136.1c2.3,2.3,5.1,5.2,9.2,5.2c4,0,7.3-4.3,9.2-6.2L462,121.8
|
||||||
|
c1.2-1.7,2-3.6,2-5.8C464,113.5,463,111.4,461.6,109.6z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 898 B |
12
src/resources/icons/save_note.svg
Normal file
12
src/resources/icons/save_note.svg
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?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" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<polygon points="256,307.7 384,192 304,192 304,96 207.6,96 207.6,192 128,192 "/>
|
||||||
|
<path d="M465.4,297.2l-71.4-55h-42l62,61.8h-50.6c-2.3,0-4.3,1.2-5.4,2.9l-18.4,45.5H172.1l-18.4-45.5c-1-1.8-3.1-2.9-5.4-2.9H97.8
|
||||||
|
l62.2-61.8h-42.2l-71.4,55c-10.6,6.2-15.8,19-14.1,31.6l8.7,66.9c2.3,13.1,9.7,20.3,28.1,20.3h373.8c19.1,0,25.8-7.6,28.1-20.3
|
||||||
|
l8.7-66.9C481.4,315.9,476,303.4,465.4,297.2z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 892 B |
@ -8,9 +8,9 @@
|
|||||||
#include "vdocument.h"
|
#include "vdocument.h"
|
||||||
#include "vmarkdownconverter.h"
|
#include "vmarkdownconverter.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
|
#include "vedit.h"
|
||||||
|
|
||||||
class QTextBrowser;
|
class QTextBrowser;
|
||||||
class VEdit;
|
|
||||||
class QWebEngineView;
|
class QWebEngineView;
|
||||||
class VNote;
|
class VNote;
|
||||||
|
|
||||||
@ -27,6 +27,9 @@ public:
|
|||||||
// Save file
|
// Save file
|
||||||
bool saveFile();
|
bool saveFile();
|
||||||
|
|
||||||
|
inline bool getIsEditMode() const;
|
||||||
|
inline bool isModified() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isMarkdown(const QString &name);
|
bool isMarkdown(const QString &name);
|
||||||
void setupUI();
|
void setupUI();
|
||||||
@ -44,4 +47,14 @@ private:
|
|||||||
MarkdownConverterType mdConverterType;
|
MarkdownConverterType mdConverterType;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool VEditor::getIsEditMode() const
|
||||||
|
{
|
||||||
|
return isEditMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool VEditor::isModified() const
|
||||||
|
{
|
||||||
|
return textEditor->isModified();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VEDITOR_H
|
#endif // VEDITOR_H
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
|
#include <QList>
|
||||||
#include "vmainwindow.h"
|
#include "vmainwindow.h"
|
||||||
#include "vdirectorytree.h"
|
#include "vdirectorytree.h"
|
||||||
#include "vnote.h"
|
#include "vnote.h"
|
||||||
@ -81,16 +82,23 @@ void VMainWindow::setupUI()
|
|||||||
// Editor tab widget
|
// Editor tab widget
|
||||||
tabs = new VTabWidget(vnote);
|
tabs = new VTabWidget(vnote);
|
||||||
tabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
tabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
tabs->setTabBarAutoHide(true);
|
|
||||||
|
|
||||||
// Main Splitter
|
// Main Splitter
|
||||||
mainSplitter = new QSplitter();
|
mainSplitter = new QSplitter();
|
||||||
mainSplitter->addWidget(nbContainer);
|
mainSplitter->addWidget(nbContainer);
|
||||||
mainSplitter->addWidget(fileList);
|
mainSplitter->addWidget(fileList);
|
||||||
mainSplitter->addWidget(tabs);
|
mainSplitter->addWidget(tabs);
|
||||||
|
QList<int> sizes;
|
||||||
|
int sa = nbContainer->minimumSizeHint().width();
|
||||||
|
int sb = fileList->minimumSizeHint().width();
|
||||||
|
int sc = qMax(mainSplitter->sizeHint().width() - sa - sb, sa + sb);
|
||||||
|
sizes.append(sa);
|
||||||
|
sizes.append(sb);
|
||||||
|
sizes.append(sc);
|
||||||
|
mainSplitter->setSizes(sizes);
|
||||||
mainSplitter->setStretchFactor(0, 1);
|
mainSplitter->setStretchFactor(0, 1);
|
||||||
mainSplitter->setStretchFactor(1, 1);
|
mainSplitter->setStretchFactor(1, 1);
|
||||||
mainSplitter->setStretchFactor(2, 10);
|
mainSplitter->setStretchFactor(2, 200);
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
connect(notebookComboBox, SIGNAL(currentIndexChanged(int)), this,
|
connect(notebookComboBox, SIGNAL(currentIndexChanged(int)), this,
|
||||||
@ -111,6 +119,8 @@ void VMainWindow::setupUI()
|
|||||||
tabs, &VTabWidget::openFile);
|
tabs, &VTabWidget::openFile);
|
||||||
connect(vnote, &VNote::notebooksRenamed,
|
connect(vnote, &VNote::notebooksRenamed,
|
||||||
tabs, &VTabWidget::handleNotebookRenamed);
|
tabs, &VTabWidget::handleNotebookRenamed);
|
||||||
|
connect(tabs, &VTabWidget::tabModeChanged,
|
||||||
|
this, &VMainWindow::updateToolbarFromTabChage);
|
||||||
|
|
||||||
connect(newNotebookBtn, &QPushButton::clicked,
|
connect(newNotebookBtn, &QPushButton::clicked,
|
||||||
this, &VMainWindow::onNewNotebookBtnClicked);
|
this, &VMainWindow::onNewNotebookBtnClicked);
|
||||||
@ -146,17 +156,32 @@ void VMainWindow::setupUI()
|
|||||||
|
|
||||||
void VMainWindow::initActions()
|
void VMainWindow::initActions()
|
||||||
{
|
{
|
||||||
editNoteAct = new QAction(tr("&Edit"), this);
|
newNoteAct = new QAction(QIcon(":/resources/icons/create_note_tb.svg"),
|
||||||
|
tr("&New note"), this);
|
||||||
|
newNoteAct->setStatusTip(tr("Create a new note"));
|
||||||
|
connect(newNoteAct, &QAction::triggered,
|
||||||
|
fileList, &VFileList::newFile);
|
||||||
|
|
||||||
|
editNoteAct = new QAction(QIcon(":/resources/icons/edit_note.svg"),
|
||||||
|
tr("&Edit"), this);
|
||||||
editNoteAct->setStatusTip(tr("Edit current note"));
|
editNoteAct->setStatusTip(tr("Edit current note"));
|
||||||
connect(editNoteAct, &QAction::triggered,
|
connect(editNoteAct, &QAction::triggered,
|
||||||
tabs, &VTabWidget::editFile);
|
tabs, &VTabWidget::editFile);
|
||||||
|
|
||||||
readNoteAct = new QAction(tr("&Read"), this);
|
discardExitAct = new QAction(QIcon(":/resources/icons/discard_exit.svg"),
|
||||||
readNoteAct->setStatusTip(tr("Open current note in read mode"));
|
tr("Discard changes and exit"), this);
|
||||||
connect(readNoteAct, &QAction::triggered,
|
discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||||
|
connect(discardExitAct, &QAction::triggered,
|
||||||
tabs, &VTabWidget::readFile);
|
tabs, &VTabWidget::readFile);
|
||||||
|
|
||||||
saveNoteAct = new QAction(tr("&Save"), this);
|
saveExitAct = new QAction(QIcon(":/resources/icons/save_exit.svg"),
|
||||||
|
tr("Save changes and exit"), this);
|
||||||
|
saveExitAct->setStatusTip(tr("Save changes and exit edit mode"));
|
||||||
|
connect(saveExitAct, &QAction::triggered,
|
||||||
|
tabs, &VTabWidget::saveAndReadFile);
|
||||||
|
|
||||||
|
saveNoteAct = new QAction(QIcon(":/resources/icons/save_note.svg"),
|
||||||
|
tr("&Save"), this);
|
||||||
saveNoteAct->setStatusTip(tr("Save current note"));
|
saveNoteAct->setStatusTip(tr("Save current note"));
|
||||||
saveNoteAct->setShortcut(QKeySequence::Save);
|
saveNoteAct->setShortcut(QKeySequence::Save);
|
||||||
connect(saveNoteAct, &QAction::triggered,
|
connect(saveNoteAct, &QAction::triggered,
|
||||||
@ -223,9 +248,16 @@ void VMainWindow::initToolBar()
|
|||||||
{
|
{
|
||||||
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
||||||
fileToolBar->setMovable(false);
|
fileToolBar->setMovable(false);
|
||||||
|
fileToolBar->addAction(newNoteAct);
|
||||||
fileToolBar->addAction(editNoteAct);
|
fileToolBar->addAction(editNoteAct);
|
||||||
fileToolBar->addAction(readNoteAct);
|
fileToolBar->addAction(saveExitAct);
|
||||||
|
fileToolBar->addAction(discardExitAct);
|
||||||
fileToolBar->addAction(saveNoteAct);
|
fileToolBar->addAction(saveNoteAct);
|
||||||
|
|
||||||
|
editNoteAct->setVisible(false);
|
||||||
|
saveExitAct->setVisible(false);
|
||||||
|
discardExitAct->setVisible(false);
|
||||||
|
saveNoteAct->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initMenuBar()
|
void VMainWindow::initMenuBar()
|
||||||
@ -588,3 +620,25 @@ void VMainWindow::setRenderBackgroundColor(QAction *action)
|
|||||||
vconfig.setCurRenderBackgroundColor(action->data().toString());
|
vconfig.setCurRenderBackgroundColor(action->data().toString());
|
||||||
vnote->updateTemplate();
|
vnote->updateTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
||||||
|
bool editMode, bool modifiable)
|
||||||
|
{
|
||||||
|
if (notebook.isEmpty() || !modifiable) {
|
||||||
|
editNoteAct->setVisible(false);
|
||||||
|
saveExitAct->setVisible(false);
|
||||||
|
discardExitAct->setVisible(false);
|
||||||
|
saveNoteAct->setVisible(false);
|
||||||
|
return;
|
||||||
|
} else if (editMode) {
|
||||||
|
editNoteAct->setVisible(false);
|
||||||
|
saveExitAct->setVisible(true);
|
||||||
|
discardExitAct->setVisible(true);
|
||||||
|
saveNoteAct->setVisible(true);
|
||||||
|
} else {
|
||||||
|
editNoteAct->setVisible(true);
|
||||||
|
saveExitAct->setVisible(false);
|
||||||
|
discardExitAct->setVisible(false);
|
||||||
|
saveNoteAct->setVisible(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,8 @@ private slots:
|
|||||||
void setTabStopWidth(QAction *action);
|
void setTabStopWidth(QAction *action);
|
||||||
void setEditorBackgroundColor(QAction *action);
|
void setEditorBackgroundColor(QAction *action);
|
||||||
void setRenderBackgroundColor(QAction *action);
|
void setRenderBackgroundColor(QAction *action);
|
||||||
|
void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
||||||
|
bool editMode, bool modifiable);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void curNotebookChanged(const QString ¬ebookName);
|
void curNotebookChanged(const QString ¬ebookName);
|
||||||
@ -77,9 +79,11 @@ private:
|
|||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
|
QAction *newNoteAct;
|
||||||
QAction *editNoteAct;
|
QAction *editNoteAct;
|
||||||
QAction *saveNoteAct;
|
QAction *saveNoteAct;
|
||||||
QAction *readNoteAct;
|
QAction *saveExitAct;
|
||||||
|
QAction *discardExitAct;
|
||||||
QAction *importNoteAct;
|
QAction *importNoteAct;
|
||||||
QActionGroup *converterAct;
|
QActionGroup *converterAct;
|
||||||
QAction *markedAct;
|
QAction *markedAct;
|
||||||
|
@ -45,5 +45,10 @@
|
|||||||
<file>resources/icons/create_note.png</file>
|
<file>resources/icons/create_note.png</file>
|
||||||
<file>resources/icons/delete_note.png</file>
|
<file>resources/icons/delete_note.png</file>
|
||||||
<file>resources/icons/note_info.png</file>
|
<file>resources/icons/note_info.png</file>
|
||||||
|
<file>resources/icons/create_note_tb.svg</file>
|
||||||
|
<file>resources/icons/save_note.svg</file>
|
||||||
|
<file>resources/icons/edit_note.svg</file>
|
||||||
|
<file>resources/icons/save_exit.svg</file>
|
||||||
|
<file>resources/icons/discard_exit.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -12,10 +12,10 @@ VTabWidget::VTabWidget(VNote *vnote, QWidget *parent)
|
|||||||
{
|
{
|
||||||
setTabsClosable(true);
|
setTabsClosable(true);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
connect(tabBar(), &QTabBar::tabCloseRequested,
|
connect(this, &VTabWidget::tabCloseRequested,
|
||||||
this, &VTabWidget::handleTabCloseRequest);
|
this, &VTabWidget::handleTabCloseRequest);
|
||||||
|
connect(this, &VTabWidget::currentChanged,
|
||||||
openWelcomePage();
|
this, &VTabWidget::onCurrentChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VTabWidget::openWelcomePage()
|
void VTabWidget::openWelcomePage()
|
||||||
@ -33,6 +33,8 @@ int VTabWidget::insertTabWithData(int index, QWidget *page,
|
|||||||
QTabBar *tabs = tabBar();
|
QTabBar *tabs = tabBar();
|
||||||
tabs->setTabData(idx, tabData);
|
tabs->setTabData(idx, tabData);
|
||||||
|
|
||||||
|
// Need to update again with tabData
|
||||||
|
onCurrentChanged(idx);
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +114,7 @@ int VTabWidget::openFileInTab(const QString ¬ebook, const QString &relativePa
|
|||||||
QJsonObject tabJson;
|
QJsonObject tabJson;
|
||||||
tabJson["notebook"] = notebook;
|
tabJson["notebook"] = notebook;
|
||||||
tabJson["relative_path"] = relativePath;
|
tabJson["relative_path"] = relativePath;
|
||||||
|
tabJson["modifiable"] = modifiable;
|
||||||
return appendTabWithData(editor, tabJson);
|
return appendTabWithData(editor, tabJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,6 +149,14 @@ void VTabWidget::readFile()
|
|||||||
VEditor *editor = dynamic_cast<VEditor *>(currentWidget());
|
VEditor *editor = dynamic_cast<VEditor *>(currentWidget());
|
||||||
Q_ASSERT(editor);
|
Q_ASSERT(editor);
|
||||||
editor->readFile();
|
editor->readFile();
|
||||||
|
onCurrentChanged(currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
void VTabWidget::saveAndReadFile()
|
||||||
|
{
|
||||||
|
saveFile();
|
||||||
|
readFile();
|
||||||
|
onCurrentChanged(currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VTabWidget::editFile()
|
void VTabWidget::editFile()
|
||||||
@ -153,6 +164,7 @@ void VTabWidget::editFile()
|
|||||||
VEditor *editor = dynamic_cast<VEditor *>(currentWidget());
|
VEditor *editor = dynamic_cast<VEditor *>(currentWidget());
|
||||||
Q_ASSERT(editor);
|
Q_ASSERT(editor);
|
||||||
editor->editFile();
|
editor->editFile();
|
||||||
|
onCurrentChanged(currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VTabWidget::saveFile()
|
void VTabWidget::saveFile()
|
||||||
@ -175,3 +187,26 @@ void VTabWidget::handleNotebookRenamed(const QVector<VNotebook> ¬ebooks,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VTabWidget::onCurrentChanged(int index)
|
||||||
|
{
|
||||||
|
if (index == -1) {
|
||||||
|
emit tabModeChanged("", "", false, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject tabJson = tabBar()->tabData(index).toJsonObject();
|
||||||
|
if (tabJson.isEmpty()) {
|
||||||
|
// Maybe the tab data has not been set yet
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString notebook = tabJson["notebook"].toString();
|
||||||
|
QString relativePath = tabJson["relative_path"].toString();
|
||||||
|
VEditor *editor = (VEditor *)widget(index);
|
||||||
|
bool editMode = editor->getIsEditMode();
|
||||||
|
bool modifiable = tabJson["modifiable"].toBool();
|
||||||
|
|
||||||
|
emit tabModeChanged(notebook, relativePath,
|
||||||
|
editMode, modifiable);
|
||||||
|
}
|
||||||
|
@ -17,6 +17,8 @@ public:
|
|||||||
explicit VTabWidget(VNote *vnote, QWidget *parent = 0);
|
explicit VTabWidget(VNote *vnote, QWidget *parent = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void tabModeChanged(const QString ¬ebook, const QString &relativePath,
|
||||||
|
bool editMode, bool modifiable);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openFile(QJsonObject fileJson);
|
void openFile(QJsonObject fileJson);
|
||||||
@ -25,11 +27,13 @@ public slots:
|
|||||||
void editFile();
|
void editFile();
|
||||||
void saveFile();
|
void saveFile();
|
||||||
void readFile();
|
void readFile();
|
||||||
|
void saveAndReadFile();
|
||||||
void handleNotebookRenamed(const QVector<VNotebook> ¬ebooks, const QString &oldName,
|
void handleNotebookRenamed(const QVector<VNotebook> ¬ebooks, const QString &oldName,
|
||||||
const QString &newName);
|
const QString &newName);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleTabCloseRequest(int index);
|
void handleTabCloseRequest(int index);
|
||||||
|
void onCurrentChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openWelcomePage();
|
void openWelcomePage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user