Fixed issue #183. Show message "Changes saved".

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-02-17 19:02:47 +02:00
parent b05266b78e
commit 75f6bfd381
5 changed files with 268 additions and 3 deletions

View File

@ -30,6 +30,7 @@
#include "ui_dialogincrements.h"
#include "../../widgets/doubledelegate.h"
#include "../../widgets/textdelegate.h"
#include "../../widgets/vwidgetpopup.h"
#include "../../xml/vstandardmeasurements.h"
#include "../../xml/vindividualmeasurements.h"
#include "../../core/vsettings.h"
@ -379,6 +380,20 @@ void DialogIncrements::ShowHeaderUnits(QTableWidget *table, int column)
table->horizontalHeaderItem(column)->setText(unitHeader);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::ShowSuccess() const
{
VWidgetPopup *popup = new VWidgetPopup();
QLabel *label = new QLabel(tr("Data successfully saved."));
QFont f = label->font();
f.setBold(true);
f.setPixelSize(16);
label->setFont(f);
popup->SetWidget(label);
popup->SetLifeTime(2000);
popup->Show(frameGeometry().center());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogIncrements::ShowMeasurements()
{
@ -434,6 +449,10 @@ void DialogIncrements::SaveGivenName()
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -452,6 +471,10 @@ void DialogIncrements::SaveFamilyName()
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -469,6 +492,10 @@ void DialogIncrements::SaveEmail()
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -486,6 +513,10 @@ void DialogIncrements::SaveSex(int index)
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -503,6 +534,10 @@ void DialogIncrements::SaveBirthDate(const QDate & date)
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -660,6 +695,7 @@ void DialogIncrements::clickedToolButtonAdd()
ui->toolButtonRemove->setEnabled(true);
ui->tableWidgetIncrement->blockSignals(false);
emit haveLiteChange();
ShowSuccess();
}
//---------------------------------------------------------------------------------------------------------------------
@ -687,6 +723,7 @@ void DialogIncrements::clickedToolButtonRemove()
else
{
qCDebug(vDialog)<<"Could not find object with id"<<id;
return;
}
ui->tableWidgetIncrement->removeRow(row);
@ -697,6 +734,7 @@ void DialogIncrements::clickedToolButtonRemove()
ui->tableWidgetIncrement->blockSignals(false);
emit haveLiteChange();
ShowSuccess();
}
//---------------------------------------------------------------------------------------------------------------------
@ -801,6 +839,7 @@ void DialogIncrements::IncrementChanged ( qint32 row, qint32 column )
break;
}
emit haveLiteChange();
ShowSuccess();
}
//---------------------------------------------------------------------------------------------------------------------
@ -853,7 +892,10 @@ void DialogIncrements::MeasurementChanged(qint32 row, qint32 column)
messageBox.setStandardButtons(QMessageBox::Ok);
messageBox.exec();
}
else
{
ShowSuccess();
}
data->ClearVariables();
m->Measurements();

View File

@ -107,6 +107,7 @@ private:
void SetItemViewOnly(QTableWidgetItem *item);
void ShowUnits();
void ShowHeaderUnits(QTableWidget *table, int column);
void ShowSuccess() const;
};
#endif // DIALOGINCREMENTS_H

View File

