Track all three paper size search flags in settings.
This commit is contained in:
@@ -49,15 +49,6 @@ PreferencesDialog::PreferencesDialog( QWidget *parent )
|
||||
unitsPointsRadio->setChecked( true );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( Settings::preferIsoPaperSizes() )
|
||||
{
|
||||
preferedPaperSizesIsoRadio->setChecked( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
preferedPaperSizesUsRadio->setChecked( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,12 +78,3 @@ void PreferencesDialog::onUnitsRadiosChanged()
|
||||
Settings::setUnits( glabels::Distance::Units::PT );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
/// Prefered Paper Sizes Radios Changed
|
||||
///
|
||||
void PreferencesDialog::onPreferedPaperSizesRadiosChanged()
|
||||
{
|
||||
Settings::setPreferIsoPaperSizes( preferedPaperSizesIsoRadio->isChecked() );
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
/////////////////////////////////
|
||||
private slots:
|
||||
void onUnitsRadiosChanged();
|
||||
void onPreferedPaperSizesRadiosChanged();
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -20,10 +20,11 @@
|
||||
|
||||
#include "SelectProductDialog.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "libglabels/Db.h"
|
||||
#include "TemplatePickerItem.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
|
||||
///
|
||||
@@ -34,11 +35,9 @@ SelectProductDialog::SelectProductDialog( QWidget *parent )
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
// TODO: Set default based on locale and/or saved preferences
|
||||
// Perhaps move to checkboxes
|
||||
pageSizeIsoCheck->setChecked( false );
|
||||
pageSizeUsCheck->setChecked( true );
|
||||
pageSizeOtherCheck->setChecked( true );
|
||||
pageSizeIsoCheck->setChecked( Settings::searchIsoPaperSizes() );
|
||||
pageSizeUsCheck->setChecked( Settings::searchUsPaperSizes() );
|
||||
pageSizeOtherCheck->setChecked( Settings::searchOtherPaperSizes() );
|
||||
|
||||
QList<glabels::Template*> tmplates = glabels::Db::templates();
|
||||
templatePicker->setTemplates( tmplates );
|
||||
@@ -89,8 +88,12 @@ void SelectProductDialog::onSearchClearButtonClicked()
|
||||
///
|
||||
/// Page Size Check Toggled Slot
|
||||
///
|
||||
void SelectProductDialog::onPageSizeCheckToggled()
|
||||
void SelectProductDialog::onPageSizeCheckClicked()
|
||||
{
|
||||
Settings::setSearchIsoPaperSizes( pageSizeIsoCheck->isChecked() );
|
||||
Settings::setSearchUsPaperSizes( pageSizeUsCheck->isChecked() );
|
||||
Settings::setSearchOtherPaperSizes( pageSizeOtherCheck->isChecked() );
|
||||
|
||||
templatePicker->applyFilter( searchEntry->text(),
|
||||
pageSizeIsoCheck->isChecked(),
|
||||
pageSizeUsCheck->isChecked(),
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
private slots:
|
||||
void onSearchEntryTextChanged();
|
||||
void onSearchClearButtonClicked();
|
||||
void onPageSizeCheckToggled();
|
||||
void onPageSizeCheckClicked();
|
||||
void onTemplatePickerSelectionChanged();
|
||||
void onSelectButtonClicked();
|
||||
void onCancelButtonClicked();
|
||||
|
||||
+96
-35
@@ -49,41 +49,6 @@ Settings* Settings::instance()
|
||||
}
|
||||
|
||||
|
||||
bool Settings::preferIsoPaperSizes()
|
||||
{
|
||||
// Guess at a suitable default
|
||||
bool defaultValue;
|
||||
switch (QLocale::system().country())
|
||||
{
|
||||
case QLocale::UnitedStates:
|
||||
case QLocale::Canada:
|
||||
defaultValue = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
defaultValue = true;
|
||||
break;
|
||||
}
|
||||
|
||||
mInstance->beginGroup( "Locale" );
|
||||
bool returnValue = mInstance->value( "preferIsoPaperSizes", defaultValue ).toBool();
|
||||
mInstance->endGroup();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Settings::setPreferIsoPaperSizes( bool preferIsoPaperSizes )
|
||||
{
|
||||
|
||||
mInstance->beginGroup( "Locale" );
|
||||
mInstance->setValue( "preferIsoPaperSizes", preferIsoPaperSizes );
|
||||
mInstance->endGroup();
|
||||
|
||||
emit mInstance->changed();
|
||||
}
|
||||
|
||||
|
||||
glabels::Distance::Units Settings::units()
|
||||
{
|
||||
// Guess at a suitable default
|
||||
@@ -115,3 +80,99 @@ void Settings::setUnits( glabels::Distance::Units units )
|
||||
|
||||
emit mInstance->changed();
|
||||
}
|
||||
|
||||
|
||||
bool Settings::searchIsoPaperSizes()
|
||||
{
|
||||
// Guess at a suitable default
|
||||
bool defaultValue;
|
||||
switch (QLocale::system().country())
|
||||
{
|
||||
case QLocale::UnitedStates:
|
||||
case QLocale::Canada:
|
||||
defaultValue = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
defaultValue = true;
|
||||
break;
|
||||
}
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
bool returnValue = mInstance->value( "isoPaperSizes", defaultValue ).toBool();
|
||||
mInstance->endGroup();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Settings::setSearchIsoPaperSizes( bool searchIsoPaperSizes )
|
||||
{
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
mInstance->setValue( "isoPaperSizes", searchIsoPaperSizes );
|
||||
mInstance->endGroup();
|
||||
|
||||
emit mInstance->changed();
|
||||
}
|
||||
|
||||
|
||||
bool Settings::searchUsPaperSizes()
|
||||
{
|
||||
// Guess at a suitable default
|
||||
bool defaultValue;
|
||||
switch (QLocale::system().country())
|
||||
{
|
||||
case QLocale::UnitedStates:
|
||||
case QLocale::Canada:
|
||||
defaultValue = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
defaultValue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
bool returnValue = mInstance->value( "usPaperSizes", defaultValue ).toBool();
|
||||
mInstance->endGroup();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Settings::setSearchUsPaperSizes( bool searchUsPaperSizes )
|
||||
{
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
mInstance->setValue( "usPaperSizes", searchUsPaperSizes );
|
||||
mInstance->endGroup();
|
||||
|
||||
emit mInstance->changed();
|
||||
}
|
||||
|
||||
|
||||
bool Settings::searchOtherPaperSizes()
|
||||
{
|
||||
// Guess at a suitable default
|
||||
bool defaultValue = true;
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
bool returnValue = mInstance->value( "otherPaperSizes", defaultValue ).toBool();
|
||||
mInstance->endGroup();
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
||||
void Settings::setSearchOtherPaperSizes( bool searchOtherPaperSizes )
|
||||
{
|
||||
|
||||
mInstance->beginGroup( "Search" );
|
||||
mInstance->setValue( "otherPaperSizes", searchOtherPaperSizes );
|
||||
mInstance->endGroup();
|
||||
|
||||
emit mInstance->changed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
-3
@@ -59,12 +59,18 @@ signals:
|
||||
// Accessors
|
||||
/////////////////////////////////
|
||||
public:
|
||||
static bool preferIsoPaperSizes();
|
||||
static void setPreferIsoPaperSizes( bool preferIsoPaperSizes );
|
||||
|
||||
static glabels::Distance::Units units();
|
||||
static void setUnits( glabels::Distance::Units units );
|
||||
|
||||
static bool searchIsoPaperSizes();
|
||||
static void setSearchIsoPaperSizes( bool searchIsoPaperSizes );
|
||||
|
||||
static bool searchUsPaperSizes();
|
||||
static void setSearchUsPaperSizes( bool searchUsPaperSizes );
|
||||
|
||||
static bool searchOtherPaperSizes();
|
||||
static void setSearchOtherPaperSizes( bool searchOtherPaperSizes );
|
||||
|
||||
|
||||
private:
|
||||
static Settings* mInstance;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>299</width>
|
||||
<height>385</height>
|
||||
<width>318</width>
|
||||
<height>295</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -24,7 +24,7 @@
|
||||
<string>Locale</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="3" column="0">
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -88,29 +88,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Prefered Paper Sizes</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QRadioButton" name="preferedPaperSizesUsRadio">
|
||||
<property name="text">
|
||||
<string>US</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QRadioButton" name="preferedPaperSizesIsoRadio">
|
||||
<property name="text">
|
||||
<string>ISO</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
@@ -193,38 +170,6 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>preferedPaperSizesUsRadio</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>onPreferedPaperSizesRadiosChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>269</x>
|
||||
<y>276</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>298</x>
|
||||
<y>221</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>preferedPaperSizesIsoRadio</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>onPreferedPaperSizesRadiosChanged()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>269</x>
|
||||
<y>303</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>298</x>
|
||||
<y>255</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>unitsCentimetersRadio</sender>
|
||||
<signal>clicked(bool)</signal>
|
||||
|
||||
@@ -223,54 +223,6 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeIsoCheck</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckToggled()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>78</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>3</x>
|
||||
<y>110</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeUsCheck</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckToggled()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>52</x>
|
||||
<y>145</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>8</x>
|
||||
<y>144</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeOtherCheck</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckToggled()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>37</x>
|
||||
<y>170</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>10</x>
|
||||
<y>188</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>templatePicker</sender>
|
||||
<signal>itemSelectionChanged()</signal>
|
||||
@@ -294,8 +246,8 @@
|
||||
<slot>onCancelButtonClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>587</x>
|
||||
<y>708</y>
|
||||
<x>864</x>
|
||||
<y>648</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>689</x>
|
||||
@@ -310,8 +262,8 @@
|
||||
<slot>onSelectButtonClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>660</x>
|
||||
<y>689</y>
|
||||
<x>955</x>
|
||||
<y>648</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>687</x>
|
||||
@@ -319,14 +271,62 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeIsoCheck</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>40</x>
|
||||
<y>112</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>2</x>
|
||||
<y>116</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeUsCheck</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>38</x>
|
||||
<y>144</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>4</x>
|
||||
<y>141</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>pageSizeOtherCheck</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>SelectProductDialog</receiver>
|
||||
<slot>onPageSizeCheckClicked()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>35</x>
|
||||
<y>169</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>8</x>
|
||||
<y>168</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>onSearchClearButtonClicked()</slot>
|
||||
<slot>onPageSizeCheckToggled()</slot>
|
||||
<slot>onTemplatePickerSelectionChanged()</slot>
|
||||
<slot>onOrientationRadioToggled()</slot>
|
||||
<slot>onSearchEntryTextChanged()</slot>
|
||||
<slot>onCancelButtonClicked()</slot>
|
||||
<slot>onSelectButtonClicked()</slot>
|
||||
<slot>onPageSizeCheckClicked()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user