| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- #ifndef VEXPORTDIALOG_H
- #define VEXPORTDIALOG_H
- #include <QDialog>
- #include <QPageLayout>
- #include "vconstants.h"
- class QLabel;
- class VLineEdit;
- class QDialogButtonBox;
- class QComboBox;
- class QPushButton;
- class QGroupBox;
- class QPlainTextEdit;
- class VNotebook;
- class VDirectory;
- class VFile;
- class VCart;
- class VExporter;
- enum class ExportSource
- {
- CurrentNote = 0,
- CurrentDirectory,
- CurrentNotebook,
- Cart
- };
- enum class ExportFormat
- {
- Markdown = 0,
- HTML,
- PDF
- };
- struct ExportOption
- {
- ExportOption(ExportSource p_source,
- ExportFormat p_format,
- MarkdownConverterType p_renderer,
- const QString &p_renderBg,
- const QString &p_renderStyle,
- const QString &p_renderCodeBlockStyle,
- QPageLayout *p_layout)
- : 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_layout(p_layout)
- {
- }
- ExportSource m_source;
- ExportFormat m_format;
- MarkdownConverterType m_renderer;
- // Background name.
- QString m_renderBg;
- QString m_renderStyle;
- QString m_renderCodeBlockStyle;
- QPageLayout *m_layout;
- };
- 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 handleBrowseBtnClicked();
- void handleInputChanged();
- void handleLayoutBtnClicked();
- void handleCurrentFormatChanged(int p_index);
- private:
- void setupUI();
- QWidget *setupPDFAdvancedSettings();
- 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);
- int doExport(VDirectory *p_directory,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- int doExport(VNotebook *p_notebook,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- int doExport(VCart *p_cart,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- int doExportMarkdown(VFile *p_file,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- int doExportPDF(VFile *p_file,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- int doExportHTML(VFile *p_file,
- const ExportOption &p_opt,
- const QString &p_outputFolder,
- QString *p_errMsg = NULL);
- // Return false if we could not continue.
- bool checkUserAction();
- void updatePageLayoutLabel();
- QComboBox *m_srcCB;
- QComboBox *m_formatCB;
- QComboBox *m_rendererCB;
- QComboBox *m_renderBgCB;
- QComboBox *m_renderStyleCB;
- QComboBox *m_renderCodeBlockStyleCB;
- VLineEdit *m_outputEdit;
- QPushButton *m_browseBtn;
- QGroupBox *m_basicBox;
- QGroupBox *m_settingBox;
- QWidget *m_pdfSettings;
- QPlainTextEdit *m_consoleEdit;
- QDialogButtonBox *m_btnBox;
- QPushButton *m_openBtn;
- QPushButton *m_exportBtn;
- QLabel *m_layoutLabel;
- QPushButton *m_layoutBtn;
- VNotebook *m_notebook;
- VDirectory *m_directory;
- VFile *m_file;
- VCart *m_cart;
- 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 output folder path.
- static QString s_lastOutputFolder;
- // Last export format.
- static ExportFormat s_lastExportFormat;
- };
- #endif // VEXPORTDIALOG_H
|