1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-30 22:51:16 +01:00

GUI polishing

This commit is contained in:
Martin Tůma 2016-12-07 21:38:36 +01:00
parent b24136a580
commit cde4c65c53
9 changed files with 76 additions and 60 deletions

View File

@ -22,9 +22,6 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
{ {
int index; int index;
_units = QLocale::system().measurementSystem() == QLocale::ImperialSystem ?
QPrinter::Inch : QPrinter::Millimeter;
_fileSelect = new FileSelectWidget(); _fileSelect = new FileSelectWidget();
_fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)")); _fileSelect->setFilter(tr("PDF files (*.pdf);;All files (*)"));
_fileSelect->setFile(_export->fileName); _fileSelect->setFile(_export->fileName);
@ -53,12 +50,12 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
_bottomMargin = new QDoubleSpinBox(); _bottomMargin = new QDoubleSpinBox();
_leftMargin = new QDoubleSpinBox(); _leftMargin = new QDoubleSpinBox();
_rightMargin = new QDoubleSpinBox(); _rightMargin = new QDoubleSpinBox();
QString us = (_units == QPrinter::Inch) ? tr("in") : tr("mm"); QString us = (_export->units == Imperial) ? tr("in") : tr("mm");
_topMargin->setSuffix(UNIT_SPACE + us); _topMargin->setSuffix(UNIT_SPACE + us);
_bottomMargin->setSuffix(UNIT_SPACE + us); _bottomMargin->setSuffix(UNIT_SPACE + us);
_leftMargin->setSuffix(UNIT_SPACE + us); _leftMargin->setSuffix(UNIT_SPACE + us);
_rightMargin->setSuffix(UNIT_SPACE + us); _rightMargin->setSuffix(UNIT_SPACE + us);
if (_units == QPrinter::Inch) { if (_export->units == Imperial) {
_topMargin->setValue(_export->margins.top() * MM2IN); _topMargin->setValue(_export->margins.top() * MM2IN);
_bottomMargin->setValue(_export->margins.bottom() * MM2IN); _bottomMargin->setValue(_export->margins.bottom() * MM2IN);
_leftMargin->setValue(_export->margins.left() * MM2IN); _leftMargin->setValue(_export->margins.left() * MM2IN);
@ -169,7 +166,7 @@ void ExportDialog::accept()
_export->fileName = _fileSelect->file(); _export->fileName = _fileSelect->file();
_export->paperSize = paperSize; _export->paperSize = paperSize;
_export->orientation = orientation; _export->orientation = orientation;
if (_units == QPrinter::Inch) if (_export->units == Imperial)
_export->margins = MarginsF(_leftMargin->value() / MM2IN, _export->margins = MarginsF(_leftMargin->value() / MM2IN,
_topMargin->value() / MM2IN, _rightMargin->value() / MM2IN, _topMargin->value() / MM2IN, _rightMargin->value() / MM2IN,
_bottomMargin->value() / MM2IN); _bottomMargin->value() / MM2IN);

View File

@ -4,6 +4,7 @@
#include <QDialog> #include <QDialog>
#include <QPrinter> #include <QPrinter>
#include "margins.h" #include "margins.h"
#include "units.h"
class QComboBox; class QComboBox;
class QRadioButton; class QRadioButton;
@ -15,6 +16,8 @@ struct Export {
QPrinter::PaperSize paperSize; QPrinter::PaperSize paperSize;
QPrinter::Orientation orientation; QPrinter::Orientation orientation;
MarginsF margins; MarginsF margins;
Units units;
}; };
class ExportDialog : public QDialog class ExportDialog : public QDialog
@ -31,7 +34,6 @@ private:
bool checkFile(); bool checkFile();
Export *_export; Export *_export;
QPrinter::Unit _units;
FileSelectWidget *_fileSelect; FileSelectWidget *_fileSelect;
QComboBox *_paperSize; QComboBox *_paperSize;

View File

@ -1143,6 +1143,9 @@ void GUI::updatePathView()
void GUI::setUnits(Units units) void GUI::setUnits(Units units)
{ {
_export.units = units;
_options.units = units;
_pathView->setUnits(units); _pathView->setUnits(units);
for (int i = 0; i <_tabs.count(); i++) for (int i = 0; i <_tabs.count(); i++)
_tabs.at(i)->setUnits(units); _tabs.at(i)->setUnits(units);
@ -1389,10 +1392,12 @@ void GUI::readSettings()
settings.beginGroup(SETTINGS_SETTINGS_GROUP); settings.beginGroup(SETTINGS_SETTINGS_GROUP);
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) { if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial) {
setImperialUnits(); setUnits(Imperial);
_imperialUnitsAction->setChecked(true); _imperialUnitsAction->setChecked(true);
} else } else {
setUnits(Metric);
_metricUnitsAction->setChecked(true); _metricUnitsAction->setChecked(true);
}
if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool()) if (!settings.value(SHOW_TOOLBARS_SETTING, SHOW_TOOLBARS_DEFAULT).toBool())
showToolbars(false); showToolbars(false);
else else

View File

@ -11,13 +11,13 @@
#include <QComboBox> #include <QComboBox>
#include <QSysInfo> #include <QSysInfo>
#include "config.h" #include "config.h"
#include "units.h"
#include "icons.h" #include "icons.h"
#include "colorbox.h" #include "colorbox.h"
#include "stylecombobox.h" #include "stylecombobox.h"
#include "optionsdialog.h" #include "optionsdialog.h"
#define MENU_MARGIN 20 #define MENU_MARGIN 20
#define MENU_ICON_SIZE 32
QWidget *OptionsDialog::createAppearancePage() QWidget *OptionsDialog::createAppearancePage()
@ -43,34 +43,53 @@ QWidget *OptionsDialog::createAppearancePage()
_trackWidth->setMinimum(1); _trackWidth->setMinimum(1);
_trackStyle = new StyleComboBox(); _trackStyle = new StyleComboBox();
_trackStyle->setValue(_options->trackStyle); _trackStyle->setValue(_options->trackStyle);
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
QFormLayout *trackLayout = new QFormLayout(); QFormLayout *trackLayout = new QFormLayout();
trackLayout->addRow(tr("Line width:"), _trackWidth); trackLayout->addRow(tr("Track width:"), _trackWidth);
trackLayout->addRow(tr("Line style:"), _trackStyle); trackLayout->addRow(tr("Track style:"), _trackStyle);
#ifndef Q_OS_MAC
QGroupBox *trackBox = new QGroupBox(tr("Tracks"));
trackBox->setLayout(trackLayout); trackBox->setLayout(trackLayout);
#endif
_routeWidth = new QSpinBox(); _routeWidth = new QSpinBox();
_routeWidth->setValue(_options->routeWidth); _routeWidth->setValue(_options->routeWidth);
_routeWidth->setMinimum(1); _routeWidth->setMinimum(1);
_routeStyle = new StyleComboBox(); _routeStyle = new StyleComboBox();
_routeStyle->setValue(_options->routeStyle); _routeStyle->setValue(_options->routeStyle);
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
QFormLayout *routeLayout = new QFormLayout(); QFormLayout *routeLayout = new QFormLayout();
routeLayout->addRow(tr("Line width:"), _routeWidth); routeLayout->addRow(tr("Route width:"), _routeWidth);
routeLayout->addRow(tr("Line style:"), _routeStyle); routeLayout->addRow(tr("Route style:"), _routeStyle);
#ifndef Q_OS_MAC
QGroupBox *routeBox = new QGroupBox(tr("Routes"));
routeBox->setLayout(routeLayout); routeBox->setLayout(routeLayout);
#endif // Q_OS_MAC
_pathAA = new QCheckBox(tr("Use anti-aliasing")); _pathAA = new QCheckBox(tr("Use anti-aliasing"));
_pathAA->setChecked(_options->pathAntiAliasing); _pathAA->setChecked(_options->pathAntiAliasing);
QFormLayout *pathAALayout = new QFormLayout();
pathAALayout->addWidget(_pathAA);
QWidget *pathTab = new QWidget(); QWidget *pathTab = new QWidget();
QVBoxLayout *pathTabLayout = new QVBoxLayout(); QVBoxLayout *pathTabLayout = new QVBoxLayout();
#ifdef Q_OS_MAC
QFrame *l1 = new QFrame();
l1->setFrameShape(QFrame::HLine);
l1->setFrameShadow(QFrame::Sunken);
QFrame *l2 = new QFrame();
l2->setFrameShape(QFrame::HLine);
l2->setFrameShadow(QFrame::Sunken);
pathTabLayout->addLayout(trackLayout);
pathTabLayout->addWidget(l1);
pathTabLayout->addLayout(routeLayout);
pathTabLayout->addWidget(l2);
#else
pathTabLayout->addWidget(trackBox); pathTabLayout->addWidget(trackBox);
pathTabLayout->addWidget(routeBox); pathTabLayout->addWidget(routeBox);
pathTabLayout->addWidget(_pathAA); #endif
pathTabLayout->addLayout(pathAALayout);
pathTab->setLayout(pathTabLayout); pathTab->setLayout(pathTabLayout);
_graphWidth = new QSpinBox(); _graphWidth = new QSpinBox();
_graphWidth->setValue(_options->graphWidth); _graphWidth->setValue(_options->graphWidth);
_graphWidth->setMinimum(1); _graphWidth->setMinimum(1);
@ -79,11 +98,14 @@ QWidget *OptionsDialog::createAppearancePage()
_graphAA = new QCheckBox(tr("Use anti-aliasing")); _graphAA = new QCheckBox(tr("Use anti-aliasing"));
_graphAA->setChecked(_options->graphAntiAliasing); _graphAA->setChecked(_options->graphAntiAliasing);
QFormLayout *graphAALayout = new QFormLayout();
graphAALayout->addWidget(_graphAA);
QWidget *graphTab = new QWidget(); QWidget *graphTab = new QWidget();
QVBoxLayout *graphTabLayout = new QVBoxLayout(); QVBoxLayout *graphTabLayout = new QVBoxLayout();
graphTabLayout->addLayout(graphLayout); graphTabLayout->addLayout(graphLayout);
graphTabLayout->addWidget(_graphAA); graphTabLayout->addLayout(graphAALayout);
graphTabLayout->addStretch(); graphTabLayout->addStretch();
graphTab->setLayout(graphTabLayout); graphTab->setLayout(graphTabLayout);
@ -100,8 +122,13 @@ QWidget *OptionsDialog::createPOIPage()
_poiRadius = new QDoubleSpinBox(); _poiRadius = new QDoubleSpinBox();
_poiRadius->setSingleStep(1); _poiRadius->setSingleStep(1);
_poiRadius->setDecimals(1); _poiRadius->setDecimals(1);
_poiRadius->setValue(_options->poiRadius / 1000); if (_options->units == Imperial) {
_poiRadius->setSuffix(UNIT_SPACE + tr("km")); _poiRadius->setValue(_options->poiRadius / MIINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
} else {
_poiRadius->setValue(_options->poiRadius / KMINM);
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
}
QFormLayout *poiLayout = new QFormLayout(); QFormLayout *poiLayout = new QFormLayout();
poiLayout->addRow(tr("POI radius:"), _poiRadius); poiLayout->addRow(tr("POI radius:"), _poiRadius);
@ -118,12 +145,16 @@ QWidget *OptionsDialog::createPOIPage()
QWidget *OptionsDialog::createSystemPage() QWidget *OptionsDialog::createSystemPage()
{ {
_useOpenGL = new QCheckBox(tr("Use OpenGL")); _useOpenGL = new QCheckBox(tr("Use OpenGL"));
#if defined(Q_OS_WIN32) || defined(Q_OS_MAC)
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) { if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA) {
_useOpenGL->setChecked(false);
_useOpenGL->setEnabled(false);
} else
#endif // Q_OS_WIN32 #endif // Q_OS_WIN32
_useOpenGL->setChecked(false);
_useOpenGL->setEnabled(false);
#ifdef Q_OS_WIN32
} else
#endif // Q_OS_WIN32
#endif // Q_OS_WIN32 || Q_OS_MAC
_useOpenGL->setChecked(_options->useOpenGL); _useOpenGL->setChecked(_options->useOpenGL);
QFormLayout *systemLayout = new QFormLayout(); QFormLayout *systemLayout = new QFormLayout();
@ -147,6 +178,7 @@ OptionsDialog::OptionsDialog(Options *options, QWidget *parent)
pages->addWidget(createSystemPage()); pages->addWidget(createSystemPage());
QListWidget *menu = new QListWidget(); QListWidget *menu = new QListWidget();
menu->setIconSize(QSize(MENU_ICON_SIZE, MENU_ICON_SIZE));
new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"), new QListWidgetItem(QIcon(QPixmap(APPEARANCE_ICON)), tr("Appearance"),
menu); menu);
new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu); new QListWidgetItem(QIcon(QPixmap(POI_ICON)), tr("POI"), menu);
@ -195,7 +227,10 @@ void OptionsDialog::accept()
_options->graphWidth = _graphWidth->value(); _options->graphWidth = _graphWidth->value();
_options->graphAntiAliasing = _graphAA->isChecked(); _options->graphAntiAliasing = _graphAA->isChecked();
_options->poiRadius = _poiRadius->value() * 1000; if (_options->units == Imperial)
_options->poiRadius = _poiRadius->value() * MIINM;
else
_options->poiRadius = _poiRadius->value() * KMINM;
_options->useOpenGL = _useOpenGL->isChecked(); _options->useOpenGL = _useOpenGL->isChecked();

