mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add Info action to tab context menu
This commit is contained in:
parent
8a56dc8b87
commit
e33ff1fede
@ -39,6 +39,7 @@ void VFileInfoDialog::setupUI()
|
|||||||
if (infoLabel) {
|
if (infoLabel) {
|
||||||
mainLayout->addWidget(infoLabel);
|
mainLayout->addWidget(infoLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainLayout->addLayout(topLayout);
|
mainLayout->addLayout(topLayout);
|
||||||
mainLayout->addWidget(m_btnBox);
|
mainLayout->addWidget(m_btnBox);
|
||||||
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
72
src/dialog/vorphanfileinfodialog.cpp
Normal file
72
src/dialog/vorphanfileinfodialog.cpp
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#include "vorphanfileinfodialog.h"
|
||||||
|
|
||||||
|
#include <QtWidgets>
|
||||||
|
#include "vorphanfile.h"
|
||||||
|
#include "vconfigmanager.h"
|
||||||
|
#include "utils/vutils.h"
|
||||||
|
|
||||||
|
extern VConfigManager vconfig;
|
||||||
|
|
||||||
|
VOrphanFileInfoDialog::VOrphanFileInfoDialog(const VOrphanFile *p_file, QWidget *p_parent)
|
||||||
|
: QDialog(p_parent), m_file(p_file)
|
||||||
|
{
|
||||||
|
setupUI();
|
||||||
|
|
||||||
|
connect(m_imageFolderEdit, &QLineEdit::textChanged,
|
||||||
|
this, &VOrphanFileInfoDialog::handleInputChanged);
|
||||||
|
|
||||||
|
handleInputChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOrphanFileInfoDialog::setupUI()
|
||||||
|
{
|
||||||
|
QFormLayout *topLayout = new QFormLayout();
|
||||||
|
|
||||||
|
QLabel *fileLabel = new QLabel(m_file->retrivePath());
|
||||||
|
topLayout->addRow(tr("File:"), fileLabel);
|
||||||
|
|
||||||
|
QLabel *imageFolderLabel = new QLabel(tr("Image folder:"));
|
||||||
|
m_imageFolderEdit = new QLineEdit(m_file->getImageFolder());
|
||||||
|
m_imageFolderEdit->setPlaceholderText(tr("Use global configuration (%1)")
|
||||||
|
.arg(vconfig.getImageFolderExt()));
|
||||||
|
QString imgFolderTip = tr("Set the path of the image folder to store images "
|
||||||
|
"of this file.\nIf absolute path is used, "
|
||||||
|
"VNote will not manage those images."
|
||||||
|
"(empty to use global configuration)");
|
||||||
|
imageFolderLabel->setToolTip(imgFolderTip);
|
||||||
|
m_imageFolderEdit->setToolTip(imgFolderTip);
|
||||||
|
topLayout->addRow(imageFolderLabel, m_imageFolderEdit);
|
||||||
|
|
||||||
|
// Ok is the default button.
|
||||||
|
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||||
|
connect(m_btnBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
||||||
|
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
|
m_imageFolderEdit->setMinimumWidth(okBtn->sizeHint().width() * 3);
|
||||||
|
|
||||||
|
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||||
|
mainLayout->addLayout(topLayout);
|
||||||
|
mainLayout->addWidget(m_btnBox);
|
||||||
|
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
||||||
|
|
||||||
|
setLayout(mainLayout);
|
||||||
|
setWindowTitle(tr("External File Information"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString VOrphanFileInfoDialog::getImageFolder() const
|
||||||
|
{
|
||||||
|
return m_imageFolderEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VOrphanFileInfoDialog::handleInputChanged()
|
||||||
|
{
|
||||||
|
bool ok = false;
|
||||||
|
QString imgFolder = m_imageFolderEdit->text();
|
||||||
|
if (imgFolder.isEmpty() || VUtils::checkPathLegal(imgFolder)) {
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPushButton *okBtn = m_btnBox->button(QDialogButtonBox::Ok);
|
||||||
|
okBtn->setEnabled(ok);
|
||||||
|
}
|
34
src/dialog/vorphanfileinfodialog.h
Normal file
34
src/dialog/vorphanfileinfodialog.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef VORPHANFILEINFODIALOG_H
|
||||||
|
#define VORPHANFILEINFODIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
class VOrphanFile;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QLineEdit;
|
||||||
|
|
||||||
|
class VOrphanFileInfoDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
VOrphanFileInfoDialog(const VOrphanFile *p_file, QWidget *p_parent = 0);
|
||||||
|
|
||||||
|
// Get the custom image folder for this external file.
|
||||||
|
// Empty string indicates using global config.
|
||||||
|
QString getImageFolder() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
// Handle the change of the image folder input.
|
||||||
|
void handleInputChanged();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupUI();
|
||||||
|
|
||||||
|
const VOrphanFile *m_file;
|
||||||
|
|
||||||
|
QDialogButtonBox *m_btnBox;
|
||||||
|
QLineEdit *m_imageFolderEdit;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VORPHANFILEINFODIALOG_H
|
@ -270,6 +270,7 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
|
|||||||
|
|
||||||
m_imageFolderEdit = new QLineEdit(this);
|
m_imageFolderEdit = new QLineEdit(this);
|
||||||
m_imageFolderEdit->setPlaceholderText(tr("Name of the image folder"));
|
m_imageFolderEdit->setPlaceholderText(tr("Name of the image folder"));
|
||||||
|
m_imageFolderEdit->setToolTip(m_customImageFolder->toolTip());
|
||||||
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
QValidator *validator = new QRegExpValidator(QRegExp(VUtils::c_fileNameRegExp), this);
|
||||||
m_imageFolderEdit->setValidator(validator);
|
m_imageFolderEdit->setValidator(validator);
|
||||||
|
|
||||||
@ -284,15 +285,16 @@ VNoteManagementTab::VNoteManagementTab(QWidget *p_parent)
|
|||||||
// External File.
|
// External File.
|
||||||
// Image folder.
|
// Image folder.
|
||||||
m_customImageFolderExt = new QCheckBox(tr("Custom image folder"), this);
|
m_customImageFolderExt = new QCheckBox(tr("Custom image folder"), this);
|
||||||
m_customImageFolderExt->setToolTip(tr("Set the global name of the image folder to store images "
|
m_customImageFolderExt->setToolTip(tr("Set the path of the global image folder to store images "
|
||||||
"of external files (restart VNote to make it work).\nYou "
|
"of external files (restart VNote to make it work).\nYou "
|
||||||
"could use both absolute or relative path here. If you "
|
"could use both absolute or relative path here. If "
|
||||||
"use an absolute path, VNote will not manage\nthose images, "
|
"absolute path is used, VNote will not manage\nthose images, "
|
||||||
"so you need to clean up unused images manually."));
|
"so you need to clean up unused images manually."));
|
||||||
connect(m_customImageFolderExt, &QCheckBox::stateChanged,
|
connect(m_customImageFolderExt, &QCheckBox::stateChanged,
|
||||||
this, &VNoteManagementTab::customImageFolderExtChanged);
|
this, &VNoteManagementTab::customImageFolderExtChanged);
|
||||||
|
|
||||||
m_imageFolderEditExt = new QLineEdit(this);
|
m_imageFolderEditExt = new QLineEdit(this);
|
||||||
|
m_imageFolderEditExt->setToolTip(m_customImageFolderExt->toolTip());
|
||||||
m_imageFolderEditExt->setPlaceholderText(tr("Name of the image folder"));
|
m_imageFolderEditExt->setPlaceholderText(tr("Name of the image folder"));
|
||||||
|
|
||||||
QHBoxLayout *imageFolderExtLayout = new QHBoxLayout();
|
QHBoxLayout *imageFolderExtLayout = new QHBoxLayout();
|
||||||
|
@ -281,3 +281,9 @@ QTabBar::close-button:focus {
|
|||||||
image: url(:/resources/icons/close.svg);
|
image: url(:/resources/icons/close.svg);
|
||||||
background-color: @focus-color;
|
background-color: @focus-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QLineEdit[VimCommandLine="true"] {
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
@ -70,7 +70,8 @@ SOURCES += main.cpp\
|
|||||||
vvimindicator.cpp \
|
vvimindicator.cpp \
|
||||||
vbuttonwithwidget.cpp \
|
vbuttonwithwidget.cpp \
|
||||||
vtabindicator.cpp \
|
vtabindicator.cpp \
|
||||||
dialog/vupdater.cpp
|
dialog/vupdater.cpp \
|
||||||
|
dialog/vorphanfileinfodialog.cpp
|
||||||
|
|
||||||
HEADERS += vmainwindow.h \
|
HEADERS += vmainwindow.h \
|
||||||
vdirectorytree.h \
|
vdirectorytree.h \
|
||||||
@ -128,7 +129,8 @@ HEADERS += vmainwindow.h \
|
|||||||
vbuttonwithwidget.h \
|
vbuttonwithwidget.h \
|
||||||
vedittabinfo.h \
|
vedittabinfo.h \
|
||||||
vtabindicator.h \
|
vtabindicator.h \
|
||||||
dialog/vupdater.h
|
dialog/vupdater.h \
|
||||||
|
dialog/vorphanfileinfodialog.h
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
vnote.qrc \
|
vnote.qrc \
|
||||||
|
@ -5,14 +5,16 @@
|
|||||||
#include "vnote.h"
|
#include "vnote.h"
|
||||||
#include "vconfigmanager.h"
|
#include "vconfigmanager.h"
|
||||||
#include "utils/vutils.h"
|
#include "utils/vutils.h"
|
||||||
#include "vfile.h"
|
#include "vorphanfile.h"
|
||||||
#include "vmainwindow.h"
|
#include "vmainwindow.h"
|
||||||
#include "veditarea.h"
|
#include "veditarea.h"
|
||||||
#include "vopenedlistmenu.h"
|
#include "vopenedlistmenu.h"
|
||||||
#include "vmdtab.h"
|
#include "vmdtab.h"
|
||||||
#include "vhtmltab.h"
|
#include "vhtmltab.h"
|
||||||
|
#include "vfilelist.h"
|
||||||
|
|
||||||
extern VConfigManager vconfig;
|
extern VConfigManager vconfig;
|
||||||
|
extern VNote *g_vnote;
|
||||||
|
|
||||||
VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
|
VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
|
||||||
: QTabWidget(parent), vnote(vnote), m_editArea(editArea),
|
: QTabWidget(parent), vnote(vnote), m_editArea(editArea),
|
||||||
@ -62,7 +64,8 @@ void VEditWindow::initTabActions()
|
|||||||
connect(m_moveRightAct, &QAction::triggered,
|
connect(m_moveRightAct, &QAction::triggered,
|
||||||
this, &VEditWindow::handleMoveRightAct);
|
this, &VEditWindow::handleMoveRightAct);
|
||||||
|
|
||||||
m_closeTabAct = new QAction(tr("Close Tab"), this);
|
m_closeTabAct = new QAction(QIcon(":/resources/icons/close.svg"),
|
||||||
|
tr("Close Tab"), this);
|
||||||
m_closeTabAct->setToolTip(tr("Close current note tab"));
|
m_closeTabAct->setToolTip(tr("Close current note tab"));
|
||||||
connect(m_closeTabAct, &QAction::triggered,
|
connect(m_closeTabAct, &QAction::triggered,
|
||||||
this, [this](){
|
this, [this](){
|
||||||
@ -110,6 +113,24 @@ void VEditWindow::initTabActions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_noteInfoAct = new QAction(QIcon(":/resources/icons/note_info.svg"),
|
||||||
|
tr("Note Info"), this);
|
||||||
|
m_noteInfoAct->setToolTip(tr("View and edit information of the note"));
|
||||||
|
connect(m_noteInfoAct, &QAction::triggered,
|
||||||
|
this, [this](){
|
||||||
|
int tab = this->m_closeTabAct->data().toInt();
|
||||||
|
Q_ASSERT(tab != -1);
|
||||||
|
|
||||||
|
VEditTab *editor = getTab(tab);
|
||||||
|
QPointer<VFile> file = editor->getFile();
|
||||||
|
Q_ASSERT(file);
|
||||||
|
if (file->getType() == FileType::Normal) {
|
||||||
|
g_vnote->getMainWindow()->getFileList()->fileInfo(file);
|
||||||
|
} else if (file->getType() == FileType::Orphan) {
|
||||||
|
g_vnote->getMainWindow()->editOrphanFileInfo(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void VEditWindow::setupCornerWidget()
|
void VEditWindow::setupCornerWidget()
|
||||||
@ -500,14 +521,21 @@ void VEditWindow::tabbarContextMenuRequested(QPoint p_pos)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_locateAct->setData(tab);
|
|
||||||
VEditTab *editor = getTab(tab);
|
VEditTab *editor = getTab(tab);
|
||||||
QPointer<VFile> file = editor->getFile();
|
VFile *file = editor->getFile();
|
||||||
if (file->getType() == FileType::Normal) {
|
if (file->getType() == FileType::Normal) {
|
||||||
// Locate to folder.
|
// Locate to folder.
|
||||||
|
m_locateAct->setData(tab);
|
||||||
menu.addAction(m_locateAct);
|
menu.addAction(m_locateAct);
|
||||||
|
m_noteInfoAct->setData(tab);
|
||||||
|
menu.addAction(m_noteInfoAct);
|
||||||
|
} else if (file->getType() == FileType::Orphan
|
||||||
|
&& !dynamic_cast<VOrphanFile *>(file)->isSystemFile()) {
|
||||||
|
m_noteInfoAct->setData(tab);
|
||||||
|
menu.addAction(m_noteInfoAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int totalWin = m_editArea->windowCount();
|
int totalWin = m_editArea->windowCount();
|
||||||
// When there is only one tab and one split window, there is no need to
|
// When there is only one tab and one split window, there is no need to
|
||||||
// display these two actions.
|
// display these two actions.
|
||||||
|
@ -165,6 +165,9 @@ private:
|
|||||||
|
|
||||||
// Close tabs to the right in tab menu.
|
// Close tabs to the right in tab menu.
|
||||||
QAction *m_closeRightAct;
|
QAction *m_closeRightAct;
|
||||||
|
|
||||||
|
// View and edit info about this note.
|
||||||
|
QAction *m_noteInfoAct;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline QString VEditWindow::generateTooltip(const VFile *p_file) const
|
inline QString VEditWindow::generateTooltip(const VFile *p_file) const
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "vtabindicator.h"
|
#include "vtabindicator.h"
|
||||||
#include "dialog/vupdater.h"
|
#include "dialog/vupdater.h"
|
||||||
#include "vorphanfile.h"
|
#include "vorphanfile.h"
|
||||||
|
#include "dialog/vorphanfileinfodialog.h"
|
||||||
|
|
||||||
extern VConfigManager vconfig;
|
extern VConfigManager vconfig;
|
||||||
|
|
||||||
@ -1720,7 +1721,7 @@ void VMainWindow::shortcutHelp()
|
|||||||
docName = VNote::c_shortcutsDocFile_zh;
|
docName = VNote::c_shortcutsDocFile_zh;
|
||||||
}
|
}
|
||||||
|
|
||||||
VFile *file = vnote->getOrphanFile(docName, false);
|
VFile *file = vnote->getOrphanFile(docName, false, true);
|
||||||
(dynamic_cast<VOrphanFile *>(file))->setNotebookName(tr("[Help]"));
|
(dynamic_cast<VOrphanFile *>(file))->setNotebookName(tr("[Help]"));
|
||||||
editArea->openFile(file, OpenFileMode::Read);
|
editArea->openFile(file, OpenFileMode::Read);
|
||||||
}
|
}
|
||||||
@ -1815,3 +1816,15 @@ void VMainWindow::openExternalFiles(const QStringList &p_files)
|
|||||||
editArea->openFile(file, OpenFileMode::Read);
|
editArea->openFile(file, OpenFileMode::Read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMainWindow::editOrphanFileInfo(VFile *p_file)
|
||||||
|
{
|
||||||
|
VOrphanFile *file = dynamic_cast<VOrphanFile *>(p_file);
|
||||||
|
Q_ASSERT(file);
|
||||||
|
|
||||||
|
VOrphanFileInfoDialog dialog(file, this);
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
QString imgFolder = dialog.getImageFolder();
|
||||||
|
file->setImageFolder(imgFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,11 @@ public:
|
|||||||
void locateFile(VFile *p_file);
|
void locateFile(VFile *p_file);
|
||||||
void locateCurrentFile();
|
void locateCurrentFile();
|
||||||
|
|
||||||
|
VFileList *getFileList() const;
|
||||||
|
|
||||||
|
// View and edit the information of @p_file, which is an orphan file.
|
||||||
|
void editOrphanFileInfo(VFile *p_file);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void importNoteFromFile();
|
void importNoteFromFile();
|
||||||
void viewSettings();
|
void viewSettings();
|
||||||
@ -213,4 +218,9 @@ private:
|
|||||||
QVector<QPixmap> predefinedColorPixmaps;
|
QVector<QPixmap> predefinedColorPixmaps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline VFileList *VMainWindow::getFileList() const
|
||||||
|
{
|
||||||
|
return fileList;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VMAINWINDOW_H
|
#endif // VMAINWINDOW_H
|
||||||
|
@ -672,31 +672,34 @@ void VMdEditOperations::decorateText(TextDecoration p_decoration)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool validDecoration = true;
|
||||||
switch (p_decoration) {
|
switch (p_decoration) {
|
||||||
case TextDecoration::Bold:
|
case TextDecoration::Bold:
|
||||||
m_vim->setMode(VimMode::Insert, false);
|
|
||||||
decorateBold();
|
decorateBold();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextDecoration::Italic:
|
case TextDecoration::Italic:
|
||||||
m_vim->setMode(VimMode::Insert, false);
|
|
||||||
decorateItalic();
|
decorateItalic();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextDecoration::Strikethrough:
|
case TextDecoration::Strikethrough:
|
||||||
m_vim->setMode(VimMode::Insert, false);
|
|
||||||
decorateStrikethrough();
|
decorateStrikethrough();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TextDecoration::InlineCode:
|
case TextDecoration::InlineCode:
|
||||||
m_vim->setMode(VimMode::Insert, false);
|
|
||||||
decorateInlineCode();
|
decorateInlineCode();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
validDecoration = false;
|
||||||
qDebug() << "decoration" << (int)p_decoration << "is not implemented yet";
|
qDebug() << "decoration" << (int)p_decoration << "is not implemented yet";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (validDecoration && m_editConfig->m_enableVimMode) {
|
||||||
|
Q_ASSERT(m_vim);
|
||||||
|
m_vim->setMode(VimMode::Insert, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMdEditOperations::decorateBold()
|
void VMdEditOperations::decorateBold()
|
||||||
|
@ -276,7 +276,7 @@ const QString &VNote::getMonospacedFont() const
|
|||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
VFile *VNote::getOrphanFile(const QString &p_path, bool p_modifiable)
|
VFile *VNote::getOrphanFile(const QString &p_path, bool p_modifiable, bool p_systemFile)
|
||||||
{
|
{
|
||||||
if (p_path.isEmpty()) {
|
if (p_path.isEmpty()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -285,8 +285,10 @@ VFile *VNote::getOrphanFile(const QString &p_path, bool p_modifiable)
|
|||||||
// See if the file has already been opened before.
|
// See if the file has already been opened before.
|
||||||
for (auto const &file : m_externalFiles) {
|
for (auto const &file : m_externalFiles) {
|
||||||
Q_ASSERT(file->getType() == FileType::Orphan);
|
Q_ASSERT(file->getType() == FileType::Orphan);
|
||||||
if (file->retrivePath() == p_path
|
VOrphanFile *oFile = dynamic_cast<VOrphanFile *>(file);
|
||||||
&& file->isModifiable() == p_modifiable) {
|
if (oFile->retrivePath() == p_path) {
|
||||||
|
Q_ASSERT(oFile->isModifiable() == p_modifiable);
|
||||||
|
Q_ASSERT(oFile->isSystemFile() == p_systemFile);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,7 +304,7 @@ VFile *VNote::getOrphanFile(const QString &p_path, bool p_modifiable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a VOrphanFile for p_path.
|
// Create a VOrphanFile for p_path.
|
||||||
VOrphanFile *file = new VOrphanFile(p_path, this, p_modifiable);
|
VOrphanFile *file = new VOrphanFile(p_path, this, p_modifiable, p_systemFile);
|
||||||
m_externalFiles.append(file);
|
m_externalFiles.append(file);
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
@ -67,15 +67,16 @@ public:
|
|||||||
static const QString c_shortcutsDocFile_en;
|
static const QString c_shortcutsDocFile_en;
|
||||||
static const QString c_shortcutsDocFile_zh;
|
static const QString c_shortcutsDocFile_zh;
|
||||||
|
|
||||||
inline const QVector<QPair<QString, QString> > &getPalette() const;
|
const QVector<QPair<QString, QString> > &getPalette() const;
|
||||||
void initPalette(QPalette palette);
|
void initPalette(QPalette palette);
|
||||||
QString getColorFromPalette(const QString &p_name) const;
|
QString getColorFromPalette(const QString &p_name) const;
|
||||||
inline VMainWindow *getMainWindow() const;
|
VMainWindow *getMainWindow() const;
|
||||||
|
|
||||||
QString getNavigationLabelStyle(const QString &p_str) const;
|
QString getNavigationLabelStyle(const QString &p_str) const;
|
||||||
|
|
||||||
// Given the path of an external file, create a VFile struct.
|
// Given the path of an external file, create a VFile struct.
|
||||||
VFile *getOrphanFile(const QString &p_path, bool p_modifiable);
|
VFile *getOrphanFile(const QString &p_path, bool p_modifiable,
|
||||||
|
bool p_systemFile = false);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateTemplate();
|
void updateTemplate();
|
||||||
|
@ -8,9 +8,10 @@
|
|||||||
|
|
||||||
extern VConfigManager vconfig;
|
extern VConfigManager vconfig;
|
||||||
|
|
||||||
VOrphanFile::VOrphanFile(const QString &p_path, QObject *p_parent, bool p_modifiable)
|
VOrphanFile::VOrphanFile(const QString &p_path, QObject *p_parent,
|
||||||
|
bool p_modifiable, bool p_systemFile)
|
||||||
: VFile(VUtils::fileNameFromPath(p_path), p_parent, FileType::Orphan, p_modifiable),
|
: VFile(VUtils::fileNameFromPath(p_path), p_parent, FileType::Orphan, p_modifiable),
|
||||||
m_path(p_path), m_notebookName("[EXTERNAL]")
|
m_path(p_path), m_notebookName("[EXTERNAL]"), m_systemFile(p_systemFile)
|
||||||
{
|
{
|
||||||
qDebug() << "VOrphanFile" << p_path << m_name << p_modifiable;
|
qDebug() << "VOrphanFile" << p_path << m_name << p_modifiable;
|
||||||
}
|
}
|
||||||
@ -130,6 +131,8 @@ bool VOrphanFile::rename(const QString &p_name)
|
|||||||
|
|
||||||
void VOrphanFile::setImageFolder(const QString &p_path)
|
void VOrphanFile::setImageFolder(const QString &p_path)
|
||||||
{
|
{
|
||||||
|
qDebug() << "orphan file" << retrivePath() << "image folder"
|
||||||
|
<< m_imageFolder << "->" << p_path;
|
||||||
m_imageFolder = p_path;
|
m_imageFolder = p_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ class VOrphanFile : public VFile
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
VOrphanFile(const QString &p_path, QObject *p_parent, bool p_modifiable);
|
VOrphanFile(const QString &p_path, QObject *p_parent,
|
||||||
|
bool p_modifiable, bool p_systemFile = false);
|
||||||
|
|
||||||
bool open() Q_DECL_OVERRIDE;
|
bool open() Q_DECL_OVERRIDE;
|
||||||
QString retrivePath() const Q_DECL_OVERRIDE;
|
QString retrivePath() const Q_DECL_OVERRIDE;
|
||||||
@ -27,12 +28,16 @@ public:
|
|||||||
|
|
||||||
void setImageFolder(const QString &p_path);
|
void setImageFolder(const QString &p_path);
|
||||||
|
|
||||||
|
const QString getImageFolder() const;
|
||||||
|
|
||||||
// Whether the image folder is a relative path.
|
// Whether the image folder is a relative path.
|
||||||
bool isRelativeImageFolder() const Q_DECL_OVERRIDE;
|
bool isRelativeImageFolder() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
// Return the image folder part in an image link.
|
// Return the image folder part in an image link.
|
||||||
QString getImageFolderInLink() const Q_DECL_OVERRIDE;
|
QString getImageFolderInLink() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
bool isSystemFile() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool save() Q_DECL_OVERRIDE;
|
bool save() Q_DECL_OVERRIDE;
|
||||||
void convert(DocType p_curType, DocType p_targetType) Q_DECL_OVERRIDE;
|
void convert(DocType p_curType, DocType p_targetType) Q_DECL_OVERRIDE;
|
||||||
@ -50,7 +55,20 @@ private:
|
|||||||
// Empty to use the global default config.
|
// Empty to use the global default config.
|
||||||
QString m_imageFolder;
|
QString m_imageFolder;
|
||||||
|
|
||||||
|
// Whether it is a system internal file.
|
||||||
|
bool m_systemFile;
|
||||||
|
|
||||||
friend class VDirectory;
|
friend class VDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline bool VOrphanFile::isSystemFile() const
|
||||||
|
{
|
||||||
|
return m_systemFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const QString VOrphanFile::getImageFolder() const
|
||||||
|
{
|
||||||
|
return m_imageFolder;
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VORPHANFILE_H
|
#endif // VORPHANFILE_H
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
#include "vedittab.h"
|
#include "vedittab.h"
|
||||||
|
#include "vorphanfile.h"
|
||||||
|
|
||||||
VTabIndicator::VTabIndicator(QWidget *p_parent)
|
VTabIndicator::VTabIndicator(QWidget *p_parent)
|
||||||
: QWidget(p_parent)
|
: QWidget(p_parent)
|
||||||
@ -25,11 +26,16 @@ void VTabIndicator::setupUI()
|
|||||||
m_externalLabel->setToolTip(tr("This file is not managed by any notebook or folder"));
|
m_externalLabel->setToolTip(tr("This file is not managed by any notebook or folder"));
|
||||||
m_externalLabel->setProperty("ColorTealLabel", true);
|
m_externalLabel->setProperty("ColorTealLabel", true);
|
||||||
|
|
||||||
|
m_systemLabel = new QLabel(tr("System"), this);
|
||||||
|
m_systemLabel->setToolTip(tr("This file is a system file"));
|
||||||
|
m_systemLabel->setProperty("ColorGreenLabel", true);
|
||||||
|
|
||||||
m_cursorLabel = new QLabel(this);
|
m_cursorLabel = new QLabel(this);
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
QHBoxLayout *mainLayout = new QHBoxLayout(this);
|
||||||
mainLayout->addWidget(m_cursorLabel);
|
mainLayout->addWidget(m_cursorLabel);
|
||||||
mainLayout->addWidget(m_externalLabel);
|
mainLayout->addWidget(m_externalLabel);
|
||||||
|
mainLayout->addWidget(m_systemLabel);
|
||||||
mainLayout->addWidget(m_readonlyLabel);
|
mainLayout->addWidget(m_readonlyLabel);
|
||||||
mainLayout->addWidget(m_docTypeLabel);
|
mainLayout->addWidget(m_docTypeLabel);
|
||||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -73,6 +79,7 @@ void VTabIndicator::update(const VEditTabInfo &p_info)
|
|||||||
DocType docType = DocType::Html;
|
DocType docType = DocType::Html;
|
||||||
bool readonly = false;
|
bool readonly = false;
|
||||||
bool external = false;
|
bool external = false;
|
||||||
|
bool system = false;
|
||||||
QString cursorStr;
|
QString cursorStr;
|
||||||
|
|
||||||
if (p_info.m_editTab)
|
if (p_info.m_editTab)
|
||||||
@ -82,6 +89,7 @@ void VTabIndicator::update(const VEditTabInfo &p_info)
|
|||||||
docType = file->getDocType();
|
docType = file->getDocType();
|
||||||
readonly = !file->isModifiable();
|
readonly = !file->isModifiable();
|
||||||
external = file->getType() == FileType::Orphan;
|
external = file->getType() == FileType::Orphan;
|
||||||
|
system = external && dynamic_cast<const VOrphanFile *>(file)->isSystemFile();
|
||||||
|
|
||||||
if (editTab->isEditMode()) {
|
if (editTab->isEditMode()) {
|
||||||
int line = p_info.m_cursorBlockNumber + 1;
|
int line = p_info.m_cursorBlockNumber + 1;
|
||||||
@ -107,4 +115,5 @@ void VTabIndicator::update(const VEditTabInfo &p_info)
|
|||||||
m_docTypeLabel->setText(docTypeToString(docType));
|
m_docTypeLabel->setText(docTypeToString(docType));
|
||||||
m_readonlyLabel->setVisible(readonly);
|
m_readonlyLabel->setVisible(readonly);
|
||||||
m_externalLabel->setVisible(external);
|
m_externalLabel->setVisible(external);
|
||||||
|
m_systemLabel->setVisible(system);
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,9 @@ private:
|
|||||||
// Indicate whether it is a normal note or an external file.
|
// Indicate whether it is a normal note or an external file.
|
||||||
QLabel *m_externalLabel;
|
QLabel *m_externalLabel;
|
||||||
|
|
||||||
|
// Indicate whether it is a system file.
|
||||||
|
QLabel *m_systemLabel;
|
||||||
|
|
||||||
// Indicate the position of current cursor.
|
// Indicate the position of current cursor.
|
||||||
QLabel *m_cursorLabel;
|
QLabel *m_cursorLabel;
|
||||||
};
|
};
|
||||||
|
@ -23,6 +23,7 @@ VVimIndicator::VVimIndicator(QWidget *p_parent)
|
|||||||
void VVimIndicator::setupUI()
|
void VVimIndicator::setupUI()
|
||||||
{
|
{
|
||||||
m_cmdLineEdit = new VVimCmdLineEdit(this);
|
m_cmdLineEdit = new VVimCmdLineEdit(this);
|
||||||
|
m_cmdLineEdit->setProperty("VimCommandLine", true);
|
||||||
connect(m_cmdLineEdit, &VVimCmdLineEdit::commandCancelled,
|
connect(m_cmdLineEdit, &VVimCmdLineEdit::commandCancelled,
|
||||||
this, [this](){
|
this, [this](){
|
||||||
if (m_vim) {
|
if (m_vim) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user