1 /*
2 **********************************************************************************
3 **
4 ** This file was created for the LibreCAD project (librecad.org), a 2D CAD program.
5 **
6 ** Copyright (C) 2016 ravas (github.com/r-a-v-a-s)
7 **
8 ** This program is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License
10 ** as published by the Free Software Foundation; either version 2
11 ** of the License, or (at your option) any later version.
12 **
13 ** This program is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with this program; if not, write to the Free Software
20 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 **
22 **********************************************************************************
23 */
24
25 #include "lc_deviceoptions.h"
26 #include "ui_lc_deviceoptions.h"
27
28 #include <QSettings>
29
LC_DeviceOptions(QWidget * parent)30 LC_DeviceOptions::LC_DeviceOptions(QWidget* parent) :
31 QFrame(parent),
32 ui(new Ui::LC_DeviceOptions)
33 {
34 ui->setupUi(this);
35
36 QSettings settings;
37 const QString device = settings.value("Hardware/Device", "Mouse").toString();
38 int index = ui->device_combobox->findText(device);
39 ui->device_combobox->setCurrentIndex(index);
40
41 connect(ui->save_button, SIGNAL(pressed()), this, SLOT(save()));
42 connect(ui->save_button, SIGNAL(released()), parent, SLOT(close()));
43 }
44
~LC_DeviceOptions()45 LC_DeviceOptions::~LC_DeviceOptions()
46 {
47 delete ui;
48 }
49
50
save()51 void LC_DeviceOptions::save()
52 {
53 int index = ui->device_combobox->currentIndex();
54 QString device = ui->device_combobox->itemText(index);
55
56 QSettings settings;
57 settings.setValue("Hardware/Device", device);
58 }
59