parent
2147e9fd97
commit
ed25d04e5e
|
@ -36,24 +36,30 @@
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
ConfigDialog::ConfigDialog(QWidget *parent) :
|
||||
QDialog(parent), contentsWidget(nullptr), pagesWidget(nullptr), configurationPage(nullptr), patternPage(nullptr),
|
||||
communityPage(nullptr)
|
||||
communityPage(nullptr), pathPage(nullptr)
|
||||
{
|
||||
contentsWidget = new QListWidget;
|
||||
contentsWidget->setViewMode(QListView::IconMode);
|
||||
contentsWidget->setIconSize(QSize(96, 84));
|
||||
contentsWidget->setMovement(QListView::Static);
|
||||
contentsWidget->setMaximumWidth(128);
|
||||
contentsWidget->setMinimumHeight(250);
|
||||
contentsWidget->setMinimumHeight(500);
|
||||
contentsWidget->setSpacing(12);
|
||||
|
||||
pagesWidget = new QStackedWidget;
|
||||
|
||||
configurationPage = new ConfigurationPage();
|
||||
pagesWidget->addWidget(configurationPage);
|
||||
|
||||
patternPage = new PatternPage();
|
||||
pagesWidget->addWidget(patternPage);
|
||||
|
||||
communityPage = new CommunityPage();
|
||||
pagesWidget->addWidget(communityPage);
|
||||
|
||||
pathPage = new PathPage();
|
||||
pagesWidget->addWidget(pathPage);
|
||||
|
||||
QPushButton *applyButton = new QPushButton(tr("Apply"));
|
||||
QPushButton *canselButton = new QPushButton(tr("&Cancel"));
|
||||
QPushButton *okButton = new QPushButton(tr("&Ok"));
|
||||
|
@ -83,6 +89,8 @@ ConfigDialog::ConfigDialog(QWidget *parent) :
|
|||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("Config Dialog"));
|
||||
|
||||
this->setFixedSize(QSize(750, 550));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -108,27 +116,24 @@ void ConfigDialog::closeEvent(QCloseEvent *event)
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void ConfigDialog::createIcons()
|
||||
{
|
||||
QListWidgetItem *configButton = new QListWidgetItem(contentsWidget);
|
||||
configButton->setIcon(QIcon("://icon/config.png"));
|
||||
configButton->setText(tr("Configuration"));
|
||||
configButton->setTextAlignment(Qt::AlignHCenter);
|
||||
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);
|
||||
createIcon("://icon/config.png", tr("Configuration"));
|
||||
createIcon("://icon/pattern_config.png", tr("Pattern"));
|
||||
createIcon("://icon/community_config.png", tr("Community"));
|
||||
createIcon("://icon/path_config.png", tr("Paths"));
|
||||
|
||||
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()
|
||||
{
|
||||
|
@ -143,6 +148,9 @@ void ConfigDialog::Apply()
|
|||
case (2):
|
||||
communityPage->Apply();
|
||||
break;
|
||||
case (3):
|
||||
pathPage->Apply();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,9 @@ private:
|
|||
ConfigurationPage *configurationPage;
|
||||
PatternPage *patternPage;
|
||||
CommunityPage *communityPage;
|
||||
PathPage *pathPage;
|
||||
void createIcons();
|
||||
void createIcon(const QString &icon, const QString &text);
|
||||
void Apply();
|
||||
void Ok();
|
||||
};
|
||||
|
|
|
@ -32,5 +32,6 @@
|
|||
#include "configurationpage.h"
|
||||
#include "patternpage.h"
|
||||
#include "communitypage.h"
|
||||
#include "pathpage.h"
|
||||
|
||||
#endif // PAGES_H
|
||||
|
|
162
src/app/dialogs/app/configpages/pathpage.cpp
Normal file
162
src/app/dialogs/app/configpages/pathpage.cpp
Normal 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);
|
||||
}
|
58
src/app/dialogs/app/configpages/pathpage.h
Normal file
58
src/app/dialogs/app/configpages/pathpage.h
Normal 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
|
|
@ -32,6 +32,7 @@
|
|||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include "../../widgets/vapplication.h"
|
||||
#include "../../container/vcontainer.h"
|
||||
|
||||
|
@ -187,7 +188,12 @@ void DialogIndividualMeasurements::CheckState()
|
|||
void DialogIndividualMeasurements::OpenTable()
|
||||
{
|
||||
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())
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -34,7 +34,8 @@ HEADERS += \
|
|||
dialogs/app/dialogpatternxmledit.h \
|
||||
dialogs/app/configpages/configurationpage.h \
|
||||
dialogs/app/configpages/patternpage.h \
|
||||
dialogs/app/configpages/communitypage.h
|
||||
dialogs/app/configpages/communitypage.h \
|
||||
dialogs/app/configpages/pathpage.h
|
||||
|
||||
SOURCES += \
|
||||
dialogs/tools/dialogtriangle.cpp \
|
||||
|
@ -70,7 +71,8 @@ SOURCES += \
|
|||
dialogs/tools/dialogeditwrongformula.cpp \
|
||||
dialogs/app/configpages/configurationpage.cpp \
|
||||
dialogs/app/configpages/patternpage.cpp \
|
||||
dialogs/app/configpages/communitypage.cpp
|
||||
dialogs/app/configpages/communitypage.cpp \
|
||||
dialogs/app/configpages/pathpage.cpp
|
||||
|
||||
FORMS += \
|
||||
dialogs/tools/dialogtriangle.ui \
|
||||
|
|
|
@ -1393,10 +1393,13 @@ void MainWindow::ActionDetails(bool checked)
|
|||
bool MainWindow::SaveAs()
|
||||
{
|
||||
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;
|
||||
if (curFile.isEmpty())
|
||||
{
|
||||
dir = QDir::homePath() + tr("/pattern.val");
|
||||
dir = path + "/" + tr("pattern") + ".val";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -55,5 +55,6 @@
|
|||
<file>icon/32x32/arrowUp.png</file>
|
||||
<file>icon/32x32/arrowLeftUp.png</file>
|
||||
<file>icon/32x32/putHereLeft.png</file>
|
||||
<file>icon/path_config.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
src/app/share/resources/icon/path_config.png
Normal file
BIN
src/app/share/resources/icon/path_config.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
Loading…
Reference in New Issue
Block a user