Skip to content

Commit

Permalink
Merge pull request #1058 from FashionFreedom/issue-1054-fix-file-path…
Browse files Browse the repository at this point in the history
…s-prefs

bug: fix file path prefs
  • Loading branch information
slspencer committed Jan 9, 2024
2 parents 133eaab + 0dee9a2 commit 1c444cb
Show file tree
Hide file tree
Showing 18 changed files with 182 additions and 112 deletions.
6 changes: 3 additions & 3 deletions src/app/seamly2d/core/vapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,12 @@ void VApplication::InitOptions()

OpenSettings();
VSettings *settings = Seamly2DSettings();
QDir().mkpath(settings->GetDefPathLayout());
QDir().mkpath(settings->GetDefPathPattern());
QDir().mkpath(settings->getDefaultLayoutPath());
QDir().mkpath(settings->getDefaultPatternPath());
QDir().mkpath(settings->getDefaultIndividualSizePath());
QDir().mkpath(settings->getDefaultMultisizePath());
QDir().mkpath(settings->getDefaultTemplatePath());
QDir().mkpath(settings->GetDefPathLabelTemplate());
QDir().mkpath(settings->getDefaultLabelTemplatePath());
}

//---------------------------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</property>
<property name="maximumSize">
<size>
<width>487</width>
<height>572</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
Expand All @@ -32,21 +32,21 @@
<item>
<widget class="QTabWidget" name="company_Tab">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>465</width>
<height>550</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>465</width>
<height>550</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
Expand All @@ -70,6 +70,12 @@
<layout class="QVBoxLayout" name="verticalLayout_14">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<bold>true</bold>
Expand Down Expand Up @@ -1158,6 +1164,12 @@
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QGroupBox" name="language_GroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
Expand All @@ -24,8 +24,8 @@
</property>
<property name="maximumSize">
<size>
<width>485</width>
<height>570</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
Expand Down Expand Up @@ -56,8 +56,8 @@
</property>
<property name="maximumSize">
<size>
<width>465</width>
<height>550</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="font">
Expand Down Expand Up @@ -137,6 +137,12 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
Expand Down Expand Up @@ -351,6 +357,12 @@
<layout class="QVBoxLayout" name="verticalLayout_19">
<item>
<widget class="QGroupBox" name="labelFont_GroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>420</width>
Expand Down Expand Up @@ -616,6 +628,12 @@
</item>
<item>
<widget class="QGroupBox" name="pointNameFont_GroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>420</width>
Expand Down Expand Up @@ -879,6 +897,12 @@
</item>
<item>
<widget class="QGroupBox" name="pointNameFont_GroupBox_2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>420</width>
Expand Down Expand Up @@ -1176,7 +1200,7 @@
</property>
<property name="maximumSize">
<size>
<width>420</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
Expand Down Expand Up @@ -1329,7 +1353,7 @@
</property>
<property name="maximumSize">
<size>
<width>420</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
Expand Down Expand Up @@ -1482,7 +1506,7 @@
</property>
<property name="maximumSize">
<size>
<width>420</width>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
Expand Down
93 changes: 46 additions & 47 deletions src/app/seamly2d/dialogs/configpages/preferencespathpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,12 @@

#include <QDir>
#include <QFileDialog>
#include <QFileInfo>

