~ubuntu-branches/ubuntu/saucy/merkaartor/saucy

« back to all changes in this revision

Viewing changes to src/Preferences/PreferencesDialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz
  • Date: 2009-09-13 00:52:12 UTC
  • mto: (1.2.7 upstream) (0.1.3 upstream) (3.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20090913005212-pjecal8zxm07x0fj
ImportĀ upstreamĀ versionĀ 0.14+svnfixes~20090912

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// C++ Implementation: PreferencesDialog
 
3
//
 
4
// Description:
 
5
//
 
6
//
 
7
// Author: cbro <cbro@semperpax.com>, Bart Vanhauwaert (C) 2008
 
8
//
 
9
// Copyright: See COPYING file that comes with this distribution
 
10
//
 
11
//
 
12
#include "Preferences/PreferencesDialog.h"
 
13
#include "PaintStyle/EditPaintStyle.h"
 
14
 
 
15
#include "MainWindow.h"
 
16
#include "Maps/MapDocument.h"
 
17
#include "Maps/MapFeature.h"
 
18
#include "PropertiesDock.h"
 
19
 
 
20
#include <QFileDialog>
 
21
#include <QColorDialog>
 
22
#include <QMessageBox>
 
23
#include <QPainter>
 
24
#include <QStyleFactory>
 
25
#include <QNetworkProxy>
 
26
 
 
27
 
 
28
static void makeBoundaryIcon(QToolButton* bt, QColor C)
 
29
{
 
30
        QPixmap pm(36, 18);
 
31
        pm.fill(QColor(255, 255, 255));
 
32
        QPainter p(&pm);
 
33
        p.setPen(C);
 
34
        p.setBrush(C);
 
35
        p.drawRect(0, 6, 36, 6);
 
36
        bt->setIcon(pm);
 
37
}
 
38
 
 
39
PreferencesDialog::PreferencesDialog(QWidget* parent)
 
40
        : QDialog(parent)
 
41
{
 
42
#ifdef _MOBILE
 
43
        setWindowState(Qt::WindowFullScreen);
 
44
#endif
 
45
 
 
46
        setupUi(this);
 
47
 
 
48
        setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
 
49
 
 
50
    QDir intTemplates(BUILTIN_TEMPLATES_DIR);
 
51
        for (int i=0; i < intTemplates.entryList().size(); ++i) {
 
52
                cbTemplates->addItem(intTemplates.entryList().at(i));
 
53
        }
 
54
 
 
55
#ifdef FORCED_CUSTOM_STYLE
 
56
    cbCustomStyle->hide();
 
57
    comboCustomStyle->hide();
 
58
#endif
 
59
 
 
60
        resize(1,1);
 
61
        QApplication::processEvents();
 
62
 
 
63
        loadPrefs();
 
64
}
 
65
 
 
66
void PreferencesDialog::updateStyles()
 
67
{
 
68
    cbStyles->clear();
 
69
    QDir intStyles(BUILTIN_STYLES_DIR);
 
70
    for (int i=0; i < intStyles.entryList().size(); ++i) {
 
71
        cbStyles->addItem(intStyles.entryList().at(i) + " (int)", QVariant(intStyles.entryInfoList().at(i).absoluteFilePath()));
 
72
    }
 
73
    if (!CustomStylesDir->text().isEmpty()) {
 
74
        QDir customStyles(CustomStylesDir->text(), "*.mas");
 
75
        for (int i=0; i < customStyles.entryList().size(); ++i) {
 
76
            cbStyles->addItem(customStyles.entryList().at(i), QVariant(customStyles.entryInfoList().at(i).absoluteFilePath()));
 
77
        }
 
78
    }
 
79
 
 
80
    int idx = cbStyles->findData(M_PREFS->getDefaultStyle());
 
81
    if (idx == -1)
 
82
        idx = 0;
 
83
 
 
84
    cbStyles->setCurrentIndex(idx);
 
85
}
 
86
 
 
87
PreferencesDialog::~PreferencesDialog()
 
88
{
 
89
}
 
90
 
 
91
void PreferencesDialog::on_buttonBox_clicked(QAbstractButton * button)
 
92
{
 
93
        if ((button == buttonBox->button(QDialogButtonBox::Apply))) {
 
94
                savePrefs();
 
95
                emit(preferencesChanged());
 
96
        } else
 
97
                if ((button == buttonBox->button(QDialogButtonBox::Ok))) {
 
98
                        savePrefs();
 
99
                        emit(preferencesChanged());
 
100
                        this->accept();
 
101
                }
 
102
}
 
103
 
 
104
void PreferencesDialog::initLanguages(QComboBox* aBox)
 
105
{
 
106
        aBox->addItem(tr("English"),"-");
 
107
        aBox->addItem(tr("Arabic"),"ar");
 
108
        aBox->addItem(tr("Czech"),"cs");
 
109
        aBox->addItem(tr("German"),"de");
 
110
        aBox->addItem(tr("French"),"fr");
 
111
        aBox->addItem(tr("Italian"),"it");
 
112
        aBox->addItem(tr("Polish"),"pl");
 
113
        aBox->addItem(tr("Russian"),"ru");
 
114
}
 
115
 
 
116
void PreferencesDialog::loadPrefs()
 
117
{
 
118
        initLanguages(Language);
 
119
        QString CurrentLanguage(getDefaultLanguage());
 
120
        int l;
 
121
        for (l = 0; l < Language->count(); ++l)
 
122
                if (CurrentLanguage == Language->itemData(l))
 
123
                        break;
 
124
        SelectLanguage->setChecked(l < Language->count());
 
125
        Language->setEnabled(l < Language->count());
 
126
        if (l < Language->count())
 
127
                Language->setCurrentIndex(l);
 
128
        TranslateTags->setChecked(M_PREFS->getTranslateTags());
 
129
        edOsmUrl->setText(M_PREFS->getOsmWebsite());
 
130
        edOsmUser->setText(M_PREFS->getOsmUser());
 
131
    edOsmPwd->setText(M_PREFS->getOsmPassword());
 
132
 
 
133
        edGpsPort->setText(M_PREFS->getGpsPort());
 
134
 
 
135
        sbMaxDistNodes->setValue(M_PREFS->getMaxDistNodes());
 
136
 
 
137
        bbUseProxy->setChecked(M_PREFS->getProxyUse());
 
138
        edProxyHost->setText(M_PREFS->getProxyHost());
 
139
        edProxyPort->setText(QString().setNum(M_PREFS->getProxyPort()));
 
140
        edProxyUser->setText(M_PREFS->getProxyUser());
 
141
        edProxyPassword->setText(M_PREFS->getProxyPassword());
 
142
 
 
143
        //bbUse06Api->setChecked((M_PREFS->apiVersionNum() > 0.5));
 
144
 
 
145
        edCacheDir->setText(M_PREFS->getCacheDir());
 
146
        sbCacheSize->setValue(M_PREFS->getCacheSize());
 
147
 
 
148
        QString s = M_PREFS->getDefaultStyle();
 
149
        QString cs = M_PREFS->getCustomStyle();
 
150
    if (QFileInfo(cs).isFile())
 
151
        cs = QFileInfo(cs).absolutePath();
 
152
    CustomStylesDir->setText(cs);
 
153
    updateStyles();
 
154
 
 
155
        cbDisableStyleForTracks->setChecked(M_PREFS->getDisableStyleForTracks());
 
156
 
 
157
        QString t = M_PREFS->getDefaultTemplate();
 
158
        QString ct = M_PREFS->getCustomTemplate();
 
159
        CustomTemplateName->setText(ct);
 
160
        if (t.startsWith(BUILTIN_TEMPLATES_DIR)) {
 
161
                TemplateBuiltin->setChecked(true);
 
162
                cbTemplates->setEnabled(true);
 
163
                cbTemplates->setCurrentIndex(cbTemplates->findText(t.remove(QString(BUILTIN_TEMPLATES_DIR) + "/")));
 
164
        } else {
 
165
                TemplateCustom->setChecked(true);
 
166
                CustomTemplateName->setEnabled(true);
 
167
                BrowseTemplate->setEnabled(true);
 
168
        }
 
169
 
 
170
        sbZoomInPerc->setValue(M_PREFS->getZoomInPerc());
 
171
        sbZoomOutPerc->setValue(M_PREFS->getZoomOutPerc());
 
172
 
 
173
        sbAlphaLow->setValue(M_PREFS->getAlpha("Low"));
 
174
        sbAlphaHigh->setValue(M_PREFS->getAlpha("High"));
 
175
        BgColor = M_PREFS->getBgColor();
 
176
        cbBackgroundOverwriteStyle->setChecked(M_PREFS->getBackgroundOverwriteStyle());
 
177
        FocusColor = M_PREFS->getFocusColor();
 
178
        HoverColor = M_PREFS->getHoverColor();
 
179
        HighlightColor = M_PREFS->getHighlightColor();
 
180
        RelationsColor = M_PREFS->getRelationsColor();
 
181
        GpxTrackColor = M_PREFS->getGpxTrackColor();
 
182
        makeBoundaryIcon(btBgColor, BgColor);
 
183
        makeBoundaryIcon(btHoverColor, HoverColor);
 
184
        makeBoundaryIcon(btHighlightColor, HighlightColor);
 
185
        makeBoundaryIcon(btFocusColor, FocusColor);
 
186
        makeBoundaryIcon(btRelationsColor, RelationsColor);
 
187
        makeBoundaryIcon(btGpxTrackColor, GpxTrackColor);
 
188
        HoverWidth->setValue(M_PREFS->getHoverWidth());
 
189
        HighlightWidth->setValue(M_PREFS->getHighlightWidth());
 
190
        FocusWidth->setValue(M_PREFS->getFocusWidth());
 
191
        RelationsWidth->setValue(M_PREFS->getRelationsWidth());
 
192
        GpxTrackWidth->setValue(M_PREFS->getGpxTrackWidth());
 
193
        cbSimpleGpxTrack->setChecked(M_PREFS->getSimpleGpxTrack());
 
194
 
 
195
        cbAutoSaveDoc->setChecked(M_PREFS->getAutoSaveDoc());
 
196
        cbAutoExtractTracks->setChecked(M_PREFS->getAutoExtractTracks());
 
197
        cbReadonlyTracksDefault->setChecked(M_PREFS->getReadonlyTracksDefault());
 
198
 
 
199
        ToolList* tl = M_PREFS->getTools();
 
200
        ToolListIterator i(*tl);
 
201
        while (i.hasNext()) {
 
202
                i.next();
 
203
                Tool t(i.value().ToolName, i.value().ToolPath);
 
204
                theTools.push_back(t);
 
205
                lvTools->addItem(t.ToolName);
 
206
        }
 
207
 
 
208
        cbGgpsSaveLog->setChecked(M_PREFS->getGpsSaveLog());
 
209
        edGpsLogDir->setText(M_PREFS->getGpsLogDir());
 
210
        cbGpsSyncTime->setChecked(M_PREFS->getGpsSyncTime());
 
211
 
 
212
        cbMouseSingleButton->setChecked(M_PREFS->getMouseSingleButton());
 
213
        cbSeparateMoveMode->setChecked(M_PREFS->getSeparateMoveMode());
 
214
 
 
215
        cbCustomStyle->setChecked(M_PREFS->getMerkaartorStyle());
 
216
        comboCustomStyle->addItems(QStyleFactory::keys());
 
217
        comboCustomStyle->setCurrentIndex(comboCustomStyle->findText(M_PREFS->getMerkaartorStyleString()));
 
218
 
 
219
        cbUseShapefileForBackground->setChecked(M_PREFS->getUseShapefileForBackground());
 
220
}
 
221
 
 
222
void PreferencesDialog::savePrefs()
 
223
{
 
224
        if (SelectLanguage->isChecked())
 
225
                setDefaultLanguage(Language->itemData(Language->currentIndex()).toString());
 
226
        else
 
227
        setDefaultLanguage("");
 
228
 
 
229
    ((MainWindow*)parent())->updateLanguage();
 
230
    retranslateUi(this);
 
231
 
 
232
        M_PREFS->setTranslateTags(TranslateTags->isChecked());
 
233
        //M_PREFS->setUse06Api(bbUse06Api->isChecked());
 
234
 
 
235
        bool OsmDataChanged = false;
 
236
        if (edOsmUrl->text() != M_PREFS->getOsmWebsite() || 
 
237
                edOsmUser->text() != M_PREFS->getOsmUser() ||
 
238
                edOsmPwd->text() != M_PREFS->getOsmPassword())
 
239
                OsmDataChanged = true;
 
240
 
 
241
        M_PREFS->setOsmWebsite(edOsmUrl->text());
 
242
        M_PREFS->setOsmUser(edOsmUser->text());
 
243
        M_PREFS->setOsmPassword(edOsmPwd->text());
 
244
 
 
245
        M_PREFS->setXapiWebSite(M_PREFS->getXapiWebSite());
 
246
 
 
247
#ifdef Q_OS_WIN32
 
248
        if (!edGpsPort->text().startsWith("\\\\.\\"))
 
249
                edGpsPort->setText("\\\\.\\" + edGpsPort->text());
 
250
#endif 
 
251
        M_PREFS->setGpsPort(edGpsPort->text());
 
252
 
 
253
        M_PREFS->setMaxDistNodes(sbMaxDistNodes->value());
 
254
 
 
255
        M_PREFS->setProxyUse(bbUseProxy->isChecked());
 
256
        M_PREFS->setProxyHost(edProxyHost->text());
 
257
        M_PREFS->setProxyPort(edProxyPort->text().toInt());
 
258
        M_PREFS->setProxyUser(edProxyUser->text());
 
259
        M_PREFS->setProxyPassword(edProxyPassword->text());
 
260
 
 
261
        M_PREFS->setCacheDir(edCacheDir->text());
 
262
        M_PREFS->setCacheSize(sbCacheSize->value());
 
263
 
 
264
    M_PREFS->setCustomStyle(CustomStylesDir->text());
 
265
        QString NewStyle;
 
266
    NewStyle = cbStyles->itemData(cbStyles->currentIndex()).toString();
 
267
 
 
268
        bool PainterToInvalidate = false;
 
269
        if (NewStyle != M_PREFS->getDefaultStyle())
 
270
        {
 
271
                M_PREFS->setDefaultStyle(NewStyle);
 
272
                M_STYLE->loadPainters(M_PREFS->getDefaultStyle());
 
273
                PainterToInvalidate = true;
 
274
        }
 
275
        if (cbDisableStyleForTracks->isChecked() != M_PREFS->getDisableStyleForTracks()) {
 
276
                M_PREFS->setDisableStyleForTracks(cbDisableStyleForTracks->isChecked());        
 
277
                PainterToInvalidate = true;
 
278
        }
 
279
        if (cbSimpleGpxTrack->isChecked() != M_PREFS->getSimpleGpxTrack()) {
 
280
                M_PREFS->setSimpleGpxTrack(cbSimpleGpxTrack->isChecked());      
 
281
                PainterToInvalidate = true;
 
282
        }
 
283
        if (PainterToInvalidate) {
 
284
                for (FeatureIterator it(((MainWindow*)parent())->document()); !it.isEnd(); ++it)
 
285
                {
 
286
                        it.get()->invalidatePainter();
 
287
                }
 
288
        }
 
289
 
 
290
        QString NewTemplate;
 
291
        if (TemplateBuiltin->isChecked())
 
292
                NewTemplate = QString(BUILTIN_TEMPLATES_DIR) + "/" + cbTemplates->currentText();
 
293
        else
 
294
                NewTemplate = CustomTemplateName->text();
 
295
 
 
296
        if (NewTemplate != M_PREFS->getDefaultTemplate())
 
297
        {
 
298
                M_PREFS->setDefaultTemplate(NewTemplate);
 
299
                ((MainWindow*)parent())->properties()->loadTemplates(NewTemplate);
 
300
        }
 
301
 
 
302
    M_PREFS->setCustomStyle(CustomStylesDir->text());
 
303
        M_PREFS->setCustomTemplate(CustomTemplateName->text());
 
304
        M_PREFS->setZoomInPerc(sbZoomInPerc->text().toInt());
 
305
        M_PREFS->setZoomOutPerc(sbZoomOutPerc->text().toInt());
 
306
 
 
307
        M_PREFS->getAlphaPtr()->insert("Low", sbAlphaLow->value());
 
308
        M_PREFS->getAlphaPtr()->insert("High", sbAlphaHigh->value());
 
309
        M_PREFS->setBgColor(BgColor);
 
310
        M_PREFS->setBackgroundOverwriteStyle(cbBackgroundOverwriteStyle->isChecked());
 
311
        M_PREFS->setFocusColor(FocusColor,FocusWidth->value());
 
312
        M_PREFS->setHoverColor(HoverColor,HoverWidth->value());
 
313
        M_PREFS->setHighlightColor(HighlightColor,HighlightWidth->value());
 
314
        M_PREFS->setRelationsColor(RelationsColor,RelationsWidth->value());
 
315
        M_PREFS->setGpxTrackColor(GpxTrackColor,GpxTrackWidth->value());
 
316
 
 
317
        M_PREFS->setAutoSaveDoc(cbAutoSaveDoc->isChecked());
 
318
        M_PREFS->setAutoExtractTracks(cbAutoExtractTracks->isChecked());
 
319
        M_PREFS->setReadonlyTracksDefault(cbReadonlyTracksDefault->isChecked());
 
320
 
 
321
        ToolList* tl = M_PREFS->getTools();
 
322
        tl->clear();
 
323
        for (int i = 0; i < theTools.size(); ++i) {
 
324
                Tool t(theTools[i]);
 
325
                tl->insert(theTools[i].ToolName, t);
 
326
        }
 
327
 
 
328
        M_PREFS->setGpsSaveLog(cbGgpsSaveLog->isChecked());
 
329
        M_PREFS->setGpsLogDir(edGpsLogDir->text());
 
330
        M_PREFS->setGpsSyncTime(cbGpsSyncTime->isChecked());
 
331
 
 
332
        M_PREFS->setMouseSingleButton(cbMouseSingleButton->isChecked());
 
333
        M_PREFS->setSeparateMoveMode(cbSeparateMoveMode->isChecked());
 
334
 
 
335
        M_PREFS->setMerkaartorStyle(cbCustomStyle->isChecked());
 
336
        M_PREFS->setMerkaartorStyleString(comboCustomStyle->currentText());
 
337
 
 
338
        M_PREFS->setUseShapefileForBackground(cbUseShapefileForBackground->isChecked());
 
339
 
 
340
        M_PREFS->save(OsmDataChanged);
 
341
}
 
342
 
 
343
void PreferencesDialog::on_BrowseStyle_clicked()
 
344
{
 
345
    QString s = QFileDialog::getExistingDirectory(this,tr("Custom styles directory"),"");
 
346
        if (!s.isNull())
 
347
        CustomStylesDir->setText(QDir::toNativeSeparators(s));
 
348
 
 
349
    updateStyles();
 
350
}
 
351
 
 
352
void PreferencesDialog::on_BrowseTemplate_clicked()
 
353
{
 
354
        QString s = QFileDialog::getOpenFileName(this,tr("Tag Template"),"",tr("Merkaartor tag template (*.mat)"));
 
355
        if (!s.isNull())
 
356
                CustomTemplateName->setText(QDir::toNativeSeparators(s));
 
357
}
 
358
 
 
359
void PreferencesDialog::on_btBgColor_clicked()
 
360
{
 
361
        bool OK = false;
 
362
        QRgb rgb = QColorDialog::getRgba(BgColor.rgba(), &OK, this);
 
363
        if (OK) {
 
364
                BgColor = QColor::fromRgba(rgb);
 
365
                makeBoundaryIcon(btBgColor, BgColor);
 
366
        }
 
367
}
 
368
 
 
369
void PreferencesDialog::on_btFocusColor_clicked()
 
370
{
 
371
        bool OK = false;
 
372
        QRgb rgb = QColorDialog::getRgba(FocusColor.rgba(), &OK, this);
 
373
        if (OK) {
 
374
                FocusColor = QColor::fromRgba(rgb);
 
375
                makeBoundaryIcon(btFocusColor, FocusColor);
 
376
        }
 
377
}
 
378
 
 
379
void PreferencesDialog::on_btHoverColor_clicked()
 
380
{
 
381
        bool OK = false;
 
382
        QRgb rgb = QColorDialog::getRgba(HoverColor.rgba(), &OK, this);
 
383
        if (OK) {
 
384
                HoverColor = QColor::fromRgba(rgb);
 
385
                makeBoundaryIcon(btHoverColor, HoverColor);
 
386
        }
 
387
}
 
388
 
 
389
void PreferencesDialog::on_btHighlightColor_clicked()
 
390
{
 
391
        bool OK = false;
 
392
        QRgb rgb = QColorDialog::getRgba(HighlightColor.rgba(), &OK, this);
 
393
        if (OK) {
 
394
                HighlightColor = QColor::fromRgba(rgb);
 
395
                makeBoundaryIcon(btHighlightColor, HoverColor);
 
396
        }
 
397
}
 
398
 
 
399
void PreferencesDialog::on_btRelationsColor_clicked()
 
400
{
 
401
        bool OK = false;
 
402
        QRgb rgb = QColorDialog::getRgba(RelationsColor.rgba(), &OK, this);
 
403
        if (OK) {
 
404
                RelationsColor = QColor::fromRgba(rgb);
 
405
                makeBoundaryIcon(btRelationsColor, RelationsColor);
 
406
        }
 
407
}
 
408
void PreferencesDialog::on_btGpxTrackColor_clicked()
 
409
{
 
410
        bool OK = false;
 
411
        QRgb rgb = QColorDialog::getRgba(GpxTrackColor.rgba(), &OK, this);
 
412
        if (OK) {
 
413
                GpxTrackColor = QColor::fromRgba(rgb);
 
414
                makeBoundaryIcon(btGpxTrackColor, GpxTrackColor);
 
415
        }
 
416
}
 
417
 
 
418
 
 
419
/* Tools */
 
420
void PreferencesDialog::on_btAddTool_clicked(void)
 
421
{
 
422
        for (int i=0; i<theTools.size(); ++i) {
 
423
                if (theTools[i].ToolName == edToolName->text()) {
 
424
                QMessageBox::critical(this, tr("Tool already exists"), 
 
425
                        tr("A tool of this name already exists.\nPlease select another name or click the <Apply> button if you want to modify the existing one"), QMessageBox::Ok);
 
426
                return;
 
427
                }
 
428
        }
 
429
        Tool t(edToolName->text(), edToolPath->text());
 
430
        theTools.push_back(t);
 
431
        lvTools->addItem(t.ToolName);
 
432
 
 
433
        lvTools->setCurrentRow(theTools.size() - 1);
 
434
        on_lvTools_itemSelectionChanged();
 
435
}
 
436
 
 
437
void PreferencesDialog::on_btDelTool_clicked(void)
 
438
{
 
439
        int idx = static_cast<int>(lvTools->currentRow());
 
440
        if (idx >= theTools.size())
 
441
                return;
 
442
 
 
443
        if (theTools[idx].ToolName == "Inkscape") {
 
444
                QMessageBox::critical(this, tr("Cannot delete preset tool"), 
 
445
                        tr("Cannot delete preset tool \"%1\"").arg(theTools[idx].ToolName), QMessageBox::Ok);
 
446
                return;
 
447
        }
 
448
        theTools.erase(theTools.begin() + idx);
 
449
        delete lvTools->takeItem(idx);
 
450
        if (idx && (idx >= theTools.size()))
 
451
                --idx;
 
452
        lvTools->setCurrentRow(idx);
 
453
        on_lvTools_itemSelectionChanged();
 
454
}
 
455
 
 
456
void PreferencesDialog::on_btApplyTool_clicked(void)
 
457
{
 
458
        int idx = static_cast<int>(lvTools->currentRow());
 
459
        if (idx >= theTools.size())
 
460
                return;
 
461
 
 
462
        if ((theTools[idx].ToolName == "Inkscape") && edToolName->text() != theTools[idx].ToolName) {
 
463
                QMessageBox::critical(this, tr("Cannot modify preset tool name"), 
 
464
                        tr("Cannot modify preset tool \"%1\"'s name").arg(theTools[idx].ToolName), QMessageBox::Ok);
 
465
                return;
 
466
        }
 
467
        Tool& t(theTools[idx]);
 
468
        t.ToolName = edToolName->text();
 
469
        t.ToolPath = edToolPath->text();
 
470
 
 
471
        lvTools->item(lvTools->currentRow())->setText(edToolName->text());
 
472
}
 
473
 
 
474
void PreferencesDialog::on_lvTools_itemSelectionChanged()
 
475
{
 
476
        QListWidgetItem* it = lvTools->item(lvTools->currentRow());
 
477
        
 
478
        int idx = static_cast<int>(lvTools->row(it));
 
479
        if (idx >= theTools.size())
 
480
                return;
 
481
 
 
482
        Tool& t(theTools[idx]);
 
483
        edToolName->setText(t.ToolName);
 
484
        edToolPath->setText(t.ToolPath);
 
485
}
 
486
 
 
487
void PreferencesDialog::on_btBrowse_clicked()
 
488
{
 
489
        QString s = QFileDialog::getOpenFileName(this,tr("Select tool executable"));
 
490
        if (!s.isNull()) {
 
491
                edToolPath->setText(s);
 
492
        }
 
493
}
 
494
 
 
495
void PreferencesDialog::on_btGpsLogDirBrowse_clicked()
 
496
{
 
497
        QString s = QFileDialog::getExistingDirectory(this,tr("Select Log directory"));
 
498
        if (!s.isNull()) {
 
499
                edGpsLogDir->setText(s);
 
500
        }
 
501
}
 
502
 
 
503
void PreferencesDialog::changeEvent(QEvent * event)
 
504
{
 
505
        if (event->type() == QEvent::LanguageChange)
 
506
                retranslateUi(this);
 
507
        QDialog::changeEvent(event);
 
508
}
 
509