diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 389416b..51e6404 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -37,6 +37,7 @@ set (glabels_sources ObjectEditor.cpp Outline.cpp PageRenderer.cpp + PreferencesDialog.cpp PrintView.cpp PropertiesView.cpp Preview.cpp @@ -74,6 +75,7 @@ set (glabels_qobject_headers Merge.h MergePropertyEditor.h ObjectEditor.h + PreferencesDialog.h PrintView.h PropertiesView.h Preview.h @@ -88,6 +90,7 @@ set (glabels_qobject_headers set (glabels_forms ui/MergePropertyEditor.ui ui/ObjectEditor.ui + ui/PreferencesDialog.ui ui/PrintView.ui ui/PropertiesView.ui ui/SelectProductDialog.ui diff --git a/glabels/MainWindow.cpp b/glabels/MainWindow.cpp index 06f2364..6b332c6 100644 --- a/glabels/MainWindow.cpp +++ b/glabels/MainWindow.cpp @@ -33,6 +33,7 @@ #include #include "libglabels/Db.h" +#include "PreferencesDialog.h" #include "PropertiesView.h" #include "View.h" #include "ObjectEditor.h" @@ -983,7 +984,8 @@ void MainWindow::editUnSelectAll() /// void MainWindow::editPreferences() { - qDebug() << "ACTION: edit->Preferences"; + PreferencesDialog dialog( this ); + dialog.exec(); } diff --git a/glabels/PreferencesDialog.cpp b/glabels/PreferencesDialog.cpp new file mode 100644 index 0000000..eedf4ee --- /dev/null +++ b/glabels/PreferencesDialog.cpp @@ -0,0 +1,98 @@ +/* PreferencesDialog.cpp + * + * Copyright (C) 2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt 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. + * + * gLabels-qt 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 gLabels-qt. If not, see . + */ + +#include "PreferencesDialog.h" + +#include "Settings.h" + + +/// +/// Constructor +/// +PreferencesDialog::PreferencesDialog( QWidget *parent ) + : QDialog(parent) +{ + setupUi( this ); + + switch ( Settings::units() ) + { + case glabels::Distance::Units::IN: + unitsInchesRadio->setChecked( true ); + break; + case glabels::Distance::Units::MM: + unitsMillimetersRadio->setChecked( true ); + break; + case glabels::Distance::Units::CM: + unitsCentimetersRadio->setChecked( true ); + break; + case glabels::Distance::Units::PC: + unitsPicasRadio->setChecked( true ); + break; + default: + unitsPointsRadio->setChecked( true ); + break; + } + + if ( Settings::preferIsoPaperSizes() ) + { + preferedPaperSizesIsoRadio->setChecked( true ); + } + else + { + preferedPaperSizesUsRadio->setChecked( true ); + } +} + + +/// +/// Units Radios Changed +/// +void PreferencesDialog::onUnitsRadiosChanged() +{ + if ( unitsInchesRadio->isChecked() ) + { + Settings::setUnits( glabels::Distance::Units::IN ); + } + else if ( unitsMillimetersRadio->isChecked() ) + { + Settings::setUnits( glabels::Distance::Units::MM ); + } + else if ( unitsCentimetersRadio->isChecked() ) + { + Settings::setUnits( glabels::Distance::Units::CM ); + } + else if ( unitsPicasRadio->isChecked() ) + { + Settings::setUnits( glabels::Distance::Units::PC ); + } + else + { + Settings::setUnits( glabels::Distance::Units::PT ); + } +} + + +/// +/// Prefered Paper Sizes Radios Changed +/// +void PreferencesDialog::onPreferedPaperSizesRadiosChanged() +{ + Settings::setPreferIsoPaperSizes( preferedPaperSizesIsoRadio->isChecked() ); +} diff --git a/glabels/PreferencesDialog.h b/glabels/PreferencesDialog.h new file mode 100644 index 0000000..c8091ea --- /dev/null +++ b/glabels/PreferencesDialog.h @@ -0,0 +1,52 @@ +/* PreferencesDialog.h + * + * Copyright (C) 2016 Jim Evins + * + * This file is part of gLabels-qt. + * + * gLabels-qt 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. + * + * gLabels-qt 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 gLabels-qt. If not, see . + */ + +#ifndef PreferencesDialog_h +#define PreferencesDialog_h + +#include "ui_PreferencesDialog.h" + + +/// +/// New Label Dialog Widget +/// +class PreferencesDialog : public QDialog, public Ui_PreferencesDialog +{ + Q_OBJECT + + + ///////////////////////////////// + // Life Cycle + ///////////////////////////////// +public: + PreferencesDialog( QWidget *parent = 0 ); + + + ///////////////////////////////// + // Slots + ///////////////////////////////// +private slots: + void onUnitsRadiosChanged(); + void onPreferedPaperSizesRadiosChanged(); + +}; + + +#endif // PreferencesDialog_h diff --git a/glabels/Settings.cpp b/glabels/Settings.cpp index 3b248f5..aa2d8d1 100644 --- a/glabels/Settings.cpp +++ b/glabels/Settings.cpp @@ -88,14 +88,13 @@ glabels::Distance::Units Settings::units() { // Guess at a suitable default QString defaultIdString; - switch (QLocale::system().measurementSystem()) + if ( QLocale::system().measurementSystem() == QLocale::ImperialSystem ) { - case QLocale::ImperialSystem: - defaultIdString = "in"; - break; - default: - defaultIdString = "mm"; - break; + defaultIdString = glabels::Distance::toId( glabels::Distance::Units::IN ); + } + else + { + defaultIdString = glabels::Distance::toId( glabels::Distance::Units::MM ); } mInstance->beginGroup( "Locale" ); diff --git a/glabels/glabels_main.cpp b/glabels/glabels_main.cpp index 1012136..2b3fc94 100644 --- a/glabels/glabels_main.cpp +++ b/glabels/glabels_main.cpp @@ -22,6 +22,7 @@ #include #include "libglabels/Db.h" +#include "Settings.h" #include "StartupWizard.h" @@ -33,6 +34,7 @@ int main( int argc, char **argv ) QCoreApplication::setOrganizationDomain( "glabels.org" ); QCoreApplication::setApplicationName( "glabels-qt" ); + Settings::init(); glabels::Db::init(); ////// TEMPORARY TESTING //////// #if 0 diff --git a/glabels/ui/PreferencesDialog.ui b/glabels/ui/PreferencesDialog.ui new file mode 100644 index 0000000..11fce7a --- /dev/null +++ b/glabels/ui/PreferencesDialog.ui @@ -0,0 +1,265 @@ + + + PreferencesDialog + + + + 0 + 0 + 299 + 385 + + + + gLabels - Preferences + + + + + + 0 + + + + Locale + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + Select locale specific behavior. + + + + + + + Units + + + + + + Points + + + + + + + Centimeters + + + + + + + Millimeters + + + + + + + Inches + + + + + + + Picas + + + + + + + + + + Prefered Paper Sizes + + + + + + US + + + + + + + ISO + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + clicked(QAbstractButton*) + PreferencesDialog + close() + + + 289 + 368 + + + 298 + 312 + + + + + unitsPointsRadio + clicked() + PreferencesDialog + onUnitsRadiosChanged() + + + 269 + 184 + + + 298 + 105 + + + + + unitsInchesRadio + clicked() + PreferencesDialog + onUnitsRadiosChanged() + + + 269 + 102 + + + 298 + 139 + + + + + unitsMillimetersRadio + clicked() + PreferencesDialog + onUnitsRadiosChanged() + + + 269 + 131 + + + 298 + 172 + + + + + preferedPaperSizesUsRadio + clicked() + PreferencesDialog + onPreferedPaperSizesRadiosChanged() + + + 269 + 276 + + + 298 + 221 + + + + + preferedPaperSizesIsoRadio + clicked() + PreferencesDialog + onPreferedPaperSizesRadiosChanged() + + + 269 + 303 + + + 298 + 255 + + + + + unitsCentimetersRadio + clicked(bool) + PreferencesDialog + onUnitsRadiosChanged() + + + 264 + 154 + + + 295 + 164 + + + + + unitsPicasRadio + clicked() + PreferencesDialog + onUnitsRadiosChanged() + + + 243 + 215 + + + 295 + 215 + + + + + + onUnitsRadiosChanged() + onPreferedPaperSizesRadiosChanged() + +