Open new window if file was created.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-07-15 10:16:59 +03:00
parent 1aad1090b1
commit 58d1cf5fdd
19 changed files with 745 additions and 316 deletions

View File

@ -2,6 +2,9 @@
<ui version="4.0">
<class>DialogNewMeasurements</class>
<widget class="QDialog" name="DialogNewMeasurements">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>

View File

@ -43,6 +43,7 @@ int main(int argc, char *argv[])
{
return 0;
}
app.InitOptions();
QStringList args = QCoreApplication::arguments();
if (args.count() > 1)

View File

@ -30,14 +30,21 @@
#include "version.h"
#include "tmainwindow.h"
#include <QDir>
#include <QFileOpenEvent>
#include <QLibraryInfo>
#include <QLocalSocket>
#include <QTranslator>
//---------------------------------------------------------------------------------------------------------------------
MApplication::MApplication(int &argc, char **argv)
:QApplication(argc, argv),
mainWindows(),
localServer(nullptr)
localServer(nullptr),
trVars(nullptr),
_mUnit(Unit::Cm),
_mType(MeasurementsType::Individual),
settings(nullptr)
{
setApplicationDisplayName(VER_PRODUCTNAME_STR);
setApplicationName(VER_INTERNALNAME_STR);
@ -92,12 +99,6 @@ MApplication::~MApplication()
}
}
//---------------------------------------------------------------------------------------------------------------------
MApplication *MApplication::instance()
{
return (static_cast<MApplication *>(QCoreApplication::instance()));
}
//---------------------------------------------------------------------------------------------------------------------
bool MApplication::IsTheOnly() const
{
@ -127,6 +128,156 @@ QList<TMainWindow *> MApplication::MainWindows()
return list;
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::InitOptions()
{
OpenSettings();
qDebug()<<"Version:"<<APP_VERSION_STR;
qDebug()<<"Build revision:"<<BUILD_REVISION;
qDebug()<<buildCompatibilityString();
qDebug()<<"Built on"<<__DATE__<<"at"<<__TIME__;
qDebug()<<"Command-line arguments:"<<this->arguments();
qDebug()<<"Process ID:"<<this->applicationPid();
const QString checkedLocale = Settings()->GetLocale();
qDebug()<<"Checked locale:"<<checkedLocale;
QTranslator *qtTranslator = new QTranslator(this);
#if defined(Q_OS_WIN)
qtTranslator->load("qt_" + checkedLocale, translationsPath());
#else
qtTranslator->load("qt_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
installTranslator(qtTranslator);
QTranslator *qtxmlTranslator = new QTranslator(this);
#if defined(Q_OS_WIN)
qtxmlTranslator->load("qtxmlpatterns_" + checkedLocale, translationsPath());
#else
qtxmlTranslator->load("qtxmlpatterns_" + checkedLocale, QLibraryInfo::location(QLibraryInfo::TranslationsPath));
#endif
installTranslator(qtxmlTranslator);
QTranslator *appTranslator = new QTranslator(this);
appTranslator->load("valentina_" + checkedLocale, translationsPath());
installTranslator(appTranslator);
InitTrVars();//Very important do it after load QM files.
static const char * GENERIC_ICON_TO_CHECK = "document-open";
if (QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK) == false)
{
//If there is no default working icon theme then we should
//use an icon theme that we provide via a .qrc file
//This case happens under Windows and Mac OS X
//This does not happen under GNOME or KDE
QIcon::setThemeName("win.icon.theme");
}
}
//---------------------------------------------------------------------------------------------------------------------
const VTranslateVars *MApplication::TrVars()
{
return trVars;
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::InitTrVars()
{
trVars = new VTranslateVars(Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::OpenSettings()
{
settings = new VTapeSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName(), this);
}
//---------------------------------------------------------------------------------------------------------------------
VTapeSettings *MApplication::Settings()
{
SCASSERT(settings != nullptr);
return settings;
}
//---------------------------------------------------------------------------------------------------------------------
QString MApplication::translationsPath() const
{
const QString trPath = QStringLiteral("/translations");
#ifdef Q_OS_WIN
QDir dir(QApplication::applicationDirPath() + trPath);
if (dir.exists())
{
return dir.absolutePath();
}
else
{
return QApplication::applicationDirPath() + "../../valentina/bin" + trPath;
}
#else
#ifdef QT_DEBUG
QDir dir(QApplication::applicationDirPath() + trPath);
if (dir.exists())
{
return dir.absolutePath();
}
else
{
return QApplication::applicationDirPath() + "../../valentina/bin" + trPath;
}
#else
QDir dir1(QApplication::applicationDirPath() + trPath);
if (dir1.exists())
{
return dir1.absolutePath();
}
QDir dir2(QApplication::applicationDirPath() + "../../valentina/bin" + trPath);
if (dir2.exists())
{
return dir2.absolutePath();
}
else
{
return QStringLiteral("/usr/share/valentina/translations");
}
#endif
#endif
}
//---------------------------------------------------------------------------------------------------------------------
Unit MApplication::mUnit() const
{
return _mUnit;
}
//---------------------------------------------------------------------------------------------------------------------
const Unit *MApplication::mUnitP() const
{
return &_mUnit;
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::setMUnit(const Unit &mUnit)
{
_mUnit = mUnit;
}
//---------------------------------------------------------------------------------------------------------------------
MeasurementsType MApplication::mType() const
{
return mType();
}
//---------------------------------------------------------------------------------------------------------------------
void MApplication::setMType(const MeasurementsType &mType)
{
_mType = mType;
}
//---------------------------------------------------------------------------------------------------------------------
#if defined(Q_WS_MAC)
bool MApplication::event(QEvent* event)
{

View File

@ -31,9 +31,19 @@
#include <QApplication>
#include "../vpatterndb/vtranslatevars.h"
#include "../vmisc/def.h"
#include "../vmisc/vtapesettings.h"
class MApplication;// use in define
class TMainWindow;
class QLocalServer;
#if defined(qApp)
#undef qApp
#endif
#define qApp (static_cast<MApplication*>(QApplication::instance()))
class MApplication : public QApplication
{
Q_OBJECT
@ -42,8 +52,6 @@ public:
MApplication(int &argc, char **argv);
virtual ~MApplication() Q_DECL_OVERRIDE;
static MApplication *instance();
bool IsTheOnly() const;
TMainWindow *MainWindow();
QList<TMainWindow*> MainWindows();
@ -52,6 +60,23 @@ public:
bool event(QEvent *event);
#endif
void InitOptions();
virtual const VTranslateVars *TrVars();
void InitTrVars();
void OpenSettings();
VTapeSettings *Settings();
QString translationsPath() const;
Unit mUnit() const;
const Unit *mUnitP() const;
void setMUnit(const Unit &mUnit);
MeasurementsType mType() const;
void setMType(const MeasurementsType &mType);
public slots:
TMainWindow *NewMainWindow();
@ -63,6 +88,15 @@ private:
Q_DISABLE_COPY(MApplication)
QList<QPointer<TMainWindow> > mainWindows;
QLocalServer *localServer;
VTranslateVars *trVars;
Unit _mUnit;
MeasurementsType _mType;
/**
* @brief settings pointer to settings. Help hide constructor creation settings. Make make code more readable.
*/
VTapeSettings *settings;
void Clean();
};

View File

@ -7,7 +7,7 @@
# File with common stuff for whole project
include(../../../common.pri)
QT += core gui widgets network
QT += core gui widgets network xml xmlpatterns printsupport
# Name of binary file
TARGET = tape
@ -150,7 +150,7 @@ DEPENDPATH += $$PWD/../../libs/vwidgets
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
# VFormat static library (depend on VPatternDB)
# VFormat static library (depend on VPatternDB, IFC)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vformat/$${DESTDIR}/ -lvformat
INCLUDEPATH += $$PWD/../../libs/vformat
@ -159,7 +159,7 @@ DEPENDPATH += $$PWD/../../libs/vformat
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/vformat.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vformat/$${DESTDIR}/libvformat.a
#VPatternDB static library (depend on vgeometry, vmisc)
#VPatternDB static library (depend on vgeometry, vmisc, VLayout)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
INCLUDEPATH += $$PWD/../../libs/vpatterndb
@ -195,6 +195,23 @@ DEPENDPATH += $$PWD/../../libs/ifc
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/ifc.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/ifc/$${DESTDIR}/libifc.a
# VLayout static library
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vlayout/$${DESTDIR}/ -lvlayout
INCLUDEPATH += $$PWD/../../libs/vlayout
DEPENDPATH += $$PWD/../../libs/vlayout
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/vlayout.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vlayout/$${DESTDIR}/libvlayout.a
# QMuParser library
win32:CONFIG(release, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:win32:CONFIG(debug, debug|release): LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser2
else:unix: LIBS += -L$${OUT_PWD}/../../libs/qmuparser/$${DESTDIR} -lqmuparser
INCLUDEPATH += $${PWD}/../../libs/qmuparser
DEPENDPATH += $${PWD}/../../libs/qmuparser
noDebugSymbols{ # For enable run qmake with CONFIG+=noDebugSymbols
# do nothing
} else {

View File

@ -35,7 +35,9 @@
//---------------------------------------------------------------------------------------------------------------------
TMainWindow::TMainWindow(QWidget *parent)
:QMainWindow(parent),
ui(new Ui::TMainWindow)
ui(new Ui::TMainWindow),
m(nullptr),
data(nullptr)
{
ui->setupUi(this);
ui->tabWidget->setVisible(false);
@ -46,6 +48,8 @@ TMainWindow::TMainWindow(QWidget *parent)
//---------------------------------------------------------------------------------------------------------------------
TMainWindow::~TMainWindow()
{
delete data;
delete m;
delete ui;
}
@ -59,19 +63,35 @@ void TMainWindow::LoadFile(const QString &path)
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FileNew()
{
if (m == nullptr)
{
DialogNewMeasurements measurements(this);
if (measurements.exec() == QDialog::Rejected)
{
return;
}
InitNew(measurements.Type());
InitNew(measurements.Type(), measurements.MUnit());
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->FileNew();
}
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::FileOpen()
{
if (m == nullptr)
{
}
else
{
qApp->NewMainWindow();
qApp->MainWindow()->FileOpen();
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -90,7 +110,7 @@ void TMainWindow::FileSaveAs()
void TMainWindow::AboutToShowWindowMenu()
{
ui->menuWindow->clear();
QList<TMainWindow*> windows = MApplication::instance()->MainWindows();
QList<TMainWindow*> windows = qApp->MainWindows();
for (int i = 0; i < windows.count(); ++i)
{
TMainWindow *window = windows.at(i);
@ -113,7 +133,7 @@ void TMainWindow::ShowWindow()
if (v.canConvert<int>())
{
const int offset = qvariant_cast<int>(v);
QList<TMainWindow*> windows = MApplication::instance()->MainWindows();
QList<TMainWindow*> windows = qApp->MainWindows();
windows.at(offset)->activateWindow();
}
}
@ -164,11 +184,17 @@ void TMainWindow::SetupMenu()
}
//---------------------------------------------------------------------------------------------------------------------
void TMainWindow::InitNew(MeasurementsType type)
void TMainWindow::InitNew(MeasurementsType type, Unit unit)
{
ui->labelToolTip->setVisible(false);
ui->tabWidget->setVisible(true);
qApp->setMType(type);
qApp->setMUnit(unit);
data = new VContainer(qApp->TrVars(), qApp->mUnitP());
m = new VMeasurements(data);
if (type == MeasurementsType::Standard)
{
ui->labelMType->setText(tr("Standard measurements"));

View File

@ -32,6 +32,7 @@
#include <QMainWindow>
#include "../vmisc/def.h"
#include "../vformat/vmeasurements.h"
namespace Ui
{
@ -48,10 +49,10 @@ public:
public slots:
void LoadFile(const QString &path);
private slots:
void FileNew();
void FileOpen();
private slots:
void FileSave();
void FileSaveAs();
void AboutToShowWindowMenu();
@ -61,9 +62,11 @@ private slots:
private:
Q_DISABLE_COPY(TMainWindow)
Ui::TMainWindow *ui;
VMeasurements *m;
VContainer *data;
void SetupMenu();
void InitNew(MeasurementsType type);
void InitNew(MeasurementsType type, Unit unit);
void InitTable(MeasurementsType type);
};

View File

@ -576,7 +576,7 @@ const VTranslateVars *VApplication::TrVars()
//---------------------------------------------------------------------------------------------------------------------
void VApplication::InitTrVars()
{
trVars = new VTranslateVars(Settings());
trVars = new VTranslateVars(Settings()->GetOsSeparator());
}
#if defined(Q_OS_WIN) && defined(Q_CC_GNU)

View File

@ -161,8 +161,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::MainWindow *ui;
/** @brief tool current tool */
Tool currentTool;

View File

@ -567,7 +567,7 @@ DEPENDPATH += $$PWD/../../libs/vwidgets
win32:!win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/vwidgets.lib
else:unix|win32-g++: PRE_TARGETDEPS += $$OUT_PWD/../../libs/vwidgets/$${DESTDIR}/libvwidgets.a
#VPatternDB static library (depend on vgeometry, vmisc)
#VPatternDB static library (depend on vgeometry, vmisc, VLayout)
unix|win32: LIBS += -L$$OUT_PWD/../../libs/vpatterndb/$${DESTDIR} -lvpatterndb
INCLUDEPATH += $$PWD/../../libs/vpatterndb

View File

@ -28,7 +28,15 @@
#include "vmeasurements.h"
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::VMeasurements(VContainer *data)
:VDomDocument(),
data(data)
{
SCASSERT(data != nullptr)
}
VMeasurements::VMeasurements()
//---------------------------------------------------------------------------------------------------------------------
VMeasurements::~VMeasurements()
{
}

View File

@ -29,12 +29,21 @@
#ifndef VMEASUREMENTS_H
#define VMEASUREMENTS_H
#include "../ifc/xml/vdomdocument.h"
#include "../vpatterndb/vcontainer.h"
class VMeasurements
class VMeasurements : public VDomDocument
{
public:
VMeasurements();
VMeasurements(VContainer *data);
virtual ~VMeasurements() Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(VMeasurements)
/** @brief data container with data. */
VContainer *data;
};
#endif // VMEASUREMENTS_H

View File

@ -0,0 +1,269 @@
/************************************************************************
**
** @file vcommonsettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 7, 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 "vcommonsettings.h"
#include <QDir>
#include <QDebug>
#include <QLocale>
#include <QApplication>
#include "../../libs/ifc/ifcdef.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
# include "../../libs/vmisc/vmath.h"
#else
# include <QtMath>
#endif
const QString VCommonSettings::SettingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
const QString VCommonSettings::SettingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
const QString VCommonSettings::SettingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time");
const QString VCommonSettings::SettingConfigurationSendReportState = QStringLiteral("configuration/send_report/state");
const QString VCommonSettings::SettingConfigurationLocale = QStringLiteral("configuration/locale");
const QString VCommonSettings::SettingConfigurationUnit = QStringLiteral("configuration/unit");
const QString VCommonSettings::SettingConfigurationConfirmItemDeletion
= QStringLiteral("configuration/confirm_item_deletion");
const QString VCommonSettings::SettingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
const QString VCommonSettings::SettingPatternUser = QStringLiteral("pattern/user");
const QString VCommonSettings::SettingPatternUndo = QStringLiteral("pattern/undo");
const QString VCommonSettings::SettingGeneralRecentFileList = QStringLiteral("recentFileList");
const QString VCommonSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList");
const QString VCommonSettings::SettingGeneralGeometry = QStringLiteral("geometry");
const QString VCommonSettings::SettingGeneralWindowState = QStringLiteral("windowState");
const QString VCommonSettings::SettingGeneralToolbarsState = QStringLiteral("toolbarsState");
//---------------------------------------------------------------------------------------------------------------------
VCommonSettings::VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:QSettings(format, scope, organization, application, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetOsSeparator() const
{
return value(SettingConfigurationOsSeparator, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetOsSeparator(const bool &value)
{
setValue(SettingConfigurationOsSeparator, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetAutosaveState() const
{
return value(SettingConfigurationAutosaveState, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetAutosaveState(const bool &value)
{
setValue(SettingConfigurationAutosaveState, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetAutosaveTime() const
{
bool ok = false;
int val = value(SettingConfigurationAutosaveTime, 1).toInt(&ok);
if (ok == false)
{
qDebug()<<"Could not convert value"<<value(SettingConfigurationAutosaveTime, 1)
<<"to int. Return default value for autosave time"<<1<<"minutes.";
val = 1;
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetAutosaveTime(const int &value)
{
setValue(SettingConfigurationAutosaveTime, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetSendReportState() const
{
return value(SettingConfigurationSendReportState, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetSendReportState(const bool &value)
{
setValue(SettingConfigurationSendReportState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetLocale() const
{
return value(SettingConfigurationLocale, QLocale::system().name()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetLocale(const QString &value)
{
setValue(SettingConfigurationLocale, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetUnit() const
{
return value(SettingConfigurationUnit, "cm").toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUnit(const QString &value)
{
setValue(SettingConfigurationUnit, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetConfirmItemDelete() const
{
return value(SettingConfigurationConfirmItemDeletion, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetConfirmItemDelete(const bool &value)
{
setValue(SettingConfigurationConfirmItemDeletion, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VCommonSettings::GetToolBarStyle() const
{
return value(SettingConfigurationToolBarStyle, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetToolBarStyle(const bool &value)
{
setValue(SettingConfigurationToolBarStyle, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VCommonSettings::GetUser() const
{
QString user;
#ifdef Q_OS_WIN
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
return user;
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUser(const QString &value)
{
setValue(SettingPatternUser, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VCommonSettings::GetUndoCount() const
{
bool ok = false;
int val = value(SettingPatternUndo, 0).toInt(&ok);
if (ok == false)
{
qDebug()<<"Could not convert value"<<value(SettingPatternUndo, 0)
<<"to int. Return default value for undo counts 0 (no limit).";
val = 0;
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetUndoCount(const int &value)
{
setValue(SettingPatternUndo, value);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetRecentFileList() const
{
return value(SettingGeneralRecentFileList).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetRecentFileList(const QStringList &value)
{
setValue(SettingGeneralRecentFileList, value);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VCommonSettings::GetRestoreFileList() const
{
return value(SettingGeneralRestoreFileList).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetRestoreFileList(const QStringList &value)
{
setValue(SettingGeneralRestoreFileList, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VCommonSettings::GetGeometry() const
{
return value(SettingGeneralGeometry).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetGeometry(const QByteArray &value)
{
setValue(SettingGeneralGeometry, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VCommonSettings::GetWindowState() const
{
return value(SettingGeneralWindowState).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetWindowState(const QByteArray &value)
{
setValue(SettingGeneralWindowState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VCommonSettings::GetToolbarsState() const
{
return value(SettingGeneralToolbarsState).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VCommonSettings::SetToolbarsState(const QByteArray &value)
{
setValue(SettingGeneralToolbarsState, value);
}

View File

@ -0,0 +1,108 @@
/************************************************************************
**
** @file vcommonsettings.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 7, 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 VCOMMONSETTINGS_H
#define VCOMMONSETTINGS_H
#include <QSettings>
#include "../../libs/vlayout/vbank.h"
class VCommonSettings : public QSettings
{
Q_OBJECT
public:
VCommonSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = 0);
bool GetOsSeparator() const;
void SetOsSeparator(const bool &value);
bool GetAutosaveState() const;
void SetAutosaveState(const bool &value);
int GetAutosaveTime() const;
void SetAutosaveTime(const int &value);
bool GetSendReportState() const;
void SetSendReportState(const bool &value);
QString GetLocale() const;
void SetLocale(const QString &value);
QString GetUnit() const;
void SetUnit(const QString &value);
bool GetConfirmItemDelete() const;
void SetConfirmItemDelete(const bool &value);
bool GetToolBarStyle() const;
void SetToolBarStyle(const bool &value);
QString GetUser() const;
void SetUser(const QString &value);
int GetUndoCount() const;
void SetUndoCount(const int &value);
QStringList GetRecentFileList() const;
void SetRecentFileList(const QStringList &value);
QStringList GetRestoreFileList() const;
void SetRestoreFileList(const QStringList &value);
QByteArray GetGeometry() const;
void SetGeometry(const QByteArray &value);
QByteArray GetWindowState() const;
void SetWindowState(const QByteArray &value);
QByteArray GetToolbarsState() const;
void SetToolbarsState(const QByteArray &value);
private:
Q_DISABLE_COPY(VCommonSettings)
static const QString SettingConfigurationOsSeparator;
static const QString SettingConfigurationAutosaveState;
static const QString SettingConfigurationAutosaveTime;
static const QString SettingConfigurationSendReportState;
static const QString SettingConfigurationLocale;
static const QString SettingConfigurationUnit;
static const QString SettingConfigurationConfirmItemDeletion;
static const QString SettingConfigurationToolBarStyle;
static const QString SettingPatternUser;
static const QString SettingPatternUndo;
static const QString SettingGeneralRecentFileList;
static const QString SettingGeneralRestoreFileList;
static const QString SettingGeneralGeometry;
static const QString SettingGeneralWindowState;
static const QString SettingGeneralToolbarsState;
};
#endif // VCOMMONSETTINGS_H

View File

@ -9,7 +9,9 @@ SOURCES += \
$$PWD/backport/qcommandlineparser.cpp \
$$PWD/vsettings.cpp \
$$PWD/vabstractapplication.cpp \
projectversion.cpp
$$PWD/projectversion.cpp \
$$PWD/vcommonsettings.cpp \
$$PWD/vtapesettings.cpp
HEADERS += \
$$PWD/stable.h \
@ -21,4 +23,6 @@ HEADERS += \
$$PWD/backport/qcommandlineparser.h \
$$PWD/vsettings.h \
$$PWD/vabstractapplication.h \
projectversion.h
$$PWD/projectversion.h \
$$PWD/vcommonsettings.h \
$$PWD/vtapesettings.h

View File

@ -41,31 +41,14 @@
# include <QtMath>
#endif
const QString VSettings::SettingConfigurationOsSeparator = QStringLiteral("configuration/osSeparator");
const QString VSettings::SettingConfigurationAutosaveState = QStringLiteral("configuration/autosave/state");
const QString VSettings::SettingConfigurationAutosaveTime = QStringLiteral("configuration/autosave/time");
const QString VSettings::SettingConfigurationSendReportState = QStringLiteral("configuration/send_report/state");
const QString VSettings::SettingConfigurationLocale = QStringLiteral("configuration/locale");
const QString VSettings::SettingConfigurationUnit = QStringLiteral("configuration/unit");
const QString VSettings::SettingConfigurationLabelLanguage = QStringLiteral("configuration/label_language");
const QString VSettings::SettingConfigurationConfirmItemDeletion
= QStringLiteral("configuration/confirm_item_deletion");
const QString VSettings::SettingConfigurationToolBarStyle = QStringLiteral("configuration/tool_bar_style");
const QString VSettings::SettingPathsIndividualMeasurements = QStringLiteral("paths/individual_measurements");
const QString VSettings::SettingPathsStandardMeasurements = QStringLiteral("paths/standard_measurements");
const QString VSettings::SettingPathsPattern = QStringLiteral("paths/pattern");
const QString VSettings::SettingPathsLayout = QStringLiteral("paths/layout");
const QString VSettings::SettingPatternUser = QStringLiteral("pattern/user");
const QString VSettings::SettingPatternGraphicalOutput = QStringLiteral("pattern/graphicalOutput");
const QString VSettings::SettingPatternUndo = QStringLiteral("pattern/undo");
const QString VSettings::SettingGeneralRecentFileList = QStringLiteral("recentFileList");
const QString VSettings::SettingGeneralRestoreFileList = QStringLiteral("restoreFileList");
const QString VSettings::SettingGeneralGeometry = QStringLiteral("geometry");
const QString VSettings::SettingGeneralWindowState = QStringLiteral("windowState");
const QString VSettings::SettingGeneralToolbarsState = QStringLiteral("toolbarsState");
const QString VSettings::SettingCommunityServer = QStringLiteral("community/server");
const QString VSettings::SettingCommunityServerSecure = QStringLiteral("community/serverSecure");
@ -92,89 +75,9 @@ const QString VSettings::SettingLayoutUnitePages = QStringLitera
//---------------------------------------------------------------------------------------------------------------------
VSettings::VSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:QSettings(format, scope, organization, application, parent)
:VCommonSettings(format, scope, organization, application, parent)
{}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetOsSeparator() const
{
return value(SettingConfigurationOsSeparator, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetOsSeparator(const bool &value)
{
setValue(SettingConfigurationOsSeparator, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetAutosaveState() const
{
return value(SettingConfigurationAutosaveState, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetAutosaveState(const bool &value)
{
setValue(SettingConfigurationAutosaveState, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetAutosaveTime() const
{
bool ok = false;
int val = value(SettingConfigurationAutosaveTime, 1).toInt(&ok);
if (ok == false)
{
qDebug()<<"Could not convert value"<<value(SettingConfigurationAutosaveTime, 1)
<<"to int. Return default value for autosave time"<<1<<"minutes.";
val = 1;
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetAutosaveTime(const int &value)
{
setValue(SettingConfigurationAutosaveTime, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetSendReportState() const
{
return value(SettingConfigurationSendReportState, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetSendReportState(const bool &value)
{
setValue(SettingConfigurationSendReportState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLocale() const
{
return value(SettingConfigurationLocale, QLocale::system().name()).toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetLocale(const QString &value)
{
setValue(SettingConfigurationLocale, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetUnit() const
{
return value(SettingConfigurationUnit, "cm").toString();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetUnit(const QString &value)
{
setValue(SettingConfigurationUnit, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetLabelLanguage() const
{
@ -187,30 +90,6 @@ void VSettings::SetLabelLanguage(const QString &value)
setValue(SettingConfigurationLabelLanguage, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetConfirmItemDelete() const
{
return value(SettingConfigurationConfirmItemDeletion, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetConfirmItemDelete(const bool &value)
{
setValue(SettingConfigurationConfirmItemDeletion, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetToolBarStyle() const
{
return value(SettingConfigurationToolBarStyle, 1).toBool();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetToolBarStyle(const bool &value)
{
setValue(SettingConfigurationToolBarStyle, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetPathIndividualMeasurements() const
{
@ -259,24 +138,6 @@ void VSettings::SetPathLayout(const QString &value)
setValue(SettingPathsLayout, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetUser() const
{
QString user;
#ifdef Q_OS_WIN
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USERNAME").constData())).toString();
#else
user = value(SettingPatternUser, QString::fromLocal8Bit(qgetenv("USER").constData())).toString();
#endif
return user;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetUser(const QString &value)
{
setValue(SettingPatternUser, value);
}
//---------------------------------------------------------------------------------------------------------------------
bool VSettings::GetGraphicalOutput() const
{
@ -289,86 +150,6 @@ void VSettings::SetGraphicalOutput(const bool &value)
setValue(SettingPatternGraphicalOutput, value);
}
//---------------------------------------------------------------------------------------------------------------------
int VSettings::GetUndoCount() const
{
bool ok = false;
int val = value(SettingPatternUndo, 0).toInt(&ok);
if (ok == false)
{
qDebug()<<"Could not convert value"<<value(SettingPatternUndo, 0)
<<"to int. Return default value for undo counts 0 (no limit).";
val = 0;
}
return val;
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetUndoCount(const int &value)
{
setValue(SettingPatternUndo, value);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VSettings::GetRecentFileList() const
{
return value(SettingGeneralRecentFileList).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetRecentFileList(const QStringList &value)
{
setValue(SettingGeneralRecentFileList, value);
}
//---------------------------------------------------------------------------------------------------------------------
QStringList VSettings::GetRestoreFileList() const
{
return value(SettingGeneralRestoreFileList).toStringList();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetRestoreFileList(const QStringList &value)
{
setValue(SettingGeneralRestoreFileList, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VSettings::GetGeometry() const
{
return value(SettingGeneralGeometry).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetGeometry(const QByteArray &value)
{
setValue(SettingGeneralGeometry, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VSettings::GetWindowState() const
{
return value(SettingGeneralWindowState).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetWindowState(const QByteArray &value)
{
setValue(SettingGeneralWindowState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QByteArray VSettings::GetToolbarsState() const
{
return value(SettingGeneralToolbarsState).toByteArray();
}
//---------------------------------------------------------------------------------------------------------------------
void VSettings::SetToolbarsState(const QByteArray &value)
{
setValue(SettingGeneralToolbarsState, value);
}
//---------------------------------------------------------------------------------------------------------------------
QString VSettings::GetServer() const
{

View File

@ -29,10 +29,10 @@
#ifndef VSETTINGS_H
#define VSETTINGS_H
#include <QSettings>
#include "vcommonsettings.h"
#include "../../libs/vlayout/vbank.h"
class VSettings : public QSettings
class VSettings : public VCommonSettings
{
Q_OBJECT
public:
@ -41,33 +41,9 @@ public:
static QString StandardTablesPath();
bool GetOsSeparator() const;
void SetOsSeparator(const bool &value);
bool GetAutosaveState() const;
void SetAutosaveState(const bool &value);
int GetAutosaveTime() const;
void SetAutosaveTime(const int &value);
bool GetSendReportState() const;
void SetSendReportState(const bool &value);
QString GetLocale() const;
void SetLocale(const QString &value);
QString GetUnit() const;
void SetUnit(const QString &value);
QString GetLabelLanguage() const;
void SetLabelLanguage(const QString &value);
bool GetConfirmItemDelete() const;
void SetConfirmItemDelete(const bool &value);
bool GetToolBarStyle() const;
void SetToolBarStyle(const bool &value);
QString GetPathIndividualMeasurements() const;
void SetPathIndividualMeasurements(const QString &value);
@ -80,30 +56,9 @@ public:
QString GetPathLayout() const;
void SetPathLayout(const QString &value);
QString GetUser() const;
void SetUser(const QString &value);
bool GetGraphicalOutput() const;
void SetGraphicalOutput(const bool &value);
int GetUndoCount() const;
void SetUndoCount(const int &value);
QStringList GetRecentFileList() const;
void SetRecentFileList(const QStringList &value);
QStringList GetRestoreFileList() const;
void SetRestoreFileList(const QStringList &value);
QByteArray GetGeometry() const;
void SetGeometry(const QByteArray &value);
QByteArray GetWindowState() const;
void SetWindowState(const QByteArray &value);
QByteArray GetToolbarsState() const;
void SetToolbarsState(const QByteArray &value);
QString GetServer() const;
void SetServer(const QString &value);
@ -171,30 +126,14 @@ public:
private:
Q_DISABLE_COPY(VSettings)
static const QString SettingConfigurationOsSeparator;
static const QString SettingConfigurationAutosaveState;
static const QString SettingConfigurationAutosaveTime;
static const QString SettingConfigurationSendReportState;
static const QString SettingConfigurationLocale;
static const QString SettingConfigurationUnit;
static const QString SettingConfigurationLabelLanguage;
static const QString SettingConfigurationConfirmItemDeletion;
static const QString SettingConfigurationToolBarStyle;
static const QString SettingPathsIndividualMeasurements;
static const QString SettingPathsStandardMeasurements;
static const QString SettingPathsPattern;
static const QString SettingPathsLayout;
static const QString SettingPatternUser;
static const QString SettingPatternGraphicalOutput;
static const QString SettingPatternUndo;
static const QString SettingGeneralRecentFileList;
static const QString SettingGeneralRestoreFileList;
static const QString SettingGeneralGeometry;
static const QString SettingGeneralWindowState;
static const QString SettingGeneralToolbarsState;
static const QString SettingCommunityServer;
static const QString SettingCommunityServerSecure;

View File

@ -0,0 +1,36 @@
/************************************************************************
**
** @file vtapesettings.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 7, 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 "vtapesettings.h"
//---------------------------------------------------------------------------------------------------------------------
VTapeSettings::VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application,
QObject *parent)
:VCommonSettings(format, scope, organization, application, parent)
{
}

View File

@ -0,0 +1,42 @@
/************************************************************************
**
** @file vtapesettings.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 15 7, 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 VTAPESETTINGS_H
#define VTAPESETTINGS_H
#include "vcommonsettings.h"
class VTapeSettings : public VCommonSettings
{
Q_OBJECT
public:
VTapeSettings(Format format, Scope scope, const QString &organization, const QString &application = QString(),
QObject *parent = 0);
};
#endif // VTAPESETTINGS_H