Warn a user when need to update a file format version.
--HG-- branch : release
This commit is contained in:
parent
f384639ac3
commit
a1caf972a9
|
@ -75,7 +75,7 @@ enum {ColumnName = 0, ColumnFullName, ColumnCalcValue, ColumnFormula, ColumnBase
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
TMainWindow::TMainWindow(QWidget *parent)
|
||||
:QMainWindow(parent),
|
||||
: VAbstractMainWindow(parent),
|
||||
ui(new Ui::TMainWindow),
|
||||
m(nullptr),
|
||||
data(nullptr),
|
||||
|
@ -270,11 +270,15 @@ bool TMainWindow::LoadFile(const QString &path)
|
|||
if (mType == MeasurementsType::Standard)
|
||||
{
|
||||
VVSTConverter converter(path);
|
||||
m_curFileFormatVersion = converter.GetCurrentFormatVarsion();
|
||||
m_curFileFormatVersionStr = converter.GetVersionStr();
|
||||
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||
}
|
||||
else
|
||||
{
|
||||
VVITConverter converter(path);
|
||||
m_curFileFormatVersion = converter.GetCurrentFormatVarsion();
|
||||
m_curFileFormatVersionStr = converter.GetVersionStr();
|
||||
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||
}
|
||||
|
||||
|
@ -337,6 +341,13 @@ bool TMainWindow::LoadFile(const QString &path)
|
|||
return true;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::ShowToolTip(const QString &toolTip)
|
||||
{
|
||||
Q_UNUSED(toolTip)
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void TMainWindow::FileNew()
|
||||
{
|
||||
|
@ -645,6 +656,19 @@ bool TMainWindow::FileSave()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (mType == MeasurementsType::Standard
|
||||
&& m_curFileFormatVersion < VVSTConverter::MeasurementMaxVer
|
||||
&& not ContinueFormatRewrite(m_curFileFormatVersionStr, VVSTConverter::MeasurementMaxVerStr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (mType == MeasurementsType::Individual
|
||||
&& m_curFileFormatVersion < VVITConverter::MeasurementMaxVer
|
||||
&& not ContinueFormatRewrite(m_curFileFormatVersionStr, VVITConverter::MeasurementMaxVerStr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
@ -703,6 +727,19 @@ bool TMainWindow::FileSave()
|
|||
messageBox.exec();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mType == MeasurementsType::Standard)
|
||||
{
|
||||
m_curFileFormatVersion = VVSTConverter::MeasurementMaxVer;
|
||||
m_curFileFormatVersionStr = VVSTConverter::MeasurementMaxVerStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_curFileFormatVersion = VVITConverter::MeasurementMaxVer;
|
||||
m_curFileFormatVersionStr = VVITConverter::MeasurementMaxVerStr;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2794,12 +2831,14 @@ bool TMainWindow::LoadFromExistingFile(const QString &path)
|
|||
|
||||
if (mType == MeasurementsType::Standard)
|
||||
{
|
||||
VException e(tr("Export standard measurements not supported."));
|
||||
VException e(tr("Export from standard measurements is not supported."));
|
||||
throw e;
|
||||
}
|
||||
else
|
||||
{
|
||||
VVITConverter converter(path);
|
||||
m_curFileFormatVersion = converter.GetCurrentFormatVarsion();
|
||||
m_curFileFormatVersionStr = converter.GetVersionStr();
|
||||
m->setXMLContent(converter.Convert());// Read again after conversion
|
||||
}
|
||||
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#ifndef TMAINWINDOW_H
|
||||
#define TMAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTableWidget>
|
||||
|
||||
#include "../vmisc/def.h"
|
||||
#include "../vmisc/vlockguard.h"
|
||||
#include "../vformat/vmeasurements.h"
|
||||
#include "../vmisc/vtablesearch.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -44,7 +44,7 @@ namespace Ui
|
|||
|
||||
class QLabel;
|
||||
|
||||
class TMainWindow : public QMainWindow
|
||||
class TMainWindow : public VAbstractMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -62,6 +62,9 @@ public:
|
|||
|
||||
bool LoadFile(const QString &path);
|
||||
|
||||
public slots:
|
||||
virtual void ShowToolTip(const QString &toolTip) Q_DECL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
||||
|
|
|
@ -140,6 +140,8 @@ void ConfigDialog::showEvent(QShowEvent *event)
|
|||
resize(sz);
|
||||
}
|
||||
|
||||
okButton->setFocus();
|
||||
|
||||
isInitialized = true;//first show windows are held
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
|
|||
unitChanged(false),
|
||||
labelLangChanged(false),
|
||||
sendReportCheck(nullptr),
|
||||
askPointDeletionCheck(nullptr),
|
||||
resetWarningsButton(nullptr),
|
||||
toolBarStyleCheck(nullptr),
|
||||
saveGroup(nullptr),
|
||||
intervalLabel(nullptr),
|
||||
|
@ -112,7 +112,6 @@ void ConfigurationPage::Apply()
|
|||
|
||||
settings->SetOsSeparator(osOptionCheck->isChecked());
|
||||
settings->SetSendReportState(sendReportCheck->isChecked());
|
||||
settings->SetConfirmItemDelete(askPointDeletionCheck->isChecked());
|
||||
settings->SetToolBarStyle(toolBarStyleCheck->isChecked());
|
||||
|
||||
if (langChanged || systemChanged)
|
||||
|
@ -366,11 +365,16 @@ QGroupBox *ConfigurationPage::DrawGroup()
|
|||
{
|
||||
drawGroup = new QGroupBox(tr("Pattern Editing"));
|
||||
|
||||
askPointDeletionCheck = new QCheckBox(tr("Confirm item deletion"));
|
||||
askPointDeletionCheck->setChecked(qApp->ValentinaSettings()->GetConfirmItemDelete());
|
||||
resetWarningsButton = new QPushButton(tr("Reset warnings"));
|
||||
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
sizePolicy.setHorizontalStretch(0);
|
||||
sizePolicy.setVerticalStretch(0);
|
||||
sizePolicy.setHeightForWidth(resetWarningsButton->sizePolicy().hasHeightForWidth());
|
||||
resetWarningsButton->setSizePolicy(sizePolicy);
|
||||
connect(resetWarningsButton, &QPushButton::released, this, &ConfigurationPage::ResetWarnings);
|
||||
|
||||
QVBoxLayout *editLayout = new QVBoxLayout;
|
||||
editLayout->addWidget(askPointDeletionCheck);
|
||||
editLayout->addWidget(resetWarningsButton);
|
||||
|
||||
drawGroup->setLayout(editLayout);
|
||||
return drawGroup;
|
||||
|
@ -425,11 +429,20 @@ void ConfigurationPage::changeEvent(QEvent *event)
|
|||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ConfigurationPage::ResetWarnings()
|
||||
{
|
||||
VSettings *settings = qApp->ValentinaSettings();
|
||||
|
||||
settings->SetConfirmItemDelete(true);
|
||||
settings->SetConfirmFormatRewriting(true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ConfigurationPage::RetranslateUi()
|
||||
{
|
||||
toolBarStyleCheck->setText(tr("The text appears under the icon (recommended for beginners)."));
|
||||
askPointDeletionCheck->setText(tr("Confirm item deletion"));
|
||||
resetWarningsButton->setText(tr("Reset warnings"));
|
||||
|
||||
saveGroup->setTitle(tr("Save"));
|
||||
autoSaveCheck->setText(tr("Auto-save modified pattern"));
|
||||
|
@ -477,7 +490,7 @@ void ConfigurationPage::RetranslateUi()
|
|||
"Crash_reports\">kind of information</a> we collect."));
|
||||
|
||||
drawGroup->setTitle(tr("Pattern Editing"));
|
||||
askPointDeletionCheck->setText(tr("Confirm item deletion"));
|
||||
resetWarningsButton->setText(tr("Confirm item deletion"));
|
||||
toolBarGroup->setTitle(tr("Toolbar"));
|
||||
toolBarStyleCheck->setText(tr("The text appears under the icon (recommended for beginners)."));
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QWidget>
|
||||
|
||||
class QCheckBox;
|
||||
|
@ -52,6 +53,8 @@ public slots:
|
|||
void LabelLangChanged();
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) Q_DECL_OVERRIDE;
|
||||
private slots:
|
||||
void ResetWarnings();
|
||||
private:
|
||||
Q_DISABLE_COPY(ConfigurationPage)
|
||||
QCheckBox *autoSaveCheck;
|
||||
|
@ -65,7 +68,7 @@ private:
|
|||
bool unitChanged;
|
||||
bool labelLangChanged;
|
||||
QCheckBox *sendReportCheck;
|
||||
QCheckBox *askPointDeletionCheck;
|
||||
QPushButton *resetWarningsButton;
|
||||
QCheckBox *toolBarStyleCheck;
|
||||
|
||||
QGroupBox *saveGroup;
|
||||
|
|
|
@ -2563,6 +2563,11 @@ bool MainWindow::Save()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_curFileFormatVersion < VPatternConverter::PatternMaxVer
|
||||
&& not ContinueFormatRewrite(m_curFileFormatVersionStr, VPatternConverter::PatternMaxVerStr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#ifdef Q_OS_WIN32
|
||||
qt_ntfs_permission_lookup++; // turn checking on
|
||||
#endif /*Q_OS_WIN32*/
|
||||
|
@ -2614,6 +2619,8 @@ bool MainWindow::Save()
|
|||
if (result)
|
||||
{
|
||||
QFile::remove(curFile + autosavePrefix);
|
||||
m_curFileFormatVersion = VPatternConverter::PatternMaxVer;
|
||||
m_curFileFormatVersionStr = VPatternConverter::PatternMaxVerStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4090,6 +4097,8 @@ bool MainWindow::LoadPattern(const QString &fileName, const QString& customMeasu
|
|||
try
|
||||
{
|
||||
VPatternConverter converter(fileName);
|
||||
m_curFileFormatVersion = converter.GetCurrentFormatVarsion();
|
||||
m_curFileFormatVersionStr = converter.GetVersionStr();
|
||||
doc->setXMLContent(converter.Convert());
|
||||
if (!customMeasureFile.isEmpty())
|
||||
{
|
||||
|
|
|
@ -86,6 +86,12 @@ QString VAbstractConverter::Convert()
|
|||
return m_convertedFileName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VAbstractConverter::GetCurrentFormatVarsion() const
|
||||
{
|
||||
return m_ver;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VAbstractConverter::GetVersionStr() const
|
||||
{
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
|
||||
QString Convert();
|
||||
|
||||
int GetCurrentFormatVarsion() const;
|
||||
QString GetVersionStr() const;
|
||||
|
||||
static int GetVersion(const QString &version);
|
||||
|
||||
protected:
|
||||
|
@ -87,8 +90,6 @@ private:
|
|||
|
||||
QTemporaryFile m_tmpFile;
|
||||
|
||||
QString GetVersionStr() const;
|
||||
|
||||
static void ValidateVersion(const QString &version);
|
||||
|
||||
void ReserveFile() const;
|
||||
|
|
|
@ -54,6 +54,7 @@ const QString settingConfigurationLocale = QStringLiteral("configur
|
|||
const QString settingPMSystemCode = QStringLiteral("configuration/pmscode");
|
||||
const QString settingConfigurationUnit = QStringLiteral("configuration/unit");
|
||||
const QString settingConfigurationConfirmItemDeletion = QStringLiteral("configuration/confirm_item_deletion");
|
||||
const QString settingConfigurationConfirmFormatRewriting = QStringLiteral("configuration/confirm_format_rewriting");
|
||||
const QString settingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
|
||||
|
||||
const QString settingPatternUser = QStringLiteral("pattern/user");
|
||||
|
@ -392,6 +393,18 @@ void VCommonSettings::SetConfirmItemDelete(const bool &value)
|
|||
setValue(settingConfigurationConfirmItemDeletion, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommonSettings::GetConfirmFormatRewriting() const
|
||||
{
|
||||
return value(settingConfigurationConfirmFormatRewriting, 1).toBool();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetConfirmFormatRewriting(const bool &value)
|
||||
{
|
||||
setValue(settingConfigurationConfirmFormatRewriting, value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VCommonSettings::GetToolBarStyle() const
|
||||
{
|
||||
|
|
|
@ -90,6 +90,9 @@ public:
|
|||
bool GetConfirmItemDelete() const;
|
||||
void SetConfirmItemDelete(const bool &value);
|
||||
|
||||
bool GetConfirmFormatRewriting() const;
|
||||
void SetConfirmFormatRewriting(const bool &value);
|
||||
|
||||
bool GetToolBarStyle() const;
|
||||
void SetToolBarStyle(const bool &value);
|
||||
|
||||
|
|
|
@ -27,10 +27,44 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "vabstractmainwindow.h"
|
||||
#include "../vpropertyexplorer/checkablemessagebox.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
|
||||
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent) : QMainWindow(parent)
|
||||
#include <QStyle>
|
||||
|
||||
VAbstractMainWindow::VAbstractMainWindow(QWidget *parent)
|
||||
: QMainWindow(parent),
|
||||
m_curFileFormatVersion(0x0),
|
||||
m_curFileFormatVersionStr(QLatin1String("0.0.0"))
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VAbstractMainWindow::~VAbstractMainWindow()
|
||||
{}
|
||||
bool VAbstractMainWindow::ContinueFormatRewrite(const QString ¤tFormatVersion,
|
||||
const QString &maxFormatVersion)
|
||||
{
|
||||
if (qApp->Settings()->GetConfirmFormatRewriting())
|
||||
{
|
||||
Utils::CheckableMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Confirm format rewriting"));
|
||||
msgBox.setText(tr("This file is using previous format version v%1. The current is v%2. "
|
||||
"Saving the file with this app version will update the format version for this "
|
||||
"file. This may prevent you from be abale to open the file with older app versions. "
|
||||
"Do you really want to continue?").arg(currentFormatVersion).arg(maxFormatVersion));
|
||||
msgBox.setStandardButtons(QDialogButtonBox::Yes | QDialogButtonBox::No);
|
||||
msgBox.setDefaultButton(QDialogButtonBox::No);
|
||||
msgBox.setIconPixmap(QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion).pixmap(32, 32));
|
||||
|
||||
int dialogResult = msgBox.exec();
|
||||
|
||||
if (dialogResult == QDialog::Accepted)
|
||||
{
|
||||
qApp->Settings()->SetConfirmFormatRewriting(not msgBox.isChecked());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -40,10 +40,19 @@ class VAbstractMainWindow : public QMainWindow
|
|||
Q_OBJECT
|
||||
public:
|
||||
explicit VAbstractMainWindow(QWidget *parent = nullptr);
|
||||
virtual ~VAbstractMainWindow() Q_DECL_OVERRIDE;
|
||||
virtual ~VAbstractMainWindow() Q_DECL_EQ_DEFAULT;
|
||||
|
||||
public slots:
|
||||
virtual void ShowToolTip(const QString &toolTip)=0;
|
||||
|
||||
protected:
|
||||
int m_curFileFormatVersion;
|
||||
QString m_curFileFormatVersionStr;
|
||||
|
||||
bool ContinueFormatRewrite(const QString ¤tFormatVersion, const QString &maxFormatVersion);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VAbstractMainWindow)
|
||||
};
|
||||
|
||||
#endif // VABSTRACTMAINWINDOW_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user