| 97 | } |
| 98 | |
| 99 | RoutingSettings::RoutingSettings(QWidget * parent, Framework & framework) : QDialog(parent), m_framework(framework) |
| 100 | { |
| 101 | setWindowTitle("Routing settings"); |
| 102 | QVBoxLayout * layout = new QVBoxLayout(this); |
| 103 | |
| 104 | { |
| 105 | QFrame * frame = new QFrame(this); |
| 106 | frame->setFrameShape(QFrame::Box); |
| 107 | QFormLayout * form = new QFormLayout(frame); |
| 108 | |
| 109 | auto const addCoordLine = [&](char const * title, bool isStart) |
| 110 | { |
| 111 | QLineEdit * lineEdit = new QLineEdit(frame); |
| 112 | if (isStart) |
| 113 | m_startInput = lineEdit; |
| 114 | else |
| 115 | m_finishInput = lineEdit; |
| 116 | |
| 117 | std::string defaultText; |
| 118 | settings::TryGet(isStart ? kStartCoordsCachedSettings : kFinishCoordsCachedSettings, defaultText); |
| 119 | |
| 120 | lineEdit->setText(defaultText.c_str()); |
| 121 | form->addRow(title, lineEdit); |
| 122 | }; |
| 123 | addCoordLine("Start coords (lat, lon)", true); |
| 124 | addCoordLine("Finish coords (lat, lon)", false); |
| 125 | |
| 126 | using namespace routing; |
| 127 | m_routerType = new QComboBox(frame); |
| 128 | m_routerType->insertItem(static_cast<int>(RouterType::Vehicle), "car"); |
| 129 | m_routerType->insertItem(static_cast<int>(RouterType::Pedestrian), "pedestrian"); |
| 130 | m_routerType->insertItem(static_cast<int>(RouterType::Bicycle), "bicycle"); |
| 131 | m_routerType->insertItem(static_cast<int>(RouterType::Transit), "transit"); |
| 132 | m_routerType->insertItem(static_cast<int>(RouterType::Ruler), "ruler"); |
| 133 | form->addRow("Choose router:", m_routerType); |
| 134 | |
| 135 | m_showTurnsCheckbox = new QCheckBox({}, frame); |
| 136 | form->addRow("Show turns:", m_showTurnsCheckbox); |
| 137 | |
| 138 | m_useDebugGuideCheckbox = new QCheckBox({}, frame); |
| 139 | form->addRow("Use debug guide track:", m_useDebugGuideCheckbox); |
| 140 | |
| 141 | layout->addWidget(frame); |
| 142 | } |
| 143 | |
| 144 | { |
| 145 | m_saveSessionCheckbox = new QCheckBox("Save these settings for the next app session", this); |
| 146 | layout->addWidget(m_saveSessionCheckbox); |
| 147 | } |
| 148 | |
| 149 | { |
| 150 | auto * buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); |
| 151 | QObject::connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 152 | QObject::connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 153 | |
| 154 | layout->addWidget(buttonBox); |
| 155 | } |
| 156 | |