diff --git a/src/resources/icons/create_rootdir_tb.svg b/src/resources/icons/create_rootdir_tb.svg
new file mode 100644
index 00000000..610c0cf5
--- /dev/null
+++ b/src/resources/icons/create_rootdir_tb.svg
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/src/vdirectorytree.cpp b/src/vdirectorytree.cpp
index 9e71e369..5264ec7f 100644
--- a/src/vdirectorytree.cpp
+++ b/src/vdirectorytree.cpp
@@ -23,7 +23,8 @@ VDirectoryTree::VDirectoryTree(VNote *vnote, QWidget *parent)
void VDirectoryTree::initActions()
{
- newRootDirAct = new QAction(tr("New &root directory"), this);
+ newRootDirAct = new QAction(QIcon(":/resources/icons/create_rootdir.svg"),
+ tr("New &root directory"), this);
newRootDirAct->setStatusTip(tr("Create a new root directory in current notebook"));
connect(newRootDirAct, &QAction::triggered,
this, &VDirectoryTree::newRootDirectory);
@@ -38,10 +39,17 @@ void VDirectoryTree::initActions()
connect(newSubDirAct, &QAction::triggered,
this, &VDirectoryTree::newSubDirectory);
- deleteDirAct = new QAction(tr("&Delete"), this);
+ deleteDirAct = new QAction(QIcon(":/resources/icons/delete_dir.svg"),
+ tr("&Delete"), this);
deleteDirAct->setStatusTip(tr("Delete selected directory"));
connect(deleteDirAct, &QAction::triggered,
this, &VDirectoryTree::deleteDirectory);
+
+ dirInfoAct = new QAction(QIcon(":/resources/icons/dir_info.svg"),
+ tr("&Info"), this);
+ dirInfoAct->setStatusTip(tr("View and edit current directory's information"));
+ connect(dirInfoAct, &QAction::triggered,
+ this, &VDirectoryTree::editDirectoryInfo);
}
void VDirectoryTree::setNotebook(const QString& notebookName)
@@ -263,6 +271,7 @@ void VDirectoryTree::contextMenuRequested(QPoint pos)
menu.addAction(newSubDirAct);
}
menu.addAction(deleteDirAct);
+ menu.addAction(dirInfoAct);
}
menu.exec(mapToGlobal(pos));
}
diff --git a/src/vdirectorytree.h b/src/vdirectorytree.h
index 19bc3950..286a25c8 100644
--- a/src/vdirectorytree.h
+++ b/src/vdirectorytree.h
@@ -72,6 +72,7 @@ private:
QAction *newSiblingDirAct;
QAction *newSubDirAct;
QAction *deleteDirAct;
+ QAction *dirInfoAct;
};
#endif // VDIRECTORYTREE_H
diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp
index ddd0ff3e..00144de0 100644
--- a/src/vmainwindow.cpp
+++ b/src/vmainwindow.cpp
@@ -46,13 +46,6 @@ void VMainWindow::setupUI()
notebookInfoBtn = new QPushButton(QIcon(":/resources/icons/notebook_info.svg"), "");
notebookInfoBtn->setToolTip(tr("View and edit current notebook's information"));
- newRootDirBtn = new QPushButton(QIcon(":/resources/icons/create_rootdir.svg"), "");
- newRootDirBtn->setToolTip(tr("Create a new root directory"));
- deleteDirBtn = new QPushButton(QIcon(":/resources/icons/delete_dir.svg"), "");
- deleteDirBtn->setToolTip(tr("Delete current directory"));
- dirInfoBtn = new QPushButton(QIcon(":/resources/icons/dir_info.svg"), "");
- dirInfoBtn->setToolTip(tr("View and edit current directory's information"));
-
notebookComboBox = new QComboBox();
notebookComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
directoryTree = new VDirectoryTree(vnote);
@@ -66,9 +59,6 @@ void VMainWindow::setupUI()
QHBoxLayout *dirBtnLayout = new QHBoxLayout;
dirBtnLayout->addWidget(directoryLabel);
dirBtnLayout->addStretch();
- dirBtnLayout->addWidget(newRootDirBtn);
- dirBtnLayout->addWidget(deleteDirBtn);
- dirBtnLayout->addWidget(dirInfoBtn);
QVBoxLayout *nbLayout = new QVBoxLayout;
nbLayout->addLayout(nbBtnLayout);
nbLayout->addWidget(notebookComboBox);
@@ -137,12 +127,6 @@ void VMainWindow::setupUI()
directoryTree, &VDirectoryTree::setNotebook);
connect(vnote, &VNote::notebooksRenamed,
directoryTree, &VDirectoryTree::handleNotebookRenamed);
- connect(newRootDirBtn, &QPushButton::clicked,
- directoryTree, &VDirectoryTree::newRootDirectory);
- connect(deleteDirBtn, &QPushButton::clicked,
- directoryTree, &VDirectoryTree::deleteDirectory);
- connect(dirInfoBtn, &QPushButton::clicked,
- directoryTree, &VDirectoryTree::editDirectoryInfo);
setCentralWidget(mainSplitter);
// Create and show the status bar
@@ -151,6 +135,11 @@ void VMainWindow::setupUI()
void VMainWindow::initActions()
{
+ newRootDirAct = new QAction(QIcon(":/resources/icons/create_rootdir_tb.svg"),
+ tr("&New rood directory"), this);
+ newRootDirAct->setStatusTip(tr("Create a new root directory"));
+ connect(newRootDirAct, &QAction::triggered,
+ directoryTree, &VDirectoryTree::newRootDirectory);
newNoteAct = new QAction(QIcon(":/resources/icons/create_note_tb.svg"),
tr("&New note"), this);
newNoteAct->setStatusTip(tr("Create a new note"));
@@ -263,12 +252,14 @@ void VMainWindow::initActions()
void VMainWindow::initToolBar()
{
QToolBar *fileToolBar = addToolBar(tr("Note"));
+ fileToolBar->addAction(newRootDirAct);
fileToolBar->addAction(newNoteAct);
fileToolBar->addAction(editNoteAct);
fileToolBar->addAction(saveExitAct);
fileToolBar->addAction(discardExitAct);
fileToolBar->addAction(saveNoteAct);
+ newRootDirAct->setEnabled(false);
newNoteAct->setEnabled(false);
editNoteAct->setEnabled(false);
saveExitAct->setVisible(false);
@@ -432,6 +423,9 @@ void VMainWindow::setCurNotebookIndex(int index)
if (index > -1) {
vconfig.setCurNotebookIndex(index);
notebook = vnote->getNotebooks()[index].getName();
+ newRootDirAct->setEnabled(true);
+ } else {
+ newRootDirAct->setEnabled(false);
}
emit curNotebookChanged(notebook);
}
diff --git a/src/vmainwindow.h b/src/vmainwindow.h
index 39384299..e4e7f0c4 100644
--- a/src/vmainwindow.h
+++ b/src/vmainwindow.h
@@ -76,9 +76,6 @@ private:
QPushButton *newNotebookBtn;
QPushButton *deleteNotebookBtn;
QPushButton *notebookInfoBtn;
- QPushButton *newRootDirBtn;
- QPushButton *deleteDirBtn;
- QPushButton *dirInfoBtn;
VFileList *fileList;
VDirectoryTree *directoryTree;
QSplitter *mainSplitter;
@@ -87,6 +84,7 @@ private:
VOutline *outline;
// Actions
+ QAction *newRootDirAct;
QAction *newNoteAct;
QAction *editNoteAct;
QAction *saveNoteAct;
diff --git a/src/vnote.qrc b/src/vnote.qrc
index d5370c4c..c98a1302 100644
--- a/src/vnote.qrc
+++ b/src/vnote.qrc
@@ -58,5 +58,6 @@
resources/icons/remove_split.svg
resources/icons/corner_tablist.svg
resources/icons/outline.svg
+ resources/icons/create_rootdir_tb.svg