mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
upgrade to Qt6
This commit is contained in:
parent
cbd3956cdc
commit
2f6afb2f97
@ -1 +1 @@
|
|||||||
Subproject commit 398ec0f8523d9c74a44cb746b5a1017741521e48
|
Subproject commit 7fc093c14e8bc4b8f9203f81499ddd993b707906
|
@ -560,9 +560,9 @@ bool NotebookDatabaseAccess::updateNodeTags(Node *p_node)
|
|||||||
const auto &nodeTags = p_node->getTags();
|
const auto &nodeTags = p_node->getTags();
|
||||||
|
|
||||||
{
|
{
|
||||||
QStringList list = queryNodeTags(p_node->getId());
|
QStringList tagsList = queryNodeTags(p_node->getId());
|
||||||
QSet<QString> tags;
|
QSet<QString> tags;
|
||||||
for (auto &s : list)
|
for (const auto &s : tagsList)
|
||||||
{
|
{
|
||||||
tags.insert(s);
|
tags.insert(s);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTemporaryDir>
|
#include <QTemporaryDir>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <widgets/editors/markdownviewer.h>
|
#include <widgets/editors/markdownviewer.h>
|
||||||
#include <widgets/editors/markdownvieweradapter.h>
|
#include <widgets/editors/markdownvieweradapter.h>
|
||||||
@ -19,7 +20,6 @@
|
|||||||
#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;
|
||||||
|
|
||||||
@ -359,22 +359,23 @@ void WebViewExporter::prepareWkhtmltopdfArguments(const ExportPdfOption &p_pdfOp
|
|||||||
bool WebViewExporter::embedStyleResources(QString &p_html) const
|
bool WebViewExporter::embedStyleResources(QString &p_html) const
|
||||||
{
|
{
|
||||||
bool altered = false;
|
bool altered = false;
|
||||||
QRegExp reg("\\burl\\(\"((file|qrc):[^\"\\)]+)\"\\);");
|
QRegularExpression reg("\\burl\\(\"((file|qrc):[^\"\\)]+)\"\\);");
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = reg.indexIn(p_html, pos);
|
QRegularExpressionMatch match;
|
||||||
|
int idx = p_html.indexOf(reg, pos, &match);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString dataURI = WebUtils::toDataUri(QUrl(reg.cap(1)), false);
|
QString dataURI = WebUtils::toDataUri(QUrl(match.captured(1)), false);
|
||||||
if (dataURI.isEmpty()) {
|
if (dataURI.isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + match.capturedLength();
|
||||||
} else {
|
} else {
|
||||||
// Replace the url string in html.
|
// Replace the url string in html.
|
||||||
QString newUrl = QString("url('%1');").arg(dataURI);
|
QString newUrl = QString("url('%1');").arg(dataURI);
|
||||||
p_html.replace(idx, reg.matchedLength(), newUrl);
|
p_html.replace(idx, match.capturedLength(), newUrl);
|
||||||
pos = idx + newUrl.size();
|
pos = idx + newUrl.size();
|
||||||
altered = true;
|
altered = true;
|
||||||
}
|
}
|
||||||
@ -390,28 +391,29 @@ bool WebViewExporter::embedBodyResources(const QUrl &p_baseUrl, QString &p_html)
|
|||||||
return altered;
|
return altered;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegExp reg(c_imgRegExp);
|
QRegularExpression reg(c_imgRegExp);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = reg.indexIn(p_html, pos);
|
QRegularExpressionMatch match;
|
||||||
|
int idx = p_html.indexOf(reg, pos, &match);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.cap(2).isEmpty()) {
|
if (match.captured(2).isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + match.capturedLength();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl srcUrl(p_baseUrl.resolved(reg.cap(2)));
|
QUrl srcUrl(p_baseUrl.resolved(match.captured(2)));
|
||||||
const auto dataURI = WebUtils::toDataUri(srcUrl, true);
|
const auto dataURI = WebUtils::toDataUri(srcUrl, true);
|
||||||
if (dataURI.isEmpty()) {
|
if (dataURI.isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + match.capturedLength();
|
||||||
} else {
|
} else {
|
||||||
// Replace the url string in html.
|
// Replace the url string in html.
|
||||||
QString newUrl = QString("<img %1src='%2'%3>").arg(reg.cap(1), dataURI, reg.cap(3));
|
QString newUrl = QString("<img %1src='%2'%3>").arg(match.captured(1), dataURI, match.captured(3));
|
||||||
p_html.replace(idx, reg.matchedLength(), newUrl);
|
p_html.replace(idx, match.capturedLength(), newUrl);
|
||||||
pos = idx + newUrl.size();
|
pos = idx + newUrl.size();
|
||||||
altered = true;
|
altered = true;
|
||||||
}
|
}
|
||||||
@ -437,28 +439,29 @@ bool WebViewExporter::fixBodyResources(const QUrl &p_baseUrl,
|
|||||||
return altered;
|
return altered;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRegExp reg(c_imgRegExp);
|
QRegularExpression reg(c_imgRegExp);
|
||||||
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_html.size()) {
|
while (pos < p_html.size()) {
|
||||||
int idx = reg.indexIn(p_html, pos);
|
QRegularExpressionMatch match;
|
||||||
|
int idx = p_html.indexOf(reg, pos, &match);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.cap(2).isEmpty()) {
|
if (match.captured(2).isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + match.capturedLength();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl srcUrl(p_baseUrl.resolved(reg.cap(2)));
|
QUrl srcUrl(p_baseUrl.resolved(match.captured(2)));
|
||||||
QString targetFile = WebUtils::copyResource(srcUrl, p_folder);
|
QString targetFile = WebUtils::copyResource(srcUrl, p_folder);
|
||||||
if (targetFile.isEmpty()) {
|
if (targetFile.isEmpty()) {
|
||||||
pos = idx + reg.matchedLength();
|
pos = idx + match.capturedLength();
|
||||||
} else {
|
} else {
|
||||||
// Replace the url string in html.
|
// Replace the url string in html.
|
||||||
QString newUrl = QString("<img %1src=\"%2\"%3>").arg(reg.cap(1), getResourceRelativePath(targetFile), reg.cap(3));
|
QString newUrl = QString("<img %1src=\"%2\"%3>").arg(match.captured(1), getResourceRelativePath(targetFile), match.captured(3));
|
||||||
p_html.replace(idx, reg.matchedLength(), newUrl);
|
p_html.replace(idx, match.capturedLength(), newUrl);
|
||||||
pos = idx + newUrl.size();
|
pos = idx + newUrl.size();
|
||||||
altered = true;
|
altered = true;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ using namespace vnotex;
|
|||||||
|
|
||||||
void loadTranslators(QApplication &p_app);
|
void loadTranslators(QApplication &p_app);
|
||||||
|
|
||||||
|
|
||||||
void showMessageOnCommandLineIfAvailable(const QString &p_msg);
|
void showMessageOnCommandLineIfAvailable(const QString &p_msg);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@ -78,7 +77,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Application app(argc, argv);
|
Application app(argc, argv);
|
||||||
|
|
||||||
|
|
||||||
QAccessible::installFactory(&FakeAccessible::accessibleFactory);
|
QAccessible::installFactory(&FakeAccessible::accessibleFactory);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "iconutils.h"
|
#include "iconutils.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -80,17 +80,18 @@ QString IconUtils::replaceForegroundOfIcon(const QString &p_iconContent, const Q
|
|||||||
bool IconUtils::isMonochrome(const QString &p_iconContent)
|
bool IconUtils::isMonochrome(const QString &p_iconContent)
|
||||||
{
|
{
|
||||||
// Match color-hex codes.
|
// Match color-hex codes.
|
||||||
QRegExp monoRe("#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})");
|
QRegularExpression monoRe("#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})");
|
||||||
|
|
||||||
QString lastColor = "";
|
QString lastColor = "";
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
while (pos < p_iconContent.size()) {
|
while (pos < p_iconContent.size()) {
|
||||||
int idx = monoRe.indexIn(p_iconContent, pos);
|
QRegularExpressionMatch match;
|
||||||
|
int idx = p_iconContent.indexOf(monoRe, pos, &match);
|
||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto curColor = monoRe.cap(1).toLower();
|
auto curColor = match.captured(1).toLower();
|
||||||
if (curColor.size() == 3) {
|
if (curColor.size() == 3) {
|
||||||
for (int i = curColor.size() - 1; i >= 0; --i) {
|
for (int i = curColor.size() - 1; i >= 0; --i) {
|
||||||
curColor.insert(i, curColor[i]);
|
curColor.insert(i, curColor[i]);
|
||||||
@ -105,7 +106,7 @@ bool IconUtils::isMonochrome(const QString &p_iconContent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pos += monoRe.matchedLength();
|
pos += match.capturedLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionMatch>
|
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@ -42,7 +42,8 @@ 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::ISODate)
|
QLocale locale;
|
||||||
|
return locale.toString(p_dateTime.date())
|
||||||
+ " "
|
+ " "
|
||||||
+ p_dateTime.time().toString(Qt::TextDate);
|
+ p_dateTime.time().toString(Qt::TextDate);
|
||||||
}
|
}
|
||||||
@ -69,15 +70,16 @@ QChar Utils::keyToChar(int p_key, bool p_lowerCase)
|
|||||||
|
|
||||||
QString Utils::pickAvailableFontFamily(const QStringList &p_families)
|
QString Utils::pickAvailableFontFamily(const QStringList &p_families)
|
||||||
{
|
{
|
||||||
auto availableFonts = QFontDatabase().families();
|
auto availableFonts = QFontDatabase::families();
|
||||||
for (const auto& f : p_families) {
|
for (const auto& f : p_families) {
|
||||||
auto family = f.trimmed();
|
auto family = f.trimmed();
|
||||||
if (family.isEmpty()) {
|
if (family.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRegularExpression regExp("\\[.*\\]");
|
||||||
for (auto availableFont : availableFonts) {
|
for (auto availableFont : availableFonts) {
|
||||||
availableFont.remove(QRegularExpression("\\[.*\\]"));
|
availableFont.remove(regExp);
|
||||||
availableFont = availableFont.trimmed();
|
availableFont = availableFont.trimmed();
|
||||||
if (family == availableFont
|
if (family == availableFont
|
||||||
|| family.toLower() == availableFont.toLower()) {
|
|| family.toLower() == availableFont.toLower()) {
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
#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"
|
||||||
@ -546,8 +545,9 @@ bool MarkdownEditor::processHtmlFromMimeData(const QMimeData *p_source)
|
|||||||
const QString html(p_source->html());
|
const QString html(p_source->html());
|
||||||
|
|
||||||
// Process <img>.
|
// Process <img>.
|
||||||
QRegExp reg("<img ([^>]*)src=\"([^\"]+)\"([^>]*)>");
|
QRegularExpression reg("<img ([^>]*)src=\"([^\"]+)\"([^>]*)>");
|
||||||
if (reg.indexIn(html) != -1 && HtmlUtils::hasOnlyImgTag(html)) {
|
QRegularExpressionMatch match;
|
||||||
|
if (html.indexOf(reg, 0, &match) != -1 && HtmlUtils::hasOnlyImgTag(html)) {
|
||||||
if (p_source->hasImage()) {
|
if (p_source->hasImage()) {
|
||||||
// Both image data and URL are embedded.
|
// Both image data and URL are embedded.
|
||||||
SelectDialog dialog(tr("Insert From Clipboard"), this);
|
SelectDialog dialog(tr("Insert From Clipboard"), this);
|
||||||
@ -563,7 +563,7 @@ bool MarkdownEditor::processHtmlFromMimeData(const QMimeData *p_source)
|
|||||||
return true;
|
return true;
|
||||||
} else if (selection == 2) {
|
} else if (selection == 2) {
|
||||||
// Insert as link.
|
// Insert as link.
|
||||||
auto imageLink = vte::MarkdownUtils::generateImageLink("", reg.cap(2), "");
|
auto imageLink = vte::MarkdownUtils::generateImageLink("", match.captured(2), "");
|
||||||
m_textEdit->insertPlainText(imageLink);
|
m_textEdit->insertPlainText(imageLink);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -572,7 +572,7 @@ bool MarkdownEditor::processHtmlFromMimeData(const QMimeData *p_source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
insertImageFromUrl(reg.cap(2));
|
insertImageFromUrl(match.captured(2));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1220,9 +1220,9 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
|||||||
proDlg.setWindowModality(Qt::WindowModal);
|
proDlg.setWindowModality(Qt::WindowModal);
|
||||||
proDlg.setWindowTitle(tr("Fetch Images To Local"));
|
proDlg.setWindowTitle(tr("Fetch Images To Local"));
|
||||||
|
|
||||||
QRegExp zhihuRegExp("^https?://www\\.zhihu\\.com/equation\\?tex=(.+)$");
|
QRegularExpression zhihuRegExp("^https?://www\\.zhihu\\.com/equation\\?tex=(.+)$");
|
||||||
|
|
||||||
QRegExp regExp(vte::MarkdownUtils::c_imageLinkRegExp);
|
QRegularExpression regExp(vte::MarkdownUtils::c_imageLinkRegExp);
|
||||||
for (int i = regs.size() - 1; i >= 0; --i) {
|
for (int i = regs.size() - 1; i >= 0; --i) {
|
||||||
proDlg.setValue(regs.size() - 1 - i);
|
proDlg.setValue(regs.size() - 1 - i);
|
||||||
if (proDlg.wasCanceled()) {
|
if (proDlg.wasCanceled()) {
|
||||||
@ -1231,14 +1231,15 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
|||||||
|
|
||||||
const auto ® = regs[i];
|
const auto ® = regs[i];
|
||||||
QString linkText = p_text.mid(reg.m_startPos, reg.m_endPos - reg.m_startPos);
|
QString linkText = p_text.mid(reg.m_startPos, reg.m_endPos - reg.m_startPos);
|
||||||
if (regExp.indexIn(linkText) == -1) {
|
QRegularExpressionMatch match;
|
||||||
|
if (linkText.indexOf(regExp, 0, &match) == -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "fetching image link" << linkText;
|
qDebug() << "fetching image link" << linkText;
|
||||||
|
|
||||||
const QString imageTitle = purifyImageTitle(regExp.cap(1).trimmed());
|
const QString imageTitle = purifyImageTitle(match.captured(1).trimmed());
|
||||||
QString imageUrl = regExp.cap(2).trimmed();
|
QString imageUrl = match.captured(2).trimmed();
|
||||||
|
|
||||||
const int maxUrlLength = 100;
|
const int maxUrlLength = 100;
|
||||||
QString urlToDisplay(imageUrl);
|
QString urlToDisplay(imageUrl);
|
||||||
@ -1248,8 +1249,9 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
|||||||
proDlg.setLabelText(tr("Fetching image (%1)").arg(urlToDisplay));
|
proDlg.setLabelText(tr("Fetching image (%1)").arg(urlToDisplay));
|
||||||
|
|
||||||
// Handle equation from zhihu.com like http://www.zhihu.com/equation?tex=P.
|
// Handle equation from zhihu.com like http://www.zhihu.com/equation?tex=P.
|
||||||
if (zhihuRegExp.indexIn(imageUrl) != -1) {
|
QRegularExpressionMatch zhihuMatch;
|
||||||
QString tex = zhihuRegExp.cap(1).trimmed();
|
if (imageUrl.indexOf(zhihuRegExp, 0, &zhihuMatch) != -1) {
|
||||||
|
QString tex = zhihuMatch.captured(1).trimmed();
|
||||||
|
|
||||||
// Remove the +.
|
// Remove the +.
|
||||||
tex.replace(QChar('+'), " ");
|
tex.replace(QChar('+'), " ");
|
||||||
@ -1322,7 +1324,7 @@ void MarkdownEditor::fetchImagesToLocalAndReplace(QString &p_text)
|
|||||||
|
|
||||||
// Replace URL in link.
|
// Replace URL in link.
|
||||||
QString newLink = QString("")
|
QString newLink = QString("")
|
||||||
.arg(imageTitle, urlInLink, regExp.cap(3), regExp.cap(6));
|
.arg(imageTitle, urlInLink, match.captured(3), match.captured(6));
|
||||||
p_text.replace(reg.m_startPos,
|
p_text.replace(reg.m_startPos,
|
||||||
reg.m_endPos - reg.m_startPos,
|
reg.m_endPos - reg.m_startPos,
|
||||||
newLink);
|
newLink);
|
||||||
|
@ -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(this->createStandardContextMenu());
|
QScopedPointer<QMenu> menu(createStandardContextMenu());
|
||||||
const QList<QAction *> actions = menu->actions();
|
const QList<QAction *> actions = menu->actions();
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
@ -395,7 +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);
|
connect(m_viewer, &MarkdownViewer::printFinished,
|
||||||
|
this, &MarkdownViewWindow::onPrintFinished);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,7 +506,8 @@ void MarkdownViewWindow::setupViewer()
|
|||||||
setEditViewMode(m_editViewMode);
|
setEditViewMode(m_editViewMode);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_viewer->settings()->resetAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls);
|
|
||||||
|
m_viewer->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
||||||
@ -1403,30 +1405,19 @@ void MarkdownViewWindow::print()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
m_printer = PrintUtils::promptForPrint(m_viewer->hasSelection(), this);
|
||||||
|
|
||||||
if (m_printer)
|
if (m_printer)
|
||||||
{
|
{
|
||||||
m_printer->setOutputFormat(QPrinter::PdfFormat);
|
m_printer->setOutputFormat(QPrinter::PdfFormat);
|
||||||
m_viewer->print(m_printer.get());
|
m_viewer->print(m_printer.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MarkdownViewWindow::onPrintFinish(bool isSeccess)
|
|
||||||
|
void MarkdownViewWindow::onPrintFinished(bool succeeded)
|
||||||
{
|
{
|
||||||
m_printer.reset();
|
m_printer.reset();
|
||||||
QString message;
|
showMessage(succeeded ? tr("Printed to PDF") : tr("Failed to print to PDF"));
|
||||||
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;
|
||||||
|
@ -13,6 +13,7 @@ class QWebEngineView;
|
|||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class QPrinter;
|
class QPrinter;
|
||||||
|
|
||||||
namespace vte
|
namespace vte
|
||||||
{
|
{
|
||||||
class MarkdownEditorConfig;
|
class MarkdownEditorConfig;
|
||||||
@ -61,7 +62,8 @@ namespace vnotex
|
|||||||
public slots:
|
public slots:
|
||||||
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
void handleEditorConfigChange() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void onPrintFinish(bool isSeccess);
|
void onPrintFinished(bool succeeded);
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void setModified(bool p_modified) Q_DECL_OVERRIDE;
|
void setModified(bool p_modified) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@ -238,6 +240,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;
|
QSharedPointer<QPrinter> m_printer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
namespace vnotex
|
namespace vnotex
|
||||||
{
|
{
|
||||||
typedef QVector<int> SectionNumber;
|
typedef QVector<int> SectionNumber;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
#include "viewwindow.h"
|
#include "viewwindow.h"
|
||||||
#include "viewarea.h"
|
#include "viewarea.h"
|
||||||
@ -25,7 +26,6 @@
|
|||||||
#include <core/coreconfig.h>
|
#include <core/coreconfig.h>
|
||||||
#include "propertydefs.h"
|
#include "propertydefs.h"
|
||||||
#include "fileopenparameters.h"
|
#include "fileopenparameters.h"
|
||||||
#include "sessionconfig.h"
|
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user