Dialog File > Preferences.
This commit is contained in:
parent
05645ca7df
commit
06d19ace25
|
@ -0,0 +1,104 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file puzzlepreferencesconfigurationpage.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "puzzlepreferencesconfigurationpage.h"
|
||||
#include "ui_puzzlepreferencesconfigurationpage.h"
|
||||
#include "../../vpapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PuzzlePreferencesConfigurationPage::PuzzlePreferencesConfigurationPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PuzzlePreferencesConfigurationPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
InitLanguages(ui->langCombo);
|
||||
connect(ui->langCombo, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
|
||||
{
|
||||
m_langChanged = true;
|
||||
});
|
||||
|
||||
// Theme
|
||||
ui->darkModeCheck->setChecked(VPApplication::VApp()->PuzzleSettings()->GetDarkMode());
|
||||
|
||||
// Native dialogs
|
||||
ui->checkBoxDontUseNativeDialog->setChecked(VPApplication::VApp()->PuzzleSettings()->IsDontUseNativeDialog());
|
||||
|
||||
//----------------------- Toolbar
|
||||
ui->toolBarStyleCheck->setChecked(VPApplication::VApp()->PuzzleSettings()->GetToolBarStyle());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PuzzlePreferencesConfigurationPage::~PuzzlePreferencesConfigurationPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QStringList PuzzlePreferencesConfigurationPage::Apply()
|
||||
{
|
||||
QStringList preferences;
|
||||
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||
|
||||
settings->SetToolBarStyle(ui->toolBarStyleCheck->isChecked());
|
||||
|
||||
if (settings->GetDarkMode() != ui->darkModeCheck->isChecked())
|
||||
{
|
||||
settings->SetDarkMode(ui->darkModeCheck->isChecked());
|
||||
preferences.append(tr("dark mode"));
|
||||
}
|
||||
|
||||
if (settings->IsDontUseNativeDialog() != ui->checkBoxDontUseNativeDialog->isChecked())
|
||||
{
|
||||
settings->SetDontUseNativeDialog(ui->checkBoxDontUseNativeDialog->isChecked());
|
||||
}
|
||||
|
||||
if (m_langChanged)
|
||||
{
|
||||
const QString locale = qvariant_cast<QString>(ui->langCombo->currentData());
|
||||
settings->SetLocale(locale);
|
||||
m_langChanged = false;
|
||||
|
||||
VAbstractApplication::VApp()->LoadTranslation(locale);
|
||||
qApp->processEvents();// force to call changeEvent
|
||||
}
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesConfigurationPage::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
// remember to call base class implementation
|
||||
QWidget::changeEvent(event);
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file puzzlepreferencesconfigurationpage.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 PUZZLEPREFERENCESCONFIGURATIONPAGE_H
|
||||
#define PUZZLEPREFERENCESCONFIGURATIONPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PuzzlePreferencesConfigurationPage;
|
||||
}
|
||||
|
||||
class PuzzlePreferencesConfigurationPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PuzzlePreferencesConfigurationPage(QWidget *parent = nullptr);
|
||||
virtual ~PuzzlePreferencesConfigurationPage();
|
||||
|
||||
QStringList Apply();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(PuzzlePreferencesConfigurationPage)
|
||||
Ui::PuzzlePreferencesConfigurationPage *ui;
|
||||
bool m_langChanged{false};
|
||||
};
|
||||
|
||||
#endif // PUZZLEPREFERENCESCONFIGURATIONPAGE_H
|
|
@ -0,0 +1,117 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PuzzlePreferencesConfigurationPage</class>
|
||||
<widget class="QWidget" name="PuzzlePreferencesConfigurationPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>505</width>
|
||||
<height>548</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea">
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>494</width>
|
||||
<height>514</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>GUI language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="langCombo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_6">
|
||||
<property name="title">
|
||||
<string>Toolbar</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="toolBarStyleCheck">
|
||||
<property name="text">
|
||||
<string>The text appears under the icon (recommended for beginners).</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
<property name="title">
|
||||
<string>User Interface</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="darkModeCheck">
|
||||
<property name="text">
|
||||
<string>Activate dark mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxDontUseNativeDialog">
|
||||
<property name="text">
|
||||
<string>Don't use the native file dialog</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
220
src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp
Normal file
220
src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.cpp
Normal file
|
@ -0,0 +1,220 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file puzzlepreferencespathpage.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "puzzlepreferencespathpage.h"
|
||||
#include "ui_puzzlepreferencespathpage.h"
|
||||
#include "../../vpapplication.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PuzzlePreferencesPathPage::PuzzlePreferencesPathPage(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::PuzzlePreferencesPathPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
InitTable();
|
||||
|
||||
connect(ui->pathTable, &QTableWidget::itemSelectionChanged, this, [this]()
|
||||
{
|
||||
ui->defaultButton->setEnabled(not ui->pathTable->selectedItems().isEmpty());
|
||||
ui->defaultButton->setDefault(false);
|
||||
|
||||
ui->editButton->setEnabled(not ui->pathTable->selectedItems().isEmpty());
|
||||
ui->editButton->setDefault(true);
|
||||
});
|
||||
|
||||
connect(ui->defaultButton, &QPushButton::clicked, this, &PuzzlePreferencesPathPage::DefaultPath);
|
||||
connect(ui->editButton, &QPushButton::clicked, this, &PuzzlePreferencesPathPage::EditPath);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
PuzzlePreferencesPathPage::~PuzzlePreferencesPathPage()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesPathPage::Apply()
|
||||
{
|
||||
VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||
settings->SetPathIndividualMeasurements(ui->pathTable->item(0, 1)->text());
|
||||
settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text());
|
||||
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
|
||||
settings->SetPathTemplate(ui->pathTable->item(3, 1)->text());
|
||||
settings->SetPathManualLayouts(ui->pathTable->item(4, 1)->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesPathPage::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
InitTable();
|
||||
}
|
||||
// remember to call base class implementation
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesPathPage::DefaultPath()
|
||||
{
|
||||
const int row = ui->pathTable->currentRow();
|
||||
QTableWidgetItem *item = ui->pathTable->item(row, 1);
|
||||
SCASSERT(item != nullptr)
|
||||
|
||||
QString path;
|
||||
switch (row)
|
||||
{
|
||||
case 0: // individual measurements
|
||||
path = VCommonSettings::GetDefPathIndividualMeasurements();
|
||||
break;
|
||||
case 1: // multisize measurements
|
||||
path = VCommonSettings::GetDefPathMultisizeMeasurements();
|
||||
break;
|
||||
case 2: // pattern path
|
||||
path = VCommonSettings::GetDefPathPattern();
|
||||
break;
|
||||
case 3: // templates
|
||||
path = VCommonSettings::GetDefPathTemplate();
|
||||
break;
|
||||
case 4: // layouts
|
||||
path = VCommonSettings::GetDefPathManualLayouts();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
item->setText(path);
|
||||
item->setToolTip(path);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesPathPage::EditPath()
|
||||
{
|
||||
const int row = ui->pathTable->currentRow();
|
||||
QTableWidgetItem *item = ui->pathTable->item(row, 1);
|
||||
SCASSERT(item != nullptr)
|
||||
|
||||
QString path;
|
||||
switch (row)
|
||||
{
|
||||
case 0: // individual measurements
|
||||
path = VPApplication::VApp()->PuzzleSettings()->GetPathIndividualMeasurements();
|
||||
break;
|
||||
case 1: // multisize measurements
|
||||
path = VPApplication::VApp()->PuzzleSettings()->GetPathMultisizeMeasurements();
|
||||
path = VCommonSettings::PrepareMultisizeTables(path);
|
||||
break;
|
||||
case 2: // pattern path
|
||||
path = VPApplication::VApp()->PuzzleSettings()->GetPathPattern();
|
||||
break;
|
||||
case 3: // templates
|
||||
path = VPApplication::VApp()->PuzzleSettings()->GetPathTemplate();
|
||||
break;
|
||||
case 4: // layouts
|
||||
path = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
bool usedNotExistedDir = false;
|
||||
QDir directory(path);
|
||||
if (not directory.exists())
|
||||
{
|
||||
usedNotExistedDir = directory.mkpath(QChar('.'));
|
||||
}
|
||||
|
||||
const QString dir = QFileDialog::getExistingDirectory(
|
||||
this, tr("Open Directory"), path,
|
||||
VAbstractApplication::VApp()->NativeFileDialog(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));
|
||||
if (dir.isEmpty())
|
||||
{
|
||||
if (usedNotExistedDir)
|
||||
{
|
||||
QDir(path).rmpath(QChar('.'));
|
||||
}
|
||||
|
||||
DefaultPath();
|
||||
return;
|
||||
}
|
||||
|
||||
item->setText(dir);
|
||||
item->setToolTip(dir);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void PuzzlePreferencesPathPage::InitTable()
|
||||
{
|
||||
ui->pathTable->clearContents();
|
||||
ui->pathTable->setRowCount(5);
|
||||
ui->pathTable->setColumnCount(2);
|
||||
|
||||
const VPSettings *settings = VPApplication::VApp()->PuzzleSettings();
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(0, 0, new QTableWidgetItem(tr("My Individual Measurements")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathIndividualMeasurements());
|
||||
item->setToolTip(settings->GetPathIndividualMeasurements());
|
||||
ui->pathTable->setItem(0, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(1, 0, new QTableWidgetItem(tr("My Multisize Measurements")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathMultisizeMeasurements());
|
||||
item->setToolTip(settings->GetPathMultisizeMeasurements());
|
||||
ui->pathTable->setItem(1, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(2, 0, new QTableWidgetItem(tr("My Patterns")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathPattern());
|
||||
item->setToolTip(settings->GetPathPattern());
|
||||
ui->pathTable->setItem(2, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(3, 0, new QTableWidgetItem(tr("My Templates")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathTemplate());
|
||||
item->setToolTip(settings->GetPathTemplate());
|
||||
ui->pathTable->setItem(3, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts());
|
||||
item->setToolTip(settings->GetPathManualLayouts());
|
||||
ui->pathTable->setItem(4, 1, item);
|
||||
}
|
||||
|
||||
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
|
||||
ui->pathTable->resizeColumnsToContents();
|
||||
ui->pathTable->resizeRowsToContents();
|
||||
ui->pathTable->horizontalHeader()->setStretchLastSection(true);
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file puzzlepreferencespathpage.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 PUZZLEPREFERENCESPATHPAGE_H
|
||||
#define PUZZLEPREFERENCESPATHPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class PuzzlePreferencesPathPage;
|
||||
}
|
||||
|
||||
class PuzzlePreferencesPathPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PuzzlePreferencesPathPage(QWidget *parent = nullptr);
|
||||
virtual ~PuzzlePreferencesPathPage();
|
||||
|
||||
void Apply();
|
||||
|
||||
protected:
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void DefaultPath();
|
||||
void EditPath();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(PuzzlePreferencesPathPage)
|
||||
Ui::PuzzlePreferencesPathPage *ui;
|
||||
|
||||
void InitTable();
|
||||
};
|
||||
|
||||
#endif // PUZZLEPREFERENCESPATHPAGE_H
|
111
src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.ui
Normal file
111
src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.ui
Normal file
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PuzzlePreferencesPathPage</class>
|
||||
<widget class="QWidget" name="PuzzlePreferencesPathPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>586</width>
|
||||
<height>808</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Paths that Valentina uses</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableWidget" name="pathTable">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="showGrid">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Path</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="defaultButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="editButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
160
src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp
Normal file
160
src/app/puzzle/dialogs/dialogpuzzlepreferences.cpp
Normal file
|
@ -0,0 +1,160 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpuzzlepreferences.cpp
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 "dialogpuzzlepreferences.h"
|
||||
#include "ui_dialogpuzzlepreferences.h"
|
||||
#include "../vpapplication.h"
|
||||
#include "configpages/puzzlepreferencesconfigurationpage.h"
|
||||
#include "configpages/puzzlepreferencespathpage.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QShowEvent>
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPuzzlePreferences::DialogPuzzlePreferences(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::DialogPuzzlePreferences),
|
||||
m_configurationPage(new PuzzlePreferencesConfigurationPage),
|
||||
m_pathPage(new PuzzlePreferencesPathPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
setWindowFlags(Qt::Window);
|
||||
#endif
|
||||
|
||||
VAbstractApplication::VApp()->Settings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
|
||||
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
SCASSERT(bOk != nullptr)
|
||||
connect(bOk, &QPushButton::clicked, this, &DialogPuzzlePreferences::Ok);
|
||||
|
||||
QPushButton *bApply = ui->buttonBox->button(QDialogButtonBox::Apply);
|
||||
SCASSERT(bApply != nullptr)
|
||||
connect(bApply, &QPushButton::clicked, this, &DialogPuzzlePreferences::Apply);
|
||||
|
||||
ui->pagesWidget->insertWidget(0, m_configurationPage);
|
||||
ui->pagesWidget->insertWidget(1, m_pathPage);
|
||||
|
||||
connect(ui->contentsWidget, &QListWidget::currentItemChanged, this, &DialogPuzzlePreferences::PageChanged);
|
||||
ui->pagesWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPuzzlePreferences::~DialogPuzzlePreferences()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::showEvent(QShowEvent *event)
|
||||
{
|
||||
QDialog::showEvent( event );
|
||||
if ( event->spontaneous() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// do your init stuff here
|
||||
|
||||
QSize sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize();
|
||||
if (not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
||||
m_isInitialized = true;//first show windows are held
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
// remember the size for the next time this dialog is opened, but only
|
||||
// if widget was already initialized, which rules out the resize at
|
||||
// dialog creating, which would
|
||||
if (m_isInitialized)
|
||||
{
|
||||
VAbstractApplication::VApp()->Settings()->SetPreferenceDialogSize(size());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::changeEvent(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
// remember to call base class implementation
|
||||
QDialog::changeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::Apply()
|
||||
{
|
||||
QStringList preferences;
|
||||
|
||||
preferences += m_configurationPage->Apply();
|
||||
m_pathPage->Apply();
|
||||
|
||||
if (not preferences.isEmpty())
|
||||
{
|
||||
const QString text = tr("Followed %n option(s) require restart to take effect: %1.", "",
|
||||
preferences.size()).arg(preferences.join(QStringLiteral(", ")));
|
||||
QMessageBox::information(this, QCoreApplication::applicationName(), text);
|
||||
}
|
||||
|
||||
VPApplication::VApp()->PuzzleSettings()->GetOsSeparator() ? setLocale(QLocale()) : setLocale(QLocale::c());
|
||||
emit UpdateProperties();
|
||||
setResult(QDialog::Accepted);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::Ok()
|
||||
{
|
||||
Apply();
|
||||
done(QDialog::Accepted);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPuzzlePreferences::PageChanged(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (current == nullptr)
|
||||
{
|
||||
current = previous;
|
||||
}
|
||||
int rowIndex = ui->contentsWidget->row(current);
|
||||
ui->pagesWidget->setCurrentIndex(rowIndex);
|
||||
}
|
71
src/app/puzzle/dialogs/dialogpuzzlepreferences.h
Normal file
71
src/app/puzzle/dialogs/dialogpuzzlepreferences.h
Normal file
|
@ -0,0 +1,71 @@
|
|||
/************************************************************************
|
||||
**
|
||||
** @file dialogpuzzlepreferences.h
|
||||
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
||||
** @date 21 5, 2021
|
||||
**
|
||||
** @brief
|
||||
** @copyright
|
||||
** This source code is part of the Valentina project, a pattern making
|
||||
** program, whose allow create and modeling patterns of clothing.
|
||||
** Copyright (C) 2021 Valentina project
|
||||
** <https://gitlab.com/smart-pattern/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 DIALOGPUZZLEPREFERENCES_H
|
||||
#define DIALOGPUZZLEPREFERENCES_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class DialogPuzzlePreferences;
|
||||
}
|
||||
|
||||
class PuzzlePreferencesConfigurationPage;
|
||||
class PuzzlePreferencesPathPage;
|
||||
class QListWidgetItem;
|
||||
|
||||
class DialogPuzzlePreferences : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogPuzzlePreferences(QWidget *parent = nullptr);
|
||||
virtual ~DialogPuzzlePreferences();
|
||||
|
||||
signals:
|
||||
void UpdateProperties();
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void Apply();
|
||||
void Ok();
|
||||
void PageChanged(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPuzzlePreferences)
|
||||
Ui::DialogPuzzlePreferences *ui;
|
||||
bool m_isInitialized{false};
|
||||
PuzzlePreferencesConfigurationPage *m_configurationPage;
|
||||
PuzzlePreferencesPathPage *m_pathPage;
|
||||
};
|
||||
|
||||
#endif // DIALOGPUZZLEPREFERENCES_H
|
159
src/app/puzzle/dialogs/dialogpuzzlepreferences.ui
Normal file
159
src/app/puzzle/dialogs/dialogpuzzlepreferences.ui
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogPuzzlePreferences</class>
|
||||
<widget class="QDialog" name="DialogPuzzlePreferences">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>851</width>
|
||||
<height>551</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Puzzle preferences</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../share/resources/puzzleicon.qrc">
|
||||
<normaloff>:/puzzleicon/64x64/logo.png</normaloff>:/puzzleicon/64x64/logo.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="contentsWidget">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>96</width>
|
||||
<height>84</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="textElideMode">
|
||||
<enum>Qt::ElideMiddle</enum>
|
||||
</property>
|
||||
<property name="movement">
|
||||
<enum>QListView::Static</enum>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<property name="viewMode">
|
||||
<enum>QListView::IconMode</enum>
|
||||
</property>
|
||||
<property name="currentRow">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Configuration</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/config.png</normaloff>:/icon/config.png</iconset>
|
||||
</property>
|
||||
<property name="flags">
|
||||
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Paths</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignCenter</set>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../libs/vmisc/share/resources/icon.qrc">
|
||||
<normaloff>:/icon/path_config.png</normaloff>:/icon/path_config.png</iconset>
|
||||
</property>
|
||||
<property name="flags">
|
||||
<set>ItemIsSelectable|ItemIsUserCheckable|ItemIsEnabled</set>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="pagesWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<widget class="QWidget" name="page_2"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../share/resources/puzzleicon.qrc"/>
|
||||
<include location="../../../libs/vmisc/share/resources/icon.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogPuzzlePreferences</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>DialogPuzzlePreferences</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -53,6 +53,11 @@ int main(int argc, char *argv[])
|
|||
#endif // defined(APPIMAGE) && defined(Q_OS_LINUX)
|
||||
|
||||
Q_INIT_RESOURCE(puzzleicon);
|
||||
Q_INIT_RESOURCE(theme);
|
||||
Q_INIT_RESOURCE(icon);
|
||||
Q_INIT_RESOURCE(schema);
|
||||
Q_INIT_RESOURCE(flags);
|
||||
Q_INIT_RESOURCE(style);
|
||||
|
||||
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations
|
||||
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
# This need for corect working file translations.pro
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencespathpage.cpp \
|
||||
$$PWD/dialogs/dialogpuzzlepreferences.cpp \
|
||||
$$PWD/dialogs/vpdialogabout.cpp \
|
||||
$$PWD/main.cpp \
|
||||
$$PWD/vpapplication.cpp \
|
||||
|
@ -29,6 +32,9 @@ SOURCES += \
|
|||
*msvc*:SOURCES += $$PWD/stable.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencesconfigurationpage.h \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencespathpage.h \
|
||||
$$PWD/dialogs/dialogpuzzlepreferences.h \
|
||||
$$PWD/dialogs/vpdialogabout.h \
|
||||
$$PWD/stable.h \
|
||||
$$PWD/vpapplication.h \
|
||||
|
@ -54,6 +60,9 @@ HEADERS += \
|
|||
$$PWD/xml/vplayoutliterals.h
|
||||
|
||||
FORMS += \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencesconfigurationpage.ui \
|
||||
$$PWD/dialogs/configpages/puzzlepreferencespathpage.ui \
|
||||
$$PWD/dialogs/dialogpuzzlepreferences.ui \
|
||||
$$PWD/dialogs/vpdialogabout.ui \
|
||||
$$PWD/vpcarrousel.ui \
|
||||
$$PWD/vpmainwindow.ui
|
||||
|
|
|
@ -340,7 +340,7 @@ auto VPApplication::MainWindow()-> VPMainWindow *
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPApplication::MainWindows() -> QList<VPMainWindow *>
|
||||
auto VPApplication::MainWindows() -> QList<VPMainWindow *>
|
||||
{
|
||||
Clean();
|
||||
QList<VPMainWindow*> list;
|
||||
|
@ -367,6 +367,7 @@ auto VPApplication::NewMainWindow(const VPCommandLinePtr &cmd) -> VPMainWindow *
|
|||
if (not cmd->IsTestModeEnabled())
|
||||
{
|
||||
puzzle->show();
|
||||
puzzle->UpdateWindowTitle();
|
||||
}
|
||||
puzzle->InitZoom();
|
||||
return puzzle;
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "../ifc/exception/vexception.h"
|
||||
#include "../vwidgets/vmaingraphicsscene.h"
|
||||
#include "vpsheet.h"
|
||||
#include "dialogs/dialogpuzzlepreferences.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
|
||||
#include "../vmisc/backport/qscopeguard.h"
|
||||
|
@ -111,7 +112,6 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) :
|
|||
|
||||
SetPropertiesData();
|
||||
|
||||
UpdateWindowTitle();
|
||||
ReadSettings();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
@ -825,7 +825,15 @@ void VPMainWindow::UpdateWindowTitle()
|
|||
}
|
||||
else
|
||||
{
|
||||
showName = tr("untitled %1.vlt").arg(VPApplication::VApp()->MainWindows().size()+1);
|
||||
int index = VPApplication::VApp()->MainWindows().indexOf(this);
|
||||
if (index != -1)
|
||||
{
|
||||
showName = tr("untitled %1.vlt").arg(index+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
showName = tr("untitled.vlt");
|
||||
}
|
||||
}
|
||||
|
||||
showName += QLatin1String("[*]");
|
||||
|
@ -1111,10 +1119,11 @@ void VPMainWindow::changeEvent(QEvent *event)
|
|||
{
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{
|
||||
WindowsLocale();
|
||||
|
||||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
|
||||
WindowsLocale();
|
||||
UpdateWindowTitle();
|
||||
}
|
||||
|
||||
// remember to call base class implementation
|
||||
|
@ -1134,7 +1143,7 @@ void VPMainWindow::on_actionOpen_triggered()
|
|||
|
||||
const QString filter(tr("Layout files") + QLatin1String(" (*.vlt)"));
|
||||
//Use standard path to individual measurements
|
||||
const QString pathTo = VPApplication::VApp()->PuzzleSettings()->GetPathLayouts();
|
||||
const QString pathTo = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
|
||||
|
||||
bool usedNotExistedDir = false;
|
||||
QDir directory(pathTo);
|
||||
|
@ -1205,7 +1214,7 @@ bool VPMainWindow::on_actionSaveAs_triggered()
|
|||
QString dir;
|
||||
if (curFile.isEmpty())
|
||||
{
|
||||
dir = VPApplication::VApp()->PuzzleSettings()->GetPathLayouts();
|
||||
dir = VPApplication::VApp()->PuzzleSettings()->GetPathManualLayouts();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1874,23 +1883,23 @@ void VPMainWindow::ShowWindow() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPMainWindow::Preferences()
|
||||
void VPMainWindow::on_actionPreferences_triggered()
|
||||
{
|
||||
// Calling constructor of the dialog take some time. Because of this user have time to call the dialog twice.
|
||||
// static QPointer<DialogPuzzlePreferences> guard;// Prevent any second run
|
||||
// if (guard.isNull())
|
||||
// {
|
||||
// QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
// auto *preferences = new DialogPuzzlePreferences(this);
|
||||
// // QScopedPointer needs to be sure any exception will never block guard
|
||||
// QScopedPointer<DialogPuzzlePreferences> dlg(preferences);
|
||||
// guard = preferences;
|
||||
// // Must be first
|
||||
// connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::WindowsLocale);
|
||||
// connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::ToolBarStyles);
|
||||
// QGuiApplication::restoreOverrideCursor();
|
||||
// dlg->exec();
|
||||
// }
|
||||
static QPointer<DialogPuzzlePreferences> guard;// Prevent any second run
|
||||
if (guard.isNull())
|
||||
{
|
||||
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||
auto *preferences = new DialogPuzzlePreferences(this);
|
||||
// QScopedPointer needs to be sure any exception will never block guard
|
||||
QScopedPointer<DialogPuzzlePreferences> dlg(preferences);
|
||||
guard = preferences;
|
||||
// Must be first
|
||||
connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::WindowsLocale);
|
||||
connect(dlg.data(), &DialogPuzzlePreferences::UpdateProperties, this, &VPMainWindow::ToolBarStyles);
|
||||
QGuiApplication::restoreOverrideCursor();
|
||||
dlg->exec();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -89,6 +89,8 @@ public:
|
|||
*/
|
||||
void InitZoom();
|
||||
|
||||
void UpdateWindowTitle();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief on_actionNew_triggered When the menu action File > New
|
||||
|
@ -391,8 +393,10 @@ private slots:
|
|||
*/
|
||||
void on_MouseMoved(const QPointF &scenePos);
|
||||
|
||||
void on_actionPreferences_triggered();
|
||||
|
||||
void ShowWindow() const;
|
||||
void Preferences();
|
||||
|
||||
void ToolBarStyles();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
@ -534,8 +538,6 @@ private:
|
|||
*/
|
||||
void SetCheckBoxValue(QCheckBox *checkbox, bool value);
|
||||
|
||||
void UpdateWindowTitle();
|
||||
|
||||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ void TapePreferencesPathPage::Apply()
|
|||
settings->SetPathMultisizeMeasurements(ui->pathTable->item(1, 1)->text());
|
||||
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
|
||||
settings->SetPathTemplate(ui->pathTable->item(3, 1)->text());
|
||||
settings->SetPathManualLayouts(ui->pathTable->item(4, 1)->text());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -107,6 +108,9 @@ void TapePreferencesPathPage::DefaultPath()
|
|||
case 3: // templates
|
||||
path = VCommonSettings::GetDefPathTemplate();
|
||||
break;
|
||||
case 4: // layouts
|
||||
path = VCommonSettings::GetDefPathManualLayouts();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -138,6 +142,9 @@ void TapePreferencesPathPage::EditPath()
|
|||
case 3: // templates
|
||||
path = MApplication::VApp()->TapeSettings()->GetPathTemplate();
|
||||
break;
|
||||
case 4: // layouts
|
||||
path = MApplication::VApp()->TapeSettings()->GetPathManualLayouts();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -171,7 +178,7 @@ void TapePreferencesPathPage::EditPath()
|
|||
void TapePreferencesPathPage::InitTable()
|
||||
{
|
||||
ui->pathTable->clearContents();
|
||||
ui->pathTable->setRowCount(4);
|
||||
ui->pathTable->setRowCount(5);
|
||||
ui->pathTable->setColumnCount(2);
|
||||
|
||||
const VTapeSettings *settings = MApplication::VApp()->TapeSettings();
|
||||
|
@ -204,6 +211,13 @@ void TapePreferencesPathPage::InitTable()
|
|||
ui->pathTable->setItem(3, 1, item);
|
||||
}
|
||||
|
||||
{
|
||||
ui->pathTable->setItem(4, 0, new QTableWidgetItem(tr("My Layouts")));
|
||||
QTableWidgetItem *item = new QTableWidgetItem(settings->GetPathManualLayouts());
|
||||
item->setToolTip(settings->GetPathManualLayouts());
|
||||
ui->pathTable->setItem(4, 1, item);
|
||||
}
|
||||
|
||||
ui->pathTable->verticalHeader()->setDefaultSectionSize(20);
|
||||
ui->pathTable->resizeColumnsToContents();
|
||||
ui->pathTable->resizeRowsToContents();
|
||||
|
|
|
@ -89,7 +89,7 @@ void DialogTapePreferences::showEvent(QShowEvent *event)
|
|||
// do your init stuff here
|
||||
|
||||
QSize sz = VAbstractApplication::VApp()->Settings()->GetPreferenceDialogSize();
|
||||
if (sz.isEmpty() == false)
|
||||
if (not sz.isEmpty())
|
||||
{
|
||||
resize(sz);
|
||||
}
|
||||
|
|
|
@ -854,6 +854,7 @@ TMainWindow *MApplication::NewMainWindow()
|
|||
if (not MApplication::VApp()->IsTestMode())
|
||||
{
|
||||
tape->show();
|
||||
tape->UpdateWindowTitle();
|
||||
}
|
||||
return tape;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ TMainWindow::TMainWindow(QWidget *parent)
|
|||
connect(gradation, &QTimer::timeout, this, &TMainWindow::GradationChanged);
|
||||
|
||||
SetupMenu();
|
||||
UpdateWindowTitle();
|
||||
|
||||
ReadSettings();
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
@ -594,6 +594,8 @@ void TMainWindow::changeEvent(QEvent *event)
|
|||
// retranslate designer form (single inheritance approach)
|
||||
ui->retranslateUi(this);
|
||||
|
||||
UpdateWindowTitle();
|
||||
|
||||
InitMeasurementUnits();
|
||||
|
||||
if (mType == MeasurementsType::Multisize)
|
||||
|
@ -3241,7 +3243,15 @@ void TMainWindow::UpdateWindowTitle()
|
|||
}
|
||||
else
|
||||
{
|
||||
showName = tr("untitled %1").arg(MApplication::VApp()->MainWindows().size()+1);
|
||||
int index = MApplication::VApp()->MainWindows().indexOf(this);
|
||||
if (index != -1)
|
||||
{
|
||||
showName = tr("untitled %1").arg(index+1);
|
||||
}
|
||||
else
|
||||
{
|
||||
showName = tr("untitled");
|
||||
}
|
||||
mType == MeasurementsType::Multisize ? showName += QLatin1String(".vst") : showName += QLatin1String(".vit");
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,8 @@ public:
|
|||
|
||||
bool LoadFile(const QString &path);
|
||||
|
||||
void UpdateWindowTitle();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual void changeEvent(QEvent* event) override;
|
||||
|
@ -215,7 +217,6 @@ private:
|
|||
void MeasurementGUI();
|
||||
void Controls();
|
||||
void MFields(bool enabled);
|
||||
void UpdateWindowTitle();
|
||||
|
||||
void ReadSettings();
|
||||
void WriteSettings();
|
||||
|
|
|
@ -73,7 +73,6 @@ namespace
|
|||
{
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsIndividualMeasurements, (QLatin1String("paths/individual_measurements")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsMultisizeMeasurements, (QLatin1String("paths/standard_measurements")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLayouts, (QLatin1String("paths/layouts")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsPattern, (QLatin1String("paths/pattern")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsTemplates, (QLatin1String("paths/templates")))
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(const QString, settingPathsLabelTemplate, (QLatin1String("paths/labels")))
|
||||
|
@ -407,27 +406,6 @@ void VCommonSettings::SetPathMultisizeMeasurements(const QString &value)
|
|||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetDefPathLayouts()
|
||||
{
|
||||
return QDir::homePath() + QLatin1String("/valentina/") + tr("layouts");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetPathLayouts() const
|
||||
{
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
||||
return settings.value(*settingPathsLayouts, GetDefPathLayouts()).toString();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VCommonSettings::SetPathLayouts(const QString &value)
|
||||
{
|
||||
QSettings settings(this->format(), this->scope(), this->organizationName(), *commonIniFilename);
|
||||
settings.setValue(*settingPathsLayouts, value);
|
||||
settings.sync();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VCommonSettings::GetDefPathPattern()
|
||||
{
|
||||
|
|
|
@ -68,10 +68,6 @@ public:
|
|||
QString GetPathMultisizeMeasurements() const;
|
||||
void SetPathMultisizeMeasurements(const QString &value);
|
||||
|
||||
static QString GetDefPathLayouts();
|
||||
QString GetPathLayouts() const;
|
||||
void SetPathLayouts(const QString &value);
|
||||
|
||||
static QString GetDefPathPattern();
|
||||
QString GetPathPattern() const;
|
||||
void SetPathPattern(const QString &value);
|
||||
|
|
Loading…
Reference in New Issue
Block a user