File indexing completed on 2025-01-05 03:58:23
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-28-04 0007 * Description : first run assistant dialog 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "openfilepage.h" 0016 0017 // Qt includes 0018 0019 #include <QLabel> 0020 #include <QRadioButton> 0021 #include <QButtonGroup> 0022 #include <QVBoxLayout> 0023 #include <QApplication> 0024 #include <QStyle> 0025 0026 // KDE includes 0027 0028 #include <kconfiggroup.h> 0029 #include <klocalizedstring.h> 0030 #include <ksharedconfig.h> 0031 0032 // Local includes 0033 0034 #include "dlayoutbox.h" 0035 #include "applicationsettings.h" 0036 0037 namespace Digikam 0038 { 0039 0040 class Q_DECL_HIDDEN OpenFilePage::Private 0041 { 0042 public: 0043 0044 explicit Private() 0045 : openAsPreview(nullptr), 0046 openInEditor(nullptr), 0047 openFileBehavior(nullptr) 0048 { 0049 } 0050 0051 QRadioButton* openAsPreview; 0052 QRadioButton* openInEditor; 0053 QButtonGroup* openFileBehavior; 0054 }; 0055 0056 OpenFilePage::OpenFilePage(QWizard* const dlg) 0057 : DWizardPage(dlg, i18n("<b>Configure Open File Behavior</b>")), 0058 d(new Private) 0059 { 0060 const int spacing = qMin(QApplication::style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing), 0061 QApplication::style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing)); 0062 0063 DVBox* const vbox = new DVBox(this); 0064 QLabel* const label1 = new QLabel(vbox); 0065 label1->setWordWrap(true); 0066 label1->setText(i18n("<qt>" 0067 "<p>Specify how images should be opened when left-clicked on in the icon view:</p>" 0068 "</qt>")); 0069 0070 QWidget* const btns = new QWidget(vbox); 0071 QVBoxLayout* const vlay = new QVBoxLayout(btns); 0072 0073 d->openFileBehavior = new QButtonGroup(btns); 0074 d->openAsPreview = new QRadioButton(btns); 0075 d->openAsPreview->setText(i18n("Open a preview")); 0076 d->openAsPreview->setChecked(true); 0077 d->openFileBehavior->addButton(d->openAsPreview); 0078 0079 d->openInEditor = new QRadioButton(btns); 0080 d->openInEditor->setText(i18n("Open in the editor")); 0081 d->openFileBehavior->addButton(d->openInEditor); 0082 0083 vlay->addWidget(d->openAsPreview); 0084 vlay->addWidget(d->openInEditor); 0085 vlay->setContentsMargins(spacing, spacing, spacing, spacing); 0086 vlay->setSpacing(spacing); 0087 0088 QLabel* const label2 = new QLabel(vbox); 0089 label2->setWordWrap(true); 0090 label2->setText(i18n("<qt>" 0091 "<p><i>Note:</i> using a preview is always faster than using the editor, " 0092 "especially when checking a series of shots. However, you cannot change or fix the image " 0093 "in preview mode. " 0094 "Note that if you want to compare images quickly, it is often better to use the light table: " 0095 "images can be displayed side-by-side, and synchronized zooming and panning can be performed.</p>" 0096 "</qt>")); 0097 0098 setPageWidget(vbox); 0099 setLeftBottomPix(QIcon::fromTheme(QLatin1String("folder-pictures"))); //image-stack 0100 } 0101 0102 OpenFilePage::~OpenFilePage() 0103 { 0104 delete d; 0105 } 0106 0107 void OpenFilePage::saveSettings() 0108 { 0109 KSharedConfig::Ptr config = KSharedConfig::openConfig(); 0110 KConfigGroup group = config->group(QLatin1String("Album Settings")); 0111 group.writeEntry(QLatin1String("Item Left Click Action"), (int)(d->openInEditor->isChecked() ? 0112 ApplicationSettings::StartEditor : ApplicationSettings::ShowPreview)); 0113 0114 config->sync(); 0115 } 0116 0117 } // namespace Digikam 0118 0119 #include "moc_openfilepage.cpp"