mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
PrintDialog: add separate Preview/Print buttons
We rename our old 'Print' button to 'Preview' (as it did just that), and add a new one called 'Print' which does the direct printing, by creating a QPrintDialog instance. Both buttons are located on top of the dialog for now in a QHBoxLayout. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
576c3f559f
commit
d90cca5c4e
2 changed files with 20 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QPrintPreviewDialog>
|
#include <QPrintPreviewDialog>
|
||||||
|
#include <QPrintDialog>
|
||||||
|
|
||||||
PrintDialog *PrintDialog::instance()
|
PrintDialog *PrintDialog::instance()
|
||||||
{
|
{
|
||||||
|
@ -30,9 +31,16 @@ PrintDialog::PrintDialog(QWidget *parent, Qt::WindowFlags f)
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
|
QHBoxLayout *hLayout = new QHBoxLayout();
|
||||||
|
layout->addLayout(hLayout);
|
||||||
|
|
||||||
|
QPushButton *previewButton = new QPushButton(tr("&Preview"));
|
||||||
|
connect(previewButton, SIGNAL(clicked(bool)), this, SLOT(previewClicked()));
|
||||||
|
hLayout->addWidget(previewButton);
|
||||||
|
|
||||||
QPushButton *printButton = new QPushButton(tr("&Print"));
|
QPushButton *printButton = new QPushButton(tr("&Print"));
|
||||||
connect(printButton, SIGNAL(clicked(bool)), this, SLOT(printClicked()));
|
connect(printButton, SIGNAL(clicked(bool)), this, SLOT(printClicked()));
|
||||||
layout->addWidget(printButton);
|
hLayout->addWidget(printButton);
|
||||||
|
|
||||||
QProgressBar *progressBar = new QProgressBar();
|
QProgressBar *progressBar = new QProgressBar();
|
||||||
connect(printLayout, SIGNAL(signalProgress(int)), progressBar, SLOT(setValue(int)));
|
connect(printLayout, SIGNAL(signalProgress(int)), progressBar, SLOT(setValue(int)));
|
||||||
|
@ -53,11 +61,18 @@ void PrintDialog::runDialog()
|
||||||
exec();
|
exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintDialog::printClicked(void)
|
void PrintDialog::previewClicked(void)
|
||||||
{
|
{
|
||||||
QPrintPreviewDialog previewDialog(&printer, this);
|
QPrintPreviewDialog previewDialog(&printer, this);
|
||||||
QObject::connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
|
QObject::connect(&previewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(onPaintRequested(QPrinter *)));
|
||||||
previewDialog.exec();
|
previewDialog.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintDialog::printClicked(void)
|
||||||
|
{
|
||||||
|
QPrintDialog printDialog(&printer, this);
|
||||||
|
if (printDialog.exec() == QDialog::Accepted)
|
||||||
|
printLayout->print();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
|
void PrintDialog::onPaintRequested(QPrinter *printerPtr)
|
||||||
|
|
|
@ -23,6 +23,7 @@ private:
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void previewClicked();
|
||||||
void printClicked();
|
void printClicked();
|
||||||
void onPaintRequested(QPrinter *);
|
void onPaintRequested(QPrinter *);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue