mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add toolbuttons for changing view
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
de44760cf3
commit
a6647bb113
12
src/resources/icons/expand.svg
Normal file
12
src/resources/icons/expand.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="274,209.7 337.9,145.9 288,96 416,96 416,224 366.1,174.1 302.3,238 "/>
|
||||||
|
<polygon points="274,302.3 337.9,366.1 288,416 416,416 416,288 366.1,337.9 302.3,274 "/>
|
||||||
|
<polygon points="238,302.3 174.1,366.1 224,416 96,416 96,288 145.9,337.9 209.7,274 "/>
|
||||||
|
<polygon points="238,209.7 174.1,145.9 224,96 96,96 96,224 145.9,174.1 209.7,238 "/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 861 B |
10
src/resources/icons/one_panel.svg
Normal file
10
src/resources/icons/one_panel.svg
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
|
||||||
|
<title>one_panel</title>
|
||||||
|
<g>
|
||||||
|
<title>Layer 1</title>
|
||||||
|
<rect id="svg_1" height="395" width="395" y="57" x="58" stroke-width="40" stroke="#000000" fill="none"/>
|
||||||
|
<line id="svg_4" y2="455" x2="193" y1="61" x1="193" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="40" stroke="#000000" fill="none"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 540 B |
11
src/resources/icons/two_panels.svg
Normal file
11
src/resources/icons/two_panels.svg
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<svg width="512" height="512" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
|
||||||
|
<title>one_panel</title>
|
||||||
|
<g>
|
||||||
|
<title>Layer 1</title>
|
||||||
|
<rect id="svg_1" height="395" width="395" y="57" x="58" stroke-width="40" stroke="#000000" fill="none"/>
|
||||||
|
<line id="svg_4" y2="454" x2="153" y1="60" x1="153" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="40" stroke="#000000" fill="none"/>
|
||||||
|
<line id="svg_5" y2="451.005195" x2="246" y1="66" x1="246" stroke-linecap="null" stroke-linejoin="null" stroke-dasharray="null" stroke-width="40" stroke="#000000" fill="none"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 719 B |
@ -179,6 +179,27 @@ void VMainWindow::initActions()
|
|||||||
connect(saveNoteAct, &QAction::triggered,
|
connect(saveNoteAct, &QAction::triggered,
|
||||||
tabs, &VTabWidget::saveFile);
|
tabs, &VTabWidget::saveFile);
|
||||||
|
|
||||||
|
viewAct = new QActionGroup(this);
|
||||||
|
twoPanelViewAct = new QAction(QIcon(":/resources/icons/two_panels.svg"),
|
||||||
|
tr("&Two Panels"), viewAct);
|
||||||
|
twoPanelViewAct->setStatusTip(tr("Display the directory and notes browser panel"));
|
||||||
|
twoPanelViewAct->setCheckable(true);
|
||||||
|
twoPanelViewAct->setData(2);
|
||||||
|
onePanelViewAct = new QAction(QIcon(":/resources/icons/one_panel.svg"),
|
||||||
|
tr("&Single panel"), viewAct);
|
||||||
|
onePanelViewAct->setStatusTip(tr("Display only the notes browser panel"));
|
||||||
|
onePanelViewAct->setCheckable(true);
|
||||||
|
onePanelViewAct->setData(1);
|
||||||
|
expandViewAct = new QAction(QIcon(":/resources/icons/expand.svg"),
|
||||||
|
tr("&Expand"), viewAct);
|
||||||
|
expandViewAct->setStatusTip(tr("Expand the editing area"));
|
||||||
|
expandViewAct->setCheckable(true);
|
||||||
|
expandViewAct->setData(0);
|
||||||
|
connect(viewAct, &QActionGroup::triggered,
|
||||||
|
this, &VMainWindow::changePanelView);
|
||||||
|
// Must be called after setting up the signal to sync the state and settings
|
||||||
|
twoPanelViewAct->setChecked(true);
|
||||||
|
|
||||||
importNoteAct = new QAction(tr("&Import note from file"), this);
|
importNoteAct = new QAction(tr("&Import note from file"), this);
|
||||||
importNoteAct->setStatusTip(tr("Import notes into current directory from files"));
|
importNoteAct->setStatusTip(tr("Import notes into current directory from files"));
|
||||||
connect(importNoteAct, &QAction::triggered,
|
connect(importNoteAct, &QAction::triggered,
|
||||||
@ -239,7 +260,6 @@ void VMainWindow::initActions()
|
|||||||
void VMainWindow::initToolBar()
|
void VMainWindow::initToolBar()
|
||||||
{
|
{
|
||||||
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
||||||
fileToolBar->setMovable(false);
|
|
||||||
fileToolBar->addAction(newNoteAct);
|
fileToolBar->addAction(newNoteAct);
|
||||||
fileToolBar->addAction(editNoteAct);
|
fileToolBar->addAction(editNoteAct);
|
||||||
fileToolBar->addAction(saveExitAct);
|
fileToolBar->addAction(saveExitAct);
|
||||||
@ -250,6 +270,11 @@ void VMainWindow::initToolBar()
|
|||||||
saveExitAct->setVisible(false);
|
saveExitAct->setVisible(false);
|
||||||
discardExitAct->setVisible(false);
|
discardExitAct->setVisible(false);
|
||||||
saveNoteAct->setVisible(false);
|
saveNoteAct->setVisible(false);
|
||||||
|
|
||||||
|
QToolBar *viewToolBar = addToolBar(tr("View"));
|
||||||
|
viewToolBar->addAction(twoPanelViewAct);
|
||||||
|
viewToolBar->addAction(onePanelViewAct);
|
||||||
|
viewToolBar->addAction(expandViewAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initMenuBar()
|
void VMainWindow::initMenuBar()
|
||||||
@ -634,3 +659,39 @@ void VMainWindow::updateToolbarFromTabChage(const QString ¬ebook, const QStri
|
|||||||
saveNoteAct->setVisible(false);
|
saveNoteAct->setVisible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::changePanelView(QAction *action)
|
||||||
|
{
|
||||||
|
if (!action) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int nrPanel = action->data().toInt();
|
||||||
|
|
||||||
|
changeSplitterView(nrPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VMainWindow::changeSplitterView(int nrPanel)
|
||||||
|
{
|
||||||
|
switch (nrPanel) {
|
||||||
|
case 0:
|
||||||
|
// Expand
|
||||||
|
mainSplitter->widget(0)->hide();
|
||||||
|
mainSplitter->widget(1)->hide();
|
||||||
|
mainSplitter->widget(2)->show();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
// Single panel
|
||||||
|
mainSplitter->widget(0)->hide();
|
||||||
|
mainSplitter->widget(1)->show();
|
||||||
|
mainSplitter->widget(2)->show();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
// Two panels
|
||||||
|
mainSplitter->widget(0)->show();
|
||||||
|
mainSplitter->widget(1)->show();
|
||||||
|
mainSplitter->widget(2)->show();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
qWarning() << "error: invalid panel number" << nrPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -46,6 +46,7 @@ private slots:
|
|||||||
void setRenderBackgroundColor(QAction *action);
|
void setRenderBackgroundColor(QAction *action);
|
||||||
void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
||||||
bool editMode, bool modifiable);
|
bool editMode, bool modifiable);
|
||||||
|
void changePanelView(QAction *action);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void curNotebookChanged(const QString ¬ebookName);
|
void curNotebookChanged(const QString ¬ebookName);
|
||||||
@ -59,6 +60,7 @@ private:
|
|||||||
void initPredefinedColorPixmaps();
|
void initPredefinedColorPixmaps();
|
||||||
void initRenderBackgroundMenu(QMenu *menu);
|
void initRenderBackgroundMenu(QMenu *menu);
|
||||||
void initEditorBackgroundMenu(QMenu *menu);
|
void initEditorBackgroundMenu(QMenu *menu);
|
||||||
|
void changeSplitterView(int nrPanel);
|
||||||
|
|
||||||
// If true, comboBox changes will not trigger any signal out
|
// If true, comboBox changes will not trigger any signal out
|
||||||
bool notebookComboMuted;
|
bool notebookComboMuted;
|
||||||
@ -84,6 +86,10 @@ private:
|
|||||||
QAction *saveNoteAct;
|
QAction *saveNoteAct;
|
||||||
QAction *saveExitAct;
|
QAction *saveExitAct;
|
||||||
QAction *discardExitAct;
|
QAction *discardExitAct;
|
||||||
|
QActionGroup *viewAct;
|
||||||
|
QAction *twoPanelViewAct;
|
||||||
|
QAction *onePanelViewAct;
|
||||||
|
QAction *expandViewAct;
|
||||||
QAction *importNoteAct;
|
QAction *importNoteAct;
|
||||||
QActionGroup *converterAct;
|
QActionGroup *converterAct;
|
||||||
QAction *markedAct;
|
QAction *markedAct;
|
||||||
|
@ -50,5 +50,8 @@
|
|||||||
<file>resources/icons/note_info.svg</file>
|
<file>resources/icons/note_info.svg</file>
|
||||||
<file>resources/icons/dir_info.svg</file>
|
<file>resources/icons/dir_info.svg</file>
|
||||||
<file>resources/icons/notebook_info.svg</file>
|
<file>resources/icons/notebook_info.svg</file>
|
||||||
|
<file>resources/icons/expand.svg</file>
|
||||||
|
<file>resources/icons/two_panels.svg</file>
|
||||||
|
<file>resources/icons/one_panel.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user