From f6380cf7398c9c5d6ec943d7849230d3981a088b Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 14 Jan 2015 19:52:16 +0200 Subject: [PATCH] Dialog for showing progress of creation. --HG-- branch : feature --- src/app/dialogs/app/dialoglayoutprogress.cpp | 106 +++++++++++++++++++ src/app/dialogs/app/dialoglayoutprogress.h | 64 +++++++++++ src/app/dialogs/app/dialoglayoutprogress.ui | 66 ++++++++++++ src/app/dialogs/dialogs.pri | 9 +- 4 files changed, 242 insertions(+), 3 deletions(-) create mode 100644 src/app/dialogs/app/dialoglayoutprogress.cpp create mode 100644 src/app/dialogs/app/dialoglayoutprogress.h create mode 100644 src/app/dialogs/app/dialoglayoutprogress.ui diff --git a/src/app/dialogs/app/dialoglayoutprogress.cpp b/src/app/dialogs/app/dialoglayoutprogress.cpp new file mode 100644 index 000000000..670cd90fd --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutprogress.cpp @@ -0,0 +1,106 @@ +/************************************************************************ + ** + ** @file dialoglayoutprogress.cpp + ** @author Roman Telezhynskyi + ** @date 14 1, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialoglayoutprogress.h" +#include "ui_dialoglayoutprogress.h" +#include "../options.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent) + :QDialog(parent), ui(new Ui::DialogLayoutProgress) +{ + ui->setupUi(this); + ui->progressBar->setMaximum(count); + ui->progressBar->setValue(0); + + QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel); + SCASSERT(bCancel != nullptr); + connect(bCancel, &QPushButton::clicked, this, &DialogLayoutProgress::StopWorking); + setModal(true); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogLayoutProgress::~DialogLayoutProgress() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutProgress::Start() +{ + show(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutProgress::Arranged(int count) +{ + ui->progressBar->setValue(count); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutProgress::Error(const LayoutErrors &state) +{ + QString text; + switch(state) + { + case LayoutErrors::NoError: + return; + case LayoutErrors::PrepareLayoutError: + text = tr("Couldn't prepare data for creation layout"); + QMessageBox::critical(this, tr("Critical error"), text, QMessageBox::Ok, QMessageBox::Ok); + break; + case LayoutErrors::PaperSizeError: + text = tr("Wrong paper size"); + QMessageBox::critical(this, tr("Critical error"), text, QMessageBox::Ok, QMessageBox::Ok); + break; + case LayoutErrors::ProcessStoped: + break; + case LayoutErrors::EmptyPaperError: + text = tr("Several workpieces left not arranged, but none of them match for paper"); + QMessageBox::critical(this, tr("Critical error"), text, QMessageBox::Ok, QMessageBox::Ok); + break; + default: + break; + } + + done(QDialog::Rejected); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutProgress::Finished() +{ + done(QDialog::Accepted); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLayoutProgress::StopWorking() +{ + emit Abort(); +} diff --git a/src/app/dialogs/app/dialoglayoutprogress.h b/src/app/dialogs/app/dialoglayoutprogress.h new file mode 100644 index 000000000..f2deb93fb --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutprogress.h @@ -0,0 +1,64 @@ +/************************************************************************ + ** + ** @file dialoglayoutprogress.h + ** @author Roman Telezhynskyi + ** @date 14 1, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DIALOGLAYOUTPROGRESS_H +#define DIALOGLAYOUTPROGRESS_H + +#include + +#include "../../libs/vlayout/vlayoutdef.h" + +namespace Ui +{ + class DialogLayoutProgress; +} + +class DialogLayoutProgress : public QDialog +{ + Q_OBJECT + +public: + explicit DialogLayoutProgress(int count, QWidget *parent = 0); + ~DialogLayoutProgress(); + +signals: + void Abort(); + +public slots: + void Start(); + void Arranged(int count); + void Error(const LayoutErrors &state); + void Finished(); + void StopWorking(); + +private: + Q_DISABLE_COPY(DialogLayoutProgress) + Ui::DialogLayoutProgress *ui; +}; + +#endif // DIALOGLAYOUTPROGRESS_H diff --git a/src/app/dialogs/app/dialoglayoutprogress.ui b/src/app/dialogs/app/dialoglayoutprogress.ui new file mode 100644 index 000000000..f2e02ea51 --- /dev/null +++ b/src/app/dialogs/app/dialoglayoutprogress.ui @@ -0,0 +1,66 @@ + + + DialogLayoutProgress + + + Qt::ApplicationModal + + + + 0 + 0 + 566 + 119 + + + + Creation a layout + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + true + + + + + + + 0 + 0 + + + + <html><head/><body><p>Finding best position for worpieces. Please, waite.</p></body></html> + + + + + + + + 0 + 0 + + + + 24 + + + + + + + QDialogButtonBox::Cancel + + + + + + + + + + diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index cfb7025cf..ce99dd510 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -42,7 +42,8 @@ HEADERS += \ $$PWD/app/configpages/pathpage.h \ $$PWD/app/dialogundo.h \ $$PWD/tools/dialogcurveintersectaxis.h \ - $$PWD/app/dialoglayoutsettings.h + $$PWD/app/dialoglayoutsettings.h \ + $$PWD/app/dialoglayoutprogress.h SOURCES += \ $$PWD/tools/dialogtriangle.cpp \ @@ -83,7 +84,8 @@ SOURCES += \ $$PWD/app/configpages/pathpage.cpp \ $$PWD/app/dialogundo.cpp \ $$PWD/tools/dialogcurveintersectaxis.cpp \ - $$PWD/app/dialoglayoutsettings.cpp + $$PWD/app/dialoglayoutsettings.cpp \ + $$PWD/app/dialoglayoutprogress.cpp FORMS += \ $$PWD/tools/dialogtriangle.ui \ @@ -118,4 +120,5 @@ FORMS += \ $$PWD/app/dialogpatternxmledit.ui \ $$PWD/app/dialogundo.ui \ $$PWD/tools/dialogcurveintersectaxis.ui \ - $$PWD/app/dialoglayoutsettings.ui + $$PWD/app/dialoglayoutsettings.ui \ + $$PWD/app/dialoglayoutprogress.ui