mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
parent
4ab2033a81
commit
cbd3956cdc
@ -6,6 +6,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QBitArray>
|
||||
#include <QDataStream>
|
||||
#include <QIODevice>
|
||||
|
||||
namespace vnotex
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <core/exception.h>
|
||||
#include "notebook.h"
|
||||
#include "nodeparameters.h"
|
||||
#include <QRandomGenerator>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -483,7 +484,7 @@ QList<QSharedPointer<File>> Node::collectFiles()
|
||||
|
||||
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()
|
||||
|
@ -560,7 +560,12 @@ bool NotebookDatabaseAccess::updateNodeTags(Node *p_node)
|
||||
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()) {
|
||||
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)
|
||||
@ -742,7 +747,7 @@ QStringList NotebookDatabaseAccess::getNodesOfTags(const QStringList &p_tags)
|
||||
allIds.insert(id);
|
||||
}
|
||||
}
|
||||
nodeIds = allIds.toList();
|
||||
nodeIds = allIds.values();
|
||||
}
|
||||
|
||||
for (const auto &id : nodeIds) {
|
||||
|
@ -465,7 +465,7 @@ QSharedPointer<Node> VXNotebookConfigMgr::loadNodeByPath(const QSharedPointer<No
|
||||
return p_root;
|
||||
}
|
||||
|
||||
auto paths = p.split('/', QString::SkipEmptyParts);
|
||||
auto paths = p.split('/', Qt::SkipEmptyParts);
|
||||
auto node = p_root;
|
||||
for (auto &pa : paths) {
|
||||
// Find child @pa in @node.
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <utils/processutils.h>
|
||||
#include <utils/htmlutils.h>
|
||||
#include <core/file.h>
|
||||
#include <QRegExp>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
@ -362,7 +363,7 @@ bool WebViewExporter::embedStyleResources(QString &p_html) const
|
||||
|
||||
int pos = 0;
|
||||
while (pos < p_html.size()) {
|
||||
int idx = p_html.indexOf(reg, pos);
|
||||
int idx = reg.indexIn(p_html, pos);
|
||||
if (idx == -1) {
|
||||
break;
|
||||
}
|
||||
@ -393,7 +394,7 @@ bool WebViewExporter::embedBodyResources(const QUrl &p_baseUrl, QString &p_html)
|
||||
|
||||
int pos = 0;
|
||||
while (pos < p_html.size()) {
|
||||
int idx = p_html.indexOf(reg, pos);
|
||||
int idx = reg.indexIn(p_html, pos);
|
||||
if (idx == -1) {
|
||||
break;
|
||||
}
|
||||
@ -440,7 +441,7 @@ bool WebViewExporter::fixBodyResources(const QUrl &p_baseUrl,
|
||||
|
||||
int pos = 0;
|
||||
while (pos < p_html.size()) {
|
||||
int idx = p_html.indexOf(reg, pos);
|
||||
int idx = reg.indexIn(p_html, pos);
|
||||
if (idx == -1) {
|
||||
break;
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ using namespace vnotex;
|
||||
|
||||
void loadTranslators(QApplication &p_app);
|
||||
|
||||
void initWebEngineSettings();
|
||||
|
||||
void showMessageOnCommandLineIfAvailable(const QString &p_msg);
|
||||
|
||||
@ -79,7 +78,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
Application app(argc, argv);
|
||||
|
||||
initWebEngineSettings();
|
||||
|
||||
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)
|
||||
{
|
||||
#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")
|
||||
|
||||
QT += core gui widgets webenginewidgets webchannel network svg printsupport
|
||||
QT += core gui widgets webenginewidgets webchannel network svg printsupport core5compat
|
||||
QT += sql
|
||||
|
||||
CONFIG -= qtquickcompiler
|
||||
|
@ -41,19 +41,19 @@ void IUnitedEntry::process(const QString &p_args,
|
||||
initOnFirstProcess();
|
||||
}
|
||||
|
||||
m_askedToStop.store(0);
|
||||
m_askedToStop.storeRelaxed(0);
|
||||
|
||||
return processInternal(p_args, p_popupWidgetFunc);
|
||||
}
|
||||
|
||||
void IUnitedEntry::stop()
|
||||
{
|
||||
m_askedToStop.store(1);
|
||||
m_askedToStop.storeRelaxed(1);
|
||||
}
|
||||
|
||||
bool IUnitedEntry::isAskedToStop() const
|
||||
{
|
||||
return m_askedToStop.load() == 1;
|
||||
return m_askedToStop.loadAcquire() == 1;
|
||||
}
|
||||
|
||||
void IUnitedEntry::setOngoing(bool p_ongoing)
|
||||
|
@ -9,12 +9,12 @@ AsyncWorker::AsyncWorker(QObject *p_parent)
|
||||
|
||||
void AsyncWorker::stop()
|
||||
{
|
||||
m_askedToStop.store(1);
|
||||
m_askedToStop.fetchAndStoreAcquire(1);
|
||||
}
|
||||
|
||||
bool AsyncWorker::isAskedToStop() const
|
||||
{
|
||||
return m_askedToStop.load() == 1;
|
||||
return m_askedToStop.loadAcquire() == 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <core/global.h>
|
||||
|
||||
#include "pathutils.h"
|
||||
#include <QRandomGenerator>
|
||||
|
||||
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.
|
||||
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;
|
||||
if (!p_suffix.isEmpty()) {
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "htmlutils.h"
|
||||
|
||||
#include <QRegExp>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
bool HtmlUtils::hasOnlyImgTag(const QString &p_html)
|
||||
{
|
||||
// Tricky.
|
||||
QRegExp reg(QStringLiteral("<(?:p|span|div) "));
|
||||
QRegularExpression reg(QStringLiteral("<(?:p|span|div) "));
|
||||
return !p_html.contains(reg);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ QString IconUtils::replaceForegroundOfIcon(const QString &p_iconContent, const Q
|
||||
}
|
||||
|
||||
// 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) {
|
||||
auto newContent(p_iconContent);
|
||||
newContent.replace(styleRe, QString("\\1\\2\\3%1").arg(p_foreground));
|
||||
@ -85,7 +85,7 @@ bool IconUtils::isMonochrome(const QString &p_iconContent)
|
||||
QString lastColor = "";
|
||||
int pos = 0;
|
||||
while (pos < p_iconContent.size()) {
|
||||
int idx = p_iconContent.indexOf(monoRe, pos);
|
||||
int idx = monoRe.indexIn(p_iconContent, pos);
|
||||
if (idx == -1) {
|
||||
break;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ QSharedPointer<QPrinter> PrintUtils::promptForPrint(bool p_printSelectionEnabled
|
||||
|
||||
QPrintDialog dialog(printer.data(), p_parent);
|
||||
if (p_printSelectionEnabled) {
|
||||
dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection);
|
||||
dialog.setOption(QAbstractPrintDialog::PrintSelection);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
return p_dateTime.date().toString(Qt::DefaultLocaleLongDate)
|
||||
return p_dateTime.date().toString(Qt::ISODate)
|
||||
+ " "
|
||||
+ p_dateTime.time().toString(Qt::TextDate);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
QT += widgets svg
|
||||
QT += widgets svg core5compat
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/asyncworker.cpp \
|
||||
|
@ -58,7 +58,8 @@ QString WebUtils::toDataUri(const QUrl &p_url, bool p_keepTitle)
|
||||
|
||||
if (!p_keepTitle) {
|
||||
// Remove <title>...</title>.
|
||||
QRegExp reg("<title>.*</title>", Qt::CaseInsensitive);
|
||||
QRegularExpression reg("<title>.*</title>");
|
||||
reg.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
|
||||
uri.remove(reg);
|
||||
}
|
||||
} else {
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <QStyle>
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QDesktopServices>
|
||||
#include <QKeyEvent>
|
||||
@ -71,8 +70,7 @@ bool WidgetUtils::isScrollBarVisible(QAbstractScrollArea *p_widget, bool p_horiz
|
||||
|
||||
QSize WidgetUtils::availableScreenSize(QWidget *p_widget)
|
||||
{
|
||||
auto geo = QApplication::desktop()->availableGeometry(p_widget);
|
||||
return geo.size();
|
||||
return p_widget->screen()->availableGeometry().size();
|
||||
}
|
||||
|
||||
void WidgetUtils::openUrlByDesktop(const QUrl &p_url)
|
||||
@ -374,7 +372,7 @@ QString WidgetUtils::getMonospaceFont()
|
||||
for (const auto &candidate : candidates) {
|
||||
QString family = candidate.trimmed().toLower();
|
||||
for (auto availFamily : availFamilies) {
|
||||
availFamily.remove(QRegExp("\\[.*\\]"));
|
||||
availFamily.remove(QRegularExpression("\\[.*\\]"));
|
||||
if (family == availFamily.trimmed().toLower()) {
|
||||
font = availFamily;
|
||||
return font;
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QPlainTextEdit>
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QSpinBox>
|
||||
#include <QSlider>
|
||||
#include <QScrollArea>
|
||||
@ -88,7 +88,7 @@ void ImageInsertDialog::setupUI(const QString &p_title,
|
||||
|
||||
// Image Title.
|
||||
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);
|
||||
gridLayout->addWidget(new QLabel(tr("Title:"), mainWidget), 1, 0, 1, 1);
|
||||
gridLayout->addWidget(m_imageTitleEdit, 1, 1, 1, 3);
|
||||
@ -97,7 +97,7 @@ void ImageInsertDialog::setupUI(const QString &p_title,
|
||||
|
||||
// Image Alt.
|
||||
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);
|
||||
gridLayout->addWidget(new QLabel(tr("Alt text:"), mainWidget), 2, 0, 1, 1);
|
||||
gridLayout->addWidget(m_imageAltEdit, 2, 1, 1, 3);
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QPlainTextEdit>
|
||||
|
@ -73,7 +73,7 @@ void SelectDialog::addSelection(const QString &p_selectStr, int p_selectID)
|
||||
QChar shortcut;
|
||||
if (m_nextShortcut < c_cancelShortcut) {
|
||||
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);
|
||||
QListWidgetItem *item = new QListWidgetItem(icon, p_selectStr);
|
||||
|
@ -64,7 +64,7 @@ bool FileAssociationPage::saveInternal()
|
||||
if (name.isEmpty()) {
|
||||
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)));
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ void SortDialog::updateTreeWidget()
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsDropEnabled);
|
||||
}
|
||||
|
||||
m_treeWidget->sortByColumn(-1);
|
||||
m_treeWidget->sortByColumn(-1, Qt::AscendingOrder);
|
||||
m_treeWidget->setSortingEnabled(true);
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ void SortDialog::handleMoveOperation(MoveOperation p_op)
|
||||
Q_ASSERT(first <= last && (last - first + 1) == selectedItems.size());
|
||||
QTreeWidgetItem *firstItem = nullptr;
|
||||
|
||||
m_treeWidget->sortByColumn(-1);
|
||||
m_treeWidget->sortByColumn(-1, Qt::AscendingOrder);
|
||||
|
||||
switch (p_op) {
|
||||
case MoveOperation::Top:
|
||||
|
@ -63,7 +63,9 @@ void TableInsertDialog::setupUI(const QString &p_title)
|
||||
buttonGroup->addButton(rightBtn, static_cast<int>(Alignment::Right));
|
||||
|
||||
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){
|
||||
if (p_checked) {
|
||||
m_alignment = static_cast<Alignment>(p_id);
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <imagehost/imagehostutils.h>
|
||||
#include <imagehost/imagehost.h>
|
||||
#include <imagehost/imagehostmgr.h>
|
||||
#include <QRegExp>
|
||||
|
||||
#include "previewhelper.h"
|
||||
#include "../outlineprovider.h"
|
||||
@ -1198,7 +1199,7 @@ void MarkdownEditor::handleHtmlToMarkdownData(quint64 p_id, TimeStamp p_timeStam
|
||||
|
||||
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)
|
||||
|
@ -214,10 +214,10 @@ void MarkdownTable::initWidths(const QTextBlock &p_block, int p_borderPos)
|
||||
}
|
||||
|
||||
QFontMetricsF fmf(font);
|
||||
s_spaceWidth = fmf.width(' ');
|
||||
s_minusWidth = fmf.width('-');
|
||||
s_colonWidth = fmf.width(':');
|
||||
s_defaultDelimiterWidth = fmf.width(c_defaultDelimiter);
|
||||
s_spaceWidth = fmf.horizontalAdvance(' ');
|
||||
s_minusWidth = fmf.horizontalAdvance('-');
|
||||
s_colonWidth = fmf.horizontalAdvance(':');
|
||||
s_defaultDelimiterWidth = fmf.horizontalAdvance(c_defaultDelimiter);
|
||||
|
||||
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)
|
||||
{
|
||||
QScopedPointer<QMenu> menu(page()->createStandardContextMenu());
|
||||
QScopedPointer<QMenu> menu(this->createStandardContextMenu());
|
||||
const QList<QAction *> actions = menu->actions();
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
|
@ -338,7 +338,7 @@ void PreviewHelper::updateEditorInplacePreviewCodeBlock()
|
||||
m_previousInplacePreviewCodeBlockSize = previewItems.size();
|
||||
|
||||
if (!obsoleteBlocks.isEmpty()) {
|
||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.toList());
|
||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.values());
|
||||
}
|
||||
|
||||
m_codeBlockCache.setCapacityHint(m_codeBlocksData.size());
|
||||
@ -434,7 +434,7 @@ void PreviewHelper::updateEditorInplacePreviewMathBlock()
|
||||
m_previousInplacePreviewMathBlockSize = previewItems.size();
|
||||
|
||||
if (!obsoleteBlocks.isEmpty()) {
|
||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.toList());
|
||||
emit potentialObsoletePreviewBlocksUpdated(obsoleteBlocks.values());
|
||||
}
|
||||
|
||||
m_mathBlockCache.setCapacityHint(m_mathBlocksData.size());
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "fullscreentoggleaction.h"
|
||||
|
||||
#include <QEvent>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
|
@ -45,7 +45,7 @@ void LabelWithButtonsWidget::paintEvent(QPaintEvent *p_event)
|
||||
Q_UNUSED(p_event);
|
||||
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
opt.initFrom(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QActionGroup>
|
||||
#include <QTimer>
|
||||
#include <QPrinter>
|
||||
#include <QWebEngineSettings>
|
||||
|
||||
#include <core/fileopenparameters.h>
|
||||
#include <core/editorconfig.h>
|
||||
@ -394,6 +395,8 @@ void MarkdownViewWindow::setupTextEditor()
|
||||
|
||||
connect(m_editor, &MarkdownEditor::applySnippetRequested,
|
||||
this, QOverload<>::of(&MarkdownViewWindow::applySnippet));
|
||||
connect(m_viewer, &MarkdownViewer::printFinished, this, &MarkdownViewWindow::onPrintFinish);
|
||||
|
||||
}
|
||||
|
||||
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
|
||||
@ -502,6 +505,7 @@ void MarkdownViewWindow::setupViewer()
|
||||
setEditViewMode(m_editViewMode);
|
||||
}
|
||||
});
|
||||
m_viewer->settings()->resetAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
|
||||
}
|
||||
|
||||
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
||||
@ -1398,15 +1402,31 @@ void MarkdownViewWindow::print()
|
||||
return;
|
||||
}
|
||||
|
||||
auto printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
||||
if (printer) {
|
||||
m_viewer->page()->print(printer.data(), [printer](bool p_succeeded) mutable {
|
||||
Q_UNUSED(p_succeeded);
|
||||
printer.reset();
|
||||
});
|
||||
m_printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
||||
|
||||
if (m_printer)
|
||||
{
|
||||
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)
|
||||
{
|
||||
static bool stylesInitialized = false;
|
||||
|
@ -12,7 +12,7 @@ class QStackedWidget;
|
||||
class QWebEngineView;
|
||||
class QActionGroup;
|
||||
class QTimer;
|
||||
|
||||
class QPrinter;
|
||||
namespace vte
|
||||
{
|
||||
class MarkdownEditorConfig;
|
||||
@ -61,6 +61,7 @@ namespace vnotex
|
||||
public slots:
|
||||
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
||||
|
||||
void onPrintFinish(bool isSeccess);
|
||||
protected slots:
|
||||
void setModified(bool p_modified) Q_DECL_OVERRIDE;
|
||||
|
||||
@ -237,6 +238,7 @@ namespace vnotex
|
||||
MarkdownEditorConfig::EditViewMode m_editViewMode = MarkdownEditorConfig::EditViewMode::EditOnly;
|
||||
|
||||
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);
|
||||
font.setBold(true);
|
||||
QFontMetrics fm(font);
|
||||
pxWidth = fm.width(p_str) + 5;
|
||||
pxWidth = fm.horizontalAdvance(p_str) + 5;
|
||||
pxHeight = fm.capHeight() + 5;
|
||||
lastLen = p_str.size();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "notebookexplorersession.h"
|
||||
#include <QIODevice>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QVector>
|
||||
|
||||
#include <limits.h>
|
||||
namespace vnotex
|
||||
{
|
||||
typedef QVector<int> SectionNumber;
|
||||
|
@ -194,7 +194,7 @@ void QuickSelector::searchAndFilter(const QString &p_text)
|
||||
}
|
||||
|
||||
// Check name.
|
||||
auto parts = text.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||
auto parts = text.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||
Q_ASSERT(!parts.isEmpty());
|
||||
QRegularExpression regExp;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ namespace vnotex
|
||||
void setActionButtonsAlwaysShown(bool p_shown);
|
||||
|
||||
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;
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <utils/iconutils.h>
|
||||
#include "thememgr.h"
|
||||
#include "vnotex.h"
|
||||
#include <QActionGroup>
|
||||
|
||||
using namespace vnotex;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user