Qt Virtual Chart Table (QVCT)
CSettingsMiscEditView.cpp
Go to the documentation of this file.
1 // INDENTING (emacs/vi): -*- mode:c++; tab-width:2; c-basic-offset:2; intent-tabs-mode:nil; -*- ex: set tabstop=2 expandtab:
2 
3 /*
4  * Qt Virtual Chart Table (QVCT)
5  * Copyright (C) 2012 Cedric Dufour <http://cedric.dufour.name>
6  * Author: Cedric Dufour <http://cedric.dufour.name>
7  *
8  * The Qt Virtual Chart Table (QVCT) is free software:
9  * you can redistribute it and/or modify it under the terms of the GNU General
10  * Public License as published by the Free Software Foundation, Version 3.
11  *
12  * The Qt Virtual Chart Table (QVCT) is distributed in the hope
13  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
14  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU General Public License for more details.
17  */
18 
19 // QT
20 #include <QCheckBox>
21 #include <QGridLayout>
22 #include <QLabel>
23 #include <QLineEdit>
24 #include <QSpacerItem>
25 #include <QSpinBox>
26 #include <QWidget>
27 
28 // QVCT
29 #include "QVCTRuntime.hpp"
31 
32 
33 //------------------------------------------------------------------------------
34 // CONSTRUCTORS / DESTRUCTOR
35 //------------------------------------------------------------------------------
36 
38  : QWidget( _pqParent )
39 {
41 }
42 
44 {
45  // Retrieve user settings
46  CSettings* __poSettings = QVCTRuntime::useSettings();
47 
48  // Create layout
49  QGridLayout* __pqGridLayout = new QGridLayout();
50 
51  // Add items
52  int __iRow = -1;
53 
54  // ... screen resolution (DPI)
55  __iRow++;
56  __pqGridLayout->addWidget( new QLabel( tr("Screen Resolution")+":" ), __iRow, 0 );
57  QSpinBox* __pqSpinBoxScreenDpi = new QSpinBox();
58  __pqSpinBoxScreenDpi->setToolTip( tr("Manually set the screen resolution for optimal rendering/sizing, in DPI") );
59  __pqSpinBoxScreenDpi->setRange( 1, 1200 );
60  __pqSpinBoxScreenDpi->setValue( __poSettings->getScreenDpi() );
61  __pqGridLayout->addWidget( __pqSpinBoxScreenDpi, __iRow, 1 );
62  connect( __pqSpinBoxScreenDpi, SIGNAL( valueChanged(int) ), __poSettings, SLOT( slotScreenDpi(int) ) );
63 
64  // ... screen gestures
65  __iRow++;
66  __pqGridLayout->addWidget( new QLabel( tr("Screen Gestures")+":" ), __iRow, 0 );
67  QCheckBox* __pqCheckBoxScreenGestures = new QCheckBox();
68  __pqCheckBoxScreenGestures->setCheckState( __poSettings->isScreenGestures() ? Qt::Checked : Qt::Unchecked );
69  __pqCheckBoxScreenGestures->setToolTip( tr("Whether to enable screen gestures, like pinch-to-zoom\nWARNING: this may lead to unresponsive interface on incompatible devices!") );
70  __pqGridLayout->addWidget( __pqCheckBoxScreenGestures, __iRow, 1 );
71  connect( __pqCheckBoxScreenGestures, SIGNAL( stateChanged(int) ), __poSettings, SLOT( slotScreenGestures(int) ) );
72 
73  // ... refresh rate
74  __iRow++;
75  __pqGridLayout->addWidget( new QLabel( tr("Refresh Rate (detail)")+":" ), __iRow, 0 );
76  QSpinBox* __pqSpinBoxRateRefresh = new QSpinBox();
77  __pqSpinBoxRateRefresh->setToolTip( tr("How often to refresh the interface content (chart, overlays, textual data, etc.), in milli-seconds [ms]\nWARNING: the lower this setting, the higher the CPU usage!") );
78  __pqSpinBoxRateRefresh->setRange( 100, 5000 );
79  __pqSpinBoxRateRefresh->setValue( __poSettings->getRateRefresh() );
80  __pqGridLayout->addWidget( __pqSpinBoxRateRefresh, __iRow, 1 );
81  connect( __pqSpinBoxRateRefresh, SIGNAL( valueChanged(int) ), __poSettings, SLOT( slotRateRefresh(int) ) );
82 
83  // ... redraw rate
84  __iRow++;
85  __pqGridLayout->addWidget( new QLabel( tr("Redraw Rate (chart)")+":" ), __iRow, 0 );
86  QSpinBox* __pqSpinBoxRateRedraw = new QSpinBox();
87  __pqSpinBoxRateRedraw->setToolTip( tr("How often to inconditionally redraw the charted content (chart and overlays), in seconds [s]\nWARNING: the lower this setting, the higher the CPU usage!") );
88  __pqSpinBoxRateRedraw->setRange( 1, 300 );
89  __pqSpinBoxRateRedraw->setValue( __poSettings->getRateRedraw() );
90  __pqGridLayout->addWidget( __pqSpinBoxRateRedraw, __iRow, 1 );
91  connect( __pqSpinBoxRateRedraw, SIGNAL( valueChanged(int) ), __poSettings, SLOT( slotRateRedraw(int) ) );
92 
93  // ... chart opacity
94  __iRow++;
95  __pqGridLayout->addWidget( new QLabel( tr("Chart Opacity")+":" ), __iRow, 0 );
96  QSpinBox* __pqSpinBoxChartOpacity = new QSpinBox();
97  __pqSpinBoxChartOpacity->setToolTip( tr("Chart opacity/dimming (to improve overlays contrast), in percent [%]") );
98  __pqSpinBoxChartOpacity->setRange( 0, 100 );
99  __pqSpinBoxChartOpacity->setValue( __poSettings->getChartOpacity() );
100  __pqGridLayout->addWidget( __pqSpinBoxChartOpacity, __iRow, 1 );
101  connect( __pqSpinBoxChartOpacity, SIGNAL( valueChanged(int) ), __poSettings, SLOT( slotChartOpacity(int) ) );
102 
103  // ... symbols path
104  // TODO: Use a QFileDialog for user-friendliness
105  __iRow++;
106  __pqGridLayout->addWidget( new QLabel( tr("Symbols Path")+":" ), __iRow, 0 );
107  QLineEdit* __pqLineEditPathSymbolsDirectory = new QLineEdit();
108  __pqLineEditPathSymbolsDirectory->setToolTip( tr("Directory path to symbols (PNG files) library\nNOTE: Symbol names (used in landmark, waypoint or vessel definition)\nwill be lower-cased and space-stripped before a library match is looked for") );
109  __pqLineEditPathSymbolsDirectory->setText( __poSettings->getPathSymbolsDirectory() );
110  __pqGridLayout->addWidget( __pqLineEditPathSymbolsDirectory, __iRow, 1 );
111  connect( __pqLineEditPathSymbolsDirectory, SIGNAL( textChanged(const QString&) ), __poSettings, SLOT( slotPathSymbolsDirectory(const QString&) ) );
112 
113  // ... symbols visibility
114  __iRow++;
115  __pqGridLayout->addWidget( new QLabel( tr("Symbols Visibility")+":" ), __iRow, 0 );
116  QCheckBox* __pqCheckBoxVisibleSymbols = new QCheckBox();
117  __pqCheckBoxVisibleSymbols->setToolTip( tr("Whether to draw the symbols associated with landmarks, waypoints or vessels") );
118  __pqCheckBoxVisibleSymbols->setCheckState( __poSettings->isVisibleSymbols() ? Qt::Checked : Qt::Unchecked );
119  __pqGridLayout->addWidget( __pqCheckBoxVisibleSymbols, __iRow, 1 );
120  connect( __pqCheckBoxVisibleSymbols, SIGNAL( stateChanged(int) ), __poSettings, SLOT( slotVisibleSymbols(int) ) );
121 
122  // ... printing resolution
123  __iRow++;
124  __pqGridLayout->addWidget( new QLabel( tr("High-Resolution Printing")+":" ), __iRow, 0 );
125  QCheckBox* __pqCheckBoxPrintHighRes = new QCheckBox();
126  __pqCheckBoxPrintHighRes->setToolTip( tr("Whether to print charted content in high-resolution (1200 DPI) or screen resolution (see above Screen Resolution)\nWARNING: high-resolution prints may take very long to reach your printer!") );
127  __pqCheckBoxPrintHighRes->setCheckState( __poSettings->isPrintHighRes() ? Qt::Checked : Qt::Unchecked );
128  __pqGridLayout->addWidget( __pqCheckBoxPrintHighRes, __iRow, 1 );
129  connect( __pqCheckBoxPrintHighRes, SIGNAL( stateChanged(int) ), __poSettings, SLOT( slotPrintHighRes(int) ) );
130 
131  // Set the layout
132  __iRow++;
133  __pqGridLayout->addItem( new QSpacerItem( 0, this->height() ), __iRow, 0, 3 );
134  QWidget::setLayout( __pqGridLayout );
135 }
void constructLayout()
Constructs the layout of the user interface.
CSettingsMiscEditView(QWidget *_pqParent=0)
[UI] Container for the application's settings
Definition: CSettings.hpp:51
int getChartOpacity()
[Misc] Returns the chart opacity [0,100]
Definition: CSettings.hpp:437
bool isPrintHighRes()
[Misc] Returns the high-resolution printing status
Definition: CSettings.hpp:441
int getScreenDpi()
[Misc] Returns the screen Dots-per-Inch (DPI)
Definition: CSettings.hpp:429
bool isVisibleSymbols()
[Misc] Returns the symbols visibility (on chart)
Definition: CSettings.hpp:439
bool isScreenGestures()
[Misc] Returns the screen (multitouch) gestures activation status
Definition: CSettings.hpp:431
QString getPathSymbolsDirectory()
[Path] Returns the symbols directory
Definition: CSettings.hpp:336
int getRateRefresh()
[Misc] Returns the content refresh rate, in milliseconds
Definition: CSettings.hpp:433
int getRateRedraw()
[Misc] Returns the content redraw rate, in seconds
Definition: CSettings.hpp:435
static CSettings * useSettings()