mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add config insert_new_note_in_front
This commit is contained in:
parent
32991051a9
commit
3d188fa648
@ -255,6 +255,9 @@ smart_live_preview=3
|
|||||||
; Support multiple keyboard layout
|
; Support multiple keyboard layout
|
||||||
multiple_keyboard_layout=true
|
multiple_keyboard_layout=true
|
||||||
|
|
||||||
|
; Whether insert new note in front
|
||||||
|
insert_new_note_in_front=false
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
; Auto indent as previous line
|
; Auto indent as previous line
|
||||||
auto_indent=true
|
auto_indent=true
|
||||||
|
@ -317,6 +317,9 @@ void VConfigManager::initialize()
|
|||||||
m_multipleKeyboardLayout = getConfigFromSettings("global",
|
m_multipleKeyboardLayout = getConfigFromSettings("global",
|
||||||
"multiple_keyboard_layout").toBool();
|
"multiple_keyboard_layout").toBool();
|
||||||
|
|
||||||
|
m_insertNewNoteInFront = getConfigFromSettings("global",
|
||||||
|
"insert_new_note_in_front").toBool();
|
||||||
|
|
||||||
initEditorConfigs();
|
initEditorConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,6 +558,9 @@ public:
|
|||||||
|
|
||||||
bool getMultipleKeyboardLayout() const;
|
bool getMultipleKeyboardLayout() const;
|
||||||
|
|
||||||
|
bool getInsertNewNoteInFront() const;
|
||||||
|
void setInsertNewNoteInFront(bool p_enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Look up a config from user and default settings.
|
// Look up a config from user and default settings.
|
||||||
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
QVariant getConfigFromSettings(const QString §ion, const QString &key) const;
|
||||||
@ -1001,6 +1004,9 @@ private:
|
|||||||
// Support multiple keyboard layout.
|
// Support multiple keyboard layout.
|
||||||
bool m_multipleKeyboardLayout;
|
bool m_multipleKeyboardLayout;
|
||||||
|
|
||||||
|
// Whether insert new note in front.
|
||||||
|
bool m_insertNewNoteInFront;
|
||||||
|
|
||||||
// The name of the config file in each directory.
|
// The name of the config file in each directory.
|
||||||
static const QString c_dirConfigFile;
|
static const QString c_dirConfigFile;
|
||||||
|
|
||||||
@ -2576,4 +2582,19 @@ inline bool VConfigManager::getMultipleKeyboardLayout() const
|
|||||||
{
|
{
|
||||||
return m_multipleKeyboardLayout;
|
return m_multipleKeyboardLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool VConfigManager::getInsertNewNoteInFront() const
|
||||||
|
{
|
||||||
|
return m_insertNewNoteInFront;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void VConfigManager::setInsertNewNoteInFront(bool p_enabled)
|
||||||
|
{
|
||||||
|
if (m_insertNewNoteInFront == p_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_insertNewNoteInFront = p_enabled;
|
||||||
|
setConfigToSettings("global", "insert_new_note_in_front", m_insertNewNoteInFront);
|
||||||
|
}
|
||||||
#endif // VCONFIGMANAGER_H
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -289,7 +289,7 @@ bool VDirectory::containsFile(const VFile *p_file) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
VNoteFile *VDirectory::createFile(const QString &p_name)
|
VNoteFile *VDirectory::createFile(const QString &p_name, bool p_front)
|
||||||
{
|
{
|
||||||
Q_ASSERT(!p_name.isEmpty());
|
Q_ASSERT(!p_name.isEmpty());
|
||||||
if (!open()) {
|
if (!open()) {
|
||||||
@ -312,11 +312,19 @@ VNoteFile *VDirectory::createFile(const QString &p_name)
|
|||||||
true,
|
true,
|
||||||
dateTime,
|
dateTime,
|
||||||
dateTime);
|
dateTime);
|
||||||
m_files.append(ret);
|
int idx = -1;
|
||||||
|
if (p_front) {
|
||||||
|
m_files.prepend(ret);
|
||||||
|
idx = 0;
|
||||||
|
} else {
|
||||||
|
m_files.append(ret);
|
||||||
|
idx = m_files.size() - 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!writeToConfig()) {
|
if (!writeToConfig()) {
|
||||||
file.remove();
|
file.remove();
|
||||||
delete ret;
|
delete ret;
|
||||||
m_files.removeLast();
|
m_files.remove(idx);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
// If current dir or its sub-dir contains @p_file.
|
// If current dir or its sub-dir contains @p_file.
|
||||||
bool containsFile(const VFile *p_file) const;
|
bool containsFile(const VFile *p_file) const;
|
||||||
|
|
||||||
VNoteFile *createFile(const QString &p_name);
|
VNoteFile *createFile(const QString &p_name, bool p_front);
|
||||||
|
|
||||||
// Remove the file in the config and m_files without deleting it in the disk.
|
// Remove the file in the config and m_files without deleting it in the disk.
|
||||||
// It won't change the parent of @p_file to enable it find its path.
|
// It won't change the parent of @p_file to enable it find its path.
|
||||||
|
@ -349,7 +349,8 @@ void VFileList::newFile()
|
|||||||
true);
|
true);
|
||||||
VNewFileDialog dialog(tr("Create Note"), info, defaultName, m_directory, this);
|
VNewFileDialog dialog(tr("Create Note"), info, defaultName, m_directory, this);
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
VNoteFile *file = m_directory->createFile(dialog.getNameInput());
|
VNoteFile *file = m_directory->createFile(dialog.getNameInput(),
|
||||||
|
g_config->getInsertNewNoteInFront());
|
||||||
if (!file) {
|
if (!file) {
|
||||||
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
|
VUtils::showMessage(QMessageBox::Warning, tr("Warning"),
|
||||||
tr("Fail to create note <span style=\"%1\">%2</span>.")
|
tr("Fail to create note <span style=\"%1\">%2</span>.")
|
||||||
@ -998,6 +999,7 @@ void VFileList::pasteFiles(VDirectory *p_destDir,
|
|||||||
fileName,
|
fileName,
|
||||||
file,
|
file,
|
||||||
p_isCut,
|
p_isCut,
|
||||||
|
g_config->getInsertNewNoteInFront() ? 0 : -1,
|
||||||
&destFile,
|
&destFile,
|
||||||
&msg);
|
&msg);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
@ -453,6 +453,7 @@ bool VNoteFile::copyFile(VDirectory *p_destDir,
|
|||||||
const QString &p_destName,
|
const QString &p_destName,
|
||||||
VNoteFile *p_file,
|
VNoteFile *p_file,
|
||||||
bool p_isCut,
|
bool p_isCut,
|
||||||
|
int p_idx,
|
||||||
VNoteFile **p_targetFile,
|
VNoteFile **p_targetFile,
|
||||||
QString *p_errMsg)
|
QString *p_errMsg)
|
||||||
{
|
{
|
||||||
@ -506,13 +507,13 @@ bool VNoteFile::copyFile(VDirectory *p_destDir,
|
|||||||
if (p_isCut) {
|
if (p_isCut) {
|
||||||
srcDir->removeFile(p_file);
|
srcDir->removeFile(p_file);
|
||||||
p_file->setName(p_destName);
|
p_file->setName(p_destName);
|
||||||
if (p_destDir->addFile(p_file, -1)) {
|
if (p_destDir->addFile(p_file, p_idx)) {
|
||||||
destFile = p_file;
|
destFile = p_file;
|
||||||
} else {
|
} else {
|
||||||
destFile = NULL;
|
destFile = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
destFile = p_destDir->addFile(p_destName, -1);
|
destFile = p_destDir->addFile(p_destName, p_idx);
|
||||||
// Copy tags to this file.
|
// Copy tags to this file.
|
||||||
if (destFile) {
|
if (destFile) {
|
||||||
const QStringList &tags = p_file->getTags();
|
const QStringList &tags = p_file->getTags();
|
||||||
|
@ -135,6 +135,7 @@ public:
|
|||||||
const QString &p_destName,
|
const QString &p_destName,
|
||||||
VNoteFile *p_file,
|
VNoteFile *p_file,
|
||||||
bool p_isCut,
|
bool p_isCut,
|
||||||
|
int p_idx,
|
||||||
VNoteFile **p_targetFile,
|
VNoteFile **p_targetFile,
|
||||||
QString *p_errMsg = NULL);
|
QString *p_errMsg = NULL);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user