30 #include "ui_show_info_dialog.h"
32 #include <QApplication>
34 #include <QFileDialog>
37 #include <QPageLayout>
40 #include <QPrintDialog>
41 #include <QPrintPreviewDialog>
44 #include <QTextDocument>
47 #include "../core/vapplication.h"
48 #include "../xml/vpattern.h"
63 , m_isInitialized(false)
66 setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
68 qApp->Seamly2DSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
72 QString url = QString(
"<img src=\"data:image/png;base64, ") + byteArray +
"\" width = 280 />";
74 const QString info = tr(
"<table style=font-size:11pt; font-weight:600>"
75 "<tr><td align = right><b>Company: </b></td><td>%1</td><tr>"
76 "<tr><td align = right><b>Customer: </b></td><td>%2</td><tr>"
77 "<tr><td align = right><b>Pattern Name:</b></td><td>%3</td><tr>"
78 "<tr><td align = right><b>Pattern No: </b></td><td>%4</td><tr>"
79 "<tr><td align = right><b>Version: </b></td><td>%5</td><tr>"
80 "<tr><td align = right><b>Units: </b></td><td>%6</td><tr>"
81 "<tr><td align = right><b>Measurements:</b></td><td>%7<br></td><tr>"
82 "<tr><td align = right><b>Description: </b></td><td>%8<br></td><tr>"
83 "<tr><td align = right><b>Notes: </b></td><td>%9<br></td><tr>"
84 "<tr><td align = right><b>Image: </b></td><td>%10</td><tr>"
97 ui->info_TextBrowser->setHtml(info);
122 QDialog::showEvent(event);
123 if (event->spontaneous())
133 setMaximumSize(size());
134 setMinimumSize(size());
145 QClipboard *clipboard = QApplication::clipboard();
146 clipboard->setText(
ui->info_TextBrowser->toPlainText());
148 ui->info_TextBrowser->selectAll();
149 ui->info_TextBrowser->copy();
159 QPrintDialog printDialog(&printer);
160 if(printDialog.exec())
162 QTextDocument textDocument;
163 textDocument.setHtml(
ui->info_TextBrowser->toHtml());
164 textDocument.print(&printer);
174 QString filters(tr(
"Info files") + QLatin1String(
"(*.pdf)"));
175 QString filename = QFileDialog::getSaveFileName(
this, tr(
"Export PDF"),
177 filters,
nullptr, QFileDialog::DontUseNativeDialog);
179 if (QFileInfo(filename).suffix().isEmpty())
181 filename.append(
".pdf");
183 QPrinter printer(QPrinter::PrinterResolution);
184 printer.setOutputFormat(QPrinter::PdfFormat);
185 printer.setPageSize(printer.pageLayout().pageSize());
186 printer.setOutputFileName(filename);
188 QTextDocument textDocument;
189 textDocument.setHtml(
ui->info_TextBrowser->toHtml());
190 textDocument.setPageSize(printer.pageLayout().paintRectPixels(printer.resolution()).size());
191 textDocument.print(&printer);
ShowInfoDialog(VPattern *doc, QWidget *parent=nullptr)
virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE
virtual ~ShowInfoDialog()
QString GetCompanyName() const
QString GetPatternName() const
QString GetPatternNumber() const
QString GetVersion() const
QString GetDescription() const
QString GetCustomerName() const
The VPattern class working with pattern file.
QString UnitsToStr(const Unit &unit, const bool translate)
UnitsToStr translate unit to string.