[Uml-devel] KDE/kdesdk/umbrello/umbrello
Ralf Habacker
ralf.habacker at gmail.com
Tue Nov 29 18:55:40 UTC 2011
SVN commit 1266465 by habacker:
Show diagram print settings dialog before print or print preview dialog
M +41 -8 uml.cpp
M +5 -1 uml.h
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.cpp #1266464:1266465
@@ -79,6 +79,7 @@
#include <QtCore/QRegExp>
#include <QtCore/QTimer>
#include <QtGui/QClipboard>
+#include <QtGui/QDialogButtonBox>
#include <QtGui/QSlider>
#include <QtGui/QToolButton>
#include <QtGui/QKeyEvent>
@@ -138,6 +139,7 @@
m_doc = new UMLDoc();
m_doc->init();
m_hasBegunMacro = false;
+ m_printSettings = 0;
m_printer = new QPrinter;
m_printer->setFullPage(true);
@@ -1266,6 +1268,32 @@
slotFileNew();
}
+bool UMLApp::slotPrintSettings()
+{
+ if (m_printSettings)
+ delete m_printSettings;
+ m_printSettings = new DiagramPrintPage(0, m_doc);
+
+ QDialog *d = new QDialog;
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->addWidget(m_printSettings);
+
+ QDialogButtonBox *b = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ connect(b, SIGNAL(accepted()), d, SLOT(accept()));
+ connect(b, SIGNAL(rejected()), d, SLOT(reject()));
+ layout->addWidget(b);
+ d->setLayout(layout);
+
+ bool result = d->exec() == QDialog::Accepted;
+
+ // keep settings
+ layout->removeWidget(m_printSettings);
+ m_printSettings->setParent(0);
+
+ delete d;
+ return result;
+}
+
/**
* Print preview
*/
@@ -1273,9 +1301,15 @@
{
slotStatusMsg(i18n("Print Preview..."));
+ if(!slotPrintSettings())
+ return;
+
QPrintPreviewDialog *preview = new QPrintPreviewDialog(m_printer,this);
connect(preview, SIGNAL(paintRequested(QPrinter *)), this, SLOT(slotPrintPreviewPaintRequested(QPrinter *)));
preview->exec();
+ delete m_printSettings;
+ m_printSettings = 0;
+ resetStatusMsg();
}
/**
@@ -1283,9 +1317,7 @@
*/
void UMLApp::slotPrintPreviewPaintRequested(QPrinter *printer)
{
- DiagramPrintPage * selectPage = new DiagramPrintPage(0, m_doc);
- m_doc->print(printer, selectPage);
- delete selectPage;
+ m_doc->print(printer, m_printSettings);
}
/**
@@ -1295,17 +1327,18 @@
{
slotStatusMsg(i18n("Printing..."));
- QPrinter printer;
- printer.setFullPage(true);
+ if(!slotPrintSettings())
+ return;
- DiagramPrintPage * selectPage = new DiagramPrintPage(0, m_doc);
QPrintDialog *printDialog =
- KdePrint::createPrintDialog(m_printer, QList<QWidget*>() << selectPage, this);
+ KdePrint::createPrintDialog(m_printer, QList<QWidget*>() << m_printSettings, this);
printDialog->setWindowTitle(i18n("Print %1", m_doc->url().prettyUrl()));
if (printDialog->exec()) {
- m_doc->print(m_printer, selectPage);
+ m_doc->print(m_printer, m_printSettings);
}
+ delete m_printSettings;
+ m_printSettings = 0;
delete printDialog;
resetStatusMsg();
}
--- trunk/KDE/kdesdk/umbrello/umbrello/uml.h #1266464:1266465
@@ -33,6 +33,7 @@
class RefactoringAssistant;
class XhtmlGenerator;
class StatusBarToolButton;
+class DiagramPrintPage;
// KDE forward declarations
class KActionMenu;
@@ -196,6 +197,7 @@
void slotFileSave();
bool slotFileSaveAs();
void slotFileClose();
+ bool slotPrintSettings();
void slotPrintPreview();
void slotPrintPreviewPaintRequested(QPrinter *printer);
void slotFilePrint();
@@ -414,7 +416,6 @@
StatusBarToolButton* m_pZoomFullSBTB;
QSlider* m_pZoomSlider;
QLabel* m_statusBarMessage;
- QPrinter *m_printer;
/**
* The running XHTML documentation generator. Null when no generation is running.
*/
@@ -424,6 +425,9 @@
bool m_hasBegunMacro; ///< Macro creation flag.
+ DiagramPrintPage *m_printSettings; ///< printer diagram settings
+ QPrinter *m_printer; ///< print instance
+
signals:
void sigCutSuccessful();
More information about the umbrello-devel
mailing list