30 #include "ui_shortcuts_dialog.h"
32 #include <QApplication>
34 #include <QFileDialog>
36 #include <QTextDocument>
37 #include <QPageLayout>
39 #include <QPrintPreviewDialog>
40 #include <QPrintDialog>
45 #include "../core/vapplication.h"
51 , isInitialized(false)
54 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
70 QDialog::showEvent(event);
71 if (event->spontaneous())
82 setMaximumSize(size());
83 setMinimumSize(size());
90 ui->shortcuts_TextBrowser->selectAll();
91 ui->shortcuts_TextBrowser->copy();
96 QPrintDialog printDialog(&printer);
97 if(printDialog.exec())
99 QTextDocument textDocument;
100 textDocument.setHtml(
ui->shortcuts_TextBrowser->toHtml());
101 textDocument.print(&printer);
107 QString filename = QFileDialog::getSaveFileName(
nullptr, tr(
"Export PDF"), QString(),
108 "*.pdf",
nullptr, QFileDialog::DontUseNativeDialog);
110 if (QFileInfo(filename).suffix().isEmpty())
112 filename.append(
".pdf");
114 QPrinter printer(QPrinter::PrinterResolution);
115 printer.setOutputFormat(QPrinter::PdfFormat);
116 printer.setPageSize(printer.pageLayout().pageSize());
117 printer.setOutputFileName(filename);
119 QTextDocument textDocument;
120 textDocument.setHtml(
ui->shortcuts_TextBrowser->toHtml());
121 textDocument.setPageSize(printer.pageLayout().paintRectPixels(printer.resolution()).size());
122 textDocument.print(&printer);
virtual ~ShortcutsDialog()
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
ShortcutsDialog(QWidget *parent=nullptr)