//---------------------------------------------------------------------------------------------------------------------
PreferencesPathPage::PreferencesPathPage(QWidget *parent)
: QWidget(parent),
ui(new Ui::PreferencesPathPage)
: QWidget(parent)
, ui(new Ui::PreferencesPathPage)
{
ui->setupUi(this);

Expand Down Expand Up @@ -95,11 +96,11 @@ void PreferencesPathPage::changeEvent(QEvent *event)
void PreferencesPathPage::Apply()
{
VSettings *settings = qApp->Seamly2DSettings();
settings->setIndividualSizePath(ui->pathTable->item(0, 1)->text());
settings->setMultisizePath(ui->pathTable->item(1, 1)->text());
settings->SetPathPattern(ui->pathTable->item(2, 1)->text());
settings->SetPathLayout(ui->pathTable->item(3, 1)->text());
settings->setTemplatePath(ui->pathTable->item(4, 1)->text());
settings->SetPathPattern(ui->pathTable->item(0, 1)->text());
settings->setTemplatePath(ui->pathTable->item(1, 1)->text());
settings->setIndividualSizePath(ui->pathTable->item(2, 1)->text());
settings->setMultisizePath(ui->pathTable->item(3, 1)->text());
settings->SetPathLayout(ui->pathTable->item(4, 1)->text());
settings->SetPathLabelTemplate(ui->pathTable->item(5, 1)->text());
}

Expand All @@ -114,23 +115,23 @@ void PreferencesPathPage::defaultPath()

switch (row)
{
case 1: // multisize measurements
path = VCommonSettings::getDefaultMultisizePath();
case 0: // pattern path
path = VSettings::getDefaultPatternPath();
break;
case 2: // pattern path
path = VSettings::GetDefPathPattern();
case 1: // templates
path = VCommonSettings::getDefaultTemplatePath();
break;
case 0: // individual measurements
case 2: // individual measurements
path = VCommonSettings::getDefaultIndividualSizePath();
break;
case 3: // layout path
path = VSettings::GetDefPathLayout();
case 3: // multisize measurements
path = VCommonSettings::getDefaultMultisizePath();
break;
case 4: // templates
path = VCommonSettings::getDefaultTemplatePath();
case 4: // layout path
path = VSettings::getDefaultLayoutPath();
break;
case 5: // label templates
path = VSettings::GetDefPathLabelTemplate();
path = VSettings::getDefaultLabelTemplatePath();
break;
default:
break;
Expand All @@ -150,24 +151,24 @@ void PreferencesPathPage::editPath()
QString path;
switch (row)
{
case 0: // individual measurements
case 0: // pattern path
path = qApp->Seamly2DSettings()->getPatternPath();
break;
case 1: // templates
path = qApp->Seamly2DSettings()->getTemplatePath();
break;
case 2: // individual measurements
path = qApp->Seamly2DSettings()->getIndividualSizePath();
break;
case 1: // multisize measurements
case 3: // multisize measurements
path = qApp->Seamly2DSettings()->getMultisizePath();
path = VCommonSettings::prepareMultisizeTables(path);
break;
case 2: // pattern path
path = qApp->Seamly2DSettings()->GetPathPattern();
break;
case 3: // layout path
case 4: // layout path
path = qApp->Seamly2DSettings()->getLayoutPath();
break;
case 4: // templates
path = qApp->Seamly2DSettings()->getTemplatePath();
break;
case 5: // label templates
path = qApp->Seamly2DSettings()->GetPathLabelTemplate();
path = qApp->Seamly2DSettings()->getLabelTemplatePath();
break;
default:
break;
Expand All @@ -180,29 +181,27 @@ void PreferencesPathPage::editPath()
usedNotExistedDir = directory.mkpath(".");
}

const QString dir = QFileDialog::getExistingDirectory(this, tr("Open Directory"), path,
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks
| QFileDialog::DontUseNativeDialog);
if (dir.isEmpty())
{
if (usedNotExistedDir)
{
QDir directory(path);
directory.rmpath(".");
}
defaultPath();
return;
}
QString filename = fileDialog(this, tr("Open Directory"), path, QString(""), nullptr,
QFileDialog::ShowDirsOnly |
QFileDialog::DontResolveSymlinks |
QFileDialog::DontUseNativeDialog,
QFileDialog::Directory, QFileDialog::AcceptOpen);

item->setText(dir);
item->setToolTip(dir);
const QString dir = QFileInfo(filename).filePath();

if (usedNotExistedDir)
{
QDir directory(path);
directory.rmpath(".");
}

if (dir.isEmpty())
{
return;
}

item->setText(dir);
item->setToolTip(dir);
}

//---------------------------------------------------------------------------------------------------------------------
Expand All @@ -217,8 +216,8 @@ void PreferencesPathPage::initializeTable()
QTableWidgetItem *item = new QTableWidgetItem(tr("My Patterns"));
item->setIcon(QIcon("://icon/32x32/seamly2d_file.png"));
ui->pathTable->setItem(0, 0, item);
item = new QTableWidgetItem(settings->GetPathPattern());
item->setToolTip(settings->GetPathPattern());
item = new QTableWidgetItem(settings->getPatternPath());
item->setToolTip(settings->getPatternPath());
ui->pathTable->setItem(0, 1, item);
}

Expand Down Expand Up @@ -262,8 +261,8 @@ void PreferencesPathPage::initializeTable()
QTableWidgetItem *item = new QTableWidgetItem(tr("My Label Templates"));
item->setIcon(QIcon("://icon/32x32/labels.png"));
ui->pathTable->setItem(5, 0, item);
item = new QTableWidgetItem(settings->GetPathLabelTemplate());
item->setToolTip(settings->GetPathLabelTemplate());
item = new QTableWidgetItem(settings->getLabelTemplatePath());
item->setToolTip(settings->getLabelTemplatePath());
ui->pathTable->setItem(5, 1, item);
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/seamly2d/dialogs/configpages/preferencespathpage.ui
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
</property>
<property name="maximumSize">
<size>
<width>485</width>
<height>570</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void PreferencesPatternPage::setDefaultTemplate()

QString filter(tr("Label template") + QLatin1String("(*.xml)"));
const QString fileName = QFileDialog::getOpenFileName(this, tr("Import template"),
settings->GetPathLabelTemplate(), filter, nullptr,
settings->getLabelTemplatePath(), filter, nullptr,
QFileDialog::DontUseNativeDialog);


Expand Down

0 comments on commit 1c444cb

Please sign in to comment.