configdialog.cpp 5.91 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
56
57
58
59
60
61
    
    mThumbnailActionsGroup = new InvisibleButtonGroup(widget);
    mThumbnailActionsGroup->setObjectName(QLatin1String("kcfg_ThumbnailActions"));
    mThumbnailActionsGroup->addButton(mGeneralConfigPage.allButtonsThumbnailActionsRadioButton, int(ThumbnailActions::AllButtons));
    mThumbnailActionsGroup->addButton(mGeneralConfigPage.selectionOnlyThumbnailActionsRadioButton, int(ThumbnailActions::ShowSelectionButtonOnly));
    mThumbnailActionsGroup->addButton(mGeneralConfigPage.noneThumbnailActionsRadioButton, int(ThumbnailActions::None));

62
    pageItem = addPage(widget, i18n("General"));
David Edmundson's avatar
David Edmundson committed
63
    pageItem->setIcon(QIcon::fromTheme("gwenview"));
Frederik Gladhorn's avatar
Frederik Gladhorn committed
64
    connect(mGeneralConfigPage.kcfg_ViewBackgroundValue, SIGNAL(valueChanged(int)), SLOT(updateViewBackgroundFrame()));
65
66

    // Image View
Frederik Gladhorn's avatar
Frederik Gladhorn committed
67
68
69
70
    widget = setupPage(mImageViewConfigPage);

    mAlphaBackgroundModeGroup = new InvisibleButtonGroup(widget);
    mAlphaBackgroundModeGroup->setObjectName(QLatin1String("kcfg_AlphaBackgroundMode"));
71
72
    mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.checkBoardRadioButton, int(AbstractImageView::AlphaBackgroundCheckBoard));
    mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.solidColorRadioButton, int(AbstractImageView::AlphaBackgroundSolid));
Frederik Gladhorn's avatar
Frederik Gladhorn committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94

    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));
95
96

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

    // Advanced
Frederik Gladhorn's avatar
Frederik Gladhorn committed
100
    widget = setupPage(mAdvancedConfigPage);
101
102
103
104
105
106

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

107
    pageItem = addPage(widget, i18n("Advanced"));
David Edmundson's avatar
David Edmundson committed
108
    pageItem->setIcon(QIcon::fromTheme("preferences-other"));
Frederik Gladhorn's avatar
Frederik Gladhorn committed
109
    mAdvancedConfigPage.cacheHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
110
111
    mAdvancedConfigPage.perceptualHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
    mAdvancedConfigPage.relativeHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
112
113

    updateViewBackgroundFrame();
114
115
}

116
117
void ConfigDialog::updateViewBackgroundFrame()
{
Frederik Gladhorn's avatar
Frederik Gladhorn committed
118
    QColor color = QColor::fromHsv(0, 0, mGeneralConfigPage.kcfg_ViewBackgroundValue->value());
119
120
121
122
123
124
125
126
127
    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
128
    mGeneralConfigPage.backgroundValueFrame->setStyleSheet(css);
129
130
}

131
} // namespace