2015-01-14 18:52:16 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file dialoglayoutprogress.cpp
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @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.
|
2015-02-27 11:27:48 +01:00
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2015-01-14 18:52:16 +01:00
|
|
|
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "dialoglayoutprogress.h"
|
|
|
|
#include "ui_dialoglayoutprogress.h"
|
2015-06-19 13:21:46 +02:00
|
|
|
#include "../options.h"
|
|
|
|
#include "../core/vapplication.h"
|
2015-01-14 18:52:16 +01:00
|
|
|
|
|
|
|
#include <QMessageBox>
|
2015-02-09 17:34:50 +01:00
|
|
|
#include <QPushButton>
|
2015-10-18 21:30:51 +02:00
|
|
|
#include <QMovie>
|
|
|
|
#include <QtDebug>
|
2015-01-14 18:52:16 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogLayoutProgress::DialogLayoutProgress(int count, QWidget *parent)
|
2015-11-05 14:01:33 +01:00
|
|
|
:QDialog(parent), ui(new Ui::DialogLayoutProgress), maxCount(count), movie(nullptr), isInitialized(false)
|
2015-01-14 18:52:16 +01:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2015-02-10 20:27:11 +01:00
|
|
|
|
2015-07-24 14:06:53 +02:00
|
|
|
qApp->ValentinaSettings()->GetOsSeparator() ? setLocale(QLocale::system()) : setLocale(QLocale(QLocale::C));
|
2015-02-10 20:27:11 +01:00
|
|
|
|
2015-05-06 14:49:27 +02:00
|
|
|
ui->progressBar->setMaximum(maxCount);
|
2015-01-14 18:52:16 +01:00
|
|
|
ui->progressBar->setValue(0);
|
|
|
|
|
2015-05-06 16:31:28 +02:00
|
|
|
ui->labelMessage->setText(tr("Arranged workpieces: %1 from %2").arg(0).arg(count));
|
|
|
|
|
|
|
|
movie = new QMovie("://icon/16x16/progress.gif");
|
|
|
|
ui->labelProgress->setMovie (movie);
|
|
|
|
movie->start ();
|
2015-05-06 14:49:27 +02:00
|
|
|
|
2015-01-14 18:52:16 +01:00
|
|
|
QPushButton *bCancel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
SCASSERT(bCancel != nullptr);
|
2016-07-13 13:41:44 +02:00
|
|
|
connect(bCancel, &QPushButton::clicked, [this](){emit Abort();});
|
2015-01-14 18:52:16 +01:00
|
|
|
setModal(true);
|
2015-01-22 17:22:37 +01:00
|
|
|
|
|
|
|
this->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
|
2015-01-14 18:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
DialogLayoutProgress::~DialogLayoutProgress()
|
|
|
|
{
|
|
|
|
delete ui;
|
2015-05-06 16:31:28 +02:00
|
|
|
delete movie;
|
2015-01-14 18:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogLayoutProgress::Start()
|
|
|
|
{
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogLayoutProgress::Arranged(int count)
|
|
|
|
{
|
|
|
|
ui->progressBar->setValue(count);
|
2015-05-06 16:31:28 +02:00
|
|
|
ui->labelMessage->setText(tr("Arranged workpieces: %1 from %2").arg(count).arg(maxCount));
|
2015-01-14 18:52:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogLayoutProgress::Error(const LayoutErrors &state)
|
|
|
|
{
|
2015-03-02 18:11:43 +01:00
|
|
|
switch (state)
|
2015-01-14 18:52:16 +01:00
|
|
|
{
|
|
|
|
case LayoutErrors::NoError:
|
|
|
|
return;
|
|
|
|
case LayoutErrors::PrepareLayoutError:
|
2015-10-01 16:59:01 +02:00
|
|
|
qCritical() << tr("Couldn't prepare data for creation layout");
|
2015-01-14 18:52:16 +01:00
|
|
|
break;
|
|
|
|
case LayoutErrors::ProcessStoped:
|
|
|
|
break;
|
|
|
|
case LayoutErrors::EmptyPaperError:
|
2015-10-01 16:59:01 +02:00
|
|
|
qCritical() << tr("Several workpieces left not arranged, but none of them match for paper");
|
2015-01-14 18:52:16 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
done(QDialog::Rejected);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogLayoutProgress::Finished()
|
|
|
|
{
|
|
|
|
done(QDialog::Accepted);
|
|
|
|
}
|
|
|
|
|
2015-11-05 14:01:33 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DialogLayoutProgress::showEvent(QShowEvent *event)
|
|
|
|
{
|
|
|
|
QDialog::showEvent( event );
|
|
|
|
if ( event->spontaneous() )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isInitialized)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// do your init stuff here
|
|
|
|
|
|
|
|
setMaximumSize(size());
|
|
|
|
setMinimumSize(size());
|
|
|
|
|
|
|
|
isInitialized = true;//first show windows are held
|
|
|
|
}
|