mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +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();
|
fileList->clear();
|
||||||
if (dirJson.isEmpty()) {
|
if (dirJson.isEmpty()) {
|
||||||
clearDirectoryInfo();
|
clearDirectoryInfo();
|
||||||
|
emit directoryChanged("", "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,6 +86,8 @@ void VFileList::setDirectory(QJsonObject dirJson)
|
|||||||
Q_ASSERT(!rootPath.isEmpty());
|
Q_ASSERT(!rootPath.isEmpty());
|
||||||
|
|
||||||
updateFileList();
|
updateFileList();
|
||||||
|
|
||||||
|
emit directoryChanged(notebook, relativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::clearDirectoryInfo()
|
void VFileList::clearDirectoryInfo()
|
||||||
|
@ -26,6 +26,7 @@ signals:
|
|||||||
void fileCreated(QJsonObject fileJson);
|
void fileCreated(QJsonObject fileJson);
|
||||||
void fileRenamed(const QString ¬ebook, const QString &oldPath,
|
void fileRenamed(const QString ¬ebook, const QString &oldPath,
|
||||||
const QString &newPath);
|
const QString &newPath);
|
||||||
|
void directoryChanged(const QString ¬ebook, const QString &relativePath);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void contextMenuRequested(QPoint pos);
|
void contextMenuRequested(QPoint pos);
|
||||||
|
@ -102,6 +102,8 @@ void VMainWindow::setupUI()
|
|||||||
fileList, &VFileList::setDirectory);
|
fileList, &VFileList::setDirectory);
|
||||||
connect(directoryTree, &VDirectoryTree::directoryRenamed,
|
connect(directoryTree, &VDirectoryTree::directoryRenamed,
|
||||||
fileList, &VFileList::handleDirectoryRenamed);
|
fileList, &VFileList::handleDirectoryRenamed);
|
||||||
|
connect(fileList, &VFileList::directoryChanged,
|
||||||
|
this, &VMainWindow::handleFileListDirectoryChanged);
|
||||||
|
|
||||||
connect(fileList, &VFileList::fileClicked,
|
connect(fileList, &VFileList::fileClicked,
|
||||||
tabs, &VTabWidget::openFile);
|
tabs, &VTabWidget::openFile);
|
||||||
@ -266,6 +268,7 @@ void VMainWindow::initToolBar()
|
|||||||
fileToolBar->addAction(discardExitAct);
|
fileToolBar->addAction(discardExitAct);
|
||||||
fileToolBar->addAction(saveNoteAct);
|
fileToolBar->addAction(saveNoteAct);
|
||||||
|
|
||||||
|
newNoteAct->setEnabled(false);
|
||||||
editNoteAct->setEnabled(false);
|
editNoteAct->setEnabled(false);
|
||||||
saveExitAct->setVisible(false);
|
saveExitAct->setVisible(false);
|
||||||
discardExitAct->setVisible(false);
|
discardExitAct->setVisible(false);
|
||||||
@ -695,3 +698,12 @@ void VMainWindow::changeSplitterView(int nrPanel)
|
|||||||
qWarning() << "error: invalid panel number" << 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,
|
void updateToolbarFromTabChage(const QString ¬ebook, const QString &relativePath,
|
||||||
bool editMode, bool modifiable);
|
bool editMode, bool modifiable);
|
||||||
void changePanelView(QAction *action);
|
void changePanelView(QAction *action);
|
||||||
|
void handleFileListDirectoryChanged(const QString ¬ebook, const QString &relativePath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void curNotebookChanged(const QString ¬ebookName);
|
void curNotebookChanged(const QString ¬ebookName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user