File indexing completed on 2024-05-05 04:19:14
0001 // vim: set tabstop=4 shiftwidth=4 expandtab: 0002 /* 0003 Gwenview: an image viewer 0004 Copyright 2007 Aurélien Gâteau <agateau@kde.org> 0005 0006 This program is free software; you can redistribute it and/or 0007 modify it under the terms of the GNU General Public License 0008 as published by the Free Software Foundation; either version 2 0009 of the License, or (at your option) any later version. 0010 0011 This program is distributed in the hope that it will be useful, 0012 but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 GNU General Public License for more details. 0015 0016 You should have received a copy of the GNU General Public License 0017 along with this program; if not, write to the Free Software 0018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 0019 0020 */ 0021 // Self 0022 #include "configdialog.h" 0023 0024 // Qt 0025 #include <QFontDatabase> 0026 0027 // KF 0028 #include <KLocalizedString> 0029 0030 // Local 0031 #include <lib/gwenviewconfig.h> 0032 #include <lib/invisiblebuttongroup.h> 0033 0034 namespace Gwenview 0035 { 0036 template<class Ui> 0037 QWidget *setupPage(Ui &ui) 0038 { 0039 auto widget = new QWidget; 0040 ui.setupUi(widget); 0041 return widget; 0042 } 0043 0044 ConfigDialog::ConfigDialog(QWidget *parent) 0045 : KConfigDialog(parent, QStringLiteral("Settings"), GwenviewConfig::self()) 0046 { 0047 setFaceType(KPageDialog::List); 0048 0049 // General 0050 QWidget *widget = setupPage(mGeneralConfigPage); 0051 0052 mWrapNavigationBehaviorGroup = new InvisibleButtonGroup(widget); 0053 mWrapNavigationBehaviorGroup->setObjectName(QStringLiteral("kcfg_NavigationEndNotification")); 0054 mWrapNavigationBehaviorGroup->addButton(mGeneralConfigPage.neverShowWrapNoticeRadioButton, int(SlideShow::NavigationEndNotification::NeverWarn)); 0055 mWrapNavigationBehaviorGroup->addButton(mGeneralConfigPage.wrapNoticeOnSlideshowRadioButton, int(SlideShow::NavigationEndNotification::WarnOnSlideshow)); 0056 mWrapNavigationBehaviorGroup->addButton(mGeneralConfigPage.alwaysShowWrapNoticeRadioButton, int(SlideShow::NavigationEndNotification::AlwaysWarn)); 0057 0058 mFullScreenBackgroundGroup = new InvisibleButtonGroup(widget); 0059 mFullScreenBackgroundGroup->setObjectName(QStringLiteral("kcfg_FullScreenBackground")); 0060 mFullScreenBackgroundGroup->addButton(mGeneralConfigPage.fullscreenBackgroundBlackRadioButton, int(FullScreenBackground::Black)); 0061 mFullScreenBackgroundGroup->addButton(mGeneralConfigPage.fullscreenBackgroundImageRadioButton, int(FullScreenBackground::Image)); 0062 0063 mThumbnailActionsGroup = new InvisibleButtonGroup(widget); 0064 mThumbnailActionsGroup->setObjectName(QStringLiteral("kcfg_ThumbnailActions")); 0065 mThumbnailActionsGroup->addButton(mGeneralConfigPage.allButtonsThumbnailActionsRadioButton, int(ThumbnailActions::AllButtons)); 0066 mThumbnailActionsGroup->addButton(mGeneralConfigPage.selectionOnlyThumbnailActionsRadioButton, int(ThumbnailActions::ShowSelectionButtonOnly)); 0067 mThumbnailActionsGroup->addButton(mGeneralConfigPage.noneThumbnailActionsRadioButton, int(ThumbnailActions::None)); 0068 0069 mGeneralConfigPageItem = addPage(widget, i18n("General")); 0070 mGeneralConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("gwenview"))); 0071 connect(mGeneralConfigPage.kcfg_JPEGQuality, &QAbstractSlider::valueChanged, this, [=](int value) { 0072 mGeneralConfigPage.jpegQualitySpinner->setValue(value); 0073 }); 0074 connect(mGeneralConfigPage.jpegQualitySpinner, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](int value) { 0075 mGeneralConfigPage.kcfg_JPEGQuality->setValue(value); 0076 }); 0077 mGeneralConfigPage.jpegQualitySpinner->setValue(mGeneralConfigPage.kcfg_JPEGQuality->value()); 0078 mGeneralConfigPage.lossyImageFormatHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); 0079 0080 mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(mGeneralConfigPage.kcfg_ListVideos->isChecked()); 0081 connect(mGeneralConfigPage.kcfg_ListVideos, &QCheckBox::stateChanged, this, [=](int state) { 0082 mGeneralConfigPage.kcfg_AutoplayVideos->setEnabled(state == Qt::Checked); 0083 }); 0084 0085 // Image View 0086 widget = setupPage(mImageViewConfigPage); 0087 0088 mAlphaBackgroundModeGroup = new InvisibleButtonGroup(widget); 0089 mAlphaBackgroundModeGroup->setObjectName(QStringLiteral("kcfg_AlphaBackgroundMode")); 0090 mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.surroundingRadioButton, int(AbstractImageView::AlphaBackgroundNone)); 0091 mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.checkBoardRadioButton, int(AbstractImageView::AlphaBackgroundCheckBoard)); 0092 mAlphaBackgroundModeGroup->addButton(mImageViewConfigPage.solidColorRadioButton, int(AbstractImageView::AlphaBackgroundSolid)); 0093 0094 mWheelBehaviorGroup = new InvisibleButtonGroup(widget); 0095 mWheelBehaviorGroup->setObjectName(QStringLiteral("kcfg_MouseWheelBehavior")); 0096 mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelScrollRadioButton, int(MouseWheelBehavior::Scroll)); 0097 mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelBrowseRadioButton, int(MouseWheelBehavior::Browse)); 0098 mWheelBehaviorGroup->addButton(mImageViewConfigPage.mouseWheelZoomRadioButton, int(MouseWheelBehavior::Zoom)); 0099 0100 mAnimationMethodGroup = new InvisibleButtonGroup(widget); 0101 mAnimationMethodGroup->setObjectName(QStringLiteral("kcfg_AnimationMethod")); 0102 #ifdef QT_NO_OPENGL 0103 mImageViewConfigPage.glAnimationRadioButton->setEnabled(false); 0104 mAnimationMethodGroup->addButton(mImageViewConfigPage.glAnimationRadioButton, int(DocumentView::NoAnimation)); 0105 #else 0106 mAnimationMethodGroup->addButton(mImageViewConfigPage.glAnimationRadioButton, int(DocumentView::GLAnimation)); 0107 #endif 0108 mAnimationMethodGroup->addButton(mImageViewConfigPage.softwareAnimationRadioButton, int(DocumentView::SoftwareAnimation)); 0109 mAnimationMethodGroup->addButton(mImageViewConfigPage.noAnimationRadioButton, int(DocumentView::NoAnimation)); 0110 0111 mZoomModeGroup = new InvisibleButtonGroup(widget); 0112 mZoomModeGroup->setObjectName(QStringLiteral("kcfg_ZoomMode")); 0113 mZoomModeGroup->addButton(mImageViewConfigPage.autofitZoomModeRadioButton, int(ZoomMode::Autofit)); 0114 mZoomModeGroup->addButton(mImageViewConfigPage.keepSameZoomModeRadioButton, int(ZoomMode::KeepSame)); 0115 mZoomModeGroup->addButton(mImageViewConfigPage.individualZoomModeRadioButton, int(ZoomMode::Individual)); 0116 0117 mThumbnailBarOrientationGroup = new InvisibleButtonGroup(widget); 0118 mThumbnailBarOrientationGroup->setObjectName(QStringLiteral("kcfg_ThumbnailBarOrientation")); 0119 mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.horizontalRadioButton, int(Qt::Horizontal)); 0120 mThumbnailBarOrientationGroup->addButton(mImageViewConfigPage.verticalRadioButton, int(Qt::Vertical)); 0121 0122 mImageViewConfigPageItem = addPage(widget, i18n("Image View")); 0123 mImageViewConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-desktop-display-color"))); 0124 0125 // Advanced 0126 widget = setupPage(mAdvancedConfigPage); 0127 0128 mRenderingIntentGroup = new InvisibleButtonGroup(widget); 0129 mRenderingIntentGroup->setObjectName(QStringLiteral("kcfg_RenderingIntent")); 0130 mRenderingIntentGroup->addButton(mAdvancedConfigPage.relativeRenderingIntentRadioButton, int(RenderingIntent::Relative)); 0131 mRenderingIntentGroup->addButton(mAdvancedConfigPage.perceptualRenderingIntentRadioButton, int(RenderingIntent::Perceptual)); 0132 0133 mAdvancedConfigPageItem = addPage(widget, i18n("Advanced")); 0134 mAdvancedConfigPageItem->setIcon(QIcon::fromTheme(QStringLiteral("preferences-other"))); 0135 mAdvancedConfigPage.cacheHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); 0136 mAdvancedConfigPage.perceptualHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); 0137 mAdvancedConfigPage.relativeHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); 0138 mAdvancedConfigPage.colorProfileHelpLabel->setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont)); 0139 } 0140 0141 void ConfigDialog::setCurrentPage(int page) 0142 { 0143 switch (page) { 0144 case 1: 0145 return KPageDialog::setCurrentPage(mImageViewConfigPageItem); 0146 case 2: 0147 return KPageDialog::setCurrentPage(mAdvancedConfigPageItem); 0148 default: 0149 return KPageDialog::setCurrentPage(mGeneralConfigPageItem); 0150 } 0151 } 0152 0153 } // namespace 0154 0155 #include "moc_configdialog.cpp"