View File

@ -3,6 +3,7 @@
#include <QDialog> #include <QDialog>
#include "palette.h" #include "palette.h"
#include "units.h"
class ColorBox; class ColorBox;
class StyleComboBox; class StyleComboBox;
@ -25,6 +26,8 @@ struct Options {
int poiRadius; int poiRadius;
// System // System
bool useOpenGL; bool useOpenGL;
Units units;
}; };
class OptionsDialog : public QDialog class OptionsDialog : public QDialog

View File

@ -89,7 +89,7 @@
#define GRAPH_AA_SETTING "graphAntiAliasing" #define GRAPH_AA_SETTING "graphAntiAliasing"
#define GRAPH_AA_DEFAULT false #define GRAPH_AA_DEFAULT false
#define POI_RADIUS_SETTING "poiRadius" #define POI_RADIUS_SETTING "poiRadius"
#define POI_RADIUS_DEFAULT 1000 /* m */ #define POI_RADIUS_DEFAULT (IMPERIAL_UNITS() ? KMINM : MIINM)
#define USE_OPENGL_SETTING "useOpenGL" #define USE_OPENGL_SETTING "useOpenGL"
#define USE_OPENGL_DEFAULT false #define USE_OPENGL_DEFAULT false

View File

@ -4,7 +4,7 @@
#include "stylecombobox.h" #include "stylecombobox.h"
#define MIN_LINE_LENGTH 50 #define MIN_LINE_LENGTH 60
#define LINE_WIDTH_RATIO 7 #define LINE_WIDTH_RATIO 7
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a)) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
@ -42,26 +42,3 @@ void StyleComboBox::setValue(Qt::PenStyle value)
} }
} }
} }
void StyleComboBox::resizeEvent(QResizeEvent *event)
{
QSize is = iconSize();
setIconSize(QSize(qMax(event->size().width() - 40, MIN_LINE_LENGTH),
is.height()));
is = iconSize();
for (int i = 0; i < count(); i++) {
QPixmap pm(is);
pm.fill(Qt::transparent);
QBrush brush(Qt::black);
QPen pen(brush, is.height() / LINE_WIDTH_RATIO,
(Qt::PenStyle) itemData(i).toInt());
QPainter painter(&pm);
painter.setPen(pen);
painter.drawLine(0, is.height() / 2, is.width(), is.height() / 2);
setItemIcon(i, QIcon(pm));
}
}

