Fixed issue #148. Fixed issue #149.

--HG--
branch : develop
This commit is contained in:
dismine 2014-06-22 19:46:47 +03:00
parent 2147e9fd97
commit ed25d04e5e
10 changed files with 266 additions and 23 deletions

View File

@ -36,24 +36,30 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
ConfigDialog::ConfigDialog(QWidget *parent) : ConfigDialog::ConfigDialog(QWidget *parent) :
QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr), QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr),
communityPage(nullptr) communityPage(nullptr), pathPage(nullptr)
{ {
contentsWidget = new QListWidget; contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode); contentsWidget->setViewMode(QListView::IconMode);
contentsWidget->setIconSize(QSize(96, 84)); contentsWidget->setIconSize(QSize(96, 84));
contentsWidget->setMovement(QListView::Static); contentsWidget->setMovement(QListView::Static);
contentsWidget->setMaximumWidth(128); contentsWidget->setMaximumWidth(128);
contentsWidget->setMinimumHeight(250); contentsWidget->setMinimumHeight(500);
contentsWidget->setSpacing(12); contentsWidget->setSpacing(12);
pagesWidget = new QStackedWidget; pagesWidget = new QStackedWidget;
configurationPage = new ConfigurationPage(); configurationPage = new ConfigurationPage();
pagesWidget->addWidget(configurationPage); pagesWidget->addWidget(configurationPage);
patternPage = new PatternPage(); patternPage = new PatternPage();
pagesWidget->addWidget(patternPage); pagesWidget->addWidget(patternPage);
communityPage = new CommunityPage(); communityPage = new CommunityPage();
pagesWidget->addWidget(communityPage); pagesWidget->addWidget(communityPage);
pathPage = new PathPage();
pagesWidget->addWidget(pathPage);
QPushButton *applyButton = new QPushButton(tr("Apply")); QPushButton *applyButton = new QPushButton(tr("Apply"));
QPushButton *canselButton = new QPushButton(tr("&Cancel")); QPushButton *canselButton = new QPushButton(tr("&Cancel"));
QPushButton *okButton = new QPushButton(tr("&Ok")); QPushButton *okButton = new QPushButton(tr("&Ok"));
@ -83,6 +89,8 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
setLayout(mainLayout); setLayout(mainLayout);
setWindowTitle(tr("Config Dialog")); setWindowTitle(tr("Config Dialog"));
this->setFixedSize(QSize(750, 550));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -108,27 +116,24 @@ void ConfigDialog::closeEvent(QCloseEvent *event)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::createIcons() void ConfigDialog::createIcons()
{ {
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget); createIcon("://icon/config.png", tr("Configuration"));
configButton->setIcon(QIcon("://icon/config.png")); createIcon("://icon/pattern_config.png", tr("Pattern"));
configButton->setText(tr("Configuration")); createIcon("://icon/community_config.png", tr("Community"));
configButton->setTextAlignment(Qt::AlignHCenter); createIcon("://icon/path_config.png", tr("Paths"));
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *patternButton = new QListWidgetItem(contentsWidget);
patternButton->setIcon(QIcon("://icon/pattern_config.png"));
patternButton->setText(tr("Pattern"));
patternButton->setTextAlignment(Qt::AlignHCenter);
patternButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *communityButton = new QListWidgetItem(contentsWidget);
communityButton->setIcon(QIcon("://icon/community_config.png"));
communityButton->setText(tr("Community"));
communityButton->setTextAlignment(Qt::AlignHCenter);
communityButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage); connect(contentsWidget, &QListWidget::currentItemChanged, this, &ConfigDialog::changePage);
} }
//---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::createIcon(const QString &icon, const QString &text)
{
QListWidgetItem *button = new QListWidgetItem(contentsWidget);
button->setIcon(QIcon(icon));
button->setText(text);
button->setTextAlignment(Qt::AlignHCenter);
button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void ConfigDialog::Apply() void ConfigDialog::Apply()
{ {
@ -143,6 +148,9 @@ void ConfigDialog::Apply()
case (2): case (2):
communityPage->Apply(); communityPage->Apply();
break; break;
case (3):
pathPage->Apply();
break;
default: default:
break; break;
} }

View File

@ -52,7 +52,9 @@ private:
ConfigurationPage *configurationPage; ConfigurationPage *configurationPage;
PatternPage *patternPage; PatternPage *patternPage;
CommunityPage *communityPage; CommunityPage *communityPage;
PathPage *pathPage;
void createIcons(); void createIcons();
void createIcon(const QString &icon, const QString &text);
void Apply(); void Apply();
void Ok(); void Ok();
}; };

