mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add note info button in tool bar
Signed-off-by: Le Tan <tamlokveer@gmail.com>
This commit is contained in:
parent
62c75427e7
commit
a6c2416cc8
10
src/resources/icons/note_info_tb.svg
Normal file
10
src/resources/icons/note_info_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">
|
||||||
|
<g>
|
||||||
|
<polygon points="288,448 288,192 192,192 192,208 224,208 224,448 192,448 192,464 320,464 320,448 "/>
|
||||||
|
<path d="M255.8,144.5c26.6,0,48.2-21.6,48.2-48.2s-21.6-48.2-48.2-48.2c-26.6,0-48.2,21.6-48.2,48.2S229.2,144.5,255.8,144.5z"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 733 B |
@ -108,3 +108,16 @@ bool VUtils::isMarkdown(const QString &name)
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString VUtils::fileNameFromPath(const QString &path)
|
||||||
|
{
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
return QFileInfo(QDir::cleanPath(path)).fileName();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VUtils::basePathFromPath(const QString &path)
|
||||||
|
{
|
||||||
|
return QFileInfo(path).path();
|
||||||
|
}
|
||||||
|
@ -20,6 +20,9 @@ public:
|
|||||||
const QString &format = "png");
|
const QString &format = "png");
|
||||||
static void processStyle(QString &style);
|
static void processStyle(QString &style);
|
||||||
static bool isMarkdown(const QString &fileName);
|
static bool isMarkdown(const QString &fileName);
|
||||||
|
static inline QString directoryNameFromPath(const QString& path);
|
||||||
|
static QString fileNameFromPath(const QString &path);
|
||||||
|
static QString basePathFromPath(const QString &path);
|
||||||
private:
|
private:
|
||||||
static inline void addQssVarToMap(QVector<QPair<QString, QString> > &map,
|
static inline void addQssVarToMap(QVector<QPair<QString, QString> > &map,
|
||||||
const QString &key, const QString &value);
|
const QString &key, const QString &value);
|
||||||
@ -31,4 +34,9 @@ inline void VUtils::addQssVarToMap(QVector<QPair<QString, QString> > &map,
|
|||||||
map.append(QPair<QString, QString>(key, value));
|
map.append(QPair<QString, QString>(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline QString VUtils::directoryNameFromPath(const QString &path)
|
||||||
|
{
|
||||||
|
return fileNameFromPath(path);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VUTILS_H
|
#endif // VUTILS_H
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "vedittab.h"
|
#include "vedittab.h"
|
||||||
#include "vnote.h"
|
#include "vnote.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
extern VConfigManager vconfig;
|
extern VConfigManager vconfig;
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ void VEditWindow::openWelcomePage()
|
|||||||
int VEditWindow::insertTabWithData(int index, QWidget *page,
|
int VEditWindow::insertTabWithData(int index, QWidget *page,
|
||||||
const QJsonObject &tabData)
|
const QJsonObject &tabData)
|
||||||
{
|
{
|
||||||
QString label = getFileName(tabData["relative_path"].toString());
|
QString label = VUtils::fileNameFromPath(tabData["relative_path"].toString());
|
||||||
int idx = insertTab(index, page, label);
|
int idx = insertTab(index, page, label);
|
||||||
QTabBar *tabs = tabBar();
|
QTabBar *tabs = tabBar();
|
||||||
tabs->setTabData(idx, tabData);
|
tabs->setTabData(idx, tabData);
|
||||||
@ -293,7 +294,7 @@ void VEditWindow::handleFileRenamed(const QString ¬ebook, const QString &oldR
|
|||||||
tabJson["relative_path"] = relativePath;
|
tabJson["relative_path"] = relativePath;
|
||||||
tabs->setTabData(i, tabJson);
|
tabs->setTabData(i, tabJson);
|
||||||
tabs->setTabToolTip(i, generateTooltip(tabJson));
|
tabs->setTabToolTip(i, generateTooltip(tabJson));
|
||||||
tabs->setTabText(i, getFileName(relativePath));
|
tabs->setTabText(i, VUtils::fileNameFromPath(relativePath));
|
||||||
QString path = QDir::cleanPath(QDir(vnote->getNotebookPath(notebook)).filePath(relativePath));
|
QString path = QDir::cleanPath(QDir(vnote->getNotebookPath(notebook)).filePath(relativePath));
|
||||||
getTab(i)->updatePath(path);
|
getTab(i)->updatePath(path);
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,6 @@ private:
|
|||||||
int insertTabWithData(int index, QWidget *page, const QJsonObject &tabData);
|
int insertTabWithData(int index, QWidget *page, const QJsonObject &tabData);
|
||||||
int appendTabWithData(QWidget *page, const QJsonObject &tabData);
|
int appendTabWithData(QWidget *page, const QJsonObject &tabData);
|
||||||
int openFileInTab(const QString ¬ebook, const QString &relativePath, bool modifiable);
|
int openFileInTab(const QString ¬ebook, const QString &relativePath, bool modifiable);
|
||||||
inline QString getFileName(const QString &relativePath) const;
|
|
||||||
inline VEditTab *getTab(int tabIndex) const;
|
inline VEditTab *getTab(int tabIndex) const;
|
||||||
void noticeTabStatus(int index);
|
void noticeTabStatus(int index);
|
||||||
void updateTabListMenu();
|
void updateTabListMenu();
|
||||||
@ -91,11 +90,6 @@ private:
|
|||||||
QActionGroup *tabListAct;
|
QActionGroup *tabListAct;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QString VEditWindow::getFileName(const QString &path) const
|
|
||||||
{
|
|
||||||
return QFileInfo(QDir::cleanPath(path)).fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VEditTab* VEditWindow::getTab(int tabIndex) const
|
inline VEditTab* VEditWindow::getTab(int tabIndex) const
|
||||||
{
|
{
|
||||||
return dynamic_cast<VEditTab *>(widget(tabIndex));
|
return dynamic_cast<VEditTab *>(widget(tabIndex));
|
||||||
|
@ -50,7 +50,7 @@ void VFileList::initActions()
|
|||||||
tr("&Info"), this);
|
tr("&Info"), this);
|
||||||
fileInfoAct->setStatusTip(tr("View and edit current note's information"));
|
fileInfoAct->setStatusTip(tr("View and edit current note's information"));
|
||||||
connect(fileInfoAct, &QAction::triggered,
|
connect(fileInfoAct, &QAction::triggered,
|
||||||
this, &VFileList::fileInfo);
|
this, &VFileList::curFileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::setDirectory(QJsonObject dirJson)
|
void VFileList::setDirectory(QJsonObject dirJson)
|
||||||
@ -117,21 +117,26 @@ void VFileList::updateFileList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::fileInfo()
|
void VFileList::curFileInfo()
|
||||||
{
|
{
|
||||||
QListWidgetItem *curItem = fileList->currentItem();
|
QListWidgetItem *curItem = fileList->currentItem();
|
||||||
QJsonObject curItemJson = curItem->data(Qt::UserRole).toJsonObject();
|
QJsonObject curItemJson = curItem->data(Qt::UserRole).toJsonObject();
|
||||||
Q_ASSERT(!curItemJson.isEmpty());
|
Q_ASSERT(!curItemJson.isEmpty());
|
||||||
QString curItemName = curItemJson["name"].toString();
|
QString curItemName = curItemJson["name"].toString();
|
||||||
|
fileInfo(notebook, QDir(relativePath).filePath(curItemName));
|
||||||
|
}
|
||||||
|
|
||||||
|
void VFileList::fileInfo(const QString &p_notebook, const QString &p_relativePath)
|
||||||
|
{
|
||||||
|
qDebug() << "fileInfo" << p_notebook << p_relativePath;
|
||||||
QString info;
|
QString info;
|
||||||
QString defaultName = curItemName;
|
QString defaultName = VUtils::directoryNameFromPath(p_relativePath);
|
||||||
|
QString curName = defaultName;
|
||||||
do {
|
do {
|
||||||
VFileInfoDialog dialog(tr("Note Information"), info, defaultName, this);
|
VFileInfoDialog dialog(tr("Note Information"), info, defaultName, this);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
QString name = dialog.getNameInput();
|
QString name = dialog.getNameInput();
|
||||||
if (name == curItemName) {
|
if (name == curName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isConflictNameWithExisting(name)) {
|
if (isConflictNameWithExisting(name)) {
|
||||||
@ -139,7 +144,7 @@ void VFileList::fileInfo()
|
|||||||
defaultName = name;
|
defaultName = name;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
renameFile(curItem, name);
|
renameFile(p_notebook, p_relativePath, name);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} while (true);
|
} while (true);
|
||||||
@ -176,8 +181,8 @@ void VFileList::newFile()
|
|||||||
QString text("&Note name:");
|
QString text("&Note name:");
|
||||||
QString defaultText("new_note");
|
QString defaultText("new_note");
|
||||||
do {
|
do {
|
||||||
VNewFileDialog dialog(QString("Create a new note under %1").arg(getDirectoryName()), text,
|
VNewFileDialog dialog(QString("Create a new note under %1").arg(VUtils::directoryNameFromPath(relativePath)),
|
||||||
defaultText, this);
|
text, defaultText, this);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
QString name = dialog.getNameInput();
|
QString name = dialog.getNameInput();
|
||||||
if (isConflictNameWithExisting(name)) {
|
if (isConflictNameWithExisting(name)) {
|
||||||
@ -259,6 +264,24 @@ bool VFileList::isConflictNameWithExisting(const QString &name)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QListWidgetItem* VFileList::findItem(const QString &p_notebook, const QString &p_relativePath)
|
||||||
|
{
|
||||||
|
if (p_notebook != notebook || VUtils::basePathFromPath(p_relativePath) != QDir::cleanPath(relativePath)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
QString name = VUtils::fileNameFromPath(p_relativePath);
|
||||||
|
int nrChild = fileList->count();
|
||||||
|
for (int i = 0; i < nrChild; ++i) {
|
||||||
|
QListWidgetItem *item = fileList->item(i);
|
||||||
|
QJsonObject itemJson = item->data(Qt::UserRole).toJsonObject();
|
||||||
|
Q_ASSERT(!itemJson.isEmpty());
|
||||||
|
if (itemJson["name"].toString() == name) {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
QListWidgetItem* VFileList::createFileAndUpdateList(const QString &name)
|
QListWidgetItem* VFileList::createFileAndUpdateList(const QString &name)
|
||||||
{
|
{
|
||||||
QString path = QDir(rootPath).filePath(relativePath);
|
QString path = QDir(rootPath).filePath(relativePath);
|
||||||
@ -411,29 +434,25 @@ void VFileList::handleDirectoryRenamed(const QString ¬ebook,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::renameFile(QListWidgetItem *item, const QString &newName)
|
// @p_relativePath contains the flie name
|
||||||
|
void VFileList::renameFile(const QString &p_notebook,
|
||||||
|
const QString &p_relativePath, const QString &p_newName)
|
||||||
{
|
{
|
||||||
if (!item) {
|
QString name = VUtils::fileNameFromPath(p_relativePath);
|
||||||
return;
|
|
||||||
}
|
|
||||||
QJsonObject itemJson = item->data(Qt::UserRole).toJsonObject();
|
|
||||||
Q_ASSERT(!itemJson.isEmpty());
|
|
||||||
QString name = itemJson["name"].toString();
|
|
||||||
|
|
||||||
// If change the file type, we need to convert it
|
// If change the file type, we need to convert it
|
||||||
DocType docType = VUtils::isMarkdown(name) ? DocType::Markdown : DocType::Html;
|
DocType docType = VUtils::isMarkdown(name) ? DocType::Markdown : DocType::Html;
|
||||||
DocType newDocType = VUtils::isMarkdown(newName) ? DocType::Markdown : DocType::Html;
|
DocType newDocType = VUtils::isMarkdown(p_newName) ? DocType::Markdown : DocType::Html;
|
||||||
if (docType != newDocType) {
|
if (docType != newDocType) {
|
||||||
QString fileRelativePath = QDir::cleanPath(QDir(relativePath).filePath(name));
|
if (editArea->isFileOpened(p_notebook, p_relativePath)) {
|
||||||
if (editArea->isFileOpened(notebook, fileRelativePath)) {
|
|
||||||
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), QString("Rename will change the note type"),
|
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), QString("Rename will change the note type"),
|
||||||
QMessageBox::Ok | QMessageBox::Cancel, this);
|
QMessageBox::Ok | QMessageBox::Cancel, this);
|
||||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||||
msgBox.setInformativeText(QString("You should close the note %1 before continue").arg(name));
|
msgBox.setInformativeText(QString("You should close the note %1 before continue").arg(name));
|
||||||
if (QMessageBox::Ok == msgBox.exec()) {
|
if (QMessageBox::Ok == msgBox.exec()) {
|
||||||
QJsonObject curItemJson;
|
QJsonObject curItemJson;
|
||||||
curItemJson["notebook"] = notebook;
|
curItemJson["notebook"] = p_notebook;
|
||||||
curItemJson["relative_path"] = fileRelativePath;
|
curItemJson["relative_path"] = p_relativePath;
|
||||||
curItemJson["is_forced"] = false;
|
curItemJson["is_forced"] = false;
|
||||||
if (!editArea->closeFile(curItemJson)) {
|
if (!editArea->closeFile(curItemJson)) {
|
||||||
return;
|
return;
|
||||||
@ -442,18 +461,18 @@ void VFileList::renameFile(QListWidgetItem *item, const QString &newName)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
convertFileType(notebook, fileRelativePath, docType, newDocType);
|
convertFileType(p_notebook, p_relativePath, docType, newDocType);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path = QDir(rootPath).filePath(relativePath);
|
QString path = QDir(vnote->getNotebookPath(p_notebook)).filePath(VUtils::basePathFromPath(p_relativePath));
|
||||||
QFile file(QDir(path).filePath(name));
|
QFile file(QDir(path).filePath(name));
|
||||||
QString newFilePath(QDir(path).filePath(newName));
|
QString newFilePath(QDir(path).filePath(p_newName));
|
||||||
Q_ASSERT(file.exists());
|
Q_ASSERT(file.exists());
|
||||||
if (!file.rename(newFilePath)) {
|
if (!file.rename(newFilePath)) {
|
||||||
qWarning() << "error: fail to rename file" << name << "under" << path;
|
qWarning() << "error: fail to rename file" << name << "under" << path;
|
||||||
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), QString("Could not rename note \"%1\" under \"%2\".")
|
QMessageBox msgBox(QMessageBox::Warning, tr("Warning"), QString("Could not rename note \"%1\" under \"%2\".")
|
||||||
.arg(name).arg(path), QMessageBox::Ok, this);
|
.arg(name).arg(path), QMessageBox::Ok, this);
|
||||||
msgBox.setInformativeText(QString("Please check if there already exists a file named \"%1\".").arg(newName));
|
msgBox.setInformativeText(QString("Please check if there already exists a file named \"%1\".").arg(p_newName));
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -466,7 +485,7 @@ void VFileList::renameFile(QListWidgetItem *item, const QString &newName)
|
|||||||
for (index = 0; index < fileArray.size(); ++index) {
|
for (index = 0; index < fileArray.size(); ++index) {
|
||||||
QJsonObject tmp = fileArray[index].toObject();
|
QJsonObject tmp = fileArray[index].toObject();
|
||||||
if (tmp["name"].toString() == name) {
|
if (tmp["name"].toString() == name) {
|
||||||
tmp["name"] = newName;
|
tmp["name"] = p_newName;
|
||||||
fileArray[index] = tmp;
|
fileArray[index] = tmp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -475,20 +494,24 @@ void VFileList::renameFile(QListWidgetItem *item, const QString &newName)
|
|||||||
dirJson["files"] = fileArray;
|
dirJson["files"] = fileArray;
|
||||||
if (!VConfigManager::writeDirectoryConfig(path, dirJson)) {
|
if (!VConfigManager::writeDirectoryConfig(path, dirJson)) {
|
||||||
qWarning() << "error: fail to rename file"
|
qWarning() << "error: fail to rename file"
|
||||||
<< name << "to" << newName;
|
<< name << "to" << p_newName;
|
||||||
file.rename(name);
|
file.rename(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update item
|
// Update item
|
||||||
itemJson["name"] = newName;
|
QListWidgetItem *item = findItem(p_notebook, p_relativePath);
|
||||||
item->setData(Qt::UserRole, itemJson);
|
if (item) {
|
||||||
item->setText(newName);
|
QJsonObject itemJson = item->data(Qt::UserRole).toJsonObject();
|
||||||
|
itemJson["name"] = p_newName;
|
||||||
|
item->setData(Qt::UserRole, itemJson);
|
||||||
|
item->setText(p_newName);
|
||||||
|
}
|
||||||
|
|
||||||
QString oldPath = QDir::cleanPath(QDir(relativePath).filePath(name));
|
QString oldPath = QDir::cleanPath(p_relativePath);
|
||||||
QString newPath = QDir::cleanPath(QDir(relativePath).filePath(newName));
|
QString newPath = QDir::cleanPath(QDir(VUtils::basePathFromPath(p_relativePath)).filePath(p_newName));
|
||||||
qDebug() << "file renamed" << oldPath << "to" << newPath;
|
qDebug() << "file renamed" << oldPath << "to" << newPath;
|
||||||
emit fileRenamed(notebook, oldPath, newPath);
|
emit fileRenamed(p_notebook, oldPath, newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFileList::convertFileType(const QString ¬ebook, const QString &fileRelativePath,
|
void VFileList::convertFileType(const QString ¬ebook, const QString &fileRelativePath,
|
||||||
|
@ -22,6 +22,7 @@ public:
|
|||||||
explicit VFileList(VNote *vnote, QWidget *parent = 0);
|
explicit VFileList(VNote *vnote, QWidget *parent = 0);
|
||||||
bool importFile(const QString &name);
|
bool importFile(const QString &name);
|
||||||
inline void setEditArea(VEditArea *editArea);
|
inline void setEditArea(VEditArea *editArea);
|
||||||
|
void fileInfo(const QString &p_notebook, const QString &p_relativePath);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void fileClicked(QJsonObject fileJson);
|
void fileClicked(QJsonObject fileJson);
|
||||||
@ -34,7 +35,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void contextMenuRequested(QPoint pos);
|
void contextMenuRequested(QPoint pos);
|
||||||
void handleItemClicked(QListWidgetItem *currentItem);
|
void handleItemClicked(QListWidgetItem *currentItem);
|
||||||
void fileInfo();
|
void curFileInfo();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setDirectory(QJsonObject dirJson);
|
void setDirectory(QJsonObject dirJson);
|
||||||
@ -55,10 +56,11 @@ private:
|
|||||||
QListWidgetItem *createFileAndUpdateList(const QString &name);
|
QListWidgetItem *createFileAndUpdateList(const QString &name);
|
||||||
void deleteFileAndUpdateList(QListWidgetItem *item);
|
void deleteFileAndUpdateList(QListWidgetItem *item);
|
||||||
void clearDirectoryInfo();
|
void clearDirectoryInfo();
|
||||||
inline QString getDirectoryName();
|
void renameFile(const QString &p_notebook,
|
||||||
void renameFile(QListWidgetItem *item, const QString &newName);
|
const QString &p_relativePath, const QString &p_newName);
|
||||||
void convertFileType(const QString ¬ebook, const QString &fileRelativePath,
|
void convertFileType(const QString ¬ebook, const QString &fileRelativePath,
|
||||||
DocType oldType, DocType newType);
|
DocType oldType, DocType newType);
|
||||||
|
QListWidgetItem *findItem(const QString &p_notebook, const QString &p_relativePath);
|
||||||
|
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
QString notebook;
|
QString notebook;
|
||||||
@ -77,14 +79,6 @@ private:
|
|||||||
QAction *fileInfoAct;
|
QAction *fileInfoAct;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QString VFileList::getDirectoryName()
|
|
||||||
{
|
|
||||||
if (relativePath.isEmpty()) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return QFileInfo(QDir::cleanPath(relativePath)).fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void VFileList::setEditArea(VEditArea *editArea)
|
inline void VFileList::setEditArea(VEditArea *editArea)
|
||||||
{
|
{
|
||||||
this->editArea = editArea;
|
this->editArea = editArea;
|
||||||
|
@ -148,12 +148,19 @@ void VMainWindow::initActions()
|
|||||||
newRootDirAct->setStatusTip(tr("Create a new root directory"));
|
newRootDirAct->setStatusTip(tr("Create a new root directory"));
|
||||||
connect(newRootDirAct, &QAction::triggered,
|
connect(newRootDirAct, &QAction::triggered,
|
||||||
directoryTree, &VDirectoryTree::newRootDirectory);
|
directoryTree, &VDirectoryTree::newRootDirectory);
|
||||||
|
|
||||||
newNoteAct = new QAction(QIcon(":/resources/icons/create_note_tb.svg"),
|
newNoteAct = new QAction(QIcon(":/resources/icons/create_note_tb.svg"),
|
||||||
tr("&New note"), this);
|
tr("&New note"), this);
|
||||||
newNoteAct->setStatusTip(tr("Create a new note"));
|
newNoteAct->setStatusTip(tr("Create a new note"));
|
||||||
connect(newNoteAct, &QAction::triggered,
|
connect(newNoteAct, &QAction::triggered,
|
||||||
fileList, &VFileList::newFile);
|
fileList, &VFileList::newFile);
|
||||||
|
|
||||||
|
noteInfoAct = new QAction(QIcon(":/resources/icons/note_info_tb.svg"),
|
||||||
|
tr("&Note info"), this);
|
||||||
|
noteInfoAct->setStatusTip(tr("Current note information"));
|
||||||
|
connect(noteInfoAct, &QAction::triggered,
|
||||||
|
this, &VMainWindow::curEditFileInfo);
|
||||||
|
|
||||||
editNoteAct = new QAction(QIcon(":/resources/icons/edit_note.svg"),
|
editNoteAct = new QAction(QIcon(":/resources/icons/edit_note.svg"),
|
||||||
tr("&Edit"), this);
|
tr("&Edit"), this);
|
||||||
editNoteAct->setStatusTip(tr("Edit current note"));
|
editNoteAct->setStatusTip(tr("Edit current note"));
|
||||||
@ -262,6 +269,7 @@ void VMainWindow::initToolBar()
|
|||||||
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
QToolBar *fileToolBar = addToolBar(tr("Note"));
|
||||||
fileToolBar->addAction(newRootDirAct);
|
fileToolBar->addAction(newRootDirAct);
|
||||||
fileToolBar->addAction(newNoteAct);
|
fileToolBar->addAction(newNoteAct);
|
||||||
|
fileToolBar->addAction(noteInfoAct);
|
||||||
fileToolBar->addAction(editNoteAct);
|
fileToolBar->addAction(editNoteAct);
|
||||||
fileToolBar->addAction(saveExitAct);
|
fileToolBar->addAction(saveExitAct);
|
||||||
fileToolBar->addAction(discardExitAct);
|
fileToolBar->addAction(discardExitAct);
|
||||||
@ -269,6 +277,7 @@ void VMainWindow::initToolBar()
|
|||||||
|
|
||||||
newRootDirAct->setEnabled(false);
|
newRootDirAct->setEnabled(false);
|
||||||
newNoteAct->setEnabled(false);
|
newNoteAct->setEnabled(false);
|
||||||
|
noteInfoAct->setEnabled(false);
|
||||||
editNoteAct->setEnabled(false);
|
editNoteAct->setEnabled(false);
|
||||||
saveExitAct->setVisible(false);
|
saveExitAct->setVisible(false);
|
||||||
discardExitAct->setVisible(false);
|
discardExitAct->setVisible(false);
|
||||||
@ -669,7 +678,6 @@ void VMainWindow::updateToolbarFromTabChage(bool empty, bool editMode, bool modi
|
|||||||
saveExitAct->setVisible(false);
|
saveExitAct->setVisible(false);
|
||||||
discardExitAct->setVisible(false);
|
discardExitAct->setVisible(false);
|
||||||
saveNoteAct->setVisible(false);
|
saveNoteAct->setVisible(false);
|
||||||
return;
|
|
||||||
} else if (editMode) {
|
} else if (editMode) {
|
||||||
editNoteAct->setEnabled(false);
|
editNoteAct->setEnabled(false);
|
||||||
saveExitAct->setVisible(true);
|
saveExitAct->setVisible(true);
|
||||||
@ -681,6 +689,12 @@ void VMainWindow::updateToolbarFromTabChage(bool empty, bool editMode, bool modi
|
|||||||
discardExitAct->setVisible(false);
|
discardExitAct->setVisible(false);
|
||||||
saveNoteAct->setVisible(false);
|
saveNoteAct->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty) {
|
||||||
|
noteInfoAct->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
noteInfoAct->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::handleCurTabStatusChanged(const QString ¬ebook, const QString &relativePath,
|
void VMainWindow::handleCurTabStatusChanged(const QString ¬ebook, const QString &relativePath,
|
||||||
@ -696,6 +710,9 @@ void VMainWindow::handleCurTabStatusChanged(const QString ¬ebook, const QStri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateWindowTitle(title);
|
updateWindowTitle(title);
|
||||||
|
|
||||||
|
curEditNotebook = notebook;
|
||||||
|
curEditRelativePath = relativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::changePanelView(QAction *action)
|
void VMainWindow::changePanelView(QAction *action)
|
||||||
@ -751,3 +768,8 @@ void VMainWindow::updateWindowTitle(const QString &str)
|
|||||||
}
|
}
|
||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::curEditFileInfo()
|
||||||
|
{
|
||||||
|
fileList->fileInfo(curEditNotebook, curEditRelativePath);
|
||||||
|
}
|
||||||
|
@ -50,6 +50,7 @@ private slots:
|
|||||||
bool editMode, bool modifiable, bool modified);
|
bool editMode, bool modifiable, bool modified);
|
||||||
void changePanelView(QAction *action);
|
void changePanelView(QAction *action);
|
||||||
void handleFileListDirectoryChanged(const QString ¬ebook, const QString &relativePath);
|
void handleFileListDirectoryChanged(const QString ¬ebook, const QString &relativePath);
|
||||||
|
void curEditFileInfo();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void curNotebookChanged(const QString ¬ebookName);
|
void curNotebookChanged(const QString ¬ebookName);
|
||||||
@ -72,6 +73,9 @@ private:
|
|||||||
bool notebookComboMuted;
|
bool notebookComboMuted;
|
||||||
VNote *vnote;
|
VNote *vnote;
|
||||||
|
|
||||||
|
QString curEditNotebook;
|
||||||
|
QString curEditRelativePath;
|
||||||
|
|
||||||
QLabel *notebookLabel;
|
QLabel *notebookLabel;
|
||||||
QLabel *directoryLabel;
|
QLabel *directoryLabel;
|
||||||
QComboBox *notebookComboBox;
|
QComboBox *notebookComboBox;
|
||||||
@ -88,6 +92,7 @@ private:
|
|||||||
// Actions
|
// Actions
|
||||||
QAction *newRootDirAct;
|
QAction *newRootDirAct;
|
||||||
QAction *newNoteAct;
|
QAction *newNoteAct;
|
||||||
|
QAction *noteInfoAct;
|
||||||
QAction *editNoteAct;
|
QAction *editNoteAct;
|
||||||
QAction *saveNoteAct;
|
QAction *saveNoteAct;
|
||||||
QAction *saveExitAct;
|
QAction *saveExitAct;
|
||||||
|
@ -62,5 +62,6 @@
|
|||||||
<file>resources/icons/vnote.svg</file>
|
<file>resources/icons/vnote.svg</file>
|
||||||
<file>resources/icons/vnote.ico</file>
|
<file>resources/icons/vnote.ico</file>
|
||||||
<file>resources/vnote.qss</file>
|
<file>resources/vnote.qss</file>
|
||||||
|
<file>resources/icons/note_info_tb.svg</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user