exporter: OK button to close dialog after exported

This commit is contained in:
Le Tan 2017-07-22 12:17:51 +08:00
parent 226263f77c
commit b4873feb41
2 changed files with 15 additions and 1 deletions

View File

@ -31,7 +31,8 @@ VExporter::VExporter(MarkdownConverterType p_mdType, QWidget *p_parent)
: QDialog(p_parent), m_webViewer(NULL), m_mdType(p_mdType), : QDialog(p_parent), m_webViewer(NULL), m_mdType(p_mdType),
m_file(NULL), m_type(ExportType::PDF), m_source(ExportSource::Invalid), m_file(NULL), m_type(ExportType::PDF), m_source(ExportSource::Invalid),
m_noteState(NoteState::NotReady), m_state(ExportState::Idle), m_noteState(NoteState::NotReady), m_state(ExportState::Idle),
m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0.0, 0.0, 0.0, 0.0))) m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0.0, 0.0, 0.0, 0.0))),
m_exported(false)
{ {
initMarkdownTemplate(); initMarkdownTemplate();
@ -266,6 +267,14 @@ bool VExporter::isNoteStateFailed() const
void VExporter::startExport() void VExporter::startExport()
{ {
QPushButton *cancelBtn = m_btnBox->button(QDialogButtonBox::Cancel);
if (m_exported) {
cancelBtn->show();
m_exported = false;
accept();
}
int exportedNum = 0; int exportedNum = 0;
enableUserInput(false); enableUserInput(false);
V_ASSERT(m_state == ExportState::Idle); V_ASSERT(m_state == ExportState::Idle);
@ -347,7 +356,9 @@ exit:
} }
if (exportedNum) { if (exportedNum) {
m_exported = true;
m_openBtn->show(); m_openBtn->show();
cancelBtn->hide();
} }
m_state = ExportState::Idle; m_state = ExportState::Idle;

View File

@ -112,6 +112,9 @@ private:
QPageLayout m_pageLayout; QPageLayout m_pageLayout;
// Whether a PDF has been exported.
bool m_exported;
// The default directory. // The default directory.
static QString s_defaultPathDir; static QString s_defaultPathDir;
}; };