?? settings.cpp
字號:
/*
qpegps is a program for displaying a map centered at the current longitude/
latitude as read from a gps receiver.
Copyright (C) 2002 Ralf Haselmeier <Ralf.Haselmeier@gmx.de>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "settings.h"
#include "qpegps.h"
ConfigDialog::ConfigDialog(QStringList profiles, int currItem, QWidget * parent,
const char * name, bool modal, WFlags f)
: QDialog(parent, name, modal, f)
{
resize(220, 220);
QVBox * vbox = new QVBox(this);
QLabel * info = new QLabel(tr("\nqpeGPS\n\nselect a profile:\n"), vbox);
info->setAlignment(Qt::AlignCenter);
profileSelector = new QListBox(vbox);
profileSelector->insertStringList(profiles);
profileSelector->setCurrentItem(currItem);
cbox = new QCheckBox(vbox);
cbox->setText(tr("do not show this dialog again"));
cbox->setChecked(false);
vbox->resize(geometry().size());
}
Settings::Settings(Qpegps *ap, MapDispOptions *mapDispOpts,
PlacesOptions *placesOpt, MapOptions *mapOpts,
TrackOptions *trackOpts, GeoDatumOptions *geodatumOpts,
QWidget * parent, const char * name, WFlags f)
: QScrollView (parent, name, f),
app(ap), mapDispOptions(mapDispOpts), placesOptions(placesOpt),
mapOptions(mapOpts), geodatumOptions(geodatumOpts),
trackOptions(trackOpts), configIdx(0)
{
setHScrollBarMode(AlwaysOff);
setVScrollBarMode(Auto);
QVBox * mainBox = new QVBox(this);
addChild(mainBox);
setResizePolicy(AutoOneFit);
mainBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
configFileList += QPEGPS_DEFAULT_CONF;
QVBox * vbox1 = new QVBox(mainBox);
QHBox * hbox2 = new QHBox(vbox1);
configName = new QComboBox(hbox2);
configName->setEditable(true);
configName->setInsertionPolicy(QComboBox::AtCurrent);
QHBox * hbox6 = new QHBox(vbox1);
QPushButton * configAdd = new QPushButton(tr("Add"), hbox6);
QPushButton * configDel = new QPushButton(tr("Delete"), hbox6);
showConfigDialog = new QCheckBox(hbox6);
showConfigDialog->setText(tr("startup dialog"));
QHBox * hbox3 = new QHBox(mainBox);
(void)new QLabel(tr("Map dir"), hbox3);
mapPath = new QLineEdit(hbox3);
QPushButton * mapPathB = new QPushButton(tr("search"), hbox3);
subdirTB = new QCheckBox(mainBox);
subdirTB->setText(tr("Search for maps files on subdirs"));
#if 0 // PROXY
horbox11 = new QHBox(mainBox);
proxyUrlL = new QLabel(tr("Use Proxy:"),horbox11);
proxyUrlLE = new QLineEdit(horbox11);
#endif
//geoDatL = new QLabel(tr("GEO Datum:"),mainBox);
QGrid * grid2 = new QGrid(2, mainBox);
QLabel * geoDatGpsL = new QLabel(tr("GPS"), grid2);
geoDatGpsL->setAlignment(AlignCenter | AlignVCenter);
geoDatGpsCB = new QComboBox(grid2);
geoDatGpsCB->insertStringList(app->geoDatum->getDatumList());
geoDatGpsCB->setEditable(false);
QLabel * geoDatMapL = new QLabel(tr("Map"), grid2);
geoDatMapL->setAlignment(AlignCenter | AlignVCenter);
geoDatMapCB = new QComboBox(grid2);
geoDatMapCB->insertStringList(app->geoDatum->getDatumList());
geoDatMapCB->setEditable(false);
QGrid * grid1 = new QGrid(4, mainBox);
QLabel * altL = new QLabel(tr("Altitude"), grid1);
altL->setAlignment(AlignCenter | AlignVCenter);
altCB = new QComboBox(false, grid1, "Altitude");
altCB->insertItem(tr("none"));
altCB->insertItem(tr("m"));
altCB->insertItem(tr("feet"));
altCB->insertItem(tr("FL"));
QLabel * speedL = new QLabel(tr("Speed"), grid1);
speedL->setAlignment(AlignCenter | AlignVCenter);
speedCB = new QComboBox(false, grid1, "Speed");
speedCB->insertItem(tr("none"));
speedCB->insertItem(tr("kmh"));
speedCB->insertItem(tr("kn"));
speedCB->insertItem(tr("mph"));
QLabel * distL = new QLabel(tr("Distance"), grid1);
distL->setAlignment(AlignCenter | AlignVCenter);
distCB = new QComboBox(false, grid1, "Distance");
distCB->insertItem(tr("none"));
distCB->insertItem(tr("km"));
distCB->insertItem(tr("nmi"));
distCB->insertItem(tr("mi"));
QLabel * posL = new QLabel(tr("Position"), grid1);
posL->setAlignment(AlignCenter | AlignVCenter);
posCB = new QComboBox(false, grid1, "Position");
posCB->insertItem(tr("DD.d"));
posCB->insertItem(tr("DDMM.m'"));
posCB->insertItem(tr("DDMM'SS.s''"));
QLabel * textSizeL = new QLabel(tr("Text Size"), grid1);
textSizeL->setAlignment(AlignCenter | AlignVCenter);
textSizeSB = new QSpinBox(4, 30, 1, grid1, "Text Size");
(void)new QLabel(" ", grid1); // dummy label for grid format
QPushButton * colorB = new QPushButton(tr("Colors"), grid1);
QHBox * hbox4 = new QHBox(mainBox);
(void)new QLabel(tr("Map orientation"), hbox4);
rotateCB = new QComboBox(false, hbox4, "Map orientation");
rotateCB->insertItem(tr("North up"));
rotateCB->insertItem(tr("Heading up"));
QHBox * hbox1 = new QHBox(mainBox);
(void)new QLabel(tr("display:"), hbox1 );
bearTB = new QCheckBox(hbox1);
bearTB->setText(tr("Bearing"));
headTB = new QCheckBox(hbox1);
headTB->setText(tr("Heading"));
timeTB = new QCheckBox(hbox1);
timeTB->setText(tr("Time"));
// selectConfigR(true);
connect( altCB, SIGNAL(activated(int)),
SLOT(setAlt(int)) );
connect( speedCB, SIGNAL(activated(int)),
SLOT(setSpeed(int)) );
connect( distCB, SIGNAL(activated(int)),
SLOT(setDist(int)) );
connect( posCB, SIGNAL(activated(int)),
SLOT(setPos(int)) );
connect( bearTB, SIGNAL(toggled(bool)),
SLOT(setBear(bool)) );
connect( headTB, SIGNAL(toggled(bool)),
SLOT(setHead(bool)) );
connect( timeTB, SIGNAL(toggled(bool)),
SLOT(setTime(bool)) );
connect( showConfigDialog, SIGNAL(clicked()),
SLOT(setDialog()) );
connect( mapPathB, SIGNAL(pressed()),
SLOT(setMapPath()) );
connect( subdirTB, SIGNAL(toggled(bool)),
SLOT(setSubdir(bool)) );
connect( colorB, SIGNAL(pressed()),
SLOT(setColors()) );
connect( mapPath, SIGNAL(returnPressed()),
SLOT(mapPathLEChanged()) );
connect( rotateCB, SIGNAL(activated(int)),
SLOT(setRotate(int)) );
#if 0 // PROXY
connect( proxyUrlLE, SIGNAL(returnPressed()),
SLOT(proxyUrlLEChanged()) );
#endif
connect( textSizeSB , SIGNAL(valueChanged(int)),
SLOT(textSizeChanged(int)) );
connect( geoDatGpsCB , SIGNAL(activated(int)),
SLOT(geoDatGpsChanged(int)) );
connect( geoDatMapCB , SIGNAL(activated(int)),
SLOT(geoDatMapChanged(int)) );
connect( configAdd, SIGNAL(pressed()),
SLOT(addConfig()) );
connect( configDel, SIGNAL(pressed()),
SLOT(delConfig()) );
connect( configName, SIGNAL(activated(int)),
SLOT(selectConfig(int)) );
connect( configName, SIGNAL(textChanged(const QString & )),
SLOT(selectConfigRename(const QString & )));
}
void Settings::selectConfigR(bool construct)
{
/* which config ? */
qpegpsConfigSelect = new Config("qpegps");
qpegpsConfigSelect->setGroup("main");
configIdx = qpegpsConfigSelect->readNumEntry("current", 0);
configFileList = qpegpsConfigSelect->readListEntry("profiles", '*');
if ( configFileList.isEmpty() ) {
configFileList += QPEGPS_DEFAULT_CONF;
}
configName->clear();
configName->insertStringList(configFileList);
showConfigDialog->setChecked(
qpegpsConfigSelect->readBoolEntry("startupDialog", true));
if ( construct && showConfigDialog->isChecked()
&& (configFileList.count() > 1) ) {
ConfigDialog cDialog(
configFileList, configIdx, this, tr("select profile"), true, 0);
cDialog.setCaption(tr("qpeGPS"));
cDialog.exec();
configIdx = cDialog.profileSelector->currentItem();
showConfigDialog->setChecked(!(cDialog.cbox->isChecked()));
}
configName->setCurrentItem(configIdx);
// app->setCurrentConfig(configFileList[configIdx]);
// create config file
selectConfigW(false);
}
void Settings::selectConfigW(bool add)
{
/* which config ? */
qpegpsConfigSelect->setGroup("main");
qpegpsConfigSelect->writeEntry("current", (int)configIdx);
qpegpsConfigSelect->writeEntry("profiles", configFileList.join("*"));
qpegpsConfigSelect->writeEntry(
"startupDialog", showConfigDialog->isChecked());
delete qpegpsConfigSelect;
qpegpsConfigSelect = new Config("qpegps");
app->setCurrentConfig(configFileList[configIdx], add);
}
void Settings::updateConfig()
{
// set buttons...
altCB->setCurrentItem((int)Altitude::unit);
//altCB->setCurrentItem((int)gpsData->altitude.altUnit);
speedCB->setCurrentItem((int)Speed::unit);
//speedCB->setCurrentItem((int)gpsData->speed.speedUnit);
distCB->setCurrentItem((int)Distance::unit);
//distCB->setCurrentItem((int)gpsData->wpDistance.distUnit);
posCB->setCurrentItem((int)Position::unit);
//posCB->setCurrentItem((int)gpsData->currPos.unit);
bearTB->setChecked(mapDispOptions->showBearing);
headTB->setChecked(mapDispOptions->showHeading);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -