1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

Finalize the projection combo box redesign

This commit is contained in:
Martin Tůma 2021-06-28 23:47:20 +02:00
parent fa0f7f95d2
commit e9cd0963dc
6 changed files with 44 additions and 71 deletions

View File

@ -209,7 +209,7 @@ HEADERS += src/common/config.h \
src/map/IMG/subdiv.h \
src/map/IMG/style.h \
src/map/IMG/netfile.h \
src/GUI/limitedcombobox.h \
src/GUI/projectioncombobox.h \
src/GUI/pathtickitem.h \
src/map/textitem.h \
src/map/IMG/label.h \
@ -395,7 +395,8 @@ SOURCES += src/main.cpp \
src/data/geojsonparser.cpp \
src/map/aqmmap.cpp \
src/map/mapsforgemap.cpp \
src/map/worldfilemap.cpp
src/map/worldfilemap.cpp \
src/GUI/projectioncombobox.cpp
DEFINES += APP_VERSION=\\\"$$VERSION\\\" \
QT_NO_DEPRECATED_WARNINGS

View File

@ -1,40 +0,0 @@
#ifndef LIMITEDCOMBOBOX_H
#define LIMITEDCOMBOBOX_H
#include <QComboBox>
#include <QEvent>
class LimitedComboBox : public QComboBox
{
public:
LimitedComboBox(int limit, QWidget *parent = 0)
: QComboBox(parent), _limit(limit)
{
setSizeAdjustPolicy(AdjustToMinimumContentsLengthWithIcon);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
setStyleSheet("combobox-popup: 0;");
}
QSize sizeHint() const
{
return QSize(qMin(_limit, QComboBox::sizeHint().width()),
QComboBox::sizeHint().height());
}
QSize minimumSizeHint() const
{
return QSize(qMin(_limit, QComboBox::minimumSizeHint().width()),
QComboBox::minimumSizeHint().height());
}
bool event(QEvent *e)
{
if (e->type() == QEvent::Polish)
view()->setMinimumWidth(QComboBox::sizeHint().width());
return QComboBox::event(e);
}
private:
int _limit;
};
#endif // LIMITEDCOMBOBOX_H

View File

@ -13,13 +13,12 @@
#include <QLabel>
#include <QSysInfo>
#include <QButtonGroup>
#include "map/pcs.h"
#include "icons.h"
#include "colorbox.h"
#include "stylecombobox.h"
#include "oddspinbox.h"
#include "percentslider.h"
#include "limitedcombobox.h"
#include "projectioncombobox.h"
#include "optionsdialog.h"
@ -44,34 +43,12 @@ void OptionsDialog::automaticPauseDetectionSet(bool set)
_pauseSpeed->setEnabled(!set);
}
static LimitedComboBox *projectionBox()
{
LimitedComboBox *box;
int last = -1;
box = new LimitedComboBox(200);
QList<KV<int, QString> > projections(GCS::list() + PCS::list());
std::sort(projections.begin(), projections.end());
for (int i = 0; i < projections.size(); i++) {
const KV<int, QString> &proj = projections.at(i);
// There may be same EPSG codes with different names
if (proj.key() == last)
continue;
else
last = proj.key();
QString text = QString::number(proj.key()) + " - " + proj.value();
box->addItem(text, QVariant(proj.key()));
}
return box;
}
QWidget *OptionsDialog::createMapPage()
{
_outputProjection = projectionBox();
_outputProjection = new ProjectionComboBox();
_outputProjection->setCurrentIndex(_outputProjection->findData(
_options.outputProjection));
_inputProjection = projectionBox();
_inputProjection = new ProjectionComboBox();
_inputProjection->setCurrentIndex(_inputProjection->findData(
_options.inputProjection));

View File

@ -15,7 +15,7 @@ class QComboBox;
class QCheckBox;
class QRadioButton;
class PercentSlider;
class LimitedComboBox;
class ProjectionComboBox;
struct Options {
@ -121,8 +121,8 @@ private:
ColorBox *_sliderColor;
QCheckBox *_graphAA;
// Map
LimitedComboBox *_outputProjection;
LimitedComboBox *_inputProjection;
ProjectionComboBox *_outputProjection;
ProjectionComboBox *_inputProjection;
QRadioButton *_hidpi;
QRadioButton *_lodpi;
// Data

View File

@ -0,0 +1,23 @@
#include "map/pcs.h"
#include "projectioncombobox.h"
ProjectionComboBox::ProjectionComboBox(QWidget *parent) : QComboBox(parent)
{
setSizeAdjustPolicy(AdjustToMinimumContentsLengthWithIcon);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
setStyleSheet("combobox-popup: 0;");
int last = -1;
QList<KV<int, QString> > projections(GCS::list() + PCS::list());
std::sort(projections.begin(), projections.end());
for (int i = 0; i < projections.size(); i++) {
const KV<int, QString> &proj = projections.at(i);
// There may be duplicit EPSG codes with different names
if (proj.key() == last)
continue;
else
last = proj.key();
QString text = QString::number(proj.key()) + " - " + proj.value();
addItem(text, QVariant(proj.key()));
}
}

View File

@ -0,0 +1,12 @@
#ifndef PROJECTIONCOMBOBOX_H
#define PROJECTIONCOMBOBOX_H
#include <QComboBox>
class ProjectionComboBox : public QComboBox
{
public:
ProjectionComboBox(QWidget *parent = 0);
};
#endif // PROJECTIONCOMBOBOX_H