Line 0
Link Here
|
|
|
1 |
# Run QPrinter initialization on first usage. |
2 |
# This removes possible delay on application start for non-native printer(s). |
3 |
|
4 |
--- src/stack.cpp.orig 2016-10-13 09:37:59 UTC |
5 |
+++ src/stack.cpp |
6 |
@@ -55,6 +55,7 @@ |
7 |
Stack::Stack(QWidget* parent) : |
8 |
QWidget(parent), |
9 |
m_symbols_dialog(0), |
10 |
+ m_printer(0), |
11 |
m_current_document(0), |
12 |
m_footer_margin(0), |
13 |
m_header_margin(0), |
14 |
@@ -78,17 +79,6 @@ Stack::Stack(QWidget* parent) : |
15 |
m_find_dialog = new FindDialog(this); |
16 |
connect(m_find_dialog, SIGNAL(findNextAvailable(bool)), this, SIGNAL(findNextAvailable(bool))); |
17 |
|
18 |
- m_printer = new QPrinter(QPrinter::HighResolution); |
19 |
-#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) |
20 |
- m_printer->setPageSize(QPageSize(QPageSize::Letter)); |
21 |
- m_printer->setPageOrientation(QPageLayout::Portrait); |
22 |
- m_printer->setPageMargins(QMarginsF(1.0, 1.0, 1.0, 1.0), QPageLayout::Inch); |
23 |
-#else |
24 |
- m_printer->setPageSize(QPrinter::Letter); |
25 |
- m_printer->setOrientation(QPrinter::Portrait); |
26 |
- m_printer->setPageMargins(1.0, 1.0, 1.0, 1.0, QPrinter::Inch); |
27 |
-#endif |
28 |
- |
29 |
connect(ActionManager::instance(), SIGNAL(insertText(QString)), this, SLOT(insertSymbol(QString))); |
30 |
|
31 |
m_layout = new QGridLayout(this); |
32 |
@@ -129,7 +119,8 @@ Stack::~Stack() |
33 |
{ |
34 |
m_theme_renderer->wait(); |
35 |
|
36 |
- delete m_printer; |
37 |
+ if (m_printer) |
38 |
+ delete m_printer; |
39 |
} |
40 |
|
41 |
//----------------------------------------------------------------------------- |
42 |
@@ -380,6 +371,24 @@ void Stack::increaseIndent() |
43 |
|
44 |
//----------------------------------------------------------------------------- |
45 |
|
46 |
+void Stack::initPrinter() |
47 |
+{ |
48 |
+ if (!m_printer) { |
49 |
+ m_printer = new QPrinter(QPrinter::HighResolution); |
50 |
+#if (QT_VERSION >= QT_VERSION_CHECK(5,3,0)) |
51 |
+ m_printer->setPageSize(QPageSize(QPageSize::Letter)); |
52 |
+ m_printer->setPageOrientation(QPageLayout::Portrait); |
53 |
+ m_printer->setPageMargins(QMarginsF(1.0, 1.0, 1.0, 1.0), QPageLayout::Inch); |
54 |
+#else |
55 |
+ m_printer->setPageSize(QPrinter::Letter); |
56 |
+ m_printer->setOrientation(QPrinter::Portrait); |
57 |
+ m_printer->setPageMargins(1.0, 1.0, 1.0, 1.0, QPrinter::Inch); |
58 |
+#endif |
59 |
+ } |
60 |
+} |
61 |
+ |
62 |
+//----------------------------------------------------------------------------- |
63 |
+ |
64 |
void Stack::paste() |
65 |
{ |
66 |
m_current_document->text()->paste(); |
67 |
@@ -397,6 +406,7 @@ void Stack::pasteUnformatted() |
68 |
|
69 |
void Stack::pageSetup() |
70 |
{ |
71 |
+ initPrinter(); |
72 |
QPageSetupDialog dialog(m_printer, this); |
73 |
dialog.exec(); |
74 |
} |
75 |
@@ -405,6 +415,7 @@ void Stack::pageSetup() |
76 |
|
77 |
void Stack::print() |
78 |
{ |
79 |
+ initPrinter(); |
80 |
m_current_document->print(m_printer); |
81 |
} |
82 |
|
83 |
--- src/stack.h.orig 2016-10-13 09:37:59 UTC |
84 |
+++ src/stack.h |
85 |
@@ -91,6 +91,7 @@ public slots: |
86 |
void findNext(); |
87 |
void findPrevious(); |
88 |
void increaseIndent(); |
89 |
+ void initPrinter(); |
90 |
void paste(); |
91 |
void pasteUnformatted(); |
92 |
void pageSetup(); |