mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Print preview dialog in all cases
Add print preview dialogs to all the cases where we have printable objects. Remaining were table browsers and Scintilla editors.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QPalette>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrintPreviewDialog>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
@@ -246,11 +246,15 @@ void ExtendedScintilla::showContextMenu(const QPoint &pos)
|
||||
|
||||
void ExtendedScintilla::openPrintDialog()
|
||||
{
|
||||
QsciPrinter* printer = new QsciPrinter;
|
||||
QsciPrinter printer;
|
||||
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
|
||||
|
||||
QPrintDialog printDialog(printer, this);
|
||||
if (printDialog.exec() == QDialog::Accepted)
|
||||
printer->printRange(this);
|
||||
connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
|
||||
QsciPrinter* sciPrinter = static_cast<QsciPrinter*>(previewPrinter);
|
||||
sciPrinter->printRange(this);
|
||||
});
|
||||
|
||||
delete printer;
|
||||
dialog->exec();
|
||||
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QLineEdit>
|
||||
#include <QPrinter>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrintPreviewDialog>
|
||||
#include <QTextDocument>
|
||||
#include <QCompleter>
|
||||
|
||||
@@ -874,12 +874,15 @@ void ExtendedTableWidget::openPrintDialog()
|
||||
document->setHtml(mimeData->html());
|
||||
|
||||
QPrinter printer;
|
||||
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
|
||||
|
||||
QPrintDialog *dialog = new QPrintDialog(&printer, nullptr);
|
||||
if (dialog->exec() == QDialog::Accepted) {
|
||||
document->print(&printer);
|
||||
}
|
||||
connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
|
||||
document->print(previewPrinter);
|
||||
});
|
||||
|
||||
dialog->exec();
|
||||
|
||||
delete dialog;
|
||||
delete document;
|
||||
delete mimeData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user