aboutsummaryrefslogtreecommitdiffstats
path: root/settingsdialog.cpp
blob: 7b89a659c955e384d52d54c8ce502a0ac9a63773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
 *      settingsdialog.cpp
 *
 *      Copyright 2008 gpg4usb-team <[email protected]>
 *
 *      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., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#include <QWidget>

#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QGridLayout>
#include <QGroupBox>
#include <QDialogButtonBox>
#include <QRadioButton>
#include <QButtonGroup>
#include <QSettings>
#include "settingsdialog.h"

SettingsDialog::SettingsDialog()
{
    setWindowTitle(tr("Settings"));
    resize(500, 200);
    setModal(true);

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(applySettings()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    groupBox1 = new QGroupBox(tr("Options"));
    groupBox2 = new QGroupBox(tr("Action"));


	group1 = new QButtonGroup();	
	QRadioButton *iconSizeSmall = new QRadioButton(tr("small"));
	QRadioButton *iconSizeMedium =new QRadioButton(tr("medium"));
	QRadioButton *iconSizeLarge = new QRadioButton(tr("large"));
	group1->addButton(iconSizeSmall,1);
	group1->addButton(iconSizeMedium,2);
	group1->addButton(iconSizeLarge,3);

	group2 = new QButtonGroup();
	QRadioButton *iconTextButton = new QRadioButton(tr("just text"));
	QRadioButton *iconIconsButton =new QRadioButton(tr("just icons"));
	QRadioButton *iconAllButton = new QRadioButton(tr("text and icons"));
	group2->addButton(iconTextButton,1);
	group2->addButton(iconIconsButton,2);
	group2->addButton(iconAllButton,3);

	QHBoxLayout *iconSizeBox = new QHBoxLayout();
	iconSizeBox->addWidget(iconSizeSmall);
	iconSizeBox->addWidget(iconSizeMedium);
	iconSizeBox->addWidget(iconSizeLarge);

	QHBoxLayout *iconStyleBox = new QHBoxLayout();
	iconStyleBox->addWidget(iconTextButton);
	iconStyleBox->addWidget(iconIconsButton);
	iconStyleBox->addWidget(iconAllButton);

	groupBox2->setLayout(iconStyleBox);
	groupBox1->setLayout(iconSizeBox);
	
    QVBoxLayout *vbox = new QVBoxLayout();
    vbox->addWidget(groupBox1);
	vbox->addWidget(groupBox2);
	vbox->addWidget(buttonBox);
    setLayout(vbox);
    exec();
}

void SettingsDialog::applySettings()
{
	 QSettings settings;
     //settings.setValue("geometry", saveGeometry());

	switch (group1->checkedId()){
	case 1: settings.setValue("toolbar/iconsize", QSize(12, 12));
		break;
    case 2:settings.setValue("toolbar/iconsize", QSize(24, 24));
		break;
    case 3:settings.setValue("toolbar/iconsize", QSize(32, 32));
		break;
	}

	switch (group2->checkedId()){
	case 1: settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextOnly);
		break;
    case 2:settings.setValue("toolbar/iconstyle", Qt::ToolButtonIconOnly);
		break;
    case 3:settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon);
		break;
	}
	accept();
}