refine default new note name

This commit is contained in:
Le Tan 2021-01-11 20:02:05 +08:00
parent 00b8995fc8
commit b4818e617f
5 changed files with 17 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -1391,25 +1391,30 @@
<context>
<name>vnotex::NewNoteDialog</name>
<message>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="36"/>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="35"/>
<source>New Note</source>
<translation></translation>
</message>
<message>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="63"/>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="62"/>
<source>Please specify a name for the note.</source>
<translation></translation>
</message>
<message>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="68"/>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="67"/>
<source>Name conflicts with existing note.</source>
<translation></translation>
</message>
<message>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="91"/>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="90"/>
<source>Failed to create note under (%1) in (%2) (%3).</source>
<translation> (%2) (%1) (%3)</translation>
</message>
<message>
<location filename="../../../widgets/dialogs/newnotedialog.cpp" line="113"/>
<source>note</source>
<translation></translation>
</message>
</context>
<context>
<name>vnotex::NewNotebookDialog</name>

View File

@ -6,21 +6,20 @@
#include "notebook/node.h"
#include "../widgetsfactory.h"
#include <utils/pathutils.h>
#include <utils/fileutils.h>
#include "exception.h"
#include "nodeinfowidget.h"
#include <utils/widgetutils.h>
using namespace vnotex;
const QString NewNoteDialog::c_defaultNoteName = "new_note.md";
NewNoteDialog::NewNoteDialog(Node *p_node, QWidget *p_parent)
: ScrollDialog(p_parent)
{
Q_ASSERT(p_node && p_node->isLoaded());
setupUI(p_node);
initDefaultValues();
initDefaultValues(p_node);
m_infoWidget->getNameLineEdit()->setFocus();
}
@ -106,11 +105,14 @@ const QSharedPointer<Node> &NewNoteDialog::getNewNode() const
return m_newNode;
}
void NewNoteDialog::initDefaultValues()
void NewNoteDialog::initDefaultValues(const Node *p_node)
{
{
auto lineEdit = m_infoWidget->getNameLineEdit();
lineEdit->setText(c_defaultNoteName);
auto defaultName = FileUtils::generateFileNameWithSequence(p_node->fetchAbsolutePath(),
tr("note"),
QStringLiteral("md"));
lineEdit->setText(defaultName);
WidgetUtils::selectBaseName(lineEdit);
validateInputs();

View File

@ -33,13 +33,11 @@ namespace vnotex
bool newNote();
void initDefaultValues();
void initDefaultValues(const Node *p_node);
NodeInfoWidget *m_infoWidget = nullptr;
QSharedPointer<Node> m_newNode;
static const QString c_defaultNoteName;
};
} // ns vnotex