mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
parent
4ab2033a81
commit
cbd3956cdc
@ -6,6 +6,7 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QBitArray>
|
#include <QBitArray>
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
#include <QIODevice>
|
||||||
|
|
||||||
namespace vnotex
|
namespace vnotex
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <core/exception.h>
|
#include <core/exception.h>
|
||||||
#include "notebook.h"
|
#include "notebook.h"
|
||||||
#include "nodeparameters.h"
|
#include "nodeparameters.h"
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -483,7 +484,7 @@ QList<QSharedPointer<File>> Node::collectFiles()
|
|||||||
|
|
||||||
ID Node::generateSignature()
|
ID Node::generateSignature()
|
||||||
{
|
{
|
||||||
return static_cast<ID>(QDateTime::currentDateTime().toSecsSinceEpoch() + (static_cast<qulonglong>(qrand()) << 32));
|
return static_cast<ID>(QDateTime::currentDateTime().toSecsSinceEpoch() + (static_cast<qulonglong>(QRandomGenerator::global()->generate()) << 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::checkSignature()
|
void Node::checkSignature()
|
||||||
|
@ -560,7 +560,12 @@ bool NotebookDatabaseAccess::updateNodeTags(Node *p_node)
|
|||||||
const auto &nodeTags = p_node->getTags();
|
const auto &nodeTags = p_node->getTags();
|
||||||
|
|
||||||
{
|
{
|
||||||
const auto tags = QSet<QString>::fromList(queryNodeTags(p_node->getId()));
|
QStringList list = queryNodeTags(p_node->getId());
|
||||||
|
QSet<QString> tags;
|
||||||
|
for (auto &s : list)
|
||||||
|
{
|
||||||
|
tags.insert(s);
|
||||||
|
}
|
||||||
if (tags.isEmpty() && nodeTags.isEmpty()) {
|
if (tags.isEmpty() && nodeTags.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -691,7 +696,7 @@ QList<ID> NotebookDatabaseAccess::queryTagNodesRecursive(const QString &p_tag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return allIds.toList();
|
return allIds.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList NotebookDatabaseAccess::queryTagAndChildren(const QString &p_tag)
|
QStringList NotebookDatabaseAccess::queryTagAndChildren(const QString &p_tag)
|
||||||
@ -742,7 +747,7 @@ QStringList NotebookDatabaseAccess::getNodesOfTags(const QStringList &p_tags)
|
|||||||
allIds.insert(id);
|
allIds.insert(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodeIds = allIds.toList();
|
nodeIds = allIds.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &id : nodeIds) {
|
for (const auto &id : nodeIds) {
|
||||||
|
@ -465,7 +465,7 @@ QSharedPointer<Node> VXNotebookConfigMgr::loadNodeByPath(const QSharedPointer<No
|
|||||||
return p_root;
|
return p_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto paths = p.split('/', QString::SkipEmptyParts);
|
auto paths = p.split('/', Qt::SkipEmptyParts);
|
||||||
auto node = p_root;
|
auto node = p_root;
|
||||||
for (auto &pa : paths) {
|
for (auto &pa : paths) {
|
||||||
// Find child @pa in @node.
|
// Find child @pa in @node.
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <utils/processutils.h>
|
#include <utils/processutils.h>
|
||||||
#include <utils/htmlutils.h>
|
#include <utils/htmlutils.h>
|
||||||
#include <core/file.h>
|
#include <core/file.h>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -362,7 +363,7 @@ bool WebViewExporter::embedStyleResources(QString &p_html) const
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = p_html.indexOf(reg, pos);
|
int idx = reg.indexIn(p_html, pos);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -393,7 +394,7 @@ bool WebViewExporter::embedBodyResources(const QUrl &p_baseUrl, QString &p_html)
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = p_html.indexOf(reg, pos);
|
int idx = reg.indexIn(p_html, pos);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -440,7 +441,7 @@ bool WebViewExporter::fixBodyResources(const QUrl &p_baseUrl,
|
|||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = p_html.indexOf(reg, pos);
|
int idx = reg.indexIn(p_html, pos);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ using namespace vnotex;
|
|||||||
|
|
||||||
void loadTranslators(QApplication &p_app);
|
void loadTranslators(QApplication &p_app);
|
||||||
|
|
||||||
void initWebEngineSettings();
|
|
||||||
|
|
||||||
void showMessageOnCommandLineIfAvailable(const QString &p_msg);
|
void showMessageOnCommandLineIfAvailable(const QString &p_msg);
|
||||||
|
|
||||||
@ -79,7 +78,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Application app(argc, argv);
|
Application app(argc, argv);
|
||||||
|
|
||||||
initWebEngineSettings();
|
|
||||||
|
|
||||||
QAccessible::installFactory(&FakeAccessible::accessibleFactory);
|
QAccessible::installFactory(&FakeAccessible::accessibleFactory);
|
||||||
|
|
||||||
@ -253,12 +251,6 @@ void loadTranslators(QApplication &p_app)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initWebEngineSettings()
|
|
||||||
{
|
|
||||||
auto settings = QWebEngineSettings::defaultSettings();
|
|
||||||
settings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showMessageOnCommandLineIfAvailable(const QString &p_msg)
|
void showMessageOnCommandLineIfAvailable(const QString &p_msg)
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -2,7 +2,7 @@ lessThan(QT_MAJOR_VERSION, 5): error("requires Qt 5 and above")
|
|||||||
|
|
||||||
equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 and above")
|
equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12): error("requires Qt 5.12 and above")
|
||||||
|
|
||||||
QT += core gui widgets webenginewidgets webchannel network svg printsupport
|
QT += core gui widgets webenginewidgets webchannel network svg printsupport core5compat
|
||||||
QT += sql
|
QT += sql
|
||||||
|
|
||||||
CONFIG -= qtquickcompiler
|
CONFIG -= qtquickcompiler
|
||||||
|
@ -41,19 +41,19 @@ void IUnitedEntry::process(const QString &p_args,
|
|||||||
initOnFirstProcess();
|
initOnFirstProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_askedToStop.store(0);
|
m_askedToStop.storeRelaxed(0);
|
||||||
|
|
||||||
return processInternal(p_args, p_popupWidgetFunc);
|
return processInternal(p_args, p_popupWidgetFunc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IUnitedEntry::stop()
|
void IUnitedEntry::stop()
|
||||||
{
|
{
|
||||||
m_askedToStop.store(1);
|
m_askedToStop.storeRelaxed(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IUnitedEntry::isAskedToStop() const
|
bool IUnitedEntry::isAskedToStop() const
|
||||||
{
|
{
|
||||||
return m_askedToStop.load() == 1;
|
return m_askedToStop.loadAcquire() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IUnitedEntry::setOngoing(bool p_ongoing)
|
void IUnitedEntry::setOngoing(bool p_ongoing)
|
||||||
|
@ -9,12 +9,12 @@ AsyncWorker::AsyncWorker(QObject *p_parent)
|
|||||||
|
|
||||||
void AsyncWorker::stop()
|
void AsyncWorker::stop()
|
||||||
{
|
{
|
||||||
m_askedToStop.store(1);
|
m_askedToStop.fetchAndStoreAcquire(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsyncWorker::isAskedToStop() const
|
bool AsyncWorker::isAskedToStop() const
|
||||||
{
|
{
|
||||||
return m_askedToStop.load() == 1;
|
return m_askedToStop.loadAcquire() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <core/global.h>
|
#include <core/global.h>
|
||||||
|
|
||||||
#include "pathutils.h"
|
#include "pathutils.h"
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -313,7 +314,7 @@ QString FileUtils::generateRandomFileName(const QString &p_hints, const QString
|
|||||||
|
|
||||||
// Do not use toSecsSinceEpoch() here since we want a short name.
|
// Do not use toSecsSinceEpoch() here since we want a short name.
|
||||||
const QString timeStamp(QDateTime::currentDateTime().toString(QStringLiteral("sszzzmmHHyyMMdd")));
|
const QString timeStamp(QDateTime::currentDateTime().toString(QStringLiteral("sszzzmmHHyyMMdd")));
|
||||||
const QString baseName(QString::number(timeStamp.toLongLong() + qrand()));
|
const QString baseName(QString::number(timeStamp.toLongLong() + QRandomGenerator::global()->generate()));
|
||||||
|
|
||||||
QString suffix;
|
QString suffix;
|
||||||
if (!p_suffix.isEmpty()) {
|
if (!p_suffix.isEmpty()) {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "htmlutils.h"
|
#include "htmlutils.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
bool HtmlUtils::hasOnlyImgTag(const QString &p_html)
|
bool HtmlUtils::hasOnlyImgTag(const QString &p_html)
|
||||||
{
|
{
|
||||||
// Tricky.
|
// Tricky.
|
||||||
QRegExp reg(QStringLiteral("<(?:p|span|div) "));
|
QRegularExpression reg(QStringLiteral("<(?:p|span|div) "));
|
||||||
return !p_html.contains(reg);
|
return !p_html.contains(reg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ QString IconUtils::replaceForegroundOfIcon(const QString &p_iconContent, const Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Negative lookahead to avoid fill="none".
|
// Negative lookahead to avoid fill="none".
|
||||||
QRegExp styleRe(R"((\s|"|;)(fill|stroke)(:|(="))(?!none)[^;"]*)");
|
QRegularExpression styleRe(R"((\s|"|;)(fill|stroke)(:|(="))(?!none)[^;"]*)");
|
||||||
if (p_iconContent.indexOf(styleRe) > -1) {
|
if (p_iconContent.indexOf(styleRe) > -1) {
|
||||||
auto newContent(p_iconContent);
|
auto newContent(p_iconContent);
|
||||||
newContent.replace(styleRe, QString("\\1\\2\\3%1").arg(p_foreground));
|
newContent.replace(styleRe, QString("\\1\\2\\3%1").arg(p_foreground));
|
||||||
@ -85,7 +85,7 @@ bool IconUtils::isMonochrome(const QString &p_iconContent)
|
|||||||
QString lastColor = "";
|
QString lastColor = "";
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_iconContent.size()) {
|
while (pos < p_iconContent.size()) {
|
||||||
int idx = p_iconContent.indexOf(monoRe, pos);
|
int idx = monoRe.indexIn(p_iconContent, pos);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ QSharedPointer<QPrinter> PrintUtils::promptForPrint(bool p_printSelectionEnabled
|
|||||||
|
|
||||||
QPrintDialog dialog(printer.data(), p_parent);
|
QPrintDialog dialog(printer.data(), p_parent);
|
||||||
if (p_printSelectionEnabled) {
|
if (p_printSelectionEnabled) {
|
||||||
dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
dialog.setOption(QAbstractPrintDialog::PrintSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Accepted) {
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
@ -42,7 +42,7 @@ void Utils::appendMsg(QString &p_msg, const QString &p_new)
|
|||||||
|
|
||||||
QString Utils::dateTimeString(const QDateTime &p_dateTime)
|
QString Utils::dateTimeString(const QDateTime &p_dateTime)
|
||||||
{
|
{
|
||||||
return p_dateTime.date().toString(Qt::DefaultLocaleLongDate)
|
return p_dateTime.date().toString(Qt::ISODate)
|
||||||
+ " "
|
+ " "
|
||||||
+ p_dateTime.time().toString(Qt::TextDate);
|
+ p_dateTime.time().toString(Qt::TextDate);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
QT += widgets svg
|
QT += widgets svg core5compat
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
$$PWD/asyncworker.cpp \
|
$$PWD/asyncworker.cpp \
|
||||||
|
@ -58,7 +58,8 @@ QString WebUtils::toDataUri(const QUrl &p_url, bool p_keepTitle)
|
|||||||
|
|
||||||
if (!p_keepTitle) {
|
if (!p_keepTitle) {
|
||||||
// Remove <title>...</title>.
|
// Remove <title>...</title>.
|
||||||
QRegExp reg("<title>.*</title>", Qt::CaseInsensitive);
|
QRegularExpression reg("<title>.*</title>");
|
||||||
|
reg.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||||
uri.remove(reg);
|
uri.remove(reg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QAbstractScrollArea>
|
#include <QAbstractScrollArea>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@ -71,8 +70,7 @@ bool WidgetUtils::isScrollBarVisible(QAbstractScrollArea *p_widget, bool p_horiz
|
|||||||
|
|
||||||
QSize WidgetUtils::availableScreenSize(QWidget *p_widget)
|
QSize WidgetUtils::availableScreenSize(QWidget *p_widget)
|
||||||
{
|
{
|
||||||
auto geo = QApplication::desktop()->availableGeometry(p_widget);
|
return p_widget->screen()->availableGeometry().size();
|
||||||
return geo.size();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WidgetUtils::openUrlByDesktop(const QUrl &p_url)
|
void WidgetUtils::openUrlByDesktop(const QUrl &p_url)
|
||||||
@ -374,7 +372,7 @@ QString WidgetUtils::getMonospaceFont()
|
|||||||
for (const auto &candidate : candidates) {
|
for (const auto &candidate : candidates) {
|
||||||
QString family = candidate.trimmed().toLower();
|
QString family = candidate.trimmed().toLower();
|
||||||
for (auto availFamily : availFamilies) {
|
for (auto availFamily : availFamilies) {
|
||||||
availFamily.remove(QRegExp("\\[.*\\]"));
|
availFamily.remove(QRegularExpression("\\[.*\\]"));
|
||||||
if (family == availFamily.trimmed().toLower()) {
|
if (family == availFamily.trimmed().toLower()) {
|
||||||
font = availFamily;
|
font = availFamily;
|
||||||
return font;
|
return font;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRegExpValidator>
|
#include <QRegularExpressionValidator>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
@ -88,7 +88,7 @@ void ImageInsertDialog::setupUI(const QString &p_title,
|
|||||||
|
|
||||||
// Image Title.
|
// Image Title.
|
||||||
m_imageTitleEdit = WidgetsFactory::createLineEdit(p_imageTitle, mainWidget);
|
m_imageTitleEdit = WidgetsFactory::createLineEdit(p_imageTitle, mainWidget);
|
||||||
auto titleValidator = new QRegExpValidator(QRegExp(vte::MarkdownUtils::c_imageTitleRegExp), m_imageTitleEdit);
|
auto titleValidator = new QRegularExpressionValidator(QRegularExpression(vte::MarkdownUtils::c_imageTitleRegExp), m_imageTitleEdit);
|
||||||
m_imageTitleEdit->setValidator(titleValidator);
|
m_imageTitleEdit->setValidator(titleValidator);
|
||||||
gridLayout->addWidget(new QLabel(tr("Title:"), mainWidget), 1, 0, 1, 1);
|
gridLayout->addWidget(new QLabel(tr("Title:"), mainWidget), 1, 0, 1, 1);
|
||||||
gridLayout->addWidget(m_imageTitleEdit, 1, 1, 1, 3);
|
gridLayout->addWidget(m_imageTitleEdit, 1, 1, 1, 3);
|
||||||
@ -97,7 +97,7 @@ void ImageInsertDialog::setupUI(const QString &p_title,
|
|||||||
|
|
||||||
// Image Alt.
|
// Image Alt.
|
||||||
m_imageAltEdit = WidgetsFactory::createLineEdit(p_imageAlt, mainWidget);
|
m_imageAltEdit = WidgetsFactory::createLineEdit(p_imageAlt, mainWidget);
|
||||||
auto altValidator = new QRegExpValidator(QRegExp(vte::MarkdownUtils::c_imageAltRegExp), m_imageAltEdit);
|
auto altValidator = new QRegularExpressionValidator(QRegularExpression(vte::MarkdownUtils::c_imageAltRegExp), m_imageAltEdit);
|
||||||
m_imageAltEdit->setValidator(altValidator);
|
m_imageAltEdit->setValidator(altValidator);
|
||||||
gridLayout->addWidget(new QLabel(tr("Alt text:"), mainWidget), 2, 0, 1, 1);
|
gridLayout->addWidget(new QLabel(tr("Alt text:"), mainWidget), 2, 0, 1, 1);
|
||||||
gridLayout->addWidget(m_imageAltEdit, 2, 1, 1, 3);
|
gridLayout->addWidget(m_imageAltEdit, 2, 1, 1, 3);
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QDesktopWidget>
|
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
@ -73,7 +73,7 @@ void SelectDialog::addSelection(const QString &p_selectStr, int p_selectID)
|
|||||||
QChar shortcut;
|
QChar shortcut;
|
||||||
if (m_nextShortcut < c_cancelShortcut) {
|
if (m_nextShortcut < c_cancelShortcut) {
|
||||||
shortcut = m_nextShortcut;
|
shortcut = m_nextShortcut;
|
||||||
m_nextShortcut = m_nextShortcut.toLatin1() + 1;
|
m_nextShortcut = QChar(m_nextShortcut.toLatin1() + 1);
|
||||||
}
|
}
|
||||||
const auto icon = IconUtils::drawTextIcon(shortcut, m_shortcutIconForeground, m_shortcutIconBorder);
|
const auto icon = IconUtils::drawTextIcon(shortcut, m_shortcutIconForeground, m_shortcutIconBorder);
|
||||||
QListWidgetItem *item = new QListWidgetItem(icon, p_selectStr);
|
QListWidgetItem *item = new QListWidgetItem(icon, p_selectStr);
|
||||||
|
@ -64,7 +64,7 @@ bool FileAssociationPage::saveInternal()
|
|||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto suffixes = lineEdit->text().split(c_suffixSeparator, QString::SkipEmptyParts);
|
auto suffixes = lineEdit->text().split(c_suffixSeparator, Qt::SkipEmptyParts);
|
||||||
fileTypeSuffixes.push_back(CoreConfig::FileTypeSuffix(name, Utils::toLower(suffixes)));
|
fileTypeSuffixes.push_back(CoreConfig::FileTypeSuffix(name, Utils::toLower(suffixes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ void SortDialog::updateTreeWidget()
|
|||||||
item->setFlags(item->flags() & ~Qt::ItemIsDropEnabled);
|
item->setFlags(item->flags() & ~Qt::ItemIsDropEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_treeWidget->sortByColumn(-1);
|
m_treeWidget->sortByColumn(-1, Qt::AscendingOrder);
|
||||||
m_treeWidget->setSortingEnabled(true);
|
m_treeWidget->setSortingEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ void SortDialog::handleMoveOperation(MoveOperation p_op)
|
|||||||
Q_ASSERT(first <= last && (last - first + 1) == selectedItems.size());
|
Q_ASSERT(first <= last && (last - first + 1) == selectedItems.size());
|
||||||
QTreeWidgetItem *firstItem = nullptr;
|
QTreeWidgetItem *firstItem = nullptr;
|
||||||
|
|
||||||
m_treeWidget->sortByColumn(-1);
|
m_treeWidget->sortByColumn(-1, Qt::AscendingOrder);
|
||||||
|
|
||||||
switch (p_op) {
|
switch (p_op) {
|
||||||
case MoveOperation::Top:
|
case MoveOperation::Top:
|
||||||
|
@ -63,7 +63,9 @@ void TableInsertDialog::setupUI(const QString &p_title)
|
|||||||
buttonGroup->addButton(rightBtn, static_cast<int>(Alignment::Right));
|
buttonGroup->addButton(rightBtn, static_cast<int>(Alignment::Right));
|
||||||
|
|
||||||
noneBtn->setChecked(true);
|
noneBtn->setChecked(true);
|
||||||
connect(buttonGroup, static_cast<void(QButtonGroup::*)(int, bool)>(&QButtonGroup::buttonToggled),
|
connect(buttonGroup, (void(QButtonGroup::*)(int, bool))(&QButtonGroup::buttonToggled),
|
||||||
|
|
||||||
|
|
||||||
this, [this](int p_id, bool p_checked){
|
this, [this](int p_id, bool p_checked){
|
||||||
if (p_checked) {
|
if (p_checked) {
|
||||||
m_alignment = static_cast<Alignment>(p_id);
|
m_alignment = static_cast<Alignment>(p_id);
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include <imagehost/imagehostutils.h>
|
#include <imagehost/imagehostutils.h>
|
||||||
#include <imagehost/imagehost.h>
|
#include <imagehost/imagehost.h>
|
||||||
#include <imagehost/imagehostmgr.h>
|
#include <imagehost/imagehostmgr.h>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
#include "previewhelper.h"
|
#include "previewhelper.h"
|
||||||
#include "../outlineprovider.h"
|
#include "../outlineprovider.h"
|
||||||
@ -1198,7 +1199,7 @@ void MarkdownEditor::handleHtmlToMarkdownData(quint64 p_id, TimeStamp p_timeStam
|
|||||||
|
|
||||||
static QString purifyImageTitle(QString p_title)
|
static QString purifyImageTitle(QString p_title)
|
||||||
{
|
{
|
||||||
return p_title.remove(QRegExp("[\\r\\n\\[\\]]"));
|
return p_title.remove(QRegularExpression("[\\r\\n\\[\\]]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
||||||
|
@ -214,10 +214,10 @@ void MarkdownTable::initWidths(const QTextBlock &p_block, int p_borderPos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QFontMetricsF fmf(font);
|
QFontMetricsF fmf(font);
|
||||||
s_spaceWidth = fmf.width(' ');
|
s_spaceWidth = fmf.horizontalAdvance(' ');
|
||||||
s_minusWidth = fmf.width('-');
|
s_minusWidth = fmf.horizontalAdvance('-');
|
||||||
s_colonWidth = fmf.width(':');
|
s_colonWidth = fmf.horizontalAdvance(':');
|
||||||
s_defaultDelimiterWidth = fmf.width(c_defaultDelimiter);
|
s_defaultDelimiterWidth = fmf.horizontalAdvance(c_defaultDelimiter);
|
||||||
|
|
||||||
qDebug() << "smart table widths" << font.family() << s_spaceWidth << s_minusWidth << s_colonWidth << s_defaultDelimiterWidth;
|
qDebug() << "smart table widths" << font.family() << s_spaceWidth << s_minusWidth << s_colonWidth << s_defaultDelimiterWidth;
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ void MarkdownViewer::setPreviewHelper(PreviewHelper *p_previewHelper)
|
|||||||
|
|
||||||
void MarkdownViewer::contextMenuEvent(QContextMenuEvent *p_event)
|
void MarkdownViewer::contextMenuEvent(QContextMenuEvent *p_event)
|
||||||
{
|
{
|
||||||
QScopedPointer<QMenu> menu(page()->createStandardContextMenu());
|
QScopedPointer<QMenu> menu(this->createStandardContextMenu());
|
||||||
const QList<QAction *> actions = menu->actions();
|
const QList<QAction *> actions = menu->actions();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -338,7 +338,7 @@ void PreviewHelper::updateEditorInplacePreviewCodeBlock()
|
|||||||
m_previousInplacePreviewCodeBlockSize = previewItems.size();
|
m_previousInplacePreviewCodeBlockSize = previewItems.size();
|
||||||
|
|
||||||
if (!obsoleteBlocks.isEmpty()) {
|
if (!obsoleteBlocks.isEmpty()) {
|
||||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.toList());
|
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_codeBlockCache.setCapacityHint(m_codeBlocksData.size());
|
m_codeBlockCache.setCapacityHint(m_codeBlocksData.size());
|
||||||
@ -434,7 +434,7 @@ void PreviewHelper::updateEditorInplacePreviewMathBlock()
|
|||||||
m_previousInplacePreviewMathBlockSize = previewItems.size();
|
m_previousInplacePreviewMathBlockSize = previewItems.size();
|
||||||
|
|
||||||
if (!obsoleteBlocks.isEmpty()) {
|
if (!obsoleteBlocks.isEmpty()) {
|
||||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.toList());
|
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_mathBlockCache.setCapacityHint(m_mathBlocksData.size());
|
m_mathBlockCache.setCapacityHint(m_mathBlocksData.size());
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "fullscreentoggleaction.h"
|
#include "fullscreentoggleaction.h"
|
||||||
|
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void LabelWithButtonsWidget::paintEvent(QPaintEvent *p_event)
|
|||||||
Q_UNUSED(p_event);
|
Q_UNUSED(p_event);
|
||||||
|
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
opt.init(this);
|
opt.initFrom(this);
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
|
#include <QWebEngineSettings>
|
||||||
|
|
||||||
#include <core/fileopenparameters.h>
|
#include <core/fileopenparameters.h>
|
||||||
#include <core/editorconfig.h>
|
#include <core/editorconfig.h>
|
||||||
@ -394,6 +395,8 @@ void MarkdownViewWindow::setupTextEditor()
|
|||||||
|
|
||||||
connect(m_editor, &MarkdownEditor::applySnippetRequested,
|
connect(m_editor, &MarkdownEditor::applySnippetRequested,
|
||||||
this, QOverload<>::of(&MarkdownViewWindow::applySnippet));
|
this, QOverload<>::of(&MarkdownViewWindow::applySnippet));
|
||||||
|
connect(m_viewer, &MarkdownViewer::printFinished, this, &MarkdownViewWindow::onPrintFinish);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
|
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
|
||||||
@ -502,6 +505,7 @@ void MarkdownViewWindow::setupViewer()
|
|||||||
setEditViewMode(m_editViewMode);
|
setEditViewMode(m_editViewMode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
m_viewer->settings()->resetAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
||||||
@ -1398,15 +1402,31 @@ void MarkdownViewWindow::print()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
m_printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
||||||
if (printer) {
|
|
||||||
m_viewer->page()->print(printer.data(), [printer](bool p_succeeded) mutable {
|
if (m_printer)
|
||||||
Q_UNUSED(p_succeeded);
|
{
|
||||||
printer.reset();
|
m_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||||
});
|
m_viewer->print(m_printer.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MarkdownViewWindow::onPrintFinish(bool isSeccess)
|
||||||
|
{
|
||||||
|
m_printer.reset();
|
||||||
|
QString message;
|
||||||
|
if (isSeccess) {
|
||||||
|
message = "print to pdf suceess.";
|
||||||
|
} else {
|
||||||
|
message = "print to pdf failed.";
|
||||||
|
}
|
||||||
|
showMessage(message);
|
||||||
|
|
||||||
|
// MessageBoxHelper::notify(MessageBoxHelper::Information,
|
||||||
|
// message,
|
||||||
|
// QString(),
|
||||||
|
// QString(),
|
||||||
|
// this);
|
||||||
|
}
|
||||||
void MarkdownViewWindow::handleExternalCodeBlockHighlightRequest(int p_idx, quint64 p_timeStamp, const QString &p_text)
|
void MarkdownViewWindow::handleExternalCodeBlockHighlightRequest(int p_idx, quint64 p_timeStamp, const QString &p_text)
|
||||||
{
|
{
|
||||||
static bool stylesInitialized = false;
|
static bool stylesInitialized = false;
|
||||||
|
@ -12,7 +12,7 @@ class QStackedWidget;
|
|||||||
class QWebEngineView;
|
class QWebEngineView;
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
class QPrinter;
|
||||||
namespace vte
|
namespace vte
|
||||||
{
|
{
|
||||||
class MarkdownEditorConfig;
|
class MarkdownEditorConfig;
|
||||||
@ -61,6 +61,7 @@ namespace vnotex
|
|||||||
public slots:
|
public slots:
|
||||||
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
void onPrintFinish(bool isSeccess);
|
||||||
protected slots:
|
protected slots:
|
||||||
void setModified(bool p_modified) Q_DECL_OVERRIDE;
|
void setModified(bool p_modified) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@ -237,6 +238,7 @@ namespace vnotex
|
|||||||
MarkdownEditorConfig::EditViewMode m_editViewMode = MarkdownEditorConfig::EditViewMode::EditOnly;
|
MarkdownEditorConfig::EditViewMode m_editViewMode = MarkdownEditorConfig::EditViewMode::EditOnly;
|
||||||
|
|
||||||
QTimer *m_syncPreviewTimer = nullptr;
|
QTimer *m_syncPreviewTimer = nullptr;
|
||||||
|
QSharedPointer<QPrinter> m_printer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ static QString generateNavigationLabelStyle(const QString &p_str, bool p_tiny)
|
|||||||
QFont font(fontFamily, fontPt);
|
QFont font(fontFamily, fontPt);
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
QFontMetrics fm(font);
|
QFontMetrics fm(font);
|
||||||
pxWidth = fm.width(p_str) + 5;
|
pxWidth = fm.horizontalAdvance(p_str) + 5;
|
||||||
pxHeight = fm.capHeight() + 5;
|
pxHeight = fm.capHeight() + 5;
|
||||||
lastLen = p_str.size();
|
lastLen = p_str.size();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "notebookexplorersession.h"
|
#include "notebookexplorersession.h"
|
||||||
|
#include <QIODevice>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <limits.h>
|
||||||
namespace vnotex
|
namespace vnotex
|
||||||
{
|
{
|
||||||
typedef QVector<int> SectionNumber;
|
typedef QVector<int> SectionNumber;
|
||||||
|
@ -194,7 +194,7 @@ void QuickSelector::searchAndFilter(const QString &p_text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check name.
|
// Check name.
|
||||||
auto parts = text.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
auto parts = text.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||||
Q_ASSERT(!parts.isEmpty());
|
Q_ASSERT(!parts.isEmpty());
|
||||||
QRegularExpression regExp;
|
QRegularExpression regExp;
|
||||||
regExp.setPatternOptions(regExp.patternOptions() | QRegularExpression::CaseInsensitiveOption);
|
regExp.setPatternOptions(regExp.patternOptions() | QRegularExpression::CaseInsensitiveOption);
|
||||||
|
@ -99,9 +99,9 @@ void TitleBar::setupActionButtons(TitleBar::Actions p_actionFlags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleBar::enterEvent(QEvent *p_event)
|
void TitleBar::enterEvent(QEnterEvent *p_event)
|
||||||
{
|
{
|
||||||
QWidget::enterEvent(p_event);
|
QFrame::enterEvent(p_event);
|
||||||
setActionButtonsVisible(true);
|
setActionButtonsVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ namespace vnotex
|
|||||||
void setActionButtonsAlwaysShown(bool p_shown);
|
void setActionButtonsAlwaysShown(bool p_shown);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void enterEvent(QEvent *p_event) Q_DECL_OVERRIDE;
|
void enterEvent(QEnterEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void leaveEvent(QEvent *p_event) Q_DECL_OVERRIDE;
|
void leaveEvent(QEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <utils/iconutils.h>
|
#include <utils/iconutils.h>
|
||||||
#include "thememgr.h"
|
#include "thememgr.h"
|
||||||
#include "vnotex.h"
|
#include "vnotex.h"
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user