File indexing completed on 2024-04-28 15:51:55

0001 /*
0002     SPDX-FileCopyrightText: 2004 Enrico Ros <eros.kde@email.it>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 // reimplementing this
0008 #include "preferencesdialog.h"
0009 
0010 #include <KLocalizedString>
0011 
0012 // single config pages
0013 #include "dlgaccessibility.h"
0014 #include "dlgannotations.h"
0015 #include "dlgdebug.h"
0016 #include "dlgeditor.h"
0017 #include "dlggeneral.h"
0018 #include "dlgperformance.h"
0019 #include "dlgpresentation.h"
0020 
0021 #include <QLabel>
0022 
0023 PreferencesDialog::PreferencesDialog(QWidget *parent, KConfigSkeleton *skeleton, Okular::EmbedMode embedMode, const QString &editCmd)
0024     : KConfigDialog(parent, QStringLiteral("preferences"), skeleton)
0025 {
0026     setWindowModality(Qt::ApplicationModal);
0027 
0028     m_general = new DlgGeneral(this, embedMode);
0029     m_performance = new DlgPerformance(this);
0030     m_accessibility = new DlgAccessibility(this);
0031     m_accessibilityPage = nullptr;
0032     m_presentation = nullptr;
0033     m_annotations = nullptr;
0034     m_annotationsPage = nullptr;
0035     m_editor = nullptr;
0036     m_signatures = nullptr;
0037 #ifdef OKULAR_DEBUG_CONFIGPAGE
0038     m_debug = new DlgDebug(this);
0039 #endif
0040 
0041     addPage(m_general, i18n("General"), QStringLiteral("okular"), i18n("General Options"));
0042     m_accessibilityPage = addPage(m_accessibility, i18n("Accessibility"), QStringLiteral("preferences-desktop-accessibility"), i18n("Accessibility Reading Aids"));
0043     addPage(m_performance, i18n("Performance"), QStringLiteral("preferences-system-performance"), i18n("Performance Tuning"));
0044     if (embedMode == Okular::ViewerWidgetMode) {
0045         setWindowTitle(i18n("Configure Viewer"));
0046     } else {
0047         m_presentation = new DlgPresentation(this);
0048         m_annotations = new DlgAnnotations(this);
0049         addPage(m_presentation, i18n("Presentation"), QStringLiteral("view-presentation"), i18n("Options for Presentation Mode"));
0050         m_annotationsPage = addPage(m_annotations, i18n("Annotations"), QStringLiteral("draw-freehand"), i18n("Annotation Options"));
0051         if (editCmd.isEmpty()) {
0052             m_editor = new DlgEditor(this);
0053             addPage(m_editor, i18n("Editor"), QStringLiteral("accessories-text-editor"), i18n("Editor Options"));
0054         } else {
0055             QString editStr = i18nc("Give the user a hint, that it enabled the option --editor-cmd together with the current value of the option.",
0056                                     "The editor was set by the command line to \n %1 \nIf you want to use the setting, start okular without the option --editor-cmd",
0057                                     editCmd);
0058             auto editor = new QLabel(editStr, this);
0059             addPage(editor, i18n("Editor"), QStringLiteral("accessories-text-editor"), i18n("Editor Options"));
0060         }
0061     }
0062 #ifdef OKULAR_DEBUG_CONFIGPAGE
0063     addPage(m_debug, "Debug", "system-run", "Debug options");
0064 #endif
0065     setHelp(QStringLiteral("configure"), QStringLiteral("okular"));
0066 }
0067 
0068 void PreferencesDialog::switchToAccessibilityPage()
0069 {
0070     if (m_accessibilityPage) {
0071         setCurrentPage(m_accessibilityPage);
0072     }
0073 }
0074 
0075 void PreferencesDialog::switchToAnnotationsPage()
0076 {
0077     if (m_annotationsPage) {
0078         setCurrentPage(m_annotationsPage);
0079     }
0080 }