mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-02-17 16:20:48 +01:00
Added initial open file paths configuration
This commit is contained in:
parent
3644ed3b1f
commit
5b3b7128f6
@ -19,6 +19,7 @@ CONFIG += object_parallel_to_source
|
|||||||
INCLUDEPATH += ./src
|
INCLUDEPATH += ./src
|
||||||
HEADERS += src/common/config.h \
|
HEADERS += src/common/config.h \
|
||||||
src/GUI/axislabelitem.h \
|
src/GUI/axislabelitem.h \
|
||||||
|
src/GUI/dirselectwidget.h \
|
||||||
src/GUI/graphicsscene.h \
|
src/GUI/graphicsscene.h \
|
||||||
src/GUI/mapaction.h \
|
src/GUI/mapaction.h \
|
||||||
src/GUI/mapitem.h \
|
src/GUI/mapitem.h \
|
||||||
@ -228,6 +229,7 @@ HEADERS += src/common/config.h \
|
|||||||
|
|
||||||
SOURCES += src/main.cpp \
|
SOURCES += src/main.cpp \
|
||||||
src/GUI/axislabelitem.cpp \
|
src/GUI/axislabelitem.cpp \
|
||||||
|
src/GUI/dirselectwidget.cpp \
|
||||||
src/GUI/mapitem.cpp \
|
src/GUI/mapitem.cpp \
|
||||||
src/GUI/marginswidget.cpp \
|
src/GUI/marginswidget.cpp \
|
||||||
src/GUI/markerinfoitem.cpp \
|
src/GUI/markerinfoitem.cpp \
|
||||||
|
42
src/GUI/dirselectwidget.cpp
Normal file
42
src/GUI/dirselectwidget.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#include <QPushButton>
|
||||||
|
#include <QToolButton>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QFontMetrics>
|
||||||
|
#include <QApplication>
|
||||||
|
#include "dirselectwidget.h"
|
||||||
|
|
||||||
|
DirSelectWidget::DirSelectWidget(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
QFontMetrics fm(QApplication::font());
|
||||||
|
_edit = new QLineEdit();
|
||||||
|
_edit->setMinimumWidth(fm.averageCharWidth() * (QDir::homePath().length()
|
||||||
|
+ 12));
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
_button = new QPushButton("...");
|
||||||
|
_button->setMaximumWidth(_button->sizeHint().width() / 2);
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
_button = new QToolButton();
|
||||||
|
_button->setText("...");
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
connect(_button, &QToolButton::clicked, this, &DirSelectWidget::browse);
|
||||||
|
|
||||||
|
QHBoxLayout *layout = new QHBoxLayout();
|
||||||
|
layout->setContentsMargins(QMargins());
|
||||||
|
layout->addWidget(_edit);
|
||||||
|
layout->addWidget(_button);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
QSizePolicy p(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
|
||||||
|
setSizePolicy(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DirSelectWidget::browse()
|
||||||
|
{
|
||||||
|
QString dir(QFileDialog::getExistingDirectory(this, tr("Select directory"),
|
||||||
|
_edit->text()));
|
||||||
|
|
||||||
|
if (!dir.isEmpty())
|
||||||
|
_edit->setText(dir);
|
||||||
|
}
|
30
src/GUI/dirselectwidget.h
Normal file
30
src/GUI/dirselectwidget.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef DIRSELECTWIDGET_H
|
||||||
|
#define DIRSELECTWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
class DirSelectWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DirSelectWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
|
QString dir() const {return _edit->text();}
|
||||||
|
void setDir(const QString &path) {_edit->setText(path);}
|
||||||
|
bool checkDir(QString &error) const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void browse();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLineEdit *_edit;
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
QPushButton *_button;
|
||||||
|
#else // Q_OS_WIN32
|
||||||
|
QToolButton *_button;
|
||||||
|
#endif // Q_OS_WIN32
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIRSELECTWIDGET_H
|
@ -96,12 +96,12 @@ GUI::GUI()
|
|||||||
_movingTime = 0;
|
_movingTime = 0;
|
||||||
_lastTab = 0;
|
_lastTab = 0;
|
||||||
|
|
||||||
_dataDir = QDir::homePath();
|
|
||||||
_mapDir = QDir::homePath();
|
|
||||||
_poiDir = QDir::homePath();
|
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
|
_dataDir = _options.dataPath;
|
||||||
|
_mapDir = _options.mapsPath;
|
||||||
|
_poiDir = _options.poiPath;
|
||||||
|
|
||||||
updateGraphTabs();
|
updateGraphTabs();
|
||||||
updateStatusBarInfo();
|
updateStatusBarInfo();
|
||||||
}
|
}
|
||||||
@ -2262,6 +2262,13 @@ void GUI::writeSettings()
|
|||||||
settings.setValue(INPUT_PROJECTION_SETTING, _options.inputProjection);
|
settings.setValue(INPUT_PROJECTION_SETTING, _options.inputProjection);
|
||||||
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
if (_options.hidpiMap != HIDPI_MAP_DEFAULT)
|
||||||
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
settings.setValue(HIDPI_MAP_SETTING, _options.hidpiMap);
|
||||||
|
if (_options.dataPath != DATA_PATH_DEFAULT)
|
||||||
|
settings.setValue(DATA_PATH_SETTING, _options.dataPath);
|
||||||
|
if (_options.mapsPath != MAPS_PATH_DEFAULT)
|
||||||
|
settings.setValue(MAPS_PATH_SETTING, _options.mapsPath);
|
||||||
|
if (_options.poiPath != POI_PATH_DEFAULT)
|
||||||
|
settings.setValue(POI_PATH_SETTING, _options.poiPath);
|
||||||
|
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2563,8 +2570,14 @@ void GUI::readSettings()
|
|||||||
OUTPUT_PROJECTION_DEFAULT).toInt();
|
OUTPUT_PROJECTION_DEFAULT).toInt();
|
||||||
_options.inputProjection = settings.value(INPUT_PROJECTION_SETTING,
|
_options.inputProjection = settings.value(INPUT_PROJECTION_SETTING,
|
||||||
INPUT_PROJECTION_DEFAULT).toInt();
|
INPUT_PROJECTION_DEFAULT).toInt();
|
||||||
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_SETTING)
|
_options.hidpiMap = settings.value(HIDPI_MAP_SETTING, HIDPI_MAP_DEFAULT)
|
||||||
.toBool();
|
.toBool();
|
||||||
|
_options.dataPath = settings.value(DATA_PATH_SETTING, DATA_PATH_DEFAULT)
|
||||||
|
.toString();
|
||||||
|
_options.mapsPath = settings.value(MAPS_PATH_SETTING, MAPS_PATH_DEFAULT)
|
||||||
|
.toString();
|
||||||
|
_options.poiPath = settings.value(POI_PATH_SETTING, POI_PATH_DEFAULT)
|
||||||
|
.toString();
|
||||||
|
|
||||||
_mapView->setPalette(_options.palette);
|
_mapView->setPalette(_options.palette);
|
||||||
_mapView->setMapOpacity(_options.mapOpacity);
|
_mapView->setMapOpacity(_options.mapOpacity);
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "oddspinbox.h"
|
#include "oddspinbox.h"
|
||||||
#include "percentslider.h"
|
#include "percentslider.h"
|
||||||
#include "projectioncombobox.h"
|
#include "projectioncombobox.h"
|
||||||
|
#include "dirselectwidget.h"
|
||||||
#include "optionsdialog.h"
|
#include "optionsdialog.h"
|
||||||
|
|
||||||
|
|
||||||
@ -539,12 +540,12 @@ QWidget *OptionsDialog::createDataPage()
|
|||||||
sourceTab->setLayout(sourceTabLayout);
|
sourceTab->setLayout(sourceTabLayout);
|
||||||
|
|
||||||
|
|
||||||
QTabWidget *filterPage = new QTabWidget();
|
QTabWidget *dataPage = new QTabWidget();
|
||||||
filterPage->addTab(filterTab, tr("Filtering"));
|
dataPage->addTab(filterTab, tr("Filtering"));
|
||||||
filterPage->addTab(sourceTab, tr("Sources"));
|
dataPage->addTab(sourceTab, tr("Sources"));
|
||||||
filterPage->addTab(pauseTab, tr("Pause detection"));
|
dataPage->addTab(pauseTab, tr("Pause detection"));
|
||||||
|
|
||||||
return filterPage;
|
return dataPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *OptionsDialog::createPOIPage()
|
QWidget *OptionsDialog::createPOIPage()
|
||||||
@ -683,8 +684,35 @@ QWidget *OptionsDialog::createSystemPage()
|
|||||||
systemTabLayout->addStretch();
|
systemTabLayout->addStretch();
|
||||||
systemTab->setLayout(systemTabLayout);
|
systemTab->setLayout(systemTabLayout);
|
||||||
|
|
||||||
|
_dataPath = new DirSelectWidget();
|
||||||
|
_dataPath->setDir(_options.dataPath);
|
||||||
|
_mapsPath = new DirSelectWidget();
|
||||||
|
_mapsPath->setDir(_options.mapsPath);
|
||||||
|
_poiPath = new DirSelectWidget();
|
||||||
|
_poiPath->setDir(_options.poiPath);
|
||||||
|
|
||||||
|
QLabel *info = new QLabel(tr("Select the initial paths of the file open"
|
||||||
|
" dialogues. Leave the field empty for the system default."));
|
||||||
|
QFont f = info->font();
|
||||||
|
f.setPointSize(f.pointSize() - 1);
|
||||||
|
info->setFont(f);
|
||||||
|
info->setWordWrap(true);
|
||||||
|
|
||||||
|
QFormLayout *pathsFormLayout = new QFormLayout();
|
||||||
|
pathsFormLayout->addRow(tr("Data:"), _dataPath);
|
||||||
|
pathsFormLayout->addRow(tr("Maps:"), _mapsPath);
|
||||||
|
pathsFormLayout->addRow(tr("POI:"), _poiPath);
|
||||||
|
|
||||||
|
QWidget *pathsTab = new QWidget();
|
||||||
|
QVBoxLayout *pathsTabLayout = new QVBoxLayout();
|
||||||
|
pathsTabLayout->addWidget(info);
|
||||||
|
pathsTabLayout->addLayout(pathsFormLayout);
|
||||||
|
pathsTabLayout->addStretch();
|
||||||
|
pathsTab->setLayout(pathsTabLayout);
|
||||||
|
|
||||||
QTabWidget *systemPage = new QTabWidget();
|
QTabWidget *systemPage = new QTabWidget();
|
||||||
systemPage->addTab(systemTab, tr("System"));
|
systemPage->addTab(systemTab, tr("System"));
|
||||||
|
systemPage->addTab(pathsTab, tr("Initial paths"));
|
||||||
|
|
||||||
return systemPage;
|
return systemPage;
|
||||||
}
|
}
|
||||||
@ -807,6 +835,9 @@ void OptionsDialog::accept()
|
|||||||
_options.enableHTTP2 = _enableHTTP2->isChecked();
|
_options.enableHTTP2 = _enableHTTP2->isChecked();
|
||||||
_options.pixmapCache = _pixmapCache->value();
|
_options.pixmapCache = _pixmapCache->value();
|
||||||
_options.connectionTimeout = _connectionTimeout->value();
|
_options.connectionTimeout = _connectionTimeout->value();
|
||||||
|
_options.dataPath = _dataPath->dir();
|
||||||
|
_options.mapsPath = _mapsPath->dir();
|
||||||
|
_options.poiPath = _poiPath->dir();
|
||||||
|
|
||||||
_options.hiresPrint = _hires->isChecked();
|
_options.hiresPrint = _hires->isChecked();
|
||||||
_options.printName = _name->isChecked();
|
_options.printName = _name->isChecked();
|
||||||
|
@ -16,6 +16,7 @@ class QCheckBox;
|
|||||||
class QRadioButton;
|
class QRadioButton;
|
||||||
class PercentSlider;
|
class PercentSlider;
|
||||||
class ProjectionComboBox;
|
class ProjectionComboBox;
|
||||||
|
class DirSelectWidget;
|
||||||
|
|
||||||
|
|
||||||
struct Options {
|
struct Options {
|
||||||
@ -65,6 +66,9 @@ struct Options {
|
|||||||
bool enableHTTP2;
|
bool enableHTTP2;
|
||||||
int pixmapCache;
|
int pixmapCache;
|
||||||
int connectionTimeout;
|
int connectionTimeout;
|
||||||
|
QString dataPath;
|
||||||
|
QString mapsPath;
|
||||||
|
QString poiPath;
|
||||||
// Print/Export
|
// Print/Export
|
||||||
bool hiresPrint;
|
bool hiresPrint;
|
||||||
bool printName;
|
bool printName;
|
||||||
@ -154,6 +158,9 @@ private:
|
|||||||
QSpinBox *_connectionTimeout;
|
QSpinBox *_connectionTimeout;
|
||||||
QCheckBox *_useOpenGL;
|
QCheckBox *_useOpenGL;
|
||||||
QCheckBox *_enableHTTP2;
|
QCheckBox *_enableHTTP2;
|
||||||
|
DirSelectWidget *_dataPath;
|
||||||
|
DirSelectWidget *_mapsPath;
|
||||||
|
DirSelectWidget *_poiPath;
|
||||||
// Print/Export
|
// Print/Export
|
||||||
QRadioButton *_wysiwyg;
|
QRadioButton *_wysiwyg;
|
||||||
QRadioButton *_hires;
|
QRadioButton *_hires;
|
||||||
|
@ -205,5 +205,11 @@
|
|||||||
#define INPUT_PROJECTION_DEFAULT 4326
|
#define INPUT_PROJECTION_DEFAULT 4326
|
||||||
#define HIDPI_MAP_SETTING "HiDPIMap"
|
#define HIDPI_MAP_SETTING "HiDPIMap"
|
||||||
#define HIDPI_MAP_DEFAULT true
|
#define HIDPI_MAP_DEFAULT true
|
||||||
|
#define DATA_PATH_SETTING "dataPath"
|
||||||
|
#define DATA_PATH_DEFAULT QString()
|
||||||
|
#define MAPS_PATH_SETTING "mapsPath"
|
||||||
|
#define MAPS_PATH_DEFAULT QString()
|
||||||
|
#define POI_PATH_SETTING "poiPath"
|
||||||
|
#define POI_PATH_DEFAULT QString()
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user