Show paper preview in list.

--HG--
branch : feature
This commit is contained in:
dismine 2015-01-22 18:22:37 +02:00
parent c84caa349d
commit 0b85380f20
5 changed files with 94 additions and 84 deletions

View file

@ -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);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -13,6 +13,18 @@
<height>119</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>566</width>
<height>119</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>566</width>
<height>119</height>
</size>
</property>
<property name="windowTitle">
<string>Creation a layout</string>
</property>

View file

@ -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<QGraphicsRectItem *>(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<qint32>(r.width()), static_cast<qint32>(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));
}

View file

@ -101,6 +101,7 @@ private:
void CreateShadows();
void CreateScenes();
void PrepareSceneList();
QIcon ScenePreview(int i) const;
};
#endif // TABLEWINDOW_H

View file

@ -23,7 +23,17 @@
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="VTableGraphicsView" name="view"/>
<widget class="VTableGraphicsView" name="view">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>20</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="resizeAnchor">
<enum>QGraphicsView::AnchorUnderMouse</enum>
</property>
</widget>
</item>
</layout>
</widget>
@ -33,8 +43,8 @@
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolButtonStyle">
@ -47,11 +57,6 @@
<bool>false</bool>
</attribute>
<addaction name="actionSave"/>
<addaction name="actionNext"/>
<addaction name="actionTurn"/>
<addaction name="actionAdd"/>
<addaction name="actionRemove"/>
<addaction name="actionMirror"/>
<addaction name="actionZoomIn"/>
<addaction name="actionZoomOut"/>
<addaction name="actionStop"/>
@ -59,6 +64,24 @@
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QDockWidget" name="dockWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>187</width>
<height>121</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>187</width>
<height>524287</height>
</size>
</property>
<property name="features">
<set>QDockWidget::DockWidgetMovable</set>
</property>
@ -66,7 +89,7 @@
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Pages</string>
<string>Layout pages</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
@ -75,6 +98,18 @@
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="listWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="iconSize">
<size>
<width>200</width>
@ -114,35 +149,6 @@
<string>Save layout</string>
</property>
</action>
<action name="actionNext">
<property name="icon">
<iconset theme="go-next">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Next</string>
</property>
<property name="toolTip">
<string>Next detail</string>
</property>
</action>
<action name="actionTurn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="object-rotate-left">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Turn</string>
</property>
<property name="toolTip">
<string>Turn the detail 90 degrees</string>
</property>
</action>
<action name="actionStop">
<property name="icon">
<iconset theme="process-stop">
@ -156,50 +162,6 @@
<string>Stop laying</string>
</property>
</action>
<action name="actionAdd">
<property name="icon">
<iconset theme="list-add">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Enlarge letter</string>
</property>
<property name="toolTip">
<string>Enlarge the length of the sheet</string>
</property>
</action>
<action name="actionRemove">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset theme="list-remove">
<normaloff/>
</iconset>
</property>
<property name="text">
<string>Reduce sheet</string>
</property>
<property name="toolTip">
<string>Reduce the length of the sheet</string>
</property>
</action>
<action name="actionMirror">
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="share/resources/icon.qrc">
<normaloff>:/icon/16x16/mirror.png</normaloff>:/icon/16x16/mirror.png</iconset>
</property>
<property name="text">
<string>Mirroring</string>
</property>
<property name="toolTip">
<string>Mirroring</string>
</property>
</action>
<action name="actionZoomIn">
<property name="icon">
<iconset theme="zoom-in">
@ -227,6 +189,10 @@
</property>
</action>
<action name="actionLayout">
<property name="icon">
<iconset resource="share/resources/icon.qrc">
<normaloff>:/icon/32x32/layout.png</normaloff>:/icon/32x32/layout.png</iconset>
</property>
<property name="text">
<string>Layout</string>
</property>