mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
disable newNoteAct if FileList's directory is not set
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
a69bd43e5a
commit
1bc95bcea0
@ -69,6 +69,7 @@ void VFileList::setDirectory(QJsonObject dirJson)
|
||||
fileList->clear();
|
||||
if (dirJson.isEmpty()) {
|
||||
clearDirectoryInfo();
|
||||
emit directoryChanged("", "");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -85,6 +86,8 @@ void VFileList::setDirectory(QJsonObject dirJson)
|
||||
Q_ASSERT(!rootPath.isEmpty());
|
||||
|
||||
updateFileList();
|
||||
|
||||
emit directoryChanged(notebook, relativePath);
|
||||
}
|
||||
|
||||
void VFileList::clearDirectoryInfo()
|
||||
|
@ -26,6 +26,7 @@ signals:
|
||||
void fileCreated(QJsonObject fileJson);
|
||||
void fileRenamed(const QString ¬ebook, const QString &oldPath,
|
||||
const QString &newPath);
|
||||
void directoryChanged(const QString ¬ebook, const QString &relativePath);
|
||||
|
||||
private slots:
|
||||
void contextMenuRequested(QPoint pos);
|
||||
|
@ -102,6 +102,8 @@ void VMainWindow::setupUI()
|
||||
fileList, &VFileList::setDirectory);
|
||||
connect(directoryTree, &VDirectoryTree::directoryRenamed,
|
||||
fileList, &VFileList::handleDirectoryRenamed);
|
||||
connect(fileList, &VFileList::directoryChanged,
|
||||
this, &VMainWindow::handleFileListDirectoryChanged);
|
||||
|
||||
connect(fileList, &VFileList::fileClicked,
|
||||
tabs, &VTabWidget::openFile);
|
||||
@ -266,6 +268,7 @@ void VMainWindow::initToolBar()
|
||||
fileToolBar->addAction(discardExitAct);
|
||||
fileToolBar->addAction(saveNoteAct);
|
||||
|
||||
newNoteAct->setEnabled(false);
|
||||
editNoteAct->setEnabled(false);
|
||||
saveExitAct->setVisible(false);
|
||||
discardExitAct->setVisible(false);
|
||||
@ -695,3 +698,12 @@ void VMainWindow::changeSplitterView(int nrPanel)
|
||||
qWarning() << "error: invalid panel number" << nrPanel;
|
||||
}
|
||||
}
|
||||
|
||||
void VMainWindow::handleFileListDirectoryChanged(const QString ¬ebook, const QString &relativePath)
|
||||
{
|
||||
if (relativePath.isEmpty()) {
|
||||
newNoteAct->setEnabled(false);
|
||||
} else {
|
||||
newNoteAct->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ private slots:
|
||||
void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
||||
bool editMode, bool modifiable);
|
||||
void changePanelView(QAction *action);
|
||||
void handleFileListDirectoryChanged(const QString ¬ebook, const QString &relativePath);
|
||||
|
||||
signals:
|
||||
void curNotebookChanged(const QString ¬ebookName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user