View File

@ -11,9 +11,6 @@ public:
StyleComboBox(QWidget *parent = 0); StyleComboBox(QWidget *parent = 0);
void setValue(Qt::PenStyle value); void setValue(Qt::PenStyle value);
private:
void resizeEvent(QResizeEvent *event);
}; };
#endif // STYLECOMBOBOX_H #endif // STYLECOMBOBOX_H

View File

@ -16,14 +16,14 @@ enum Units {
#define H2S 0.000277777778 // h -> s #define H2S 0.000277777778 // h -> s
#define MIN2S 0.016666666667 // min -> s #define MIN2S 0.016666666667 // min -> s
#define KMINM 1000 // 1 km in m #define KMINM 1000.0 // 1 km in m
#define MIINFT 5280 // 1 mi in ft #define MIINFT 5280.0 // 1 mi in ft
#define MIINM 1609.344 // 1 mi in m #define MIINM 1609.344 // 1 mi in m
#define MININS 60 // 1 min in s #define MININS 60.0 // 1 min in s
#define HINS 3600 // 1 hins #define HINS 3600.0 // 1 hins
#define C2FS 1.8 // Celsius to Farenheit - scale #define C2FS 1.8 // Celsius to Farenheit - scale
#define C2FO 32 // Celsius to Farenheit - offset #define C2FO 32.0 // Celsius to Farenheit - offset
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
#define UNIT_SPACE QString(" ") #define UNIT_SPACE QString(" ")