mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 05:49:53 +08:00
adapt to Qt 5.6.1
1. Remove dependency on QWebEngineView
This commit is contained in:
parent
4c3b0c96c7
commit
d8e7583179
@ -1,7 +1,6 @@
|
||||
#include "vcopytextashtmldialog.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QWebEngineView>
|
||||
#include <QClipboard>
|
||||
#include <QMimeData>
|
||||
#include <QApplication>
|
||||
@ -31,8 +30,8 @@ void VCopyTextAsHtmlDialog::setupUI()
|
||||
m_textEdit->setProperty("LineEdit", true);
|
||||
|
||||
m_htmlLabel = new QLabel(tr("HTML:"));
|
||||
m_htmlViewer = VUtils::getWebEngineView(g_config->getBaseBackground());
|
||||
m_htmlViewer->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_htmlViewer = VUtils::getTextBrowser(g_config->getBaseBackground());
|
||||
// m_htmlViewer->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_htmlViewer->setMinimumSize(600, 400);
|
||||
|
||||
m_infoLabel = new QLabel(tr("Converting text to HTML ..."));
|
||||
@ -66,7 +65,8 @@ void VCopyTextAsHtmlDialog::setConvertedHtml(const QUrl &p_baseUrl,
|
||||
const QString &p_html)
|
||||
{
|
||||
QString html = p_html;
|
||||
m_htmlViewer->setHtml("<html><body>" + html + "</body></html>", p_baseUrl);
|
||||
m_htmlViewer->setHtml("<html><body>" + html + "</body></html>");
|
||||
m_htmlViewer->setSource(p_baseUrl);
|
||||
setHtmlVisible(true);
|
||||
|
||||
g_webUtils->alterHtmlAsTarget(p_baseUrl, html, m_copyTarget);
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
class QPlainTextEdit;
|
||||
class QWebEngineView;
|
||||
class QTextBrowser;
|
||||
class QDialogButtonBox;
|
||||
class VWaitingWidget;
|
||||
class QLabel;
|
||||
@ -32,7 +32,7 @@ private:
|
||||
|
||||
QLabel *m_htmlLabel;
|
||||
|
||||
QWebEngineView *m_htmlViewer;
|
||||
QTextBrowser *m_htmlViewer;
|
||||
|
||||
QLabel *m_infoLabel;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,516 +0,0 @@
|
||||
#ifndef VEXPORTDIALOG_H
|
||||
#define VEXPORTDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QPageLayout>
|
||||
#include <QList>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "vconstants.h"
|
||||
|
||||
class QLabel;
|
||||
class VLineEdit;
|
||||
class QDialogButtonBox;
|
||||
class QPushButton;
|
||||
class QGroupBox;
|
||||
class QPlainTextEdit;
|
||||
class VNotebook;
|
||||
class VDirectory;
|
||||
class VFile;
|
||||
class VCart;
|
||||
class VExporter;
|
||||
class QCheckBox;
|
||||
class VLineEdit;
|
||||
class QProgressBar;
|
||||
|
||||
|
||||
enum class ExportSource
|
||||
{
|
||||
CurrentNote = 0,
|
||||
CurrentFolder,
|
||||
CurrentNotebook,
|
||||
Cart
|
||||
};
|
||||
|
||||
|
||||
enum class ExportFormat
|
||||
{
|
||||
Markdown = 0,
|
||||
HTML,
|
||||
PDF,
|
||||
OnePDF,
|
||||
Custom
|
||||
};
|
||||
|
||||
|
||||
enum class ExportPageNumber
|
||||
{
|
||||
None = 0,
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
};
|
||||
|
||||
|
||||
struct ExportHTMLOption
|
||||
{
|
||||
ExportHTMLOption()
|
||||
: m_embedCssStyle(true),
|
||||
m_completeHTML(true),
|
||||
m_embedImages(true),
|
||||
m_mimeHTML(false),
|
||||
m_outlinePanel(true)
|
||||
{
|
||||
}
|
||||
|
||||
ExportHTMLOption(bool p_embedCssStyle,
|
||||
bool p_completeHTML,
|
||||
bool p_embedImages,
|
||||
bool p_mimeHTML,
|
||||
bool p_outlinePanel)
|
||||
: m_embedCssStyle(p_embedCssStyle),
|
||||
m_completeHTML(p_completeHTML),
|
||||
m_embedImages(p_embedImages),
|
||||
m_mimeHTML(p_mimeHTML),
|
||||
m_outlinePanel(p_outlinePanel)
|
||||
{
|
||||
}
|
||||
|
||||
bool m_embedCssStyle;
|
||||
bool m_completeHTML;
|
||||
bool m_embedImages;
|
||||
bool m_mimeHTML;
|
||||
bool m_outlinePanel;
|
||||
};
|
||||
|
||||
|
||||
struct ExportPDFOption
|
||||
{
|
||||
ExportPDFOption()
|
||||
: m_layout(NULL),
|
||||
m_wkhtmltopdf(false),
|
||||
m_wkEnableBackground(true),
|
||||
m_enableTableOfContents(false),
|
||||
m_wkPageNumber(ExportPageNumber::None)
|
||||
{
|
||||
}
|
||||
|
||||
ExportPDFOption(QPageLayout *p_layout,
|
||||
bool p_wkhtmltopdf,
|
||||
const QString &p_wkPath,
|
||||
bool p_wkEnableBackground,
|
||||
bool p_enableTableOfContents,
|
||||
const QString &p_wkTitle,
|
||||
const QString &p_wkTargetFileName,
|
||||
ExportPageNumber p_wkPageNumber,
|
||||
const QString &p_wkExtraArgs)
|
||||
: m_layout(p_layout),
|
||||
m_wkhtmltopdf(p_wkhtmltopdf),
|
||||
m_wkPath(p_wkPath),
|
||||
m_wkEnableBackground(p_wkEnableBackground),
|
||||
m_enableTableOfContents(p_enableTableOfContents),
|
||||
m_wkTitle(p_wkTitle),
|
||||
m_wkTargetFileName(p_wkTargetFileName),
|
||||
m_wkPageNumber(p_wkPageNumber),
|
||||
m_wkExtraArgs(p_wkExtraArgs)
|
||||
{
|
||||
}
|
||||
|
||||
QPageLayout *m_layout;
|
||||
bool m_wkhtmltopdf;
|
||||
QString m_wkPath;
|
||||
bool m_wkEnableBackground;
|
||||
bool m_enableTableOfContents;;
|
||||
QString m_wkTitle;
|
||||
QString m_wkTargetFileName;
|
||||
ExportPageNumber m_wkPageNumber;
|
||||
QString m_wkExtraArgs;
|
||||
};
|
||||
|
||||
|
||||
struct ExportCustomOption
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
#define DEFAULT_SEP ";"
|
||||
#else
|
||||
#define DEFAULT_SEP ":"
|
||||
#endif
|
||||
|
||||
enum SourceFormat
|
||||
{
|
||||
Markdown = 0,
|
||||
HTML
|
||||
};
|
||||
|
||||
ExportCustomOption()
|
||||
: m_srcFormat(SourceFormat::Markdown),
|
||||
m_allInOne(false),
|
||||
m_pdfLike(false),
|
||||
m_folderSep(DEFAULT_SEP)
|
||||
{
|
||||
}
|
||||
|
||||
ExportCustomOption(const QStringList &p_config)
|
||||
: m_srcFormat(SourceFormat::Markdown),
|
||||
m_allInOne(false),
|
||||
m_pdfLike(false),
|
||||
m_folderSep(DEFAULT_SEP)
|
||||
{
|
||||
if (p_config.size() < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_config.at(0).trimmed() != "0") {
|
||||
m_srcFormat = SourceFormat::HTML;
|
||||
}
|
||||
|
||||
m_outputSuffix = p_config.at(1).trimmed();
|
||||
|
||||
m_cmd = p_config.at(2).trimmed();
|
||||
}
|
||||
|
||||
ExportCustomOption(ExportCustomOption::SourceFormat p_srcFormat,
|
||||
const QString &p_outputSuffix,
|
||||
const QString &p_cmd,
|
||||
const QString &p_cssUrl,
|
||||
const QString &p_codeBlockCssUrl,
|
||||
bool p_allInOne,
|
||||
bool p_pdfLike,
|
||||
const QString &p_folderSep,
|
||||
const QString &p_targetFileName)
|
||||
: m_srcFormat(p_srcFormat),
|
||||
m_outputSuffix(p_outputSuffix),
|
||||
m_cssUrl(p_cssUrl),
|
||||
m_codeBlockCssUrl(p_codeBlockCssUrl),
|
||||
m_allInOne(p_allInOne),
|
||||
m_pdfLike(p_pdfLike),
|
||||
m_folderSep(p_folderSep),
|
||||
m_targetFileName(p_targetFileName)
|
||||
{
|
||||
QStringList cmds = p_cmd.split('\n');
|
||||
if (!cmds.isEmpty()) {
|
||||
m_cmd = cmds.first();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList toConfig() const
|
||||
{
|
||||
QStringList config;
|
||||
config << QString::number((int)m_srcFormat);
|
||||
config << m_outputSuffix;
|
||||
config << m_cmd;
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
SourceFormat m_srcFormat;
|
||||
QString m_outputSuffix;
|
||||
QString m_cmd;
|
||||
|
||||
QString m_cssUrl;
|
||||
QString m_codeBlockCssUrl;
|
||||
|
||||
bool m_allInOne;
|
||||
bool m_pdfLike;
|
||||
|
||||
QString m_folderSep;
|
||||
QString m_targetFileName;
|
||||
};
|
||||
|
||||
|
||||
struct ExportOption
|
||||
{
|
||||
ExportOption()
|
||||
: m_source(ExportSource::CurrentNote),
|
||||
m_format(ExportFormat::Markdown),
|
||||
m_renderer(MarkdownConverterType::MarkdownIt),
|
||||
m_processSubfolders(true)
|
||||
{
|
||||
}
|
||||
|
||||
ExportOption(ExportSource p_source,
|
||||
ExportFormat p_format,
|
||||
MarkdownConverterType p_renderer,
|
||||
const QString &p_renderBg,
|
||||
const QString &p_renderStyle,
|
||||
const QString &p_renderCodeBlockStyle,
|
||||
bool p_processSubfolders,
|
||||
const ExportPDFOption &p_pdfOpt,
|
||||
const ExportHTMLOption &p_htmlOpt,
|
||||
const ExportCustomOption &p_customOpt)
|
||||
: m_source(p_source),
|
||||
m_format(p_format),
|
||||
m_renderer(p_renderer),
|
||||
m_renderBg(p_renderBg),
|
||||
m_renderStyle(p_renderStyle),
|
||||
m_renderCodeBlockStyle(p_renderCodeBlockStyle),
|
||||
m_processSubfolders(p_processSubfolders),
|
||||
m_pdfOpt(p_pdfOpt),
|
||||
m_htmlOpt(p_htmlOpt),
|
||||
m_customOpt(p_customOpt)
|
||||
{
|
||||
}
|
||||
|
||||
ExportSource m_source;
|
||||
ExportFormat m_format;
|
||||
MarkdownConverterType m_renderer;
|
||||
|
||||
// Background name.
|
||||
QString m_renderBg;
|
||||
|
||||
QString m_renderStyle;
|
||||
QString m_renderCodeBlockStyle;
|
||||
|
||||
// Whether process subfolders recursively when source is CurrentFolder.
|
||||
bool m_processSubfolders;
|
||||
|
||||
ExportPDFOption m_pdfOpt;
|
||||
|
||||
ExportHTMLOption m_htmlOpt;
|
||||
|
||||
ExportCustomOption m_customOpt;
|
||||
};
|
||||
|
||||
|
||||
class VExportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VExportDialog(VNotebook *p_notebook,
|
||||
VDirectory *p_directory,
|
||||
VFile *p_file,
|
||||
VCart *p_cart,
|
||||
MarkdownConverterType p_renderer,
|
||||
QWidget *p_parent = nullptr);
|
||||
|
||||
private slots:
|
||||
void startExport();
|
||||
|
||||
void handleOutputBrowseBtnClicked();
|
||||
|
||||
void handleWkPathBrowseBtnClicked();
|
||||
|
||||
void handleInputChanged();
|
||||
|
||||
void handleLayoutBtnClicked();
|
||||
|
||||
void handleCurrentFormatChanged(int p_index);
|
||||
|
||||
void handleCurrentSrcChanged(int p_index);
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
QWidget *setupPDFAdvancedSettings();
|
||||
|
||||
QWidget *setupHTMLAdvancedSettings();
|
||||
|
||||
QWidget *setupGeneralAdvancedSettings();
|
||||
|
||||
QWidget *setupCustomAdvancedSettings();
|
||||
|
||||
void initUIFields(MarkdownConverterType p_renderer);
|
||||
|
||||
QString getOutputDirectory() const;
|
||||
|
||||
void appendLogLine(const QString &p_text);
|
||||
|
||||
// Return number of files exported.
|
||||
int doExport(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExport(VDirectory *p_directory,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExport(VNotebook *p_notebook,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExport(VCart *p_cart,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExportMarkdown(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExportPDF(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExportHTML(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
int doExportPDFAllInOne(const QList<QString> &p_files,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
int doExportCustomAllInOne(const QList<QString> &p_files,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
int doExportCustom(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
// Return false if we could not continue.
|
||||
bool checkUserAction();
|
||||
|
||||
void updatePageLayoutLabel();
|
||||
|
||||
bool checkWkhtmltopdfExecutable(const QString &p_file);
|
||||
|
||||
ExportSource currentSource() const;
|
||||
|
||||
ExportFormat currentFormat() const;
|
||||
|
||||
int outputAsHTML(const QString &p_outputFolder,
|
||||
QString *p_errMsg = NULL,
|
||||
QList<QString> *p_outputFiles = NULL);
|
||||
|
||||
// Collect files to be handled.
|
||||
QList<QString> collectFiles(QString *p_errMsg = NULL);
|
||||
|
||||
QComboBox *m_srcCB;
|
||||
|
||||
QComboBox *m_formatCB;
|
||||
|
||||
QComboBox *m_rendererCB;
|
||||
|
||||
QComboBox *m_renderBgCB;
|
||||
|
||||
QComboBox *m_renderStyleCB;
|
||||
|
||||
QComboBox *m_renderCodeBlockStyleCB;
|
||||
|
||||
VLineEdit *m_outputEdit;
|
||||
|
||||
QGroupBox *m_basicBox;
|
||||
|
||||
QGroupBox *m_settingBox;
|
||||
|
||||
QWidget *m_pdfSettings;
|
||||
|
||||
QWidget *m_htmlSettings;
|
||||
|
||||
QWidget *m_generalSettings;
|
||||
|
||||
QWidget *m_customSettings;
|
||||
|
||||
QPlainTextEdit *m_consoleEdit;
|
||||
|
||||
QDialogButtonBox *m_btnBox;
|
||||
|
||||
QPushButton *m_openBtn;
|
||||
|
||||
QPushButton *m_exportBtn;
|
||||
|
||||
QPushButton *m_copyBtn;
|
||||
|
||||
QLabel *m_layoutLabel;
|
||||
|
||||
QCheckBox *m_wkhtmltopdfCB;
|
||||
|
||||
VLineEdit *m_wkPathEdit;
|
||||
|
||||
QPushButton *m_wkPathBrowseBtn;
|
||||
|
||||
VLineEdit *m_wkTitleEdit;
|
||||
|
||||
VLineEdit *m_wkTargetFileNameEdit;
|
||||
|
||||
QCheckBox *m_wkBackgroundCB;
|
||||
|
||||
QCheckBox *m_tableOfContentsCB;
|
||||
|
||||
QComboBox *m_wkPageNumberCB;
|
||||
|
||||
VLineEdit *m_wkExtraArgsEdit;
|
||||
|
||||
QCheckBox *m_embedStyleCB;
|
||||
|
||||
QCheckBox *m_completeHTMLCB;
|
||||
|
||||
QCheckBox *m_embedImagesCB;
|
||||
|
||||
QCheckBox *m_mimeHTMLCB;
|
||||
|
||||
QCheckBox *m_outlinePanelCB;
|
||||
|
||||
QCheckBox *m_subfolderCB;
|
||||
|
||||
QComboBox *m_customSrcFormatCB;
|
||||
|
||||
VLineEdit *m_customSuffixEdit;
|
||||
|
||||
QCheckBox *m_customAllInOneCB;
|
||||
|
||||
QCheckBox *m_customPdfLikeCB;
|
||||
|
||||
QPlainTextEdit *m_customCmdEdit;
|
||||
|
||||
VLineEdit *m_customFolderSepEdit;
|
||||
|
||||
VLineEdit *m_customTargetFileNameEdit;
|
||||
|
||||
VNotebook *m_notebook;
|
||||
|
||||
VDirectory *m_directory;
|
||||
|
||||
VFile *m_file;
|
||||
|
||||
VCart *m_cart;
|
||||
|
||||
QProgressBar *m_proBar;
|
||||
|
||||
QPageLayout m_pageLayout;
|
||||
|
||||
// Whether we are exporting files.
|
||||
bool m_inExport;
|
||||
|
||||
// Asked to stop exporting by user.
|
||||
bool m_askedToStop;
|
||||
|
||||
// Exporter used to export PDF and HTML.
|
||||
VExporter *m_exporter;
|
||||
|
||||
// Last exproted file path.
|
||||
QString m_exportedFile;
|
||||
|
||||
// Last output folder path.
|
||||
static QString s_lastOutputFolder;
|
||||
|
||||
static ExportOption s_opt;
|
||||
};
|
||||
|
||||
inline ExportSource VExportDialog::currentSource() const
|
||||
{
|
||||
return (ExportSource)m_srcCB->currentData().toInt();
|
||||
}
|
||||
|
||||
inline ExportFormat VExportDialog::currentFormat() const
|
||||
{
|
||||
return (ExportFormat)m_formatCB->currentData().toInt();
|
||||
}
|
||||
#endif // VEXPORTDIALOG_H
|
@ -62,7 +62,7 @@ VSettingsDialog::VSettingsDialog(QWidget *p_parent)
|
||||
// Add tabs.
|
||||
addTab(new VGeneralTab(), tr("General"));
|
||||
addTab(new VLookTab(), tr("Appearance"));
|
||||
addTab(new VReadEditTab(this), tr("Read/Edit"));
|
||||
addTab(new VReadEditTab(this), tr("Edit"));
|
||||
addTab(new VNoteManagementTab(), tr("Note Management"));
|
||||
addTab(new VMarkdownTab(), tr("Markdown"));
|
||||
addTab(new VMiscTab(), tr("Misc"));
|
||||
@ -684,7 +684,9 @@ VReadEditTab::VReadEditTab(VSettingsDialog *p_dlg, QWidget *p_parent)
|
||||
: QWidget(p_parent),
|
||||
m_settingsDlg(p_dlg)
|
||||
{
|
||||
m_readBox = new QGroupBox(tr("Read Mode (For Markdown Only)"));
|
||||
m_readBox = new QGroupBox(tr("Read Mode (For Markdown Only)"), this);
|
||||
m_readBox->setVisible(false);
|
||||
|
||||
m_editBox = new QGroupBox(tr("Edit Mode"));
|
||||
|
||||
// Web Zoom Factor.
|
||||
@ -771,7 +773,7 @@ VReadEditTab::VReadEditTab(VSettingsDialog *p_dlg, QWidget *p_parent)
|
||||
m_keyModeCB->setCurrentIndex(0);
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
mainLayout->addWidget(m_readBox);
|
||||
// mainLayout->addWidget(m_readBox);
|
||||
mainLayout->addWidget(m_editBox);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
@ -1211,10 +1213,11 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
||||
: QWidget(p_parent)
|
||||
{
|
||||
// Default note open mode.
|
||||
m_openModeCombo = VUtils::getComboBox();
|
||||
m_openModeCombo = VUtils::getComboBox(this);
|
||||
m_openModeCombo->setToolTip(tr("Default mode to open a file"));
|
||||
m_openModeCombo->addItem(tr("Read Mode"), (int)OpenFileMode::Read);
|
||||
m_openModeCombo->addItem(tr("Edit Mode"), (int)OpenFileMode::Edit);
|
||||
m_openModeCombo->setVisible(false);
|
||||
|
||||
// Heading sequence.
|
||||
m_headingSequenceTypeCombo = VUtils::getComboBox();
|
||||
@ -1256,20 +1259,22 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
||||
colorColumnLabel->setToolTip(m_colorColumnEdit->toolTip());
|
||||
|
||||
// MathJax.
|
||||
m_mathjaxConfigEdit = new VLineEdit();
|
||||
m_mathjaxConfigEdit = new VLineEdit(this);
|
||||
m_mathjaxConfigEdit->setToolTip(tr("Location of MathJax JavaScript and its configuration "
|
||||
"(restart VNote to make it work in in-place preview)"));
|
||||
m_mathjaxConfigEdit->setPlaceholderText(tr("Need to prepend \"file://\" to local path"));
|
||||
m_mathjaxConfigEdit->setVisible(false);
|
||||
|
||||
// PlantUML.
|
||||
m_plantUMLModeCombo = VUtils::getComboBox();
|
||||
m_plantUMLModeCombo->setToolTip(tr("Enable PlantUML support in Markdown"));
|
||||
m_plantUMLModeCombo->addItem(tr("Disabled"), PlantUMLMode::DisablePlantUML);
|
||||
m_plantUMLModeCombo->addItem(tr("Online Service"), PlantUMLMode::OnlinePlantUML);
|
||||
// m_plantUMLModeCombo->addItem(tr("Online Service"), PlantUMLMode::OnlinePlantUML);
|
||||
m_plantUMLModeCombo->addItem(tr("Local JAR"), PlantUMLMode::LocalPlantUML);
|
||||
|
||||
m_plantUMLServerEdit = new VLineEdit();
|
||||
m_plantUMLServerEdit = new VLineEdit(this);
|
||||
m_plantUMLServerEdit->setToolTip(tr("Server address for online PlantUML"));
|
||||
m_plantUMLServerEdit->setVisible(false);
|
||||
|
||||
m_plantUMLJarEdit = new VLineEdit();
|
||||
m_plantUMLJarEdit->setToolTip(tr("Location to the PlantUML JAR executable for local PlantUML"));
|
||||
@ -1349,12 +1354,12 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
||||
graphvizLayout->addWidget(graphvizTestBtn);
|
||||
|
||||
QFormLayout *mainLayout = new QFormLayout();
|
||||
mainLayout->addRow(tr("Open mode:"), m_openModeCombo);
|
||||
// mainLayout->addRow(tr("Open mode:"), m_openModeCombo);
|
||||
mainLayout->addRow(tr("Heading sequence:"), headingSequenceLayout);
|
||||
mainLayout->addRow(colorColumnLabel, m_colorColumnEdit);
|
||||
mainLayout->addRow(tr("MathJax configuration:"), m_mathjaxConfigEdit);
|
||||
// mainLayout->addRow(tr("MathJax configuration:"), m_mathjaxConfigEdit);
|
||||
mainLayout->addRow(tr("PlantUML:"), m_plantUMLModeCombo);
|
||||
mainLayout->addRow(tr("PlantUML server:"), m_plantUMLServerEdit);
|
||||
// mainLayout->addRow(tr("PlantUML server:"), m_plantUMLServerEdit);
|
||||
mainLayout->addRow(tr("PlantUML JAR:"), plantUMLLayout);
|
||||
mainLayout->addRow(m_graphvizCB);
|
||||
mainLayout->addRow(tr("Graphviz executable:"), graphvizLayout);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "vtipsdialog.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QWebEngineView>
|
||||
|
||||
#include "vconfigmanager.h"
|
||||
#include "vmarkdownconverter.h"
|
||||
@ -23,8 +22,8 @@ VTipsDialog::VTipsDialog(const QString &p_tipFile,
|
||||
|
||||
void VTipsDialog::setupUI(const QString &p_actionText)
|
||||
{
|
||||
m_viewer = VUtils::getWebEngineView(g_config->getBaseBackground());
|
||||
m_viewer->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_viewer = VUtils::getTextBrowser(g_config->getBaseBackground());
|
||||
// m_viewer->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
|
||||
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
@ -59,9 +58,10 @@ void VTipsDialog::readFile(const QString &p_tipFile)
|
||||
QString html = mdConverter.generateHtml(content,
|
||||
g_config->getMarkdownExtensions(),
|
||||
toc);
|
||||
html = VUtils::generateSimpleHtmlTemplate(html);
|
||||
// html = VUtils::generateSimpleHtmlTemplate(html);
|
||||
// Add a base URL to enable it to access local style files.
|
||||
m_viewer->setHtml(html, QUrl("qrc:/resources"));
|
||||
m_viewer->setHtml(html);
|
||||
// m_viewer->setSource(QUrl("qrc:/resources"));
|
||||
}
|
||||
|
||||
void VTipsDialog::showEvent(QShowEvent *p_event)
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include <QDialog>
|
||||
|
||||
class QDialogButtonBox;
|
||||
class QWebEngineView;
|
||||
class QPushButton;
|
||||
class QShowEvent;
|
||||
class QTextBrowser;
|
||||
|
||||
typedef std::function<void()> TipsDialogFunc;
|
||||
|
||||
@ -29,7 +29,7 @@ private:
|
||||
|
||||
void readFile(const QString &p_tipFile);
|
||||
|
||||
QWebEngineView *m_viewer;
|
||||
QTextBrowser *m_viewer;
|
||||
|
||||
QDialogButtonBox *m_btnBox;
|
||||
|
||||
|
@ -1,183 +0,0 @@
|
||||
#include "vupdater.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QTimer>
|
||||
#include <QWebEngineView>
|
||||
|
||||
#include "vconfigmanager.h"
|
||||
#include "vdownloader.h"
|
||||
#include "vmarkdownconverter.h"
|
||||
#include "utils/vutils.h"
|
||||
#include "vnote.h"
|
||||
|
||||
extern VConfigManager *g_config;
|
||||
|
||||
VUpdater::VUpdater(QWidget *p_parent)
|
||||
: QDialog(p_parent)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void VUpdater::setupUI()
|
||||
{
|
||||
QImage img(":/resources/icons/vnote_update.svg");
|
||||
QSize imgSize(128, 128);
|
||||
QLabel *imgLabel = new QLabel();
|
||||
imgLabel->setPixmap(QPixmap::fromImage(img.scaled(imgSize)));
|
||||
|
||||
m_versionLabel = new QLabel(tr("Current Version: v%1")
|
||||
.arg(g_config->c_version));
|
||||
|
||||
m_proLabel = new QLabel(tr("Checking for updates..."));
|
||||
m_proLabel->setOpenExternalLinks(true);
|
||||
m_proBar = new QProgressBar();
|
||||
m_proBar->setTextVisible(false);
|
||||
|
||||
m_descriptionWV = VUtils::getWebEngineView(g_config->getBaseBackground());
|
||||
m_descriptionWV->setContextMenuPolicy(Qt::NoContextMenu);
|
||||
m_descriptionWV->setHtml(VUtils::generateSimpleHtmlTemplate(VNote::s_sloganTemplate),
|
||||
QUrl("qrc:/resources"));
|
||||
|
||||
m_btnBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
m_btnBox->button(QDialogButtonBox::Ok)->setProperty("SpecialBtn", true);
|
||||
connect(m_btnBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
||||
|
||||
QVBoxLayout *verLayout = new QVBoxLayout();
|
||||
verLayout->addStretch();
|
||||
verLayout->addWidget(m_versionLabel);
|
||||
verLayout->addStretch();
|
||||
verLayout->addWidget(m_proLabel);
|
||||
verLayout->addWidget(m_proBar);
|
||||
|
||||
QHBoxLayout *topLayout = new QHBoxLayout();
|
||||
topLayout->addWidget(imgLabel);
|
||||
topLayout->addLayout(verLayout);
|
||||
topLayout->addStretch();
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout();
|
||||
mainLayout->addLayout(topLayout);
|
||||
mainLayout->addWidget(m_descriptionWV, 1);
|
||||
mainLayout->addWidget(m_btnBox);
|
||||
|
||||
m_proLabel->hide();
|
||||
m_proBar->hide();
|
||||
|
||||
setLayout(mainLayout);
|
||||
setWindowTitle(tr("VNote Update"));
|
||||
}
|
||||
|
||||
void VUpdater::showEvent(QShowEvent *p_event)
|
||||
{
|
||||
QDialog::showEvent(p_event);
|
||||
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setSingleShot(true);
|
||||
timer->setInterval(1000);
|
||||
connect(timer, &QTimer::timeout,
|
||||
this, [this]() {
|
||||
this->checkUpdates();
|
||||
});
|
||||
|
||||
timer->start();
|
||||
}
|
||||
|
||||
void VUpdater::checkUpdates()
|
||||
{
|
||||
// Change UI.
|
||||
m_proLabel->setText(tr("Checking for updates..."));
|
||||
m_proLabel->show();
|
||||
|
||||
m_proBar->setEnabled(true);
|
||||
m_proBar->setMinimum(0);
|
||||
m_proBar->setMaximum(100);
|
||||
m_proBar->reset();
|
||||
m_proBar->show();
|
||||
|
||||
QString url("https://api.github.com/repos/tamlok/vnote/releases/latest");
|
||||
VDownloader *downloader = new VDownloader(this);
|
||||
connect(downloader, &VDownloader::downloadFinished,
|
||||
this, &VUpdater::parseResult);
|
||||
downloader->download(url);
|
||||
|
||||
m_proBar->setValue(20);
|
||||
}
|
||||
|
||||
// Return if @p_latestVersion is newer than p_curVersion.
|
||||
// They are both in format xx.xx.xx.xx
|
||||
bool isNewerVersion(const QString &p_curVersion, const QString &p_latestVersion)
|
||||
{
|
||||
QStringList curList = p_curVersion.split('.', QString::SkipEmptyParts);
|
||||
QStringList latestList = p_latestVersion.split('.', QString::SkipEmptyParts);
|
||||
|
||||
int i = 0;
|
||||
for (; i < curList.size() && i < latestList.size(); ++i) {
|
||||
int a = curList[i].toInt();
|
||||
int b = latestList[i].toInt();
|
||||
|
||||
if (a > b) {
|
||||
return false;
|
||||
} else if (a < b) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (i < curList.size()) {
|
||||
// 1.2.1 vs 1.2
|
||||
return false;
|
||||
} else if (i < latestList.size()) {
|
||||
// 1.2 vs 1.2.1
|
||||
return true;
|
||||
} else {
|
||||
// 1.2 vs 1.2
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void VUpdater::parseResult(const QByteArray &p_data)
|
||||
{
|
||||
m_proBar->setValue(40);
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(p_data);
|
||||
QJsonObject json = jsonDoc.object();
|
||||
|
||||
if (jsonDoc.isNull() || json.empty()) {
|
||||
m_proBar->setEnabled(false);
|
||||
m_proLabel->setText(tr(":( Fail to check for updates.\n"
|
||||
"Please try it later."));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_proBar->setValue(100);
|
||||
|
||||
QString tag = json["tag_name"].toString();
|
||||
if (tag.startsWith('v') && tag.size() > 3) {
|
||||
tag = tag.right(tag.size() - 1);
|
||||
}
|
||||
|
||||
QString releaseName = json["name"].toString();
|
||||
QString releaseUrl = json["html_url"].toString();
|
||||
QString body = json["body"].toString();
|
||||
|
||||
m_versionLabel->setText(tr("Current Version: v%1\nLatest Version: v%2")
|
||||
.arg(g_config->c_version).arg(tag));
|
||||
if (isNewerVersion(g_config->c_version, tag)) {
|
||||
m_proLabel->setText(tr("<span style=\"font-weight: bold;\">Updates Available!</span><br/>"
|
||||
"Please visit <a href=\"%1\">GitHub Releases</a> to download the latest version.")
|
||||
.arg(releaseUrl));
|
||||
} else {
|
||||
m_proLabel->setText(tr("VNote is already the latest version."));
|
||||
}
|
||||
|
||||
QString mdText = "# " + releaseName + "\n" + body;
|
||||
VMarkdownConverter mdConverter;
|
||||
QString toc;
|
||||
QString html = mdConverter.generateHtml(mdText,
|
||||
g_config->getMarkdownExtensions(),
|
||||
toc);
|
||||
html = VUtils::generateSimpleHtmlTemplate(html);
|
||||
m_descriptionWV->setHtml(html, QUrl("qrc:/resources"));
|
||||
m_proBar->hide();
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef VUPDATER_H
|
||||
#define VUPDATER_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QByteArray>
|
||||
|
||||
class QLabel;
|
||||
class QDialogButtonBox;
|
||||
class QWebEngineView;
|
||||
class QProgressBar;
|
||||
class QShowEvent;
|
||||
|
||||
class VUpdater : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VUpdater(QWidget *p_parent = 0);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
|
||||
|
||||
private slots:
|
||||
// Calling to Github api got responses.
|
||||
void parseResult(const QByteArray &p_data);
|
||||
|
||||
private:
|
||||
void setupUI();
|
||||
|
||||
// Fetch the latest release info from Github.
|
||||
void checkUpdates();
|
||||
|
||||
QLabel *m_versionLabel;
|
||||
QWebEngineView *m_descriptionWV;
|
||||
QDialogButtonBox *m_btnBox;
|
||||
|
||||
// Progress label and bar.
|
||||
QLabel *m_proLabel;
|
||||
QProgressBar *m_proBar;
|
||||
};
|
||||
|
||||
#endif // VUPDATER_H
|
@ -463,7 +463,7 @@ static QSharedPointer<char> tryFixUnicodeData(const char *p_data)
|
||||
int cp;
|
||||
int nr = utf8CodePoint(ch, cp);
|
||||
if (nr == -1) {
|
||||
return NULL;
|
||||
return QSharedPointer<char>();
|
||||
}
|
||||
|
||||
if (cp > MAX_CODE_POINT) {
|
||||
@ -478,7 +478,7 @@ static QSharedPointer<char> tryFixUnicodeData(const char *p_data)
|
||||
}
|
||||
|
||||
if (!needFix) {
|
||||
return NULL;
|
||||
return QSharedPointer<char>();
|
||||
}
|
||||
|
||||
// Replace those chars with two one-byte chars.
|
||||
|
14
src/src.pro
14
src/src.pro
@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui webenginewidgets webchannel network svg printsupport
|
||||
QT += core gui network svg printsupport
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
@ -39,7 +39,6 @@ SOURCES += main.cpp\
|
||||
vedit.cpp \
|
||||
vdocument.cpp \
|
||||
utils/vutils.cpp \
|
||||
vpreviewpage.cpp \
|
||||
vstyleparser.cpp \
|
||||
dialog/vnewnotebookdialog.cpp \
|
||||
vmarkdownconverter.cpp \
|
||||
@ -69,7 +68,6 @@ SOURCES += main.cpp\
|
||||
vnavigationmode.cpp \
|
||||
vorphanfile.cpp \
|
||||
vcodeblockhighlighthelper.cpp \
|
||||
vwebview.cpp \
|
||||
vmdtab.cpp \
|
||||
vhtmltab.cpp \
|
||||
utils/vvim.cpp \
|
||||
@ -77,7 +75,6 @@ SOURCES += main.cpp\
|
||||
vvimindicator.cpp \
|
||||
vbuttonwithwidget.cpp \
|
||||
vtabindicator.cpp \
|
||||
dialog/vupdater.cpp \
|
||||
dialog/vorphanfileinfodialog.cpp \
|
||||
vtextblockdata.cpp \
|
||||
utils/vpreviewutils.cpp \
|
||||
@ -122,8 +119,6 @@ SOURCES += main.cpp\
|
||||
vsimplesearchinput.cpp \
|
||||
vstyleditemdelegate.cpp \
|
||||
vtreewidget.cpp \
|
||||
dialog/vexportdialog.cpp \
|
||||
vexporter.cpp \
|
||||
vsearcher.cpp \
|
||||
vsearch.cpp \
|
||||
vsearchresulttree.cpp \
|
||||
@ -140,7 +135,6 @@ SOURCES += main.cpp\
|
||||
vgraphvizhelper.cpp \
|
||||
vlivepreviewhelper.cpp \
|
||||
vmathjaxpreviewhelper.cpp \
|
||||
vmathjaxwebdocument.cpp \
|
||||
vmathjaxinplacepreviewhelper.cpp \
|
||||
vhistorylist.cpp \
|
||||
vexplorer.cpp \
|
||||
@ -175,7 +169,6 @@ HEADERS += vmainwindow.h \
|
||||
vconstants.h \
|
||||
vdocument.h \
|
||||
utils/vutils.h \
|
||||
vpreviewpage.h \
|
||||
vstyleparser.h \
|
||||
dialog/vnewnotebookdialog.h \
|
||||
vmarkdownconverter.h \
|
||||
@ -205,7 +198,6 @@ HEADERS += vmainwindow.h \
|
||||
vnavigationmode.h \
|
||||
vorphanfile.h \
|
||||
vcodeblockhighlighthelper.h \
|
||||
vwebview.h \
|
||||
vmdtab.h \
|
||||
vhtmltab.h \
|
||||
utils/vvim.h \
|
||||
@ -214,7 +206,6 @@ HEADERS += vmainwindow.h \
|
||||
vbuttonwithwidget.h \
|
||||
vedittabinfo.h \
|
||||
vtabindicator.h \
|
||||
dialog/vupdater.h \
|
||||
dialog/vorphanfileinfodialog.h \
|
||||
vtextblockdata.h \
|
||||
utils/vpreviewutils.h \
|
||||
@ -259,8 +250,6 @@ HEADERS += vmainwindow.h \
|
||||
vsimplesearchinput.h \
|
||||
vstyleditemdelegate.h \
|
||||
vtreewidget.h \
|
||||
dialog/vexportdialog.h \
|
||||
vexporter.h \
|
||||
vwordcountinfo.h \
|
||||
vsearcher.h \
|
||||
vsearch.h \
|
||||
@ -281,7 +270,6 @@ HEADERS += vmainwindow.h \
|
||||
vgraphvizhelper.h \
|
||||
vlivepreviewhelper.h \
|
||||
vmathjaxpreviewhelper.h \
|
||||
vmathjaxwebdocument.h \
|
||||
vmathjaxinplacepreviewhelper.h \
|
||||
markdownitoption.h \
|
||||
vhistorylist.h \
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <QKeySequence>
|
||||
#include <QComboBox>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QWebEngineView>
|
||||
#include <QAction>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QFormLayout>
|
||||
@ -32,11 +31,11 @@
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
#include <QTemporaryFile>
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include "vorphanfile.h"
|
||||
#include "vnote.h"
|
||||
#include "vnotebook.h"
|
||||
#include "vpreviewpage.h"
|
||||
#include "pegparser.h"
|
||||
#include "widgets/vcombobox.h"
|
||||
|
||||
@ -1463,20 +1462,10 @@ void VUtils::setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_va
|
||||
p_widget->style()->polish(p_widget);
|
||||
}
|
||||
|
||||
QWebEngineView *VUtils::getWebEngineView(const QColor &p_background, QWidget *p_parent)
|
||||
QTextBrowser *VUtils::getTextBrowser(const QColor &p_background, QWidget *p_parent)
|
||||
{
|
||||
QWebEngineView *viewer = new QWebEngineView(p_parent);
|
||||
VPreviewPage *page = new VPreviewPage(viewer);
|
||||
|
||||
// Setting the background to Qt::transparent will force GrayScale antialiasing.
|
||||
if (p_background.isValid() && p_background != Qt::transparent) {
|
||||
page->setBackgroundColor(p_background);
|
||||
}
|
||||
|
||||
viewer->setPage(page);
|
||||
viewer->setZoomFactor(g_config->getWebZoomFactor());
|
||||
|
||||
return viewer;
|
||||
QTextBrowser *browser = new QTextBrowser(p_parent);
|
||||
return browser;
|
||||
}
|
||||
|
||||
QString VUtils::getFileNameWithLocale(const QString &p_name, const QString &p_locale)
|
||||
|
@ -19,11 +19,11 @@ class VOrphanFile;
|
||||
class VNotebook;
|
||||
class QWidget;
|
||||
class QComboBox;
|
||||
class QWebEngineView;
|
||||
class QAction;
|
||||
class QTreeWidgetItem;
|
||||
class QFormLayout;
|
||||
class QTemporaryFile;
|
||||
class QTextBrowser;
|
||||
|
||||
#if !defined(V_ASSERT)
|
||||
#define V_ASSERT(cond) ((!(cond)) ? qt_assert(#cond, __FILE__, __LINE__) : qt_noop())
|
||||
@ -314,7 +314,7 @@ public:
|
||||
// Create and return a QComboBox.
|
||||
static QComboBox *getComboBox(QWidget *p_parent = nullptr);
|
||||
|
||||
static QWebEngineView *getWebEngineView(const QColor &p_background, QWidget *p_parent = nullptr);
|
||||
static QTextBrowser *getTextBrowser(const QColor &p_background, QWidget *p_parent = nullptr);
|
||||
|
||||
static void setDynamicProperty(QWidget *p_widget, const char *p_prop, bool p_val = true);
|
||||
|
||||
|
@ -292,7 +292,7 @@ int VEditArea::openFileInWindow(int windowIndex, VFile *p_file, OpenFileMode p_m
|
||||
{
|
||||
Q_ASSERT(windowIndex < splitter->count());
|
||||
VEditWindow *win = getWindow(windowIndex);
|
||||
return win->openFile(p_file, p_mode);
|
||||
return win->openFile(p_file, OpenFileMode::Edit);
|
||||
}
|
||||
|
||||
void VEditArea::setCurrentTab(int windowIndex, int tabIndex, bool setFocus)
|
||||
|
1053
src/vexporter.cpp
1053
src/vexporter.cpp
File diff suppressed because it is too large
Load Diff
213
src/vexporter.h
213
src/vexporter.h
@ -1,213 +0,0 @@
|
||||
#ifndef VEXPORTER_H
|
||||
#define VEXPORTER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QPageLayout>
|
||||
#include <QUrl>
|
||||
#include <QWebEngineDownloadItem>
|
||||
#include <QStringList>
|
||||
|
||||
#include "dialog/vexportdialog.h"
|
||||
|
||||
class QWidget;
|
||||
class VWebView;
|
||||
class VDocument;
|
||||
|
||||
class VExporter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VExporter(QWidget *p_parent = nullptr);
|
||||
|
||||
void prepareExport(const ExportOption &p_opt);
|
||||
|
||||
bool exportPDF(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool exportHTML(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool exportCustom(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
int exportPDFInOne(const QList<QString> &p_htmlFiles,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
int exportCustomInOne(const QList<QString> &p_files,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
void setAskedToStop(bool p_askedToStop);
|
||||
|
||||
signals:
|
||||
// Request to output log.
|
||||
void outputLog(const QString &p_log);
|
||||
|
||||
private slots:
|
||||
void handleLogicsFinished();
|
||||
|
||||
void handleLoadFinished(bool p_ok);
|
||||
|
||||
void handleDownloadRequested(QWebEngineDownloadItem *p_item);
|
||||
|
||||
private:
|
||||
enum class ExportState
|
||||
{
|
||||
Idle = 0,
|
||||
Cancelled,
|
||||
Busy,
|
||||
Failed,
|
||||
Successful
|
||||
};
|
||||
|
||||
|
||||
enum NoteState
|
||||
{
|
||||
NotReady = 0,
|
||||
WebLogicsReady = 0x1,
|
||||
WebLoadFinished = 0x2,
|
||||
Ready = 0x3,
|
||||
Failed = 0x4
|
||||
};
|
||||
|
||||
|
||||
void initWebViewer(VFile *p_file, const ExportOption &p_opt);
|
||||
|
||||
void clearWebViewer();
|
||||
|
||||
void clearNoteState();
|
||||
|
||||
bool isNoteStateReady() const;
|
||||
|
||||
bool isNoteStateFailed() const;
|
||||
|
||||
bool exportViaWebView(VFile *p_file,
|
||||
const ExportOption &p_opt,
|
||||
const QString &p_outputFile,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool exportToPDF(VWebView *p_webViewer,
|
||||
const QString &p_filePath,
|
||||
const QPageLayout &p_layout);
|
||||
|
||||
bool exportToPDFViaWK(VDocument *p_webDocument,
|
||||
const ExportPDFOption &p_opt,
|
||||
const QString &p_filePath,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool exportToCustom(VDocument *p_webDocument,
|
||||
const ExportCustomOption &p_opt,
|
||||
const QString &p_filePath,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool exportToHTML(VDocument *p_webDocument,
|
||||
const ExportHTMLOption &p_opt,
|
||||
const QString &p_filePath);
|
||||
|
||||
bool exportToMHTML(VWebView *p_webViewer,
|
||||
const ExportHTMLOption &p_opt,
|
||||
const QString &p_filePath);
|
||||
|
||||
bool htmlsToPDFViaWK(const QList<QString> &p_htmlFiles,
|
||||
const QString &p_filePath,
|
||||
const ExportPDFOption &p_opt,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
bool convertFilesViaCustom(const QList<QString> &p_files,
|
||||
const QString &p_filePath,
|
||||
const ExportCustomOption &p_opt,
|
||||
QString *p_errMsg = NULL);
|
||||
|
||||
void prepareWKArguments(const ExportPDFOption &p_opt);
|
||||
|
||||
int startProcess(const QString &p_program, const QStringList &p_args);
|
||||
|
||||
int startProcess(const QString &p_cmd);
|
||||
|
||||
// @p_embedImages: embed <img> as data URI.
|
||||
bool outputToHTMLFile(const QString &p_file,
|
||||
const QString &p_title,
|
||||
const QString &p_headContent,
|
||||
const QString &p_styleContent,
|
||||
const QString &p_bodyContent,
|
||||
bool p_embedCssStyle,
|
||||
bool p_completeHTML,
|
||||
bool p_embedImages);
|
||||
|
||||
// Fix @p_html's resources like url("...") with "file" or "qrc" schema.
|
||||
// Copy the resource to @p_folder and fix the url string.
|
||||
static bool fixStyleResources(const QString &p_folder,
|
||||
QString &p_html);
|
||||
|
||||
// Fix @p_html's resources like url("...") with "file" or "qrc" schema.
|
||||
// Embed the image data in data URIs.
|
||||
static bool embedStyleResources(QString &p_html);
|
||||
|
||||
// Fix @p_html's resources like <img>.
|
||||
// Copy the resource to @p_folder and fix the url string.
|
||||
static bool fixBodyResources(const QUrl &p_baseUrl,
|
||||
const QString &p_folder,
|
||||
QString &p_html);
|
||||
|
||||
// Embed @p_html's resources like <img>.
|
||||
static bool embedBodyResources(const QUrl &p_baseUrl, QString &p_html);
|
||||
|
||||
static QString getResourceRelativePath(const QString &p_file);
|
||||
|
||||
QPageLayout m_pageLayout;
|
||||
|
||||
// Will be allocated and free for each conversion.
|
||||
VWebView *m_webViewer;
|
||||
|
||||
VDocument *m_webDocument;
|
||||
|
||||
// Base URL of VWebView.
|
||||
QUrl m_baseUrl;
|
||||
|
||||
QString m_htmlTemplate;
|
||||
|
||||
// Template to hold the export HTML result.
|
||||
QString m_exportHtmlTemplate;
|
||||
|
||||
NoteState m_noteState;
|
||||
|
||||
ExportState m_state;
|
||||
|
||||
// Download state used for MIME HTML.
|
||||
QWebEngineDownloadItem::DownloadState m_downloadState;
|
||||
|
||||
// Arguments for wkhtmltopdf.
|
||||
QStringList m_wkArgs;
|
||||
|
||||
bool m_askedToStop;
|
||||
};
|
||||
|
||||
inline void VExporter::clearNoteState()
|
||||
{
|
||||
m_noteState = NoteState::NotReady;
|
||||
}
|
||||
|
||||
inline bool VExporter::isNoteStateReady() const
|
||||
{
|
||||
return m_noteState == NoteState::Ready;
|
||||
}
|
||||
|
||||
inline bool VExporter::isNoteStateFailed() const
|
||||
{
|
||||
return m_noteState & NoteState::Failed;
|
||||
}
|
||||
|
||||
inline void VExporter::setAskedToStop(bool p_askedToStop)
|
||||
{
|
||||
m_askedToStop = p_askedToStop;
|
||||
}
|
||||
#endif // VEXPORTER_H
|
@ -124,7 +124,7 @@ bool VFile::isChangedOutside(bool &p_missing) const
|
||||
|
||||
p_missing = false;
|
||||
QDateTime lm = QFileInfo(fetchPath()).lastModified();
|
||||
return lm.toSecsSinceEpoch() != m_lastModified.toSecsSinceEpoch();
|
||||
return lm.toMSecsSinceEpoch() != m_lastModified.toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
bool VFile::reload()
|
||||
|
@ -561,31 +561,18 @@ void VFileList::contextMenuRequested(QPoint pos)
|
||||
VNoteFile *file = getVFile(item);
|
||||
if (file) {
|
||||
if (file->getDocType() == DocType::Markdown) {
|
||||
QAction *openInReadAct = new QAction(VIconUtils::menuIcon(":/resources/icons/reading.svg"),
|
||||
tr("&Open In Read Mode"),
|
||||
QAction *openAct = new QAction(VIconUtils::menuIcon(":/resources/icons/editing.svg"),
|
||||
tr("Open"),
|
||||
&menu);
|
||||
openInReadAct->setToolTip(tr("Open current note in read mode"));
|
||||
connect(openInReadAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
QListWidgetItem *item = fileList->currentItem();
|
||||
if (item) {
|
||||
emit fileClicked(getVFile(item), OpenFileMode::Read, true);
|
||||
}
|
||||
});
|
||||
menu.addAction(openInReadAct);
|
||||
|
||||
QAction *openInEditAct = new QAction(VIconUtils::menuIcon(":/resources/icons/editing.svg"),
|
||||
tr("Open In &Edit Mode"),
|
||||
&menu);
|
||||
openInEditAct->setToolTip(tr("Open current note in edit mode"));
|
||||
connect(openInEditAct, &QAction::triggered,
|
||||
openAct->setToolTip(tr("Open and edit current note"));
|
||||
connect(openAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
QListWidgetItem *item = fileList->currentItem();
|
||||
if (item) {
|
||||
emit fileClicked(getVFile(item), OpenFileMode::Edit, true);
|
||||
}
|
||||
});
|
||||
menu.addAction(openInEditAct);
|
||||
menu.addAction(openAct);
|
||||
}
|
||||
|
||||
menu.addMenu(getOpenWithMenu());
|
||||
@ -824,7 +811,8 @@ void VFileList::activateItem(QListWidgetItem *p_item, bool p_restoreFocus)
|
||||
|
||||
// Qt seems not to update the QListWidget correctly. Manually force it to repaint.
|
||||
fileList->update();
|
||||
emit fileClicked(getVFile(p_item), g_config->getNoteOpenMode());
|
||||
// emit fileClicked(getVFile(p_item), g_config->getNoteOpenMode());
|
||||
emit fileClicked(getVFile(p_item), OpenFileMode::Edit);
|
||||
|
||||
if (p_restoreFocus) {
|
||||
fileList->setFocus();
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPainter>
|
||||
#include <QWebEnginePage>
|
||||
|
||||
#include "vmainwindow.h"
|
||||
#include "vdirectorytree.h"
|
||||
@ -18,13 +17,11 @@
|
||||
#include "dialog/vsettingsdialog.h"
|
||||
#include "vcaptain.h"
|
||||
#include "vedittab.h"
|
||||
#include "vwebview.h"
|
||||
#include "vexporter.h"
|
||||
#include "vmdtab.h"
|
||||
#include "vvimindicator.h"
|
||||
#include "vvimcmdlineedit.h"
|
||||
#include "vtabindicator.h"
|
||||
#include "dialog/vupdater.h"
|
||||
// #include "dialog/vupdater.h"
|
||||
#include "vorphanfile.h"
|
||||
#include "dialog/vorphanfileinfodialog.h"
|
||||
#include "vsingleinstanceguard.h"
|
||||
@ -39,7 +36,6 @@
|
||||
#include "utils/viconutils.h"
|
||||
#include "dialog/vtipsdialog.h"
|
||||
#include "vcart.h"
|
||||
#include "dialog/vexportdialog.h"
|
||||
#include "vsearcher.h"
|
||||
#include "vuniversalentry.h"
|
||||
#include "vsearchue.h"
|
||||
@ -755,22 +751,16 @@ QToolBar *VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
connect(deleteNoteAct, &QAction::triggered,
|
||||
this, &VMainWindow::deleteCurNote);
|
||||
|
||||
m_editReadAct = new QAction(this);
|
||||
connect(m_editReadAct, &QAction::triggered,
|
||||
this, &VMainWindow::toggleEditReadMode);
|
||||
|
||||
m_discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||
tr("Discard Changes And Read"),
|
||||
m_discardAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||
tr("Discard Changes"),
|
||||
this);
|
||||
VUtils::fixTextWithCaptainShortcut(m_discardExitAct, "DiscardAndRead");
|
||||
m_discardExitAct->setStatusTip(tr("Discard changes and exit edit mode"));
|
||||
connect(m_discardExitAct, &QAction::triggered,
|
||||
VUtils::fixTextWithCaptainShortcut(m_discardAct, "DiscardAndRead");
|
||||
m_discardAct->setStatusTip(tr("Discard changes"));
|
||||
connect(m_discardAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
m_editArea->readFile(true);
|
||||
});
|
||||
|
||||
updateEditReadAct(NULL);
|
||||
|
||||
saveNoteAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/save_note.svg"),
|
||||
tr("Save"), this);
|
||||
saveNoteAct->setStatusTip(tr("Save changes to current note"));
|
||||
@ -788,8 +778,7 @@ QToolBar *VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
newNoteAct->setEnabled(false);
|
||||
noteInfoAct->setEnabled(false);
|
||||
deleteNoteAct->setEnabled(false);
|
||||
m_editReadAct->setEnabled(false);
|
||||
m_discardExitAct->setEnabled(false);
|
||||
m_discardAct->setEnabled(false);
|
||||
saveNoteAct->setEnabled(false);
|
||||
|
||||
m_fileToolBar->addWidget(m_avatarBtn);
|
||||
@ -797,8 +786,7 @@ QToolBar *VMainWindow::initFileToolBar(QSize p_iconSize)
|
||||
m_fileToolBar->addAction(newNoteAct);
|
||||
m_fileToolBar->addAction(deleteNoteAct);
|
||||
m_fileToolBar->addAction(noteInfoAct);
|
||||
m_fileToolBar->addAction(m_editReadAct);
|
||||
m_fileToolBar->addAction(m_discardExitAct);
|
||||
m_fileToolBar->addAction(m_discardAct);
|
||||
m_fileToolBar->addAction(saveNoteAct);
|
||||
|
||||
return m_fileToolBar;
|
||||
@ -861,6 +849,7 @@ void VMainWindow::initHelpMenu()
|
||||
QDesktopServices::openUrl(url);
|
||||
});
|
||||
|
||||
/*
|
||||
QAction *updateAct = new QAction(tr("Check For &Updates"), this);
|
||||
updateAct->setToolTip(tr("Check for updates of VNote"));
|
||||
connect(updateAct, &QAction::triggered,
|
||||
@ -868,6 +857,7 @@ void VMainWindow::initHelpMenu()
|
||||
VUpdater updater(this);
|
||||
updater.exec();
|
||||
});
|
||||
*/
|
||||
|
||||
QAction *starAct = new QAction(tr("Star VNote on &GitHub"), this);
|
||||
starAct->setToolTip(tr("Give a star to VNote on GitHub project"));
|
||||
@ -901,7 +891,7 @@ void VMainWindow::initHelpMenu()
|
||||
helpMenu->addAction(mdGuideAct);
|
||||
helpMenu->addAction(docAct);
|
||||
helpMenu->addAction(donateAct);
|
||||
helpMenu->addAction(updateAct);
|
||||
// helpMenu->addAction(updateAct);
|
||||
helpMenu->addAction(starAct);
|
||||
helpMenu->addAction(feedbackAct);
|
||||
|
||||
@ -918,6 +908,7 @@ void VMainWindow::initMarkdownMenu()
|
||||
QMenu *markdownMenu = menuBar()->addMenu(tr("&Markdown"));
|
||||
markdownMenu->setToolTipsVisible(true);
|
||||
|
||||
/*
|
||||
initConverterMenu(markdownMenu);
|
||||
|
||||
initMarkdownitOptionMenu(markdownMenu);
|
||||
@ -969,6 +960,7 @@ void VMainWindow::initMarkdownMenu()
|
||||
});
|
||||
markdownMenu->addAction(lineNumberAct);
|
||||
lineNumberAct->setChecked(g_config->getEnableCodeBlockLineNumber());
|
||||
*/
|
||||
|
||||
QAction *previewImageAct = new QAction(tr("In-Place Preview"), this);
|
||||
previewImageAct->setToolTip(tr("Enable in-place preview (images, diagrams, and formulas) in edit mode (re-open current tabs to make it work)"));
|
||||
@ -1051,6 +1043,7 @@ void VMainWindow::initFileMenu()
|
||||
fileMenu->addSeparator();
|
||||
|
||||
// Export as PDF.
|
||||
/*
|
||||
m_exportAct = new QAction(tr("E&xport"), this);
|
||||
m_exportAct->setToolTip(tr("Export notes"));
|
||||
VUtils::fixTextWithCaptainShortcut(m_exportAct, "Export");
|
||||
@ -1058,8 +1051,10 @@ void VMainWindow::initFileMenu()
|
||||
this, &VMainWindow::handleExportAct);
|
||||
|
||||
fileMenu->addAction(m_exportAct);
|
||||
*/
|
||||
|
||||
// Print.
|
||||
/*
|
||||
m_printAct = new QAction(VIconUtils::menuIcon(":/resources/icons/print.svg"),
|
||||
tr("&Print"), this);
|
||||
m_printAct->setToolTip(tr("Print current note"));
|
||||
@ -1070,6 +1065,7 @@ void VMainWindow::initFileMenu()
|
||||
fileMenu->addAction(m_printAct);
|
||||
|
||||
fileMenu->addSeparator();
|
||||
*/
|
||||
|
||||
// Themes.
|
||||
initThemeMenu(fileMenu);
|
||||
@ -2080,14 +2076,14 @@ void VMainWindow::updateActionsStateFromTab(const VEditTab *p_tab)
|
||||
&& file->getType() == FileType::Orphan
|
||||
&& dynamic_cast<const VOrphanFile *>(file)->isSystemFile();
|
||||
|
||||
m_printAct->setEnabled(file && file->getDocType() == DocType::Markdown);
|
||||
|
||||
updateEditReadAct(p_tab);
|
||||
m_discardAct->setEnabled(file && editMode && p_tab->isModified());
|
||||
|
||||
saveNoteAct->setEnabled(file && editMode && file->isModifiable());
|
||||
deleteNoteAct->setEnabled(file && file->getType() == FileType::Note);
|
||||
noteInfoAct->setEnabled(file && !systemFile);
|
||||
|
||||
|
||||
m_attachmentBtn->setEnabled(file && file->getType() == FileType::Note);
|
||||
|
||||
m_headingBtn->setEnabled(file && editMode);
|
||||
@ -2569,6 +2565,7 @@ void VMainWindow::shortcutsHelp()
|
||||
|
||||
void VMainWindow::printNote()
|
||||
{
|
||||
/*
|
||||
if (m_printer
|
||||
|| !m_curFile
|
||||
|| m_curFile->getDocType() != DocType::Markdown) {
|
||||
@ -2600,6 +2597,7 @@ void VMainWindow::printNote()
|
||||
delete m_printer;
|
||||
m_printer = NULL;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
QAction *VMainWindow::newAction(const QIcon &p_icon,
|
||||
@ -2887,7 +2885,7 @@ bool VMainWindow::discardAndReadByCaptain(void *p_target, void *p_data)
|
||||
Q_UNUSED(p_data);
|
||||
VMainWindow *obj = static_cast<VMainWindow *>(p_target);
|
||||
if (obj->m_curTab) {
|
||||
obj->m_discardExitAct->trigger();
|
||||
obj->m_discardAct->trigger();
|
||||
obj->m_curTab->setFocus();
|
||||
|
||||
return false;
|
||||
@ -3267,56 +3265,8 @@ void VMainWindow::toggleEditReadMode()
|
||||
}
|
||||
}
|
||||
|
||||
void VMainWindow::updateEditReadAct(const VEditTab *p_tab)
|
||||
{
|
||||
static QIcon editIcon = VIconUtils::toolButtonIcon(":/resources/icons/edit_note.svg");
|
||||
static QString editText;
|
||||
static QIcon readIcon = VIconUtils::toolButtonIcon(":/resources/icons/save_exit.svg");
|
||||
static QString readText;
|
||||
|
||||
if (editText.isEmpty()) {
|
||||
QString keySeq = g_config->getShortcutKeySequence("EditReadNote");
|
||||
QKeySequence seq(keySeq);
|
||||
if (!seq.isEmpty()) {
|
||||
QString shortcutText = VUtils::getShortcutText(keySeq);
|
||||
editText = tr("Edit\t%1").arg(shortcutText);
|
||||
readText = tr("Save Changes And Read\t%1").arg(shortcutText);
|
||||
|
||||
m_editReadAct->setShortcut(seq);
|
||||
} else {
|
||||
editText = tr("Edit");
|
||||
readText = tr("Save Changes And Read");
|
||||
}
|
||||
}
|
||||
|
||||
if (!p_tab || !p_tab->isEditMode()) {
|
||||
// Edit.
|
||||
m_editReadAct->setIcon(editIcon);
|
||||
m_editReadAct->setText(editText);
|
||||
m_editReadAct->setStatusTip(tr("Edit current note"));
|
||||
|
||||
m_discardExitAct->setEnabled(false);
|
||||
} else {
|
||||
// Read.
|
||||
m_editReadAct->setIcon(readIcon);
|
||||
m_editReadAct->setText(readText);
|
||||
m_editReadAct->setStatusTip(tr("Save changes and exit edit mode"));
|
||||
|
||||
m_discardExitAct->setEnabled(true);
|
||||
}
|
||||
|
||||
m_editReadAct->setEnabled(p_tab);
|
||||
}
|
||||
|
||||
void VMainWindow::handleExportAct()
|
||||
{
|
||||
VExportDialog dialog(m_notebookSelector->currentNotebook(),
|
||||
m_dirTree->currentDirectory(),
|
||||
m_curFile,
|
||||
m_cart,
|
||||
g_config->getMdConverterType(),
|
||||
this);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
VNotebook *VMainWindow::getCurrentNotebook() const
|
||||
@ -3601,6 +3551,7 @@ void VMainWindow::setupFileListSplitOut(bool p_enabled)
|
||||
|
||||
void VMainWindow::collectUserStat() const
|
||||
{
|
||||
/*
|
||||
// One request per day.
|
||||
auto lastCheckDate = g_config->getLastUserTrackDate();
|
||||
if (lastCheckDate != QDate::currentDate()) {
|
||||
@ -3620,6 +3571,7 @@ void VMainWindow::collectUserStat() const
|
||||
}
|
||||
|
||||
QTimer::singleShot(30 * 60 * 1000, this, SLOT(collectUserStat()));
|
||||
*/
|
||||
}
|
||||
|
||||
void VMainWindow::promptForVNoteRestart()
|
||||
|
@ -319,8 +319,6 @@ private:
|
||||
|
||||
void initThemeMenu(QMenu *p_emnu);
|
||||
|
||||
void updateEditReadAct(const VEditTab *p_tab);
|
||||
|
||||
void initUniversalEntry();
|
||||
|
||||
void setMenuBarVisible(bool p_visible);
|
||||
@ -421,21 +419,14 @@ private:
|
||||
|
||||
QAction *deleteNoteAct;
|
||||
|
||||
// Toggle read and edit note.
|
||||
QAction *m_editReadAct;
|
||||
|
||||
QAction *saveNoteAct;
|
||||
|
||||
QAction *m_discardExitAct;
|
||||
QAction *m_discardAct;
|
||||
|
||||
QAction *expandViewAct;
|
||||
|
||||
QAction *m_importNoteAct;
|
||||
|
||||
QAction *m_printAct;
|
||||
|
||||
QAction *m_exportAct;
|
||||
|
||||
QAction *m_findReplaceAct;
|
||||
|
||||
QAction *m_findNextAct;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "vmathjaxpreviewhelper.h"
|
||||
|
||||
#include <QWebEngineView>
|
||||
#include <QWebChannel>
|
||||
// #include <QWebEngineView>
|
||||
// #include <QWebChannel>
|
||||
|
||||
#include "utils/vutils.h"
|
||||
#include "vmathjaxwebdocument.h"
|
||||
// #include "vmathjaxwebdocument.h"
|
||||
#include "vconfigmanager.h"
|
||||
|
||||
extern VConfigManager *g_config;
|
||||
@ -14,7 +14,7 @@ VMathJaxPreviewHelper::VMathJaxPreviewHelper(QWidget *p_parentWidget, QObject *p
|
||||
m_parentWidget(p_parentWidget),
|
||||
m_initialized(false),
|
||||
m_nextID(0),
|
||||
m_webView(NULL),
|
||||
// m_webView(NULL),
|
||||
m_webReady(false)
|
||||
{
|
||||
}
|
||||
@ -30,6 +30,7 @@ void VMathJaxPreviewHelper::doInit()
|
||||
|
||||
m_initialized = true;
|
||||
|
||||
/*
|
||||
m_webView = new QWebEngineView(m_parentWidget);
|
||||
connect(m_webView, &QWebEngineView::loadFinished,
|
||||
this, [this]() {
|
||||
@ -79,6 +80,7 @@ void VMathJaxPreviewHelper::doInit()
|
||||
QUrl baseUrl(QUrl::fromLocalFile(g_config->getDocumentPathOrHomePath() + QDir::separator()));
|
||||
m_webView->setHtml(VUtils::generateMathJaxPreviewTemplate(), baseUrl);
|
||||
m_webView->setEnabled(true);
|
||||
*/
|
||||
}
|
||||
|
||||
void VMathJaxPreviewHelper::previewMathJax(int p_identifier,
|
||||
@ -88,18 +90,7 @@ void VMathJaxPreviewHelper::previewMathJax(int p_identifier,
|
||||
{
|
||||
init();
|
||||
|
||||
if (!m_webReady) {
|
||||
auto func = std::bind(&VMathJaxWebDocument::previewMathJax,
|
||||
m_webDoc,
|
||||
p_identifier,
|
||||
p_id,
|
||||
p_timeStamp,
|
||||
p_text,
|
||||
false);
|
||||
m_pendingFunc.append(func);
|
||||
} else {
|
||||
m_webDoc->previewMathJax(p_identifier, p_id, p_timeStamp, p_text, false);
|
||||
}
|
||||
emit mathjaxPreviewResultReady(p_identifier, p_id, p_timeStamp, "png", "");
|
||||
}
|
||||
|
||||
void VMathJaxPreviewHelper::previewMathJaxFromHtml(int p_identifier,
|
||||
@ -109,18 +100,7 @@ void VMathJaxPreviewHelper::previewMathJaxFromHtml(int p_identifier,
|
||||
{
|
||||
init();
|
||||
|
||||
if (!m_webReady) {
|
||||
auto func = std::bind(&VMathJaxWebDocument::previewMathJax,
|
||||
m_webDoc,
|
||||
p_identifier,
|
||||
p_id,
|
||||
p_timeStamp,
|
||||
p_html,
|
||||
true);
|
||||
m_pendingFunc.append(func);
|
||||
} else {
|
||||
m_webDoc->previewMathJax(p_identifier, p_id, p_timeStamp, p_html, true);
|
||||
}
|
||||
emit mathjaxPreviewResultReady(p_identifier, p_id, p_timeStamp, "png", "");
|
||||
}
|
||||
|
||||
void VMathJaxPreviewHelper::previewDiagram(int p_identifier,
|
||||
@ -131,16 +111,5 @@ void VMathJaxPreviewHelper::previewDiagram(int p_identifier,
|
||||
{
|
||||
init();
|
||||
|
||||
if (!m_webReady) {
|
||||
auto func = std::bind(&VMathJaxWebDocument::previewDiagram,
|
||||
m_webDoc,
|
||||
p_identifier,
|
||||
p_id,
|
||||
p_timeStamp,
|
||||
p_lang,
|
||||
p_text);
|
||||
m_pendingFunc.append(func);
|
||||
} else {
|
||||
m_webDoc->previewDiagram(p_identifier, p_id, p_timeStamp, p_lang, p_text);
|
||||
}
|
||||
emit diagramPreviewResultReady(p_identifier, p_id, p_timeStamp, "png", "");
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
|
||||
#include "vconstants.h"
|
||||
|
||||
class QWebEngineView;
|
||||
class VMathJaxWebDocument;
|
||||
// class QWebEngineView;
|
||||
// class VMathJaxWebDocument;
|
||||
class QWidget;
|
||||
|
||||
typedef std::function<void(void)> PendingFunc;
|
||||
@ -67,9 +67,9 @@ private:
|
||||
|
||||
int m_nextID;
|
||||
|
||||
QWebEngineView *m_webView;
|
||||
// QWebEngineView *m_webView;
|
||||
|
||||
VMathJaxWebDocument *m_webDoc;
|
||||
// VMathJaxWebDocument *m_webDoc;
|
||||
|
||||
bool m_webReady;
|
||||
|
||||
|
@ -1,54 +0,0 @@
|
||||
#include "vmathjaxwebdocument.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
VMathJaxWebDocument::VMathJaxWebDocument(QObject *p_parent)
|
||||
: QObject(p_parent)
|
||||
{
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::previewMathJax(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_text,
|
||||
bool p_isHtml)
|
||||
{
|
||||
emit requestPreviewMathJax(p_identifier, p_id, p_timeStamp, p_text, p_isHtml);
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::mathjaxResultReady(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data)
|
||||
{
|
||||
emit mathjaxPreviewResultReady(p_identifier, p_id, p_timeStamp, p_format, p_data);
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::diagramResultReady(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data)
|
||||
{
|
||||
emit diagramPreviewResultReady(p_identifier, p_id, p_timeStamp, p_format, p_data);
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::previewDiagram(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_lang,
|
||||
const QString &p_text)
|
||||
{
|
||||
emit requestPreviewDiagram(p_identifier,
|
||||
p_id,
|
||||
p_timeStamp,
|
||||
p_lang,
|
||||
p_text);
|
||||
}
|
||||
|
||||
void VMathJaxWebDocument::setLog(const QString &p_log)
|
||||
{
|
||||
qDebug() << "JS:" << p_log;
|
||||
}
|
||||
|
@ -1,69 +0,0 @@
|
||||
#ifndef VMATHJAXWEBDOCUMENT_H
|
||||
#define VMATHJAXWEBDOCUMENT_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "vconstants.h"
|
||||
|
||||
class VMathJaxWebDocument : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VMathJaxWebDocument(QObject *p_parent = nullptr);
|
||||
|
||||
void previewMathJax(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_text,
|
||||
bool p_isHtml);
|
||||
|
||||
void previewDiagram(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_lang,
|
||||
const QString &p_text);
|
||||
|
||||
public slots:
|
||||
// Will be called in the HTML side
|
||||
|
||||
void mathjaxResultReady(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data);
|
||||
|
||||
void diagramResultReady(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data);
|
||||
|
||||
void setLog(const QString &p_log);
|
||||
|
||||
signals:
|
||||
void requestPreviewMathJax(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_text,
|
||||
bool p_isHtml);
|
||||
|
||||
void requestPreviewDiagram(int p_identifier,
|
||||
int p_id,
|
||||
unsigned long long p_timeStamp,
|
||||
const QString &p_lang,
|
||||
const QString &p_text);
|
||||
|
||||
void mathjaxPreviewResultReady(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data);
|
||||
|
||||
void diagramPreviewResultReady(int p_identifier,
|
||||
int p_id,
|
||||
TimeStamp p_timeStamp,
|
||||
const QString &p_format,
|
||||
const QString &p_data);
|
||||
};
|
||||
|
||||
#endif // VMATHJAXWEBDOCUMENT_H
|
@ -360,9 +360,11 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
||||
pasteAct = getActionByObjectName(actions, "edit-paste");
|
||||
}
|
||||
|
||||
/*
|
||||
if (copyAct && copyAct->isEnabled()) {
|
||||
initCopyAsMenu(copyAct, menu.data());
|
||||
}
|
||||
*/
|
||||
|
||||
if (pasteAct && pasteAct->isEnabled()) {
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
@ -371,9 +373,11 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
||||
initPasteAsBlockQuoteMenu(pasteAct, menu.data());
|
||||
}
|
||||
|
||||
/*
|
||||
if (mimeData->hasHtml()) {
|
||||
initPasteAfterParseMenu(pasteAct, menu.data());
|
||||
}
|
||||
*/
|
||||
|
||||
QAction *pptAct = new QAction(tr("Paste As Plain Text"), menu.data());
|
||||
VUtils::fixTextWithShortcut(pptAct, "PastePlainText");
|
||||
@ -387,44 +391,6 @@ void VMdEditor::contextMenuEvent(QContextMenuEvent *p_event)
|
||||
if (!textCursor().hasSelection()) {
|
||||
initLinkAndPreviewMenu(firstAct, menu.data(), p_event->pos());
|
||||
|
||||
QAction *saveExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/save_exit.svg"),
|
||||
tr("&Save Changes And Read"),
|
||||
menu.data());
|
||||
saveExitAct->setToolTip(tr("Save changes and exit edit mode"));
|
||||
connect(saveExitAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
emit m_object->saveAndRead();
|
||||
});
|
||||
|
||||
QAction *discardExitAct = new QAction(VIconUtils::menuIcon(":/resources/icons/discard_exit.svg"),
|
||||
tr("&Discard Changes And Read"),
|
||||
menu.data());
|
||||
discardExitAct->setToolTip(tr("Discard changes and exit edit mode"));
|
||||
connect(discardExitAct, &QAction::triggered,
|
||||
this, [this]() {
|
||||
emit m_object->discardAndRead();
|
||||
});
|
||||
|
||||
VMdTab *mdtab = dynamic_cast<VMdTab *>(m_editTab);
|
||||
if (mdtab) {
|
||||
QAction *toggleLivePreviewAct = new QAction(tr("Live Preview For Graphs"), menu.data());
|
||||
toggleLivePreviewAct->setToolTip(tr("Toggle live preview panel for graphs"));
|
||||
VUtils::fixTextWithCaptainShortcut(toggleLivePreviewAct, "LivePreview");
|
||||
connect(toggleLivePreviewAct, &QAction::triggered,
|
||||
this, [mdtab]() {
|
||||
mdtab->toggleLivePreview();
|
||||
});
|
||||
|
||||
menu->insertAction(firstAct, toggleLivePreviewAct);
|
||||
menu->insertAction(toggleLivePreviewAct, discardExitAct);
|
||||
menu->insertAction(discardExitAct, saveExitAct);
|
||||
menu->insertSeparator(toggleLivePreviewAct);
|
||||
} else {
|
||||
menu->insertAction(firstAct, discardExitAct);
|
||||
menu->insertAction(discardExitAct, saveExitAct);
|
||||
menu->insertSeparator(discardExitAct);
|
||||
}
|
||||
|
||||
if (firstAct) {
|
||||
menu->insertSeparator(firstAct);
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include <QtWidgets>
|
||||
#include <QWebChannel>
|
||||
// #include <QWebChannel>
|
||||
#include <QFileInfo>
|
||||
#include <QCoreApplication>
|
||||
#include <QWebEngineProfile>
|
||||
// #include <QWebEngineProfile>
|
||||
#include "vmdtab.h"
|
||||
#include "vdocument.h"
|
||||
#include "vnote.h"
|
||||
#include "utils/vutils.h"
|
||||
#include "vpreviewpage.h"
|
||||
// #include "vpreviewpage.h"
|
||||
#include "pegmarkdownhighlighter.h"
|
||||
#include "vconfigmanager.h"
|
||||
#include "vmarkdownconverter.h"
|
||||
@ -34,7 +34,7 @@ VMdTab::VMdTab(VFile *p_file, VEditArea *p_editArea,
|
||||
OpenFileMode p_mode, QWidget *p_parent)
|
||||
: VEditTab(p_file, p_editArea, p_parent),
|
||||
m_editor(NULL),
|
||||
m_webViewer(NULL),
|
||||
// m_webViewer(NULL),
|
||||
m_document(NULL),
|
||||
m_mdConType(g_config->getMdConverterType()),
|
||||
m_enableHeadingSequence(false),
|
||||
@ -79,6 +79,8 @@ VMdTab::VMdTab(VFile *p_file, VEditArea *p_editArea,
|
||||
m_livePreviewTimer->setInterval(500);
|
||||
connect(m_livePreviewTimer, &QTimer::timeout,
|
||||
this, [this]() {
|
||||
Q_ASSERT(false);
|
||||
/*
|
||||
QString text = m_webViewer->selectedText().trimmed();
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
@ -92,6 +94,7 @@ VMdTab::VMdTab(VFile *p_file, VEditArea *p_editArea,
|
||||
info.m_startPos,
|
||||
info.m_endPos);
|
||||
}
|
||||
*/
|
||||
});
|
||||
|
||||
QTimer::singleShot(50, this, [this, p_mode]() {
|
||||
@ -121,6 +124,7 @@ void VMdTab::setupUI()
|
||||
|
||||
void VMdTab::showFileReadMode()
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
m_isEditMode = false;
|
||||
|
||||
// Will recover the header when web side is ready.
|
||||
@ -288,13 +292,11 @@ bool VMdTab::closeFile(bool p_forced)
|
||||
Q_ASSERT(m_editor);
|
||||
m_editor->reloadFile();
|
||||
m_editor->endEdit();
|
||||
|
||||
showFileReadMode();
|
||||
} else {
|
||||
readFile();
|
||||
}
|
||||
|
||||
return !m_isEditMode;
|
||||
readFile();
|
||||
|
||||
return !isModified();
|
||||
}
|
||||
|
||||
void VMdTab::editFile()
|
||||
@ -353,7 +355,7 @@ void VMdTab::readFile(bool p_discard)
|
||||
m_editor->endEdit();
|
||||
}
|
||||
|
||||
showFileReadMode();
|
||||
showFileEditMode();
|
||||
}
|
||||
|
||||
bool VMdTab::saveFile()
|
||||
@ -434,6 +436,7 @@ void VMdTab::discardAndRead()
|
||||
|
||||
void VMdTab::setupMarkdownViewer()
|
||||
{
|
||||
/*
|
||||
m_webViewer = new VWebView(m_file, this);
|
||||
connect(m_webViewer, &VWebView::editNote,
|
||||
this, &VMdTab::editFile);
|
||||
@ -455,10 +458,12 @@ void VMdTab::setupMarkdownViewer()
|
||||
// Avoid white flash before loading content.
|
||||
// Setting Qt::transparent will force GrayScale antialias rendering.
|
||||
page->setBackgroundColor(g_config->getBaseBackground());
|
||||
*/
|
||||
|
||||
m_document = new VDocument(m_file, m_webViewer);
|
||||
m_document = new VDocument(m_file, this);
|
||||
m_documentID = m_document->registerIdentifier();
|
||||
|
||||
/*
|
||||
QWebChannel *channel = new QWebChannel(m_webViewer);
|
||||
channel->registerObject(QStringLiteral("content"), m_document);
|
||||
connect(m_document, &VDocument::tocChanged,
|
||||
@ -515,6 +520,7 @@ void VMdTab::setupMarkdownViewer()
|
||||
m_file->getBaseUrl());
|
||||
|
||||
m_splitter->addWidget(m_webViewer);
|
||||
*/
|
||||
}
|
||||
|
||||
void VMdTab::setupMarkdownEditor()
|
||||
@ -766,8 +772,9 @@ void VMdTab::nextMatch(const QString &p_text, uint p_options, bool p_forward)
|
||||
void VMdTab::findTextInWebView(const QString &p_text, uint p_options,
|
||||
bool /* p_peek */, bool p_forward)
|
||||
{
|
||||
V_ASSERT(m_webViewer);
|
||||
V_ASSERT(false);
|
||||
|
||||
/*
|
||||
QWebEnginePage::FindFlags flags;
|
||||
if (p_options & FindOption::CaseSensitive) {
|
||||
flags |= QWebEnginePage::FindCaseSensitively;
|
||||
@ -778,6 +785,7 @@ void VMdTab::findTextInWebView(const QString &p_text, uint p_options,
|
||||
}
|
||||
|
||||
m_webViewer->findText(p_text, flags);
|
||||
*/
|
||||
}
|
||||
|
||||
QString VMdTab::getSelectedText() const
|
||||
@ -787,15 +795,19 @@ QString VMdTab::getSelectedText() const
|
||||
QTextCursor cursor = m_editor->textCursor();
|
||||
return cursor.selectedText();
|
||||
} else {
|
||||
return m_webViewer->selectedText();
|
||||
Q_ASSERT(false);
|
||||
// return m_webViewer->selectedText();
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
void VMdTab::clearSearchedWordHighlight()
|
||||
{
|
||||
/*
|
||||
if (m_webViewer) {
|
||||
m_webViewer->findText("");
|
||||
}
|
||||
*/
|
||||
|
||||
if (m_editor) {
|
||||
m_editor->clearSearchedWordHighlight();
|
||||
@ -804,8 +816,7 @@ void VMdTab::clearSearchedWordHighlight()
|
||||
|
||||
void VMdTab::handleWebKeyPressed(int p_key, bool p_ctrl, bool p_shift, bool p_meta)
|
||||
{
|
||||
V_ASSERT(m_webViewer);
|
||||
|
||||
Q_ASSERT(false);
|
||||
#if defined(Q_OS_MACOS) || defined(Q_OS_MAC)
|
||||
bool macCtrl = p_meta;
|
||||
#else
|
||||
@ -841,7 +852,7 @@ void VMdTab::handleWebKeyPressed(int p_key, bool p_ctrl, bool p_shift, bool p_me
|
||||
case 48:
|
||||
if (p_ctrl || macCtrl) {
|
||||
// Recover zoom.
|
||||
m_webViewer->setZoomFactor(1);
|
||||
// m_webViewer->setZoomFactor(1);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -898,6 +909,8 @@ void VMdTab::zoom(bool p_zoomIn, qreal p_step)
|
||||
|
||||
void VMdTab::zoomWebPage(bool p_zoomIn, qreal p_step)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
/*
|
||||
V_ASSERT(m_webViewer);
|
||||
|
||||
qreal curFactor = m_webViewer->zoomFactor();
|
||||
@ -909,11 +922,7 @@ void VMdTab::zoomWebPage(bool p_zoomIn, qreal p_step)
|
||||
}
|
||||
|
||||
m_webViewer->setZoomFactor(newFactor);
|
||||
}
|
||||
|
||||
VWebView *VMdTab::getWebViewer() const
|
||||
{
|
||||
return m_webViewer;
|
||||
*/
|
||||
}
|
||||
|
||||
MarkdownConverterType VMdTab::getMarkdownConverterType() const
|
||||
@ -925,7 +934,8 @@ void VMdTab::focusChild()
|
||||
{
|
||||
switch (m_mode) {
|
||||
case Mode::Read:
|
||||
m_webViewer->setFocus();
|
||||
Q_ASSERT(false);
|
||||
// m_webViewer->setFocus();
|
||||
break;
|
||||
|
||||
case Mode::Edit:
|
||||
@ -933,10 +943,11 @@ void VMdTab::focusChild()
|
||||
break;
|
||||
|
||||
case Mode::EditPreview:
|
||||
Q_ASSERT(false);
|
||||
if (m_editor->isVisible()) {
|
||||
m_editor->setFocus();
|
||||
} else {
|
||||
m_webViewer->setFocus();
|
||||
// m_webViewer->setFocus();
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1158,7 +1169,7 @@ void VMdTab::reload()
|
||||
|
||||
// Reload web viewer.
|
||||
m_ready &= ~TabReady::ReadMode;
|
||||
m_webViewer->reload();
|
||||
// m_webViewer->reload();
|
||||
|
||||
if (!m_isEditMode) {
|
||||
VUtils::sleepWait(500);
|
||||
@ -1287,8 +1298,10 @@ void VMdTab::handleFileOrDirectoryChange(bool p_isFile, UpdateAction p_act)
|
||||
{
|
||||
// Reload the web view with new base URL.
|
||||
m_headerFromEditMode = m_currentHeader;
|
||||
/*
|
||||
m_webViewer->setHtml(VUtils::generateHtmlTemplate(m_mdConType),
|
||||
m_file->getBaseUrl());
|
||||
*/
|
||||
|
||||
if (m_editor) {
|
||||
m_editor->updateInitAndInsertedImages(p_isFile, p_act);
|
||||
@ -1436,7 +1449,8 @@ bool VMdTab::executeVimCommandInWebView(const QString &p_cmd)
|
||||
msg = tr("Quit");
|
||||
} else if (p_cmd == "nohlsearch" || p_cmd == "noh") {
|
||||
// :nohlsearch, clear highlight search.
|
||||
m_webViewer->findText("");
|
||||
Q_ASSERT(false);
|
||||
// m_webViewer->findText("");
|
||||
} else {
|
||||
validCommand = false;
|
||||
}
|
||||
@ -1450,6 +1464,7 @@ bool VMdTab::executeVimCommandInWebView(const QString &p_cmd)
|
||||
return validCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
void VMdTab::handleDownloadRequested(QWebEngineDownloadItem *p_item)
|
||||
{
|
||||
connect(p_item, &QWebEngineDownloadItem::stateChanged,
|
||||
@ -1473,6 +1488,7 @@ void VMdTab::handleDownloadRequested(QWebEngineDownloadItem *p_item)
|
||||
|
||||
void VMdTab::handleSavePageRequested()
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
static QString lastPath = g_config->getDocumentPathOrHomePath();
|
||||
|
||||
QStringList filters;
|
||||
@ -1500,8 +1516,9 @@ void VMdTab::handleSavePageRequested()
|
||||
|
||||
emit statusMessage(tr("Saving page to %1").arg(fileName));
|
||||
|
||||
m_webViewer->page()->save(fileName, format);
|
||||
// m_webViewer->page()->save(fileName, format);
|
||||
}
|
||||
*/
|
||||
|
||||
VWordCountInfo VMdTab::fetchWordCountInfo(bool p_editMode) const
|
||||
{
|
||||
@ -1527,7 +1544,8 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
return;
|
||||
}
|
||||
|
||||
qreal factor = m_webViewer->zoomFactor();
|
||||
// qreal factor = m_webViewer->zoomFactor();
|
||||
qreal factor = 1.0;
|
||||
if (m_mode == Mode::Read) {
|
||||
m_readWebViewState->m_zoomFactor = factor;
|
||||
} else if (m_mode == Mode::EditPreview) {
|
||||
@ -1539,12 +1557,13 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
|
||||
switch (p_mode) {
|
||||
case Mode::Read:
|
||||
Q_ASSERT(false);
|
||||
if (m_editor) {
|
||||
m_editor->hide();
|
||||
}
|
||||
|
||||
m_webViewer->setInPreview(false);
|
||||
m_webViewer->show();
|
||||
// m_webViewer->setInPreview(false);
|
||||
// m_webViewer->show();
|
||||
|
||||
// Fix the bug introduced by 051088be31dbffa3c04e2d382af15beec40d5fdb
|
||||
// which replace QStackedLayout with QSplitter.
|
||||
@ -1554,7 +1573,7 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
m_readWebViewState.reset(new WebViewState());
|
||||
m_readWebViewState->m_zoomFactor = factor;
|
||||
} else if (factor != m_readWebViewState->m_zoomFactor) {
|
||||
m_webViewer->setZoomFactor(m_readWebViewState->m_zoomFactor);
|
||||
// m_webViewer->setZoomFactor(m_readWebViewState->m_zoomFactor);
|
||||
}
|
||||
|
||||
m_document->setPreviewEnabled(false);
|
||||
@ -1562,7 +1581,7 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
|
||||
case Mode::Edit:
|
||||
m_document->muteWebView(true);
|
||||
m_webViewer->hide();
|
||||
// m_webViewer->hide();
|
||||
m_editor->show();
|
||||
|
||||
QCoreApplication::sendPostedEvents();
|
||||
@ -1571,9 +1590,10 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
|
||||
case Mode::EditPreview:
|
||||
Q_ASSERT(m_editor);
|
||||
Q_ASSERT(false);
|
||||
m_document->muteWebView(true);
|
||||
m_webViewer->setInPreview(true);
|
||||
m_webViewer->show();
|
||||
// m_webViewer->setInPreview(true);
|
||||
// m_webViewer->show();
|
||||
m_editor->show();
|
||||
|
||||
QCoreApplication::sendPostedEvents();
|
||||
@ -1597,7 +1617,7 @@ void VMdTab::setCurrentMode(Mode p_mode)
|
||||
newSizes.append(b);
|
||||
m_splitter->setSizes(newSizes);
|
||||
} else if (factor != m_previewWebViewState->m_zoomFactor) {
|
||||
m_webViewer->setZoomFactor(m_previewWebViewState->m_zoomFactor);
|
||||
// m_webViewer->setZoomFactor(m_previewWebViewState->m_zoomFactor);
|
||||
}
|
||||
|
||||
m_document->setPreviewEnabled(true);
|
||||
@ -1650,9 +1670,10 @@ bool VMdTab::expandRestorePreviewArea()
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(false);
|
||||
if (m_editor->isVisible()) {
|
||||
m_editor->hide();
|
||||
m_webViewer->setFocus();
|
||||
// m_webViewer->setFocus();
|
||||
} else {
|
||||
m_editor->show();
|
||||
m_editor->setFocus();
|
||||
|
12
src/vmdtab.h
12
src/vmdtab.h
@ -9,12 +9,12 @@
|
||||
#include "vmarkdownconverter.h"
|
||||
#include "vconfigmanager.h"
|
||||
|
||||
class VWebView;
|
||||
// class VWebView;
|
||||
class VDocument;
|
||||
class VMdEditor;
|
||||
class VInsertSelector;
|
||||
class QTimer;
|
||||
class QWebEngineDownloadItem;
|
||||
// class QWebEngineDownloadItem;
|
||||
class QSplitter;
|
||||
class VLivePreviewHelper;
|
||||
class VMathJaxInplacePreviewHelper;
|
||||
@ -69,7 +69,7 @@ public:
|
||||
|
||||
void clearSearchedWordHighlight() Q_DECL_OVERRIDE;
|
||||
|
||||
VWebView *getWebViewer() const;
|
||||
// VWebView *getWebViewer() const;
|
||||
|
||||
VMdEditor *getEditor() const;
|
||||
|
||||
@ -153,10 +153,10 @@ private slots:
|
||||
void restoreFromTabInfo();
|
||||
|
||||
// Handle download request from web page.
|
||||
void handleDownloadRequested(QWebEngineDownloadItem *p_item);
|
||||
// void handleDownloadRequested(QWebEngineDownloadItem *p_item);
|
||||
|
||||
// Handle save page request.
|
||||
void handleSavePageRequested();
|
||||
// void handleSavePageRequested();
|
||||
|
||||
// Selection changed in web.
|
||||
void handleWebSelectionChanged();
|
||||
@ -247,7 +247,7 @@ private:
|
||||
bool previewExpanded() const;
|
||||
|
||||
VMdEditor *m_editor;
|
||||
VWebView *m_webViewer;
|
||||
// VWebView *m_webViewer;
|
||||
VDocument *m_document;
|
||||
MarkdownConverterType m_mdConType;
|
||||
|
||||
|
@ -232,7 +232,7 @@ QString VNote::getNavigationLabelStyle(const QString &p_str, bool p_small) const
|
||||
font.setBold(true);
|
||||
QFontMetrics fm(font);
|
||||
pxWidth = fm.width(p_str);
|
||||
pxHeight = fm.capHeight() + 5;
|
||||
pxHeight = fm.height() + 5;
|
||||
lastLen = p_str.size();
|
||||
}
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
#include "vpreviewpage.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "vmainwindow.h"
|
||||
|
||||
extern VMainWindow *g_mainWin;
|
||||
|
||||
VPreviewPage::VPreviewPage(QWidget *parent) : QWebEnginePage(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool VPreviewPage::acceptNavigationRequest(const QUrl &p_url,
|
||||
QWebEnginePage::NavigationType p_type,
|
||||
bool p_isMainFrame)
|
||||
{
|
||||
Q_UNUSED(p_type);
|
||||
|
||||
if (p_url.isLocalFile()) {
|
||||
QString filePath = p_url.toLocalFile();
|
||||
if (g_mainWin->tryOpenInternalFile(filePath)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!p_isMainFrame) {
|
||||
return true;
|
||||
} else if (p_url.scheme() == "data") {
|
||||
// Qt 5.12 will trigger this when calling QWebEngineView.setHtml().
|
||||
return true;
|
||||
}
|
||||
|
||||
QDesktopServices::openUrl(p_url);
|
||||
return false;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef VPREVIEWPAGE_H
|
||||
#define VPREVIEWPAGE_H
|
||||
|
||||
#include <QWebEnginePage>
|
||||
|
||||
class VPreviewPage : public QWebEnginePage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit VPreviewPage(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
bool acceptNavigationRequest(const QUrl &p_url,
|
||||
NavigationType p_type,
|
||||
bool p_isMainFrame);
|
||||
};
|
||||
|
||||
#endif // VPREVIEWPAGE_H
|
@ -505,7 +505,7 @@ struct VSearchResultItem
|
||||
VSearchResultItem::MatchType p_matchType,
|
||||
const QString &p_text,
|
||||
const QString &p_path,
|
||||
const QSharedPointer<VSearchConfig> &p_config = nullptr)
|
||||
const QSharedPointer<VSearchConfig> &p_config = QSharedPointer<VSearchConfig>())
|
||||
: m_type(p_type),
|
||||
m_matchType(p_matchType),
|
||||
m_text(p_text),
|
||||
|
@ -27,7 +27,7 @@ extern VWebUtils *g_webUtils;
|
||||
static const QString c_ClipboardPropertyMark = "CopiedImageURLAltered";
|
||||
|
||||
VWebView::VWebView(VFile *p_file, QWidget *p_parent)
|
||||
: QWebEngineView(p_parent),
|
||||
: QTextBrowser(p_parent),
|
||||
m_file(p_file),
|
||||
m_copyImageUrlActionHooked(false),
|
||||
m_afterCopyImage(false),
|
||||
@ -481,3 +481,14 @@ void VWebView::initPreviewTunnelMenu(QAction *p_before, QMenu *p_menu)
|
||||
|
||||
p_menu->insertMenu(p_before, subMenu);
|
||||
}
|
||||
|
||||
QString VWebView::selectedText() const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
void VWebView::setHtml(const QString &p_html, const QUrl &p_baseUrl)
|
||||
{
|
||||
QTextBrowser::setHtml(p_html);
|
||||
setSource(p_baseUrl);
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
#ifndef VWEBVIEW_H
|
||||
#define VWEBVIEW_H
|
||||
|
||||
#include <QWebEngineView>
|
||||
#include <QTextBrowser>
|
||||
#include <QClipboard>
|
||||
#include <QRegExp>
|
||||
|
||||
class VFile;
|
||||
class QMenu;
|
||||
|
||||
class VWebView : public QWebEngineView
|
||||
class VWebView : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -17,6 +17,10 @@ public:
|
||||
|
||||
void setInPreview(bool p_preview);
|
||||
|
||||
QString selectedText() const;
|
||||
|
||||
void setHtml(const QString &p_html, const QUrl &p_baseUrl = QUrl());
|
||||
|
||||
signals:
|
||||
void editNote();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user