View File

@ -32,5 +32,6 @@
#include "configurationpage.h" #include "configurationpage.h"
#include "patternpage.h" #include "patternpage.h"
#include "communitypage.h" #include "communitypage.h"
#include "pathpage.h"
#endif // PAGES_H #endif // PAGES_H

View File

@ -0,0 +1,162 @@
/************************************************************************
**
** @file pathpage.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 6, 2014
**
** @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) 2014 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 "pathpage.h"
#include "../../../options.h"
#include "../../../widgets/vapplication.h"
#include <QDir>
#include <QGroupBox>
#include <QLabel>
#include <QSettings>
#include <QTimer>
#include <QSpinBox>
#include <QComboBox>
#include <QMessageBox>
#include <QCheckBox>
#include <QIcon>
#include <QVBoxLayout>
#include <QTableWidget>
#include <QPushButton>
#include <QFileDialog>
//---------------------------------------------------------------------------------------------------------------------
PathPage::PathPage(QWidget *parent)
: QWidget(parent), defaultButton(nullptr), editButton(nullptr), pathTable(nullptr)
{
QGroupBox *pathGroup = PathGroup();
SCASSERT(pathGroup != nullptr);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(pathGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::Apply()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
settings.setValue("paths/individual_measurements", pathTable->item(0, 1)->text());
settings.setValue("paths/pattern", pathTable->item(1, 1)->text());
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::TableActivated()
{
defaultButton->setEnabled(true);
defaultButton->setDefault(false);
editButton->setEnabled(true);
editButton->setDefault(true);
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::DefaultPath()
{
QTableWidgetItem *item = pathTable->item(pathTable->currentRow(), 1);
SCASSERT(item != nullptr);
item->setText(QDir::homePath());
}
//---------------------------------------------------------------------------------------------------------------------
void PathPage::EditPath()
{
QTableWidgetItem *item = pathTable->item(pathTable->currentRow(), 1);
SCASSERT(item != nullptr);
QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), QDir::homePath(),
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dir.isEmpty())
{
dir = QDir::homePath();
}
item->setText(dir);
}
//---------------------------------------------------------------------------------------------------------------------
QGroupBox *PathPage::PathGroup()
{
QGroupBox *pathGroup = new QGroupBox(tr("Path that use Valentina"));
InitTable();
defaultButton = new QPushButton(tr("Default"));
defaultButton->setEnabled(false);
connect(defaultButton, &QPushButton::clicked, this, &PathPage::DefaultPath);
editButton = new QPushButton(tr("Edit"));
editButton->setEnabled(false);
connect(editButton, &QPushButton::clicked, this, &PathPage::EditPath);
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addWidget(defaultButton);
buttonsLayout->addWidget(editButton);
QVBoxLayout *pathLayout = new QVBoxLayout;
pathLayout->addWidget(pathTable);
pathLayout->addLayout(buttonsLayout);
pathGroup->setLayout(pathLayout);
return pathGroup;
}
void PathPage::InitTable()
{
pathTable = new QTableWidget();
pathTable->setRowCount(2);
pathTable->setColumnCount(2);
pathTable->verticalHeader()->setVisible(false);
pathTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
pathTable->setSelectionBehavior(QAbstractItemView::SelectRows);
pathTable->setSelectionMode(QAbstractItemView::SingleSelection);
pathTable->setShowGrid(false);
QStringList tableHeader{tr("Type"), tr("Path")};
pathTable->setHorizontalHeaderLabels(tableHeader);
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
QString path;
pathTable->setItem(0, 0, new QTableWidgetItem(tr("Individual measurements")));
path = settings.value("paths/individual_measurements", QDir::homePath()).toString();
pathTable->setItem(0, 1, new QTableWidgetItem(path));
pathTable->setItem(1, 0, new QTableWidgetItem(tr("Patterns")));
path = settings.value("paths/pattern", QDir::homePath()).toString();
pathTable->setItem(1, 1, new QTableWidgetItem(path));
pathTable->verticalHeader()->setDefaultSectionSize(20);
pathTable->resizeColumnsToContents();
pathTable->resizeRowsToContents();
pathTable->horizontalHeader()->setStretchLastSection(true);
connect(pathTable, &QTableWidget::itemSelectionChanged, this, &PathPage::TableActivated);
}

View File

@ -0,0 +1,58 @@
/************************************************************************
**
** @file pathpage.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 21 6, 2014
**
** @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) 2014 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 PATHPAGE_H
#define PATHPAGE_H
#include <QObject>
#include <QWidget>
class QGroupBox;
class QPushButton;
class QTableWidget;
class PathPage : public QWidget
{
Q_OBJECT
public:
PathPage(QWidget *parent = nullptr);
void Apply();
public slots:
void TableActivated();
void DefaultPath();
void EditPath();
private:
Q_DISABLE_COPY(PathPage)
QPushButton *defaultButton;
QPushButton *editButton;
QTableWidget *pathTable;
QGroupBox *PathGroup();
void InitTable();
};
#endif // PATHPAGE_H

View File

@ -32,6 +32,7 @@
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
#include <QSettings>
#include "../../widgets/vapplication.h" #include "../../widgets/vapplication.h"
#include "../../container/vcontainer.h" #include "../../container/vcontainer.h"
@ -187,7 +188,12 @@ void DialogIndividualMeasurements::CheckState()
void DialogIndividualMeasurements::OpenTable() void DialogIndividualMeasurements::OpenTable()
{ {
const QString filter(tr("Individual measurements (*.vit)")); const QString filter(tr("Individual measurements (*.vit)"));
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
QString path = settings.value("paths/individual_measurements", QDir::homePath()).toString();
QString fileName = QFileDialog::getOpenFileName(this, tr("Open file"), path, filter);
if (fileName.isEmpty()) if (fileName.isEmpty())
{ {
return; return;

View File

@ -34,7 +34,8 @@ HEADERS += \
dialogs/app/dialogpatternxmledit.h \ dialogs/app/dialogpatternxmledit.h \
dialogs/app/configpages/configurationpage.h \ dialogs/app/configpages/configurationpage.h \
dialogs/app/configpages/patternpage.h \ dialogs/app/configpages/patternpage.h \
dialogs/app/configpages/communitypage.h dialogs/app/configpages/communitypage.h \
dialogs/app/configpages/pathpage.h
SOURCES += \ SOURCES += \
dialogs/tools/dialogtriangle.cpp \ dialogs/tools/dialogtriangle.cpp \
@ -70,7 +71,8 @@ SOURCES += \
dialogs/tools/dialogeditwrongformula.cpp \ dialogs/tools/dialogeditwrongformula.cpp \
dialogs/app/configpages/configurationpage.cpp \ dialogs/app/configpages/configurationpage.cpp \
dialogs/app/configpages/patternpage.cpp \ dialogs/app/configpages/patternpage.cpp \
dialogs/app/configpages/communitypage.cpp dialogs/app/configpages/communitypage.cpp \
dialogs/app/configpages/pathpage.cpp
FORMS += \ FORMS += \
dialogs/tools/dialogtriangle.ui \ dialogs/tools/dialogtriangle.ui \

View File

@ -1393,10 +1393,13 @@ void MainWindow::ActionDetails(bool checked)
bool MainWindow::SaveAs() bool MainWindow::SaveAs()
{ {
QString filters(tr("Pattern files (*.val)")); QString filters(tr("Pattern files (*.val)"));
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(),
QApplication::applicationName());
QString path = settings.value("paths/pattern", QDir::homePath()).toString();
QString dir; QString dir;
if (curFile.isEmpty()) if (curFile.isEmpty())
{ {
dir = QDir::homePath() + tr("/pattern.val"); dir = path + "/" + tr("pattern") + ".val";
} }
else else
{ {

View File

@ -55,5 +55,6 @@
<file>icon/32x32/arrowUp.png</file> <file>icon/32x32/arrowUp.png</file>
<file>icon/32x32/arrowLeftUp.png</file> <file>icon/32x32/arrowLeftUp.png</file>
<file>icon/32x32/putHereLeft.png</file> <file>icon/32x32/putHereLeft.png</file>
<file>icon/path_config.png</file>
</qresource> </qresource>
</RCC> </RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB