configdialog.cpp 3.64 KB
Newer Older
1
2
3
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
/*
Gwenview: an image viewer
Aurélien Gâteau's avatar
Aurélien Gâteau committed
4
Copyright 2007 Aurélien Gâteau <agateau@kde.org>
5
6
7
8
9
10
11
12
13
14
15
16
17

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
Dirk Mueller's avatar
Dirk Mueller committed
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
21
22
23
24
25
26

*/
// Self
#include "configdialog.h"

// Qt

// KDE
27
#include <kglobalsettings.h>
28
29

// Local
30
31
#include "ui_generalconfigpage.h"
#include "ui_imageviewconfigpage.h"
Aurélien Gâteau's avatar
Aurélien Gâteau committed
32
#include "ui_advancedconfigpage.h"
33
#include <lib/gwenviewconfig.h>
34
#include <lib/invisiblebuttongroup.h>
35
#include <lib/scrolltool.h>
36
37
38
39

namespace Gwenview {


40
struct ConfigDialogPrivate {
41
	InvisibleButtonGroup* mAlphaBackgroundModeGroup;
42
	InvisibleButtonGroup* mWheelBehaviorGroup;
43
	InvisibleButtonGroup* mThumbnailBarOrientationGroup;
44
45
	Ui_GeneralConfigPage mGeneralConfigPage;
	Ui_ImageViewConfigPage mImageViewConfigPage;
Aurélien Gâteau's avatar
Aurélien Gâteau committed
46
	Ui_AdvancedConfigPage mAdvancedConfigPage;
47
48
};

49
50
51
52
53
54
55
template <class Ui>
QWidget* setupPage(Ui& ui) {
	QWidget* widget = new QWidget;
	ui.setupUi(widget);
	widget->layout()->setMargin(0);
	return widget;
}
56
57

ConfigDialog::ConfigDialog(QWidget* parent)
Aurélien Gâteau's avatar
Aurélien Gâteau committed
58
: KConfigDialog(parent, "Settings", GwenviewConfig::self())
59
, d(new ConfigDialogPrivate) {
60
	setFaceType(KPageDialog::List);
61
62
	setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Apply | KDialog::Default);
	showButtonSeparator(true);
63
64
65
66
67
68
69
70
71
72
73

	QWidget* widget;
	KPageWidgetItem* pageItem;

	// General
	widget = setupPage(d->mGeneralConfigPage);
	pageItem = addPage(widget, i18n("General"));
	pageItem->setIcon(KIcon("gwenview"));

	// Image View
	widget = setupPage(d->mImageViewConfigPage);
74
75

	d->mAlphaBackgroundModeGroup = new InvisibleButtonGroup(widget);
Laurent Montel's avatar
Laurent Montel committed
76
	d->mAlphaBackgroundModeGroup->setObjectName( QLatin1String("kcfg_AlphaBackgroundMode" ));
77
78
	d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.checkBoardRadioButton, int(ImageView::AlphaBackgroundCheckBoard));
	d->mAlphaBackgroundModeGroup->addButton(d->mImageViewConfigPage.solidColorRadioButton, int(ImageView::AlphaBackgroundSolid));
79

80
	d->mWheelBehaviorGroup = new InvisibleButtonGroup(widget);
Laurent Montel's avatar
Laurent Montel committed
81
	d->mWheelBehaviorGroup->setObjectName( QLatin1String("kcfg_MouseWheelBehavior" ));
82
83
	d->mWheelBehaviorGroup->addButton(d->mImageViewConfigPage.mouseWheelScrollRadioButton, int(ScrollTool::MouseWheelScroll));
	d->mWheelBehaviorGroup->addButton(d->mImageViewConfigPage.mouseWheelBrowseRadioButton, int(ScrollTool::MouseWheelBrowse));
84
85

	d->mThumbnailBarOrientationGroup = new InvisibleButtonGroup(widget);
Laurent Montel's avatar
Laurent Montel committed
86
	d->mThumbnailBarOrientationGroup->setObjectName( QLatin1String("kcfg_ThumbnailBarOrientation" ));
87
88
89
	d->mThumbnailBarOrientationGroup->addButton(d->mImageViewConfigPage.horizontalRadioButton, int(Qt::Horizontal));
	d->mThumbnailBarOrientationGroup->addButton(d->mImageViewConfigPage.verticalRadioButton, int(Qt::Vertical));

90
91
	pageItem = addPage(widget, i18n("Image View"));
	pageItem->setIcon(KIcon("view-preview"));
92

Aurélien Gâteau's avatar
Aurélien Gâteau committed
93
94
95
96
97
	// Advanced
	widget = setupPage(d->mAdvancedConfigPage);
	pageItem = addPage(widget, i18n("Advanced"));
	pageItem->setIcon(KIcon("preferences-other"));
	d->mAdvancedConfigPage.cacheHelpLabel->setFont(KGlobalSettings::smallestReadableFont());
98
99
100
101
102
103
104
105
106
}


ConfigDialog::~ConfigDialog() {
	delete d;
}


} // namespace