From 0b85380f20f132de766282fdd1fc8ba01181a1ef Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 22 Jan 2015 18:22:37 +0200 Subject: [PATCH] Show paper preview in list. --HG-- branch : feature --- src/app/dialogs/app/dialoglayoutprogress.cpp | 2 + src/app/dialogs/app/dialoglayoutprogress.ui | 12 ++ src/app/tablewindow.cpp | 33 ++++- src/app/tablewindow.h | 1 + src/app/tablewindow.ui | 130 +++++++------------ 5 files changed, 94 insertions(+), 84 deletions(-) diff --git a/src/app/dialogs/app/dialoglayoutprogress.cpp b/src/app/dialogs/app/dialoglayoutprogress.cpp index 670cd90fd..a32c83a6e 100644 --- a/src/app/dialogs/app/dialoglayoutprogress.cpp +++ b/src/app/dialogs/app/dialoglayoutprogress.cpp @@ -44,6 +44,8 @@ DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent) SCASSERT(bCancel != nullptr); connect(bCancel, &QPushButton::clicked, this, &DialogLayoutProgress::StopWorking); setModal(true); + + this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/dialogs/app/dialoglayoutprogress.ui b/src/app/dialogs/app/dialoglayoutprogress.ui index f2e02ea51..edd14dddb 100644 --- a/src/app/dialogs/app/dialoglayoutprogress.ui +++ b/src/app/dialogs/app/dialoglayoutprogress.ui @@ -13,6 +13,18 @@ 119 + + + 566 + 119 + + + + + 566 + 119 + + Creation a layout diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index f348bc020..e08bc599c 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -260,6 +260,7 @@ void TableWindow::ShowPaper(int index) if (index < 0 || index > scenes.size()) { ui->view->setScene(tempScene); + ui->actionSave->setEnabled(false); } else { @@ -518,15 +519,43 @@ void TableWindow::CreateScenes() //--------------------------------------------------------------------------------------------------------------------- void TableWindow::PrepareSceneList() { - const QIcon ico("://icon/64x64/icon64x64.png"); for (int i=1; i<=scenes.size(); ++i) { - QListWidgetItem *item = new QListWidgetItem(ico, QString::number(i)); + QListWidgetItem *item = new QListWidgetItem(ScenePreview(i-1), QString::number(i)); ui->listWidget->addItem(item); } if (scenes.isEmpty() == false) { ui->listWidget->setCurrentRow(0); + ui->actionSave->setEnabled(true); } } + +//--------------------------------------------------------------------------------------------------------------------- +QIcon TableWindow::ScenePreview(int i) const +{ + QImage image; + QGraphicsRectItem *paper = qgraphicsitem_cast(papers.at(i)); + if (paper) + { + const QRectF r = paper->rect(); + // Create the image with the exact size of the shrunk scene + image = QImage(QSize(static_cast(r.width()), static_cast(r.height())), QImage::Format_RGB32); + image.fill(Qt::white); + QPainter painter(&image); + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + scenes.at(i)->render(&painter); + image.scaled(101, 146, Qt::KeepAspectRatio); + } + else + { + image = QImage(QSize(101, 146), QImage::Format_RGB32); + image.fill(Qt::white); + } + return QIcon(QBitmap::fromImage(image)); +} diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index d038308d5..22d83be71 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -101,6 +101,7 @@ private: void CreateShadows(); void CreateScenes(); void PrepareSceneList(); + QIcon ScenePreview(int i) const; }; #endif // TABLEWINDOW_H diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index 03c642d21..11bcf6891 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -23,7 +23,17 @@ - + + + + 20 + 0 + + + + QGraphicsView::AnchorUnderMouse + + @@ -33,8 +43,8 @@ - 16 - 16 + 24 + 24 @@ -47,11 +57,6 @@ false - - - - - @@ -59,6 +64,24 @@ + + + 0 + 0 + + + + + 187 + 121 + + + + + 187 + 524287 + + QDockWidget::DockWidgetMovable @@ -66,7 +89,7 @@ Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - Pages + Layout pages 1 @@ -75,6 +98,18 @@ + + + 0 + 0 + + + + + 0 + 0 + + 200 @@ -114,35 +149,6 @@ Save layout - - - - - - - - Next - - - Next detail - - - - - false - - - - - - - - Turn - - - Turn the detail 90 degrees - - @@ -156,50 +162,6 @@ Stop laying - - - - - - - - Enlarge letter - - - Enlarge the length of the sheet - - - - - false - - - - - - - - Reduce sheet - - - Reduce the length of the sheet - - - - - false - - - - :/icon/16x16/mirror.png:/icon/16x16/mirror.png - - - Mirroring - - - Mirroring - - @@ -227,6 +189,10 @@ + + + :/icon/32x32/layout.png:/icon/32x32/layout.png + Layout