configdialog.cpp 5.36 KB
Newer Older
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
3
/*
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
David Edmundson's avatar
David Edmundson committed
27
#include <KLocalizedString>
28
29

// Local
30
#include <lib/gwenviewconfig.h>
Laurent Montel's avatar
Laurent Montel committed
31
#include <QFontDatabase>
32

33
34
namespace Gwenview
{
35

36
template <class Ui>
37
38
39
40
41
42
QWidget* setupPage(Ui& ui)
{
    QWidget* widget = new QWidget;
    ui.setupUi(widget);
    widget->layout()->setMargin(0);
    return widget;
43
}
44
45

ConfigDialog::ConfigDialog(QWidget* parent)
Aurélien Gâteau's avatar
Aurélien Gâteau committed
46
: KConfigDialog(parent, "Settings", GwenviewConfig::self())
47
48
{
    setFaceType(KPageDialog::List);
49

50
51
52
53
    QWidget* widget;
    KPageWidgetItem* pageItem;

    // General
Frederik Gladhorn's avatar
Frederik Gladhorn committed
54
    widget = setupPage(mGeneralConfigPage);
55
    pageItem = addPage(widget, i18n("General"));
David Edmundson's avatar
David Edmundson committed
56
    pageItem->setIcon(QIcon::fromTheme("gwenview"));
Frederik Gladhorn's avatar
Frederik Gladhorn committed
57
    connect(mGeneralConfigPage.kcfg_ViewBackgroundValue, SIGNAL(valueChanged(int)), SLOT(updateViewBackgroundFrame()));
58
59

    // Image View
Frederik Gladhorn's avatar
Frederik Gladhorn committed
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
    widget = setupPage(mImageViewConfigPage);

    mAlphaBackgroundModeGroup = new InvisibleButtonGroup(widget);
    mAlphaBackgroundModeGroup->setObjectName(QLatin1String("kcfg_AlphaBackgroundMode"));
    mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.checkBoardRadioButton, int(RasterImageView::AlphaBackgroundCheckBoard));
    mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.solidColorRadioButton, int(RasterImageView::AlphaBackgroundSolid));

    mWheelBehaviorGroup = new InvisibleButtonGroup(widget);
    mWheelBehaviorGroup->setObjectName(QLatin1String("kcfg_MouseWheelBehavior"));
    mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelScrollRadioButton, int(MouseWheelBehavior::Scroll));
    mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelBrowseRadioButton, int(MouseWheelBehavior::Browse));

    mAnimationMethodGroup = new InvisibleButtonGroup(widget);
    mAnimationMethodGroup->setObjectName(QLatin1String("kcfg_AnimationMethod"));
    mAnimationMethodGroup->addButton(mImageViewConfigPage.glAnimationRadioButton, int(DocumentView::GLAnimation));
    mAnimationMethodGroup->addButton(mImageViewConfigPage.softwareAnimationRadioButton, int(DocumentView::SoftwareAnimation));
    mAnimationMethodGroup->addButton(mImageViewConfigPage.noAnimationRadioButton, int(DocumentView::NoAnimation));

    mZoomModeGroup = new InvisibleButtonGroup(widget);
    mZoomModeGroup->setObjectName(QLatin1String("kcfg_ZoomMode"));
    mZoomModeGroup->addButton(mImageViewConfigPage.autofitZoomModeRadioButton, int(ZoomMode::Autofit));
    mZoomModeGroup->addButton(mImageViewConfigPage.keepSameZoomModeRadioButton, int(ZoomMode::KeepSame));
    mZoomModeGroup->addButton(mImageViewConfigPage.individualZoomModeRadioButton, int(ZoomMode::Individual));

    mThumbnailBarOrientationGroup = new InvisibleButtonGroup(widget);
    mThumbnailBarOrientationGroup->setObjectName(QLatin1String("kcfg_ThumbnailBarOrientation"));
    mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.horizontalRadioButton, int(Qt::Horizontal));
    mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.verticalRadioButton, int(Qt::Vertical));
88
89

    pageItem = addPage(widget, i18n("Image View"));
David Edmundson's avatar
David Edmundson committed
90
    pageItem->setIcon(QIcon::fromTheme("view-preview"));
91
92

    // Advanced
Frederik Gladhorn's avatar
Frederik Gladhorn committed
93
    widget = setupPage(mAdvancedConfigPage);
94
95
96
97
98
99

    mRenderingIntentGroup = new InvisibleButtonGroup(widget);
    mRenderingIntentGroup->setObjectName(QLatin1String("kcfg_RenderingIntent"));
    mRenderingIntentGroup->addButton(mAdvancedConfigPage.relativeRenderingIntentRadioButton, int(RenderingIntent::Relative));
    mRenderingIntentGroup->addButton(mAdvancedConfigPage.perceptualRenderingIntentRadioButton, int(RenderingIntent::Perceptual));

100
    pageItem = addPage(widget, i18n("Advanced"));
David Edmundson's avatar
David Edmundson committed
101
    pageItem->setIcon(QIcon::fromTheme("preferences-other"));
Frederik Gladhorn's avatar
Frederik Gladhorn committed
102
    mAdvancedConfigPage.cacheHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
103
104
    mAdvancedConfigPage.perceptualHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
    mAdvancedConfigPage.relativeHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
105
106

    updateViewBackgroundFrame();
107
108
}

109
110
void ConfigDialog::updateViewBackgroundFrame()
{
Frederik Gladhorn's avatar
Frederik Gladhorn committed
111
    QColor color = QColor::fromHsv(0, 0, mGeneralConfigPage.kcfg_ViewBackgroundValue->value());
112
113
114
115
116
117
118
119
120
    QString css =
        QString(
            "background-color: %1;"
            "border-radius: 5px;"
            "border: 1px solid %1;")
        .arg(color.name());
    // When using Oxygen, setting the background color via palette causes the
    // pixels outside the frame to be painted with the new background color as
    // well. Using CSS works more like expected.
Frederik Gladhorn's avatar
Frederik Gladhorn committed
121
    mGeneralConfigPage.backgroundValueFrame->setStyleSheet(css);
122
123
}

124
} // namespace