diff --git a/src/app/dialogs/app/configdialog.cpp b/src/app/dialogs/app/configdialog.cpp index c684f3629..05d34ad67 100644 --- a/src/app/dialogs/app/configdialog.cpp +++ b/src/app/dialogs/app/configdialog.cpp @@ -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; } diff --git a/src/app/dialogs/app/configdialog.h b/src/app/dialogs/app/configdialog.h index 7832ebd4d..8045a33d2 100644 --- a/src/app/dialogs/app/configdialog.h +++ b/src/app/dialogs/app/configdialog.h @@ -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(); }; diff --git a/src/app/dialogs/app/configpages/pages.h b/src/app/dialogs/app/configpages/pages.h index e2d8c836c..271a48c3f 100644 --- a/src/app/dialogs/app/configpages/pages.h +++ b/src/app/dialogs/app/configpages/pages.h @@ -32,5 +32,6 @@ #include "configurationpage.h" #include "patternpage.h" #include "communitypage.h" +#include "pathpage.h" #endif // PAGES_H diff --git a/src/app/dialogs/app/configpages/pathpage.cpp b/src/app/dialogs/app/configpages/pathpage.cpp new file mode 100644 index 000000000..af7a27ff2 --- /dev/null +++ b/src/app/dialogs/app/configpages/pathpage.cpp @@ -0,0 +1,162 @@ +/************************************************************************ + ** + ** @file pathpage.cpp + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#include "pathpage.h" +#include "../../../options.h" +#include "../../../widgets/vapplication.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//--------------------------------------------------------------------------------------------------------------------- +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); +} diff --git a/src/app/dialogs/app/configpages/pathpage.h b/src/app/dialogs/app/configpages/pathpage.h new file mode 100644 index 000000000..f51b83da0 --- /dev/null +++ b/src/app/dialogs/app/configpages/pathpage.h @@ -0,0 +1,58 @@ +/************************************************************************ + ** + ** @file pathpage.h + ** @author Roman Telezhynskyi + ** @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 + ** 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 . + ** + *************************************************************************/ + +#ifndef PATHPAGE_H +#define PATHPAGE_H + +#include +#include + +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 diff --git a/src/app/dialogs/app/dialogindividualmeasurements.cpp b/src/app/dialogs/app/dialogindividualmeasurements.cpp index a9c2e8b34..6432244fb 100644 --- a/src/app/dialogs/app/dialogindividualmeasurements.cpp +++ b/src/app/dialogs/app/dialogindividualmeasurements.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #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; diff --git a/src/app/dialogs/dialogs.pri b/src/app/dialogs/dialogs.pri index 225479f43..2a2deb89a 100644 --- a/src/app/dialogs/dialogs.pri +++ b/src/app/dialogs/dialogs.pri @@ -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 \ diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 02b2fafa2..0d6e92e5a 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -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 { diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index e127d2f36..6b66c2418 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -55,5 +55,6 @@ icon/32x32/arrowUp.png icon/32x32/arrowLeftUp.png icon/32x32/putHereLeft.png + icon/path_config.png diff --git a/src/app/share/resources/icon/path_config.png b/src/app/share/resources/icon/path_config.png new file mode 100644 index 000000000..a1a9e0e45 Binary files /dev/null and b/src/app/share/resources/icon/path_config.png differ