@ -0,0 +1,114 @@
/************************************************************************
**
** @file vwidgetpopup.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 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
** <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 "vwidgetpopup.h"
#include <QVBoxLayout>
#include <QDesktopWidget>
#include <QTimer>
//---------------------------------------------------------------------------------------------------------------------
VWidgetPopup::VWidgetPopup(QWidget *parent)
:QFrame(parent, Qt::Popup), mWidget(nullptr), mOwn(true), mOldParent(nullptr), lifeTime(-1)
{
setAttribute(Qt::WA_WindowPropagation);
if (parentWidget() == nullptr)
{
setAttribute(Qt::WA_DeleteOnClose);
}
setLayout(new QVBoxLayout());
layout()->setContentsMargins(0, 0, 0, 0);
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetPopup::SetWidget(QWidget *widget, bool own)
{
if (mWidget)
{
layout()->removeWidget(mWidget);
if (mOwn)
{
mWidget->setParent(0);
delete mWidget;
}
else
{
mWidget->setParent(mOldParent);
}
}
mWidget = widget;
mOwn = own;
mOldParent = 0;
if (mWidget)
{
mOldParent = mWidget->parentWidget();
mWidget->setParent(this);
layout()->addWidget(mWidget);
}
}
//---------------------------------------------------------------------------------------------------------------------
void VWidgetPopup::Show(QPoint coord)
{
// important to do this before following adjustments!
QFrame::show();
const QRect screen(QDesktopWidget().availableGeometry());
coord.setX(coord.x() - width()/2);
if (coord.x() < screen.x())
{
coord.setX(screen.x());
}
if (coord.y() < screen.y())
{
coord.setY(screen.y());
}
if (coord.x() > (screen.right()-width()))
{
coord.setX(screen.right()-width());
}
if (coord.y() > (screen.bottom()-height()))
{
coord.setY(screen.bottom()-height());
}
move(coord);
if (lifeTime > 0)
{
QTimer::singleShot(lifeTime, this, SLOT(close()));
}
}

View File

@ -0,0 +1,106 @@
/************************************************************************
**
** @file vwidgetpopup.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 16 2, 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
** <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/>.
**
*************************************************************************/
#ifndef VWIDGETPOPUP_H
#define VWIDGETPOPUP_H
#include <QFrame>
/**
\brief Class showing a widget as popup window.
setWidget() function allows you to specify the widget to be popped up.
After widget is set, you normally should call show() slot in order to pop the
widget up at the specified global position.
VWidgetPopup takes care about positioning of your widget on the screen so it will
be always visible even if popped beside.
*/
class VWidgetPopup : public QFrame
{
Q_OBJECT
public:
/** Constructor.
If \a parent not specified (default), then popup widget gets
attribute Qt::WA_DeleteOnClose and will be deleted after close.
*/
VWidgetPopup(QWidget *parent = 0);
/** Sets widget to be popped up to \a widget.
If \a own is true then the widget will be reparented to the popup widget.
*/
void SetWidget(QWidget *widget, bool own = true);
/** Returns widget to be popped up. */
inline QWidget* Widget() const;
/** Returns true if widget is owned by this popup widget, false otherwise. */
inline bool isOwned() const;
int GetLifeTime() const;
void SetLifeTime(int value);
public slots:
/** Pops up the widget at global coordinates \a coord. */
void Show(QPoint coord);
protected:
Q_DISABLE_COPY(VWidgetPopup)
QWidget *mWidget;
bool mOwn;
QWidget *mOldParent;
int lifeTime;
};
//---------------------------------------------------------------------------------------------------------------------
inline QWidget *VWidgetPopup::Widget() const
{
return mWidget;
}
//---------------------------------------------------------------------------------------------------------------------
inline bool VWidgetPopup::isOwned() const
{
return mOwn;
}
//---------------------------------------------------------------------------------------------------------------------
inline int VWidgetPopup::GetLifeTime() const
{
return lifeTime;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VWidgetPopup::SetLifeTime(int value)
{
lifeTime = value;
}
#endif // VWIDGETPOPUP_H

View File

@ -9,7 +9,8 @@ HEADERS += \
$$PWD/textdelegate.h \
$$PWD/vtooloptionspropertybrowser.h \
$$PWD/vformulapropertyeditor.h \
$$PWD/vformulaproperty.h
$$PWD/vformulaproperty.h \
$$PWD/vwidgetpopup.h
SOURCES += \
$$PWD/vtablegraphicsview.cpp \
@ -19,4 +20,5 @@ SOURCES += \
$$PWD/textdelegate.cpp \
$$PWD/vtooloptionspropertybrowser.cpp \
$$PWD/vformulapropertyeditor.cpp \
$$PWD/vformulaproperty.cpp
$$PWD/vformulaproperty.cpp \
$$PWD/vwidgetpopup.cpp