mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
parent
14a3270184
commit
b9ac16d165
@ -21,6 +21,7 @@ SOURCES += \
|
|||||||
$$PWD/logger.cpp \
|
$$PWD/logger.cpp \
|
||||||
$$PWD/mainconfig.cpp \
|
$$PWD/mainconfig.cpp \
|
||||||
$$PWD/markdowneditorconfig.cpp \
|
$$PWD/markdowneditorconfig.cpp \
|
||||||
|
$$PWD/quickaccesshelper.cpp \
|
||||||
$$PWD/singleinstanceguard.cpp \
|
$$PWD/singleinstanceguard.cpp \
|
||||||
$$PWD/texteditorconfig.cpp \
|
$$PWD/texteditorconfig.cpp \
|
||||||
$$PWD/vnotex.cpp \
|
$$PWD/vnotex.cpp \
|
||||||
@ -46,6 +47,7 @@ HEADERS += \
|
|||||||
$$PWD/logger.h \
|
$$PWD/logger.h \
|
||||||
$$PWD/mainconfig.h \
|
$$PWD/mainconfig.h \
|
||||||
$$PWD/markdowneditorconfig.h \
|
$$PWD/markdowneditorconfig.h \
|
||||||
|
$$PWD/quickaccesshelper.h \
|
||||||
$$PWD/singleinstanceguard.h \
|
$$PWD/singleinstanceguard.h \
|
||||||
$$PWD/iconfig.h \
|
$$PWD/iconfig.h \
|
||||||
$$PWD/texteditorconfig.h \
|
$$PWD/texteditorconfig.h \
|
||||||
|
@ -35,6 +35,9 @@ namespace vnotex
|
|||||||
RemoveSplitAndWorkspace,
|
RemoveSplitAndWorkspace,
|
||||||
NewWorkspace,
|
NewWorkspace,
|
||||||
Export,
|
Export,
|
||||||
|
Quit,
|
||||||
|
FlashPage,
|
||||||
|
QuickAccess,
|
||||||
MaxShortcut
|
MaxShortcut
|
||||||
};
|
};
|
||||||
Q_ENUM(Shortcut)
|
Q_ENUM(Shortcut)
|
||||||
|
@ -94,6 +94,30 @@ namespace vnotex
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QStringList readStringList(const QJsonObject &p_obj,
|
||||||
|
const QString &p_key)
|
||||||
|
{
|
||||||
|
auto arr = p_obj.value(p_key).toArray();
|
||||||
|
QStringList res;
|
||||||
|
res.reserve(arr.size());
|
||||||
|
for (const auto &ele : arr) {
|
||||||
|
res.push_back(ele.toString());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void writeStringList(QJsonObject &p_obj,
|
||||||
|
const QString &p_key,
|
||||||
|
const QStringList &p_list)
|
||||||
|
{
|
||||||
|
QJsonArray arr;
|
||||||
|
for (const auto &ele : p_list) {
|
||||||
|
arr.push_back(ele);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_obj[p_key] = arr;
|
||||||
|
}
|
||||||
|
|
||||||
static QString readString(const QJsonObject &p_obj,
|
static QString readString(const QJsonObject &p_obj,
|
||||||
const QString &p_key)
|
const QString &p_key)
|
||||||
{
|
{
|
||||||
|
19
src/core/quickaccesshelper.cpp
Normal file
19
src/core/quickaccesshelper.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "quickaccesshelper.h"
|
||||||
|
|
||||||
|
#include "configmgr.h"
|
||||||
|
#include "sessionconfig.h"
|
||||||
|
|
||||||
|
using namespace vnotex;
|
||||||
|
|
||||||
|
void QuickAccessHelper::pinToQuickAccess(const QStringList &p_files)
|
||||||
|
{
|
||||||
|
if (p_files.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
|
auto qaFiles = sessionConfig.getQuickAccessFiles();
|
||||||
|
qaFiles.append(p_files);
|
||||||
|
qaFiles.removeDuplicates();
|
||||||
|
sessionConfig.setQuickAccessFiles(qaFiles);
|
||||||
|
}
|
17
src/core/quickaccesshelper.h
Normal file
17
src/core/quickaccesshelper.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef QUICKACCESSHELPER_H
|
||||||
|
#define QUICKACCESSHELPER_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace vnotex
|
||||||
|
{
|
||||||
|
class QuickAccessHelper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QuickAccessHelper() = delete;
|
||||||
|
|
||||||
|
static void pinToQuickAccess(const QStringList &p_files);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QUICKACCESSHELPER_H
|
@ -79,8 +79,7 @@ void SessionConfig::loadCore(const QJsonObject &p_session)
|
|||||||
m_newNotebookDefaultRootFolderPath = QDir::homePath();
|
m_newNotebookDefaultRootFolderPath = QDir::homePath();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentNotebookRootFolderPath = readString(coreObj,
|
m_currentNotebookRootFolderPath = readString(coreObj, QStringLiteral("current_notebook_root_folder_path"));
|
||||||
QStringLiteral("current_notebook_root_folder_path"));
|
|
||||||
|
|
||||||
{
|
{
|
||||||
auto option = readString(coreObj, QStringLiteral("opengl"));
|
auto option = readString(coreObj, QStringLiteral("opengl"));
|
||||||
@ -96,6 +95,10 @@ void SessionConfig::loadCore(const QJsonObject &p_session)
|
|||||||
if (!isUndefinedKey(coreObj, QStringLiteral("minimize_to_system_tray"))) {
|
if (!isUndefinedKey(coreObj, QStringLiteral("minimize_to_system_tray"))) {
|
||||||
m_minimizeToSystemTray = readBool(coreObj, QStringLiteral("minimize_to_system_tray")) ? 1 : 0;
|
m_minimizeToSystemTray = readBool(coreObj, QStringLiteral("minimize_to_system_tray")) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_flashPage = readString(coreObj, QStringLiteral("flash_page"));
|
||||||
|
|
||||||
|
m_quickAccessFiles = readStringList(coreObj, QStringLiteral("quick_access"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject SessionConfig::saveCore() const
|
QJsonObject SessionConfig::saveCore() const
|
||||||
@ -108,6 +111,8 @@ QJsonObject SessionConfig::saveCore() const
|
|||||||
if (m_minimizeToSystemTray != -1) {
|
if (m_minimizeToSystemTray != -1) {
|
||||||
coreObj[QStringLiteral("minimize_to_system_tray")] = m_minimizeToSystemTray > 0;
|
coreObj[QStringLiteral("minimize_to_system_tray")] = m_minimizeToSystemTray > 0;
|
||||||
}
|
}
|
||||||
|
coreObj[QStringLiteral("flash_page")] = m_flashPage;
|
||||||
|
writeStringList(coreObj, QStringLiteral("quick_access"), m_quickAccessFiles);
|
||||||
return coreObj;
|
return coreObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,3 +343,23 @@ void SessionConfig::setNotebookExplorerSession(const QByteArray &p_bytes)
|
|||||||
{
|
{
|
||||||
updateConfigWithoutCheck(m_notebookExplorerSession, p_bytes, this);
|
updateConfigWithoutCheck(m_notebookExplorerSession, p_bytes, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &SessionConfig::getFlashPage() const
|
||||||
|
{
|
||||||
|
return m_flashPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionConfig::setFlashPage(const QString &p_file)
|
||||||
|
{
|
||||||
|
updateConfig(m_flashPage, p_file, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QStringList &SessionConfig::getQuickAccessFiles() const
|
||||||
|
{
|
||||||
|
return m_quickAccessFiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SessionConfig::setQuickAccessFiles(const QStringList &p_files)
|
||||||
|
{
|
||||||
|
updateConfig(m_quickAccessFiles, p_files, this);
|
||||||
|
}
|
||||||
|
@ -97,6 +97,12 @@ namespace vnotex
|
|||||||
QByteArray getNotebookExplorerSessionAndClear();
|
QByteArray getNotebookExplorerSessionAndClear();
|
||||||
void setNotebookExplorerSession(const QByteArray &p_bytes);
|
void setNotebookExplorerSession(const QByteArray &p_bytes);
|
||||||
|
|
||||||
|
const QString &getFlashPage() const;
|
||||||
|
void setFlashPage(const QString &p_file);
|
||||||
|
|
||||||
|
const QStringList &getQuickAccessFiles() const;
|
||||||
|
void setQuickAccessFiles(const QStringList &p_files);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void loadCore(const QJsonObject &p_session);
|
void loadCore(const QJsonObject &p_session);
|
||||||
|
|
||||||
@ -139,6 +145,10 @@ namespace vnotex
|
|||||||
QByteArray m_viewAreaSession;
|
QByteArray m_viewAreaSession;
|
||||||
|
|
||||||
QByteArray m_notebookExplorerSession;
|
QByteArray m_notebookExplorerSession;
|
||||||
|
|
||||||
|
QString m_flashPage;
|
||||||
|
|
||||||
|
QStringList m_quickAccessFiles;
|
||||||
};
|
};
|
||||||
} // ns vnotex
|
} // ns vnotex
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "location.h"
|
#include "location.h"
|
||||||
|
|
||||||
#include "fileopenparameters.h"
|
#include "fileopenparameters.h"
|
||||||
|
#include "quickaccesshelper.h"
|
||||||
|
|
||||||
#include <utils/docsutils.h>
|
#include <utils/docsutils.h>
|
||||||
|
|
||||||
@ -31,6 +32,8 @@ VNoteX::VNoteX(QObject *p_parent)
|
|||||||
initBufferMgr();
|
initBufferMgr();
|
||||||
|
|
||||||
initDocsUtils();
|
initDocsUtils();
|
||||||
|
|
||||||
|
initQuickAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VNoteX::initLoad()
|
void VNoteX::initLoad()
|
||||||
@ -128,3 +131,9 @@ void VNoteX::initDocsUtils()
|
|||||||
|
|
||||||
DocsUtils::setLocale(configMgr.getCoreConfig().getLocaleToUse());
|
DocsUtils::setLocale(configMgr.getCoreConfig().getLocaleToUse());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VNoteX::initQuickAccess()
|
||||||
|
{
|
||||||
|
connect(this, &VNoteX::pinToQuickAccessRequested,
|
||||||
|
this, &QuickAccessHelper::pinToQuickAccess);
|
||||||
|
}
|
||||||
|
@ -107,6 +107,8 @@ namespace vnotex
|
|||||||
|
|
||||||
void exportRequested();
|
void exportRequested();
|
||||||
|
|
||||||
|
void pinToQuickAccessRequested(const QStringList &p_files);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit VNoteX(QObject *p_parent = nullptr);
|
explicit VNoteX(QObject *p_parent = nullptr);
|
||||||
|
|
||||||
@ -118,6 +120,8 @@ namespace vnotex
|
|||||||
|
|
||||||
void initDocsUtils();
|
void initDocsUtils();
|
||||||
|
|
||||||
|
void initQuickAccess();
|
||||||
|
|
||||||
MainWindow *m_mainWindow;
|
MainWindow *m_mainWindow;
|
||||||
|
|
||||||
// QObject managed.
|
// QObject managed.
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
<file>icons/whatsthis.svg</file>
|
<file>icons/whatsthis.svg</file>
|
||||||
<file>icons/help_menu.svg</file>
|
<file>icons/help_menu.svg</file>
|
||||||
<file>icons/import_export_menu.svg</file>
|
<file>icons/import_export_menu.svg</file>
|
||||||
|
<file>icons/flash_page_menu.svg</file>
|
||||||
|
<file>icons/quick_access_menu.svg</file>
|
||||||
<file>icons/native_notebook_default.svg</file>
|
<file>icons/native_notebook_default.svg</file>
|
||||||
<file>icons/notebook_default.svg</file>
|
<file>icons/notebook_default.svg</file>
|
||||||
<file>icons/file_node.svg</file>
|
<file>icons/file_node.svg</file>
|
||||||
|
1
src/data/core/icons/flash_page_menu.svg
Normal file
1
src/data/core/icons/flash_page_menu.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1621166645132" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3766" width="512" height="512" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><style type="text/css"></style></defs><path d="M512.10986 0.000171A405.329956 405.329956 0 0 0 321.818112 763.385809a18.261181 18.261181 0 0 1 9.727919 16.213198v79.70067a89.940584 89.940584 0 0 0 89.940584 89.940583h6.997275v12.117233a62.122149 62.122149 0 0 0 63.14614 62.634144h40.959659a62.122149 62.122149 0 0 0 61.951484-61.951483v-12.117233H601.709113a89.940584 89.940584 0 0 0 89.769919-89.940584v-79.871334a18.261181 18.261181 0 0 1 9.727918-16.213198A405.329956 405.329956 0 0 0 512.10986 0.000171z m31.231739 962.039983a10.75191 10.75191 0 0 1-10.75191 10.75191h-40.959659a10.75191 10.75191 0 0 1-10.75191-10.75191v-12.117233h62.463479zM601.709113 898.552683H422.681271a38.570345 38.570345 0 0 1-38.229014-34.133049h255.997866a38.570345 38.570345 0 0 1-38.74101 34.133049z m76.628695-180.393164h-3.071975a69.290089 69.290089 0 0 0-34.133049 59.562171v32.597061h-102.399146v-56.660861a18.773177 18.773177 0 0 1 11.093241-17.066524c16.042533-7.679936 59.050175-28.159765 59.050174-70.996742 0-55.295539-57.343522-55.295539-88.233931-55.295539a133.289556 133.289556 0 0 1-38.39968-2.901309v-1.023992c0-7.509271 11.434571-12.117232 38.74101-20.309164 34.133049-10.239915 86.697944-25.770452 86.697944-85.332622S550.50954 426.663282 512.10986 416.594032c-18.773177-4.778627-44.372964-11.263906-44.372964-19.285172v-1.023992c0-1.023991 13.482554-7.850601 42.666311-5.802618a25.599787 25.599787 0 1 0 3.58397-51.199573c-39.765002-2.730644-68.266098 4.778627-84.137965 22.527812a49.322256 49.322256 0 0 0-13.311889 36.693027c0 46.762277 48.298264 58.708844 82.943308 68.266098 42.154315 10.75191 57.172857 17.066524 57.172857 34.133049s-11.946567 24.575795-50.175581 36.010367C474.734171 546.128953 431.043868 559.440842 431.043868 606.373784c0 55.295539 57.343522 55.295539 88.233932 55.295539a133.289556 133.289556 0 0 1 37.034358 3.071975v1.023991c0 1.023991 0 10.581245-29.866418 24.917126a70.484746 70.484746 0 0 0-40.106332 63.14614v59.22084h-102.399147v-32.938392a69.290089 69.290089 0 0 0-34.133049-59.56217h-3.24264a354.301047 354.301047 0 1 1 332.285231 0z" p-id="3767" fill="#000000"></path></svg>
|
After Width: | Height: | Size: 2.4 KiB |
7
src/data/core/icons/quick_access_menu.svg
Normal file
7
src/data/core/icons/quick_access_menu.svg
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?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">
|
||||||
|
<polygon fill="#000000" points="96,288 243,288 191.9,480 416,224 269,224 320,32 "/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 568 B |
@ -28,7 +28,10 @@
|
|||||||
"DistributeSplits" : "Ctrl+G, =",
|
"DistributeSplits" : "Ctrl+G, =",
|
||||||
"RemoveSplitAndWorkspace" : "Ctrl+G, R",
|
"RemoveSplitAndWorkspace" : "Ctrl+G, R",
|
||||||
"NewWorkspace" : "Ctrl+G, N",
|
"NewWorkspace" : "Ctrl+G, N",
|
||||||
"Export" : "Ctrl+G, T"
|
"Export" : "Ctrl+G, T",
|
||||||
|
"Quit" : "Ctrl+Q",
|
||||||
|
"FlashPage" : "Ctrl+Alt+L",
|
||||||
|
"QuickAccess" : "Ctrl+Alt+I"
|
||||||
},
|
},
|
||||||
"toolbar_icon_size" : 16,
|
"toolbar_icon_size" : 16,
|
||||||
"note_management" : {
|
"note_management" : {
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <utils/pathutils.h>
|
#include <utils/pathutils.h>
|
||||||
#include <utils/clipboardutils.h>
|
#include <utils/clipboardutils.h>
|
||||||
#include <export/exporter.h>
|
#include <export/exporter.h>
|
||||||
|
#include <widgets/locationinputwithbrowsebutton.h>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -181,14 +182,9 @@ QGroupBox *ExportDialog::setupTargetGroup(QWidget *p_parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto outputLayout = new QHBoxLayout();
|
m_outputDirInput = new LocationInputWithBrowseButton(box);
|
||||||
|
layout->addRow(tr("Output directory:"), m_outputDirInput);
|
||||||
m_outputDirLineEdit = WidgetsFactory::createLineEdit(box);
|
connect(m_outputDirInput, &LocationInputWithBrowseButton::clicked,
|
||||||
outputLayout->addWidget(m_outputDirLineEdit);
|
|
||||||
|
|
||||||
auto browseBtn = new QPushButton(tr("Browse"), box);
|
|
||||||
outputLayout->addWidget(browseBtn);
|
|
||||||
connect(browseBtn, &QPushButton::clicked,
|
|
||||||
this, [this]() {
|
this, [this]() {
|
||||||
QString initPath = getOutputDir();
|
QString initPath = getOutputDir();
|
||||||
if (!QFileInfo::exists(initPath)) {
|
if (!QFileInfo::exists(initPath)) {
|
||||||
@ -202,11 +198,9 @@ QGroupBox *ExportDialog::setupTargetGroup(QWidget *p_parent)
|
|||||||
| QFileDialog::DontResolveSymlinks);
|
| QFileDialog::DontResolveSymlinks);
|
||||||
|
|
||||||
if (!dirPath.isEmpty()) {
|
if (!dirPath.isEmpty()) {
|
||||||
m_outputDirLineEdit->setText(dirPath);
|
m_outputDirInput->setText(dirPath);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
layout->addRow(tr("Output directory:"), outputLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return box;
|
return box;
|
||||||
@ -281,7 +275,7 @@ void ExportDialog::setupButtonBox()
|
|||||||
|
|
||||||
QString ExportDialog::getOutputDir() const
|
QString ExportDialog::getOutputDir() const
|
||||||
{
|
{
|
||||||
return m_outputDirLineEdit->text();
|
return m_outputDirInput->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportDialog::initOptions()
|
void ExportDialog::initOptions()
|
||||||
@ -330,7 +324,7 @@ void ExportDialog::restoreFields(const ExportOption &p_option)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_outputDirLineEdit->setText(p_option.m_outputDir);
|
m_outputDirInput->setText(p_option.m_outputDir);
|
||||||
|
|
||||||
m_recursiveCheckBox->setChecked(p_option.m_recursive);
|
m_recursiveCheckBox->setChecked(p_option.m_recursive);
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ namespace vnotex
|
|||||||
class Node;
|
class Node;
|
||||||
class Buffer;
|
class Buffer;
|
||||||
class Exporter;
|
class Exporter;
|
||||||
|
class LocationInputWithBrowseButton;
|
||||||
|
|
||||||
class ExportDialog : public ScrollDialog
|
class ExportDialog : public ScrollDialog
|
||||||
{
|
{
|
||||||
@ -130,7 +131,7 @@ namespace vnotex
|
|||||||
|
|
||||||
QComboBox *m_syntaxHighlightStyleComboBox = nullptr;
|
QComboBox *m_syntaxHighlightStyleComboBox = nullptr;
|
||||||
|
|
||||||
QLineEdit *m_outputDirLineEdit = nullptr;
|
LocationInputWithBrowseButton *m_outputDirInput = nullptr;
|
||||||
|
|
||||||
QProgressBar *m_progressBar = nullptr;
|
QProgressBar *m_progressBar = nullptr;
|
||||||
|
|
||||||
|
104
src/widgets/dialogs/settings/quickaccesspage.cpp
Normal file
104
src/widgets/dialogs/settings/quickaccesspage.cpp
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
#include "quickaccesspage.h"
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QFormLayout>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <widgets/widgetsfactory.h>
|
||||||
|
#include <core/sessionconfig.h>
|
||||||
|
#include <core/coreconfig.h>
|
||||||
|
#include <core/configmgr.h>
|
||||||
|
#include <utils/widgetutils.h>
|
||||||
|
#include <widgets/locationinputwithbrowsebutton.h>
|
||||||
|
|
||||||
|
using namespace vnotex;
|
||||||
|
|
||||||
|
QuickAccessPage::QuickAccessPage(QWidget *p_parent)
|
||||||
|
: SettingsPage(p_parent)
|
||||||
|
{
|
||||||
|
setupUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickAccessPage::setupUI()
|
||||||
|
{
|
||||||
|
auto mainLayout = new QVBoxLayout(this);
|
||||||
|
|
||||||
|
auto flashPageBox = setupFlashPageGroup();
|
||||||
|
mainLayout->addWidget(flashPageBox);
|
||||||
|
|
||||||
|
auto quickAccessBox = setupQuickAccessGroup();
|
||||||
|
mainLayout->addWidget(quickAccessBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickAccessPage::loadInternal()
|
||||||
|
{
|
||||||
|
const auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
|
|
||||||
|
m_flashPageInput->setText(sessionConfig.getFlashPage());
|
||||||
|
|
||||||
|
{
|
||||||
|
const auto &quickAccess = sessionConfig.getQuickAccessFiles();
|
||||||
|
if (!quickAccess.isEmpty()) {
|
||||||
|
m_quickAccessTextEdit->setPlainText(quickAccess.join(QChar('\n')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QuickAccessPage::saveInternal()
|
||||||
|
{
|
||||||
|
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
|
|
||||||
|
sessionConfig.setFlashPage(m_flashPageInput->text());
|
||||||
|
|
||||||
|
{
|
||||||
|
auto text = m_quickAccessTextEdit->toPlainText();
|
||||||
|
if (!text.isEmpty()) {
|
||||||
|
sessionConfig.setQuickAccessFiles(text.split(QChar('\n')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString QuickAccessPage::title() const
|
||||||
|
{
|
||||||
|
return tr("Quick Access");
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox *QuickAccessPage::setupFlashPageGroup()
|
||||||
|
{
|
||||||
|
auto box = new QGroupBox(tr("Flash Page"), this);
|
||||||
|
auto layout = WidgetsFactory::createFormLayout(box);
|
||||||
|
|
||||||
|
{
|
||||||
|
m_flashPageInput = new LocationInputWithBrowseButton(box);
|
||||||
|
m_flashPageInput->setToolTip(tr("Flash Page location (user could copy the path of one note and paste it here)"));
|
||||||
|
|
||||||
|
const QString label(tr("Flash Page:"));
|
||||||
|
layout->addRow(label, m_flashPageInput);
|
||||||
|
addSearchItem(label, m_flashPageInput->toolTip(), m_flashPageInput);
|
||||||
|
connect(m_flashPageInput, &LocationInputWithBrowseButton::textChanged,
|
||||||
|
this, &QuickAccessPage::pageIsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox *QuickAccessPage::setupQuickAccessGroup()
|
||||||
|
{
|
||||||
|
auto box = new QGroupBox(tr("Quick Access"), this);
|
||||||
|
auto layout = WidgetsFactory::createFormLayout(box);
|
||||||
|
|
||||||
|
{
|
||||||
|
m_quickAccessTextEdit = WidgetsFactory::createPlainTextEdit(box);
|
||||||
|
m_quickAccessTextEdit->setToolTip(tr("Edit the files pinned to Quick Access (one file per line)"));
|
||||||
|
|
||||||
|
const QString label(tr("Quick Access:"));
|
||||||
|
layout->addRow(label, m_quickAccessTextEdit);
|
||||||
|
addSearchItem(label, m_quickAccessTextEdit->toolTip(), m_quickAccessTextEdit);
|
||||||
|
connect(m_quickAccessTextEdit, &QPlainTextEdit::textChanged,
|
||||||
|
this, &QuickAccessPage::pageIsChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
return box;
|
||||||
|
}
|
39
src/widgets/dialogs/settings/quickaccesspage.h
Normal file
39
src/widgets/dialogs/settings/quickaccesspage.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#ifndef QUICKACCESSPAGE_H
|
||||||
|
#define QUICKACCESSPAGE_H
|
||||||
|
|
||||||
|
#include "settingspage.h"
|
||||||
|
|
||||||
|
class QGroupBox;
|
||||||
|
class QPlainTextEdit;
|
||||||
|
|
||||||
|
namespace vnotex
|
||||||
|
{
|
||||||
|
class LocationInputWithBrowseButton;
|
||||||
|
|
||||||
|
class QuickAccessPage : public SettingsPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit QuickAccessPage(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
QString title() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void loadInternal() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void saveInternal() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupUI();
|
||||||
|
|
||||||
|
QGroupBox *setupFlashPageGroup();
|
||||||
|
|
||||||
|
QGroupBox *setupQuickAccessGroup();
|
||||||
|
|
||||||
|
LocationInputWithBrowseButton *m_flashPageInput = nullptr;
|
||||||
|
|
||||||
|
QPlainTextEdit *m_quickAccessTextEdit = nullptr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // QUICKACCESSPAGE_H
|
@ -13,6 +13,7 @@
|
|||||||
#include "texteditorpage.h"
|
#include "texteditorpage.h"
|
||||||
#include "markdowneditorpage.h"
|
#include "markdowneditorpage.h"
|
||||||
#include "appearancepage.h"
|
#include "appearancepage.h"
|
||||||
|
#include "quickaccesspage.h"
|
||||||
#include "themepage.h"
|
#include "themepage.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
@ -89,6 +90,12 @@ void SettingsDialog::setupPages()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Quick Access.
|
||||||
|
{
|
||||||
|
auto page = new QuickAccessPage(this);
|
||||||
|
addPage(page);
|
||||||
|
}
|
||||||
|
|
||||||
// Editor.
|
// Editor.
|
||||||
{
|
{
|
||||||
auto page = new EditorPage(this);
|
auto page = new EditorPage(this);
|
||||||
|
45
src/widgets/locationinputwithbrowsebutton.cpp
Normal file
45
src/widgets/locationinputwithbrowsebutton.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include "locationinputwithbrowsebutton.h"
|
||||||
|
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
#include <widgets/widgetsfactory.h>
|
||||||
|
|
||||||
|
using namespace vnotex;
|
||||||
|
|
||||||
|
LocationInputWithBrowseButton::LocationInputWithBrowseButton(QWidget *p_parent)
|
||||||
|
: QWidget(p_parent)
|
||||||
|
{
|
||||||
|
auto layout = new QHBoxLayout(this);
|
||||||
|
|
||||||
|
m_lineEdit = WidgetsFactory::createLineEdit(this);
|
||||||
|
layout->addWidget(m_lineEdit, 1);
|
||||||
|
connect(m_lineEdit, &QLineEdit::textChanged,
|
||||||
|
this, &LocationInputWithBrowseButton::textChanged);
|
||||||
|
|
||||||
|
auto browseBtn = new QPushButton(tr("Browse"), this);
|
||||||
|
layout->addWidget(browseBtn);
|
||||||
|
connect(browseBtn, &QPushButton::clicked,
|
||||||
|
this, &LocationInputWithBrowseButton::clicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LocationInputWithBrowseButton::text() const
|
||||||
|
{
|
||||||
|
return m_lineEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocationInputWithBrowseButton::setText(const QString &p_text)
|
||||||
|
{
|
||||||
|
m_lineEdit->setText(p_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LocationInputWithBrowseButton::toolTip() const
|
||||||
|
{
|
||||||
|
return m_lineEdit->toolTip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LocationInputWithBrowseButton::setToolTip(const QString &p_tip)
|
||||||
|
{
|
||||||
|
m_lineEdit->setToolTip(p_tip);
|
||||||
|
}
|
35
src/widgets/locationinputwithbrowsebutton.h
Normal file
35
src/widgets/locationinputwithbrowsebutton.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#ifndef LOCATIONINPUTWITHBROWSEBUTTON_H
|
||||||
|
#define LOCATIONINPUTWITHBROWSEBUTTON_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class QLineEdit;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
|
namespace vnotex
|
||||||
|
{
|
||||||
|
class LocationInputWithBrowseButton : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LocationInputWithBrowseButton(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
QString text() const;
|
||||||
|
|
||||||
|
void setText(const QString &p_text);
|
||||||
|
|
||||||
|
QString toolTip() const;
|
||||||
|
|
||||||
|
void setToolTip(const QString &p_tip);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void clicked();
|
||||||
|
|
||||||
|
void textChanged(const QString &p_text);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit *m_lineEdit = nullptr;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // LOCATIONINPUTWITHBROWSEBUTTON_H
|
@ -904,10 +904,12 @@ void MarkdownViewWindow::handleFileOpenParameters(const QSharedPointer<FileOpenP
|
|||||||
const auto title = QString("# %1\n").arg(QFileInfo(buffer->getName()).completeBaseName());
|
const auto title = QString("# %1\n").arg(QFileInfo(buffer->getName()).completeBaseName());
|
||||||
m_editor->insertText(title);
|
m_editor->insertText(title);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
setMode(p_paras->m_mode);
|
||||||
|
|
||||||
scrollToLine(p_paras->m_lineNumber);
|
scrollToLine(p_paras->m_lineNumber);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MarkdownViewWindow::scrollToLine(int p_lineNumber)
|
void MarkdownViewWindow::scrollToLine(int p_lineNumber)
|
||||||
{
|
{
|
||||||
@ -931,7 +933,6 @@ bool MarkdownViewWindow::isReadMode() const
|
|||||||
|
|
||||||
void MarkdownViewWindow::openTwice(const QSharedPointer<FileOpenParameters> &p_paras)
|
void MarkdownViewWindow::openTwice(const QSharedPointer<FileOpenParameters> &p_paras)
|
||||||
{
|
{
|
||||||
qDebug() << p_paras->m_lineNumber;
|
|
||||||
Q_ASSERT(!p_paras || !p_paras->m_newFile);
|
Q_ASSERT(!p_paras || !p_paras->m_newFile);
|
||||||
handleFileOpenParameters(p_paras);
|
handleFileOpenParameters(p_paras);
|
||||||
}
|
}
|
||||||
|
@ -475,8 +475,6 @@ void NotebookExplorer::recoverSession()
|
|||||||
|
|
||||||
auto it = m_session.m_notebooks.find(m_currentNotebook->getRootFolderPath());
|
auto it = m_session.m_notebooks.find(m_currentNotebook->getRootFolderPath());
|
||||||
if (it != m_session.m_notebooks.end()) {
|
if (it != m_session.m_notebooks.end()) {
|
||||||
qDebug() << it.value().m_recovered << it.value().m_currentNodePath;
|
|
||||||
|
|
||||||
if (it.value().m_recovered || it.value().m_currentNodePath.isEmpty()) {
|
if (it.value().m_recovered || it.value().m_currentNodePath.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -484,7 +482,6 @@ void NotebookExplorer::recoverSession()
|
|||||||
it.value().m_recovered = true;
|
it.value().m_recovered = true;
|
||||||
|
|
||||||
auto node = m_currentNotebook->loadNodeByPath(it.value().m_currentNodePath);
|
auto node = m_currentNotebook->loadNodeByPath(it.value().m_currentNodePath);
|
||||||
qDebug() << "node" << node;
|
|
||||||
if (node) {
|
if (node) {
|
||||||
m_nodeExplorer->setCurrentNode(node.data());
|
m_nodeExplorer->setCurrentNode(node.data());
|
||||||
}
|
}
|
||||||
|
@ -870,6 +870,13 @@ void NotebookNodeExplorer::createContextMenuOnNode(QMenu *p_menu, const Node *p_
|
|||||||
act = createAction(Action::Sort, p_menu);
|
act = createAction(Action::Sort, p_menu);
|
||||||
p_menu->addAction(act);
|
p_menu->addAction(act);
|
||||||
|
|
||||||
|
{
|
||||||
|
p_menu->addSeparator();
|
||||||
|
|
||||||
|
act = createAction(Action::PinToQuickAccess, p_menu);
|
||||||
|
p_menu->addAction(act);
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedSize == 1) {
|
if (selectedSize == 1) {
|
||||||
p_menu->addSeparator();
|
p_menu->addSeparator();
|
||||||
|
|
||||||
@ -898,6 +905,13 @@ void NotebookNodeExplorer::createContextMenuOnExternalNode(QMenu *p_menu, const
|
|||||||
act = createAction(Action::ImportToConfig, p_menu);
|
act = createAction(Action::ImportToConfig, p_menu);
|
||||||
p_menu->addAction(act);
|
p_menu->addAction(act);
|
||||||
|
|
||||||
|
{
|
||||||
|
p_menu->addSeparator();
|
||||||
|
|
||||||
|
act = createAction(Action::PinToQuickAccess, p_menu);
|
||||||
|
p_menu->addAction(act);
|
||||||
|
}
|
||||||
|
|
||||||
if (selectedSize == 1) {
|
if (selectedSize == 1) {
|
||||||
p_menu->addSeparator();
|
p_menu->addSeparator();
|
||||||
|
|
||||||
@ -1154,6 +1168,27 @@ QAction *NotebookNodeExplorer::createAction(Action p_act, QObject *p_parent)
|
|||||||
act = new QAction(tr("&Expand All\t*"), p_parent);
|
act = new QAction(tr("&Expand All\t*"), p_parent);
|
||||||
connect(act, &QAction::triggered,
|
connect(act, &QAction::triggered,
|
||||||
this, &NotebookNodeExplorer::expandCurrentNodeAll);
|
this, &NotebookNodeExplorer::expandCurrentNodeAll);
|
||||||
|
|
||||||
|
case Action::PinToQuickAccess:
|
||||||
|
act = new QAction(tr("Pin To &Quick Access"), p_parent);
|
||||||
|
connect(act, &QAction::triggered,
|
||||||
|
this, [this]() {
|
||||||
|
auto nodes = getSelectedNodes();
|
||||||
|
QStringList files;
|
||||||
|
for (const auto &node : nodes.first) {
|
||||||
|
if (node->hasContent()) {
|
||||||
|
files.push_back(node->fetchAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &node : nodes.second) {
|
||||||
|
if (!node->isFolder()) {
|
||||||
|
files.push_back(node->fetchAbsolutePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
emit VNoteX::getInst().pinToQuickAccessRequested(files);
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,8 @@ namespace vnotex
|
|||||||
ReloadIndex,
|
ReloadIndex,
|
||||||
ImportToConfig,
|
ImportToConfig,
|
||||||
Open,
|
Open,
|
||||||
ExpandAll
|
ExpandAll,
|
||||||
|
PinToQuickAccess
|
||||||
};
|
};
|
||||||
|
|
||||||
void setupUI();
|
void setupUI();
|
||||||
|
@ -16,12 +16,15 @@
|
|||||||
#include <utils/iconutils.h>
|
#include <utils/iconutils.h>
|
||||||
#include <utils/widgetutils.h>
|
#include <utils/widgetutils.h>
|
||||||
#include <utils/docsutils.h>
|
#include <utils/docsutils.h>
|
||||||
|
#include <utils/pathutils.h>
|
||||||
#include "fullscreentoggleaction.h"
|
#include "fullscreentoggleaction.h"
|
||||||
#include <core/configmgr.h>
|
#include <core/configmgr.h>
|
||||||
#include <core/coreconfig.h>
|
#include <core/coreconfig.h>
|
||||||
|
#include <core/sessionconfig.h>
|
||||||
#include <core/fileopenparameters.h>
|
#include <core/fileopenparameters.h>
|
||||||
#include "propertydefs.h"
|
#include "propertydefs.h"
|
||||||
#include "dialogs/settings/settingsdialog.h"
|
#include "dialogs/settings/settingsdialog.h"
|
||||||
|
#include "messageboxhelper.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -52,38 +55,38 @@ QToolBar *ToolBarHelper::setupFileToolBar(MainWindow *p_win, QToolBar *p_toolBar
|
|||||||
toolBtn->setPopupMode(QToolButton::InstantPopup);
|
toolBtn->setPopupMode(QToolButton::InstantPopup);
|
||||||
toolBtn->setProperty(PropertyDefs::c_toolButtonWithoutMenuIndicator, true);
|
toolBtn->setProperty(PropertyDefs::c_toolButtonWithoutMenuIndicator, true);
|
||||||
|
|
||||||
auto newMenu = WidgetsFactory::createMenu(tb);
|
auto btnMenu = WidgetsFactory::createMenu(tb);
|
||||||
toolBtn->setMenu(newMenu);
|
toolBtn->setMenu(btnMenu);
|
||||||
|
|
||||||
newMenu->addAction(generateIcon("new_notebook.svg"),
|
btnMenu->addAction(generateIcon("new_notebook.svg"),
|
||||||
MainWindow::tr("New Notebook"),
|
MainWindow::tr("New Notebook"),
|
||||||
newMenu,
|
btnMenu,
|
||||||
[]() {
|
[]() {
|
||||||
emit VNoteX::getInst().newNotebookRequested();
|
emit VNoteX::getInst().newNotebookRequested();
|
||||||
});
|
});
|
||||||
|
|
||||||
// New notebook from folder.
|
// New notebook from folder.
|
||||||
newMenu->addAction(generateIcon("new_notebook_from_folder.svg"),
|
btnMenu->addAction(generateIcon("new_notebook_from_folder.svg"),
|
||||||
MainWindow::tr("New Notebook From Folder"),
|
MainWindow::tr("New Notebook From Folder"),
|
||||||
newMenu,
|
btnMenu,
|
||||||
[]() {
|
[]() {
|
||||||
emit VNoteX::getInst().newNotebookFromFolderRequested();
|
emit VNoteX::getInst().newNotebookFromFolderRequested();
|
||||||
});
|
});
|
||||||
|
|
||||||
newMenu->addSeparator();
|
btnMenu->addSeparator();
|
||||||
|
|
||||||
// Import notebook.
|
// Import notebook.
|
||||||
newMenu->addAction(generateIcon("import_notebook.svg"),
|
btnMenu->addAction(generateIcon("import_notebook.svg"),
|
||||||
MainWindow::tr("Import Notebook"),
|
MainWindow::tr("Import Notebook"),
|
||||||
newMenu,
|
btnMenu,
|
||||||
[]() {
|
[]() {
|
||||||
emit VNoteX::getInst().importNotebookRequested();
|
emit VNoteX::getInst().importNotebookRequested();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Import notebook of VNote 2.0.
|
// Import notebook of VNote 2.0.
|
||||||
newMenu->addAction(generateIcon("import_notebook_of_vnote2.svg"),
|
btnMenu->addAction(generateIcon("import_notebook_of_vnote2.svg"),
|
||||||
MainWindow::tr("Import Legacy Notebook Of VNote 2.0"),
|
MainWindow::tr("Import Legacy Notebook Of VNote 2.0"),
|
||||||
newMenu,
|
btnMenu,
|
||||||
[]() {
|
[]() {
|
||||||
emit VNoteX::getInst().importLegacyNotebookRequested();
|
emit VNoteX::getInst().importLegacyNotebookRequested();
|
||||||
});
|
});
|
||||||
@ -190,6 +193,90 @@ QToolBar *ToolBarHelper::setupQuickAccessToolBar(MainWindow *p_win, QToolBar *p_
|
|||||||
tb = createToolBar(p_win, MainWindow::tr("Quick Access"), "QuickAccessToolBar");
|
tb = createToolBar(p_win, MainWindow::tr("Quick Access"), "QuickAccessToolBar");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto &coreConfig = ConfigMgr::getInst().getCoreConfig();
|
||||||
|
|
||||||
|
// Flash Page.
|
||||||
|
{
|
||||||
|
auto flashPageAct = tb->addAction(generateIcon("flash_page_menu.svg"),
|
||||||
|
MainWindow::tr("Flash Page"),
|
||||||
|
tb,
|
||||||
|
[p_win]() {
|
||||||
|
const auto &flashPage = ConfigMgr::getInst().getSessionConfig().getFlashPage();
|
||||||
|
if (flashPage.isEmpty()) {
|
||||||
|
MessageBoxHelper::notify(
|
||||||
|
MessageBoxHelper::Type::Information,
|
||||||
|
MainWindow::tr("Please set the Flash Page location in the Settings dialog first."),
|
||||||
|
MainWindow::tr("Flash Page is a temporary page for a flash of inspiration."),
|
||||||
|
QString(),
|
||||||
|
p_win);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto paras = QSharedPointer<FileOpenParameters>::create();
|
||||||
|
paras->m_mode = ViewWindowMode::Edit;
|
||||||
|
emit VNoteX::getInst().openFileRequested(flashPage, paras);
|
||||||
|
});
|
||||||
|
WidgetUtils::addActionShortcut(flashPageAct,
|
||||||
|
coreConfig.getShortcut(CoreConfig::Shortcut::FlashPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quick Access.
|
||||||
|
{
|
||||||
|
auto toolBtn = WidgetsFactory::createToolButton(tb);
|
||||||
|
toolBtn->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
|
|
||||||
|
auto btnMenu = WidgetsFactory::createMenu(tb);
|
||||||
|
toolBtn->setMenu(btnMenu);
|
||||||
|
|
||||||
|
// Quick Acces.
|
||||||
|
auto quickAccessAct = new QAction(generateIcon("quick_access_menu.svg"), MainWindow::tr("Quick Access"), toolBtn);
|
||||||
|
MainWindow::connect(quickAccessAct, &QAction::triggered,
|
||||||
|
p_win, [p_win]() {
|
||||||
|
const auto &quickAccess = ConfigMgr::getInst().getSessionConfig().getQuickAccessFiles();
|
||||||
|
if (quickAccess.isEmpty()) {
|
||||||
|
MessageBoxHelper::notify(
|
||||||
|
MessageBoxHelper::Type::Information,
|
||||||
|
MainWindow::tr("Please pin files to Quick Access first."),
|
||||||
|
MainWindow::tr("Files could be pinned to Quick Access via context menu."),
|
||||||
|
MainWindow::tr("Quick Access could be managed in the Settings dialog."),
|
||||||
|
p_win);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit VNoteX::getInst().openFileRequested(quickAccess.first(),
|
||||||
|
QSharedPointer<FileOpenParameters>::create());
|
||||||
|
});
|
||||||
|
WidgetUtils::addActionShortcut(quickAccessAct,
|
||||||
|
coreConfig.getShortcut(CoreConfig::Shortcut::QuickAccess));
|
||||||
|
|
||||||
|
toolBtn->setDefaultAction(quickAccessAct);
|
||||||
|
// To hide the shortcut text shown in button.
|
||||||
|
toolBtn->setText(MainWindow::tr("Quick Access"));
|
||||||
|
|
||||||
|
MainWindow::connect(btnMenu, &QMenu::aboutToShow,
|
||||||
|
btnMenu, [btnMenu]() {
|
||||||
|
btnMenu->clear();
|
||||||
|
const auto &quickAccess = ConfigMgr::getInst().getSessionConfig().getQuickAccessFiles();
|
||||||
|
if (quickAccess.isEmpty()) {
|
||||||
|
auto act = btnMenu->addAction(MainWindow::tr("Quick Access Not Set"));
|
||||||
|
act->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto &file : quickAccess) {
|
||||||
|
auto act = btnMenu->addAction(PathUtils::fileName(file));
|
||||||
|
act->setData(file);
|
||||||
|
act->setToolTip(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
MainWindow::connect(btnMenu, &QMenu::triggered,
|
||||||
|
btnMenu, [](QAction *p_act) {
|
||||||
|
emit VNoteX::getInst().openFileRequested(p_act->data().toString(),
|
||||||
|
QSharedPointer<FileOpenParameters>::create());
|
||||||
|
});
|
||||||
|
tb->addWidget(toolBtn);
|
||||||
|
}
|
||||||
|
|
||||||
return tb;
|
return tb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,17 +417,20 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
|
|||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
menu->addAction(MainWindow::tr("Quit"),
|
|
||||||
menu,
|
|
||||||
[p_win]() {
|
|
||||||
p_win->quitApp();
|
|
||||||
});
|
|
||||||
|
|
||||||
menu->addAction(MainWindow::tr("Restart"),
|
menu->addAction(MainWindow::tr("Restart"),
|
||||||
menu,
|
menu,
|
||||||
[p_win]() {
|
[p_win]() {
|
||||||
p_win->restart();
|
p_win->restart();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto quitAct = menu->addAction(MainWindow::tr("Quit"),
|
||||||
|
menu,
|
||||||
|
[p_win]() {
|
||||||
|
p_win->quitApp();
|
||||||
|
});
|
||||||
|
quitAct->setMenuRole(QAction::QuitRole);
|
||||||
|
WidgetUtils::addActionShortcut(quitAct,
|
||||||
|
coreConfig.getShortcut(CoreConfig::Shortcut::Quit));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Help.
|
// Help.
|
||||||
@ -465,12 +555,12 @@ void ToolBarHelper::setupToolBars(MainWindow *p_win)
|
|||||||
{
|
{
|
||||||
m_toolBars.clear();
|
m_toolBars.clear();
|
||||||
|
|
||||||
auto quickAccessTb = setupQuickAccessToolBar(p_win, nullptr);
|
|
||||||
m_toolBars.insert(quickAccessTb->objectName(), quickAccessTb);
|
|
||||||
|
|
||||||
auto fileTab = setupFileToolBar(p_win, nullptr);
|
auto fileTab = setupFileToolBar(p_win, nullptr);
|
||||||
m_toolBars.insert(fileTab->objectName(), fileTab);
|
m_toolBars.insert(fileTab->objectName(), fileTab);
|
||||||
|
|
||||||
|
auto quickAccessTb = setupQuickAccessToolBar(p_win, nullptr);
|
||||||
|
m_toolBars.insert(quickAccessTb->objectName(), quickAccessTb);
|
||||||
|
|
||||||
auto settingsToolBar = setupSettingsToolBar(p_win, nullptr);
|
auto settingsToolBar = setupSettingsToolBar(p_win, nullptr);
|
||||||
m_toolBars.insert(settingsToolBar->objectName(), settingsToolBar);
|
m_toolBars.insert(settingsToolBar->objectName(), settingsToolBar);
|
||||||
}
|
}
|
||||||
@ -483,8 +573,8 @@ void ToolBarHelper::setupToolBars(MainWindow *p_win, QToolBar *p_toolBar)
|
|||||||
p_toolBar->setMovable(false);
|
p_toolBar->setMovable(false);
|
||||||
p_win->addToolBar(p_toolBar);
|
p_win->addToolBar(p_toolBar);
|
||||||
|
|
||||||
setupQuickAccessToolBar(p_win, p_toolBar);
|
|
||||||
setupFileToolBar(p_win, p_toolBar);
|
setupFileToolBar(p_win, p_toolBar);
|
||||||
|
setupQuickAccessToolBar(p_win, p_toolBar);
|
||||||
setupSettingsToolBar(p_win, p_toolBar);
|
setupSettingsToolBar(p_win, p_toolBar);
|
||||||
m_toolBars.insert(p_toolBar->objectName(), p_toolBar);
|
m_toolBars.insert(p_toolBar->objectName(), p_toolBar);
|
||||||
}
|
}
|
||||||
|
@ -65,10 +65,8 @@ ViewArea::ViewArea(QWidget *p_parent)
|
|||||||
close(true);
|
close(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ConfigMgr::getInst().getCoreConfig().isRecoverLastSessionOnStartEnabled()) {
|
|
||||||
connect(mainWindow, &MainWindow::mainWindowStarted,
|
connect(mainWindow, &MainWindow::mainWindowStarted,
|
||||||
this, &ViewArea::loadSession);
|
this, &ViewArea::loadSession);
|
||||||
}
|
|
||||||
|
|
||||||
connect(&VNoteX::getInst(), &VNoteX::nodeAboutToMove,
|
connect(&VNoteX::getInst(), &VNoteX::nodeAboutToMove,
|
||||||
this, &ViewArea::handleNodeChange);
|
this, &ViewArea::handleNodeChange);
|
||||||
@ -1024,8 +1022,14 @@ QList<Buffer *> ViewArea::getAllBuffersInViewSplits() const
|
|||||||
void ViewArea::loadSession()
|
void ViewArea::loadSession()
|
||||||
{
|
{
|
||||||
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
auto &sessionConfig = ConfigMgr::getInst().getSessionConfig();
|
||||||
|
// Clear it if recover is disabled.
|
||||||
auto sessionData = sessionConfig.getViewAreaSessionAndClear();
|
auto sessionData = sessionConfig.getViewAreaSessionAndClear();
|
||||||
|
|
||||||
|
if (!ConfigMgr::getInst().getCoreConfig().isRecoverLastSessionOnStartEnabled()) {
|
||||||
|
showSceneWidget();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto session = ViewAreaSession::deserialize(sessionData);
|
auto session = ViewAreaSession::deserialize(sessionData);
|
||||||
|
|
||||||
// Load widgets layout.
|
// Load widgets layout.
|
||||||
|
@ -19,6 +19,7 @@ SOURCES += \
|
|||||||
$$PWD/dialogs/settings/editorpage.cpp \
|
$$PWD/dialogs/settings/editorpage.cpp \
|
||||||
$$PWD/dialogs/settings/generalpage.cpp \
|
$$PWD/dialogs/settings/generalpage.cpp \
|
||||||
$$PWD/dialogs/settings/markdowneditorpage.cpp \
|
$$PWD/dialogs/settings/markdowneditorpage.cpp \
|
||||||
|
$$PWD/dialogs/settings/quickaccesspage.cpp \
|
||||||
$$PWD/dialogs/settings/settingspage.cpp \
|
$$PWD/dialogs/settings/settingspage.cpp \
|
||||||
$$PWD/dialogs/settings/settingsdialog.cpp \
|
$$PWD/dialogs/settings/settingsdialog.cpp \
|
||||||
$$PWD/dialogs/settings/texteditorpage.cpp \
|
$$PWD/dialogs/settings/texteditorpage.cpp \
|
||||||
@ -43,6 +44,7 @@ SOURCES += \
|
|||||||
$$PWD/lineedit.cpp \
|
$$PWD/lineedit.cpp \
|
||||||
$$PWD/lineeditdelegate.cpp \
|
$$PWD/lineeditdelegate.cpp \
|
||||||
$$PWD/listwidget.cpp \
|
$$PWD/listwidget.cpp \
|
||||||
|
$$PWD/locationinputwithbrowsebutton.cpp \
|
||||||
$$PWD/locationlist.cpp \
|
$$PWD/locationlist.cpp \
|
||||||
$$PWD/mainwindow.cpp \
|
$$PWD/mainwindow.cpp \
|
||||||
$$PWD/markdownviewwindow.cpp \
|
$$PWD/markdownviewwindow.cpp \
|
||||||
@ -112,6 +114,7 @@ HEADERS += \
|
|||||||
$$PWD/dialogs/settings/editorpage.h \
|
$$PWD/dialogs/settings/editorpage.h \
|
||||||
$$PWD/dialogs/settings/generalpage.h \
|
$$PWD/dialogs/settings/generalpage.h \
|
||||||
$$PWD/dialogs/settings/markdowneditorpage.h \
|
$$PWD/dialogs/settings/markdowneditorpage.h \
|
||||||
|
$$PWD/dialogs/settings/quickaccesspage.h \
|
||||||
$$PWD/dialogs/settings/settingspage.h \
|
$$PWD/dialogs/settings/settingspage.h \
|
||||||
$$PWD/dialogs/settings/settingsdialog.h \
|
$$PWD/dialogs/settings/settingsdialog.h \
|
||||||
$$PWD/dialogs/settings/texteditorpage.h \
|
$$PWD/dialogs/settings/texteditorpage.h \
|
||||||
@ -136,6 +139,7 @@ HEADERS += \
|
|||||||
$$PWD/lineedit.h \
|
$$PWD/lineedit.h \
|
||||||
$$PWD/lineeditdelegate.h \
|
$$PWD/lineeditdelegate.h \
|
||||||
$$PWD/listwidget.h \
|
$$PWD/listwidget.h \
|
||||||
|
$$PWD/locationinputwithbrowsebutton.h \
|
||||||
$$PWD/locationlist.h \
|
$$PWD/locationlist.h \
|
||||||
$$PWD/mainwindow.h \
|
$$PWD/mainwindow.h \
|
||||||
$$PWD/markdownviewwindow.h \
|
$$PWD/markdownviewwindow.h \
|
||||||
|
@ -95,3 +95,9 @@ QPlainTextEdit *WidgetsFactory::createPlainTextConsole(QWidget *p_parent)
|
|||||||
edit->setLineWrapMode(QPlainTextEdit::WidgetWidth);
|
edit->setLineWrapMode(QPlainTextEdit::WidgetWidth);
|
||||||
return edit;
|
return edit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPlainTextEdit *WidgetsFactory::createPlainTextEdit(QWidget *p_parent)
|
||||||
|
{
|
||||||
|
auto edit = new QPlainTextEdit(p_parent);
|
||||||
|
return edit;
|
||||||
|
}
|
||||||
|
@ -44,6 +44,8 @@ namespace vnotex
|
|||||||
static QFormLayout *createFormLayout(QWidget *p_parent = nullptr);
|
static QFormLayout *createFormLayout(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
static QPlainTextEdit *createPlainTextConsole(QWidget *p_parent = nullptr);
|
static QPlainTextEdit *createPlainTextConsole(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
static QPlainTextEdit *createPlainTextEdit(QWidget *p_parent = nullptr);
|
||||||
};
|
};
|
||||||
} // ns vnotex
|
} // ns vnotex
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user