File indexing completed on 2024-04-28 05:08:16

0001 /****************************************************************************
0002     Copyright (C) 2001-2009 Robby Stephenson <robby@periapsis.org>
0003  ***************************************************************************/
0004 
0005 /***************************************************************************
0006  *                                                                         *
0007  *   This program is free software; you can redistribute it and/or         *
0008  *   modify it under the terms of the GNU General Public License as        *
0009  *   published by the Free Software Foundation; either version 2 of        *
0010  *   the License or (at your option) version 3 or any later version        *
0011  *   accepted by the membership of KDE e.V. (or its successor approved     *
0012  *   by the membership of KDE e.V.), which shall act as a proxy            *
0013  *   defined in Section 14 of version 3 of the license.                    *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful,       *
0016  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0018  *   GNU General Public License for more details.                          *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
0022  *                                                                         *
0023  ***************************************************************************/
0024 
0025 #ifndef TELLICO_CONFIGDIALOG_H
0026 #define TELLICO_CONFIGDIALOG_H
0027 
0028 #include <config.h>
0029 
0030 #include "fetch/fetcherinfolistitem.h"
0031 
0032 #include <KPageDialog>
0033 #ifdef ENABLE_KNEWSTUFF3
0034 #include <knewstuff_version.h>
0035 #if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5, 91, 0)
0036 #include <KNS3/Button>
0037 #else
0038 #include <KNSWidgets/Button>
0039 #endif
0040 #endif
0041 
0042 #include <QListWidget>
0043 
0044 class KConfig;
0045 class KIntNumInput;
0046 class KColorCombo;
0047 
0048 class QSpinBox;
0049 class QPushButton;
0050 class QLineEdit;
0051 class QFontComboBox;
0052 class QCheckBox;
0053 class QRadioButton;
0054 class QFrame;
0055 
0056 namespace Tellico {
0057   namespace Fetch {
0058     class ConfigWidget;
0059   }
0060   namespace GUI {
0061     class ComboBox;
0062     class CollectionTypeCombo;
0063   }
0064 
0065 /**
0066  * The configuration dialog class allows the user to change the global application
0067  * preferences.
0068  *
0069  * @author Robby Stephenson
0070  */
0071 class ConfigDialog : public KPageDialog {
0072 Q_OBJECT
0073 
0074 public:
0075   /**
0076    * The constructor sets up the Tabbed dialog pages.
0077    *
0078    * @param parent A pointer to the parent widget
0079    */
0080   ConfigDialog(QWidget* parent);
0081   virtual ~ConfigDialog();
0082 
0083   /**
0084    * Saves the configuration
0085    */
0086   void saveConfiguration();
0087 
0088 Q_SIGNALS:
0089   /**
0090    * Emitted whenever the Ok or Apply button is clicked.
0091    */
0092   void signalConfigChanged();
0093 
0094 private Q_SLOTS:
0095   /**
0096    * Called when anything gets changed
0097    */
0098   void slotModified();
0099   /**
0100    * Called when the Ok button is clicked.
0101    */
0102   virtual void accept() Q_DECL_OVERRIDE;
0103   /**
0104    * Called when the Apply button is clicked.
0105    */
0106   void slotApply();
0107   /**
0108    * Called when the Default button is clicked.
0109    */
0110   void slotDefault();
0111   void slotHelp();
0112   void slotInitPage(KPageWidgetItem* item);
0113   /**
0114    * Create a new Internet source
0115    */
0116   void slotNewSourceClicked();
0117   /**
0118    * Modify a Internet source
0119    */
0120   void slotModifySourceClicked();
0121   /**
0122    * Remove a Internet source
0123    */
0124   void slotRemoveSourceClicked();
0125   void slotSelectedSourceChanged(QListWidgetItem* item);
0126   void slotMoveUpSourceClicked();
0127   void slotMoveDownSourceClicked();
0128   void slotSourceFilterChanged();
0129   void slotShowTemplatePreview();
0130   void slotInstallTemplate();
0131 #ifdef ENABLE_KNEWSTUFF3
0132 #if KNEWSTUFF_VERSION < QT_VERSION_CHECK(5, 91, 0)
0133   void slotUpdateTemplates(const QList<KNS3::Entry>& list);
0134 #else
0135   void slotUpdateTemplates(const QList<KNSCore::Entry>& list);
0136 #endif
0137 #endif
0138   void slotDeleteTemplate();
0139   void slotCreateConfigWidgets();
0140 
0141 private:
0142   enum Page {
0143     General  = 1 << 0,
0144     Printing = 1 << 1,
0145     Template = 1 << 2,
0146     Fetch    = 1 << 3
0147   };
0148   int m_initializedPages;
0149   bool isPageInitialized(Page page) const;
0150 
0151   /**
0152    * Sets-up the page for the general options.
0153    */
0154   void setupGeneralPage();
0155   void initGeneralPage(QFrame* frame);
0156   void readGeneralConfig();
0157   void saveGeneralConfig();
0158   /**
0159    * Sets-up the page for printing options.
0160    */
0161   void setupPrintingPage();
0162   void initPrintingPage(QFrame* frame);
0163   void readPrintingConfig();
0164   void savePrintingConfig();
0165   /**
0166    * Sets-up the page for template options.
0167    */
0168   void setupTemplatePage();
0169   void initTemplatePage(QFrame* frame);
0170   void readTemplateConfig();
0171   void saveTemplateConfig();
0172   /**
0173    */
0174   void setupFetchPage();
0175   void initFetchPage(QFrame* frame);
0176   void readFetchConfig();
0177   void saveFetchConfig();
0178 
0179   FetcherInfoListItem* findItem(const QString& path) const;
0180   void loadTemplateList();
0181 
0182   bool m_modifying;
0183   bool m_okClicked;
0184 
0185   QRadioButton* m_rbImageInFile;
0186   QRadioButton* m_rbImageInAppDir;
0187   QRadioButton* m_rbImageInLocalDir;
0188   QCheckBox* m_cbOpenLastFile;
0189   QCheckBox* m_cbQuickFilterRegExp;
0190   QCheckBox* m_cbEnableWebcam;
0191   QCheckBox* m_cbCapitalize;
0192   QCheckBox* m_cbFormat;
0193   QLineEdit* m_leCapitals;
0194   QLineEdit* m_leArticles;
0195   QLineEdit* m_leSuffixes;
0196   QLineEdit* m_lePrefixes;
0197 
0198   QCheckBox* m_cbPrintHeaders;
0199   QCheckBox* m_cbPrintFormatted;
0200   QCheckBox* m_cbPrintGrouped;
0201   QSpinBox* m_imageWidthBox;
0202   QSpinBox* m_imageHeightBox;
0203 
0204   GUI::ComboBox* m_templateCombo;
0205   QPushButton* m_previewButton;
0206   QFontComboBox* m_fontCombo;
0207   QSpinBox* m_fontSizeInput;
0208   KColorCombo* m_baseColorCombo;
0209   KColorCombo* m_textColorCombo;
0210   KColorCombo* m_highBaseColorCombo;
0211   KColorCombo* m_highTextColorCombo;
0212   KColorCombo* m_linkColorCombo;
0213 
0214   QListWidget* m_sourceListWidget;
0215   QMap<FetcherInfoListItem*, Fetch::ConfigWidget*> m_configWidgets;
0216   QList<Fetch::ConfigWidget*> m_newStuffConfigWidgets;
0217   QList<Fetch::ConfigWidget*> m_removedConfigWidgets;
0218   QPushButton* m_modifySourceBtn;
0219   QPushButton* m_moveUpSourceBtn;
0220   QPushButton* m_moveDownSourceBtn;
0221   QPushButton* m_removeSourceBtn;
0222   QCheckBox* m_cbFilterSource;
0223   GUI::CollectionTypeCombo* m_sourceTypeCombo;
0224 };
0225 
0226 } // end namespace
0227 #endif