File indexing completed on 2024-11-17 04:49:15
0001 /* 0002 This file is part of KOrganizer. 0003 0004 SPDX-FileCopyrightText: 2001,2003 Cornelius Schumacher <schumacher@kde.org> 0005 SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 0006 SPDX-FileCopyrightText: 2005,2008,2011 Allen Winter <winter@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 #include <KCModule> 0013 #include <KConfigSkeleton> 0014 #include <KFile> 0015 #include <KLineEdit> 0016 #include <KPageDialog> 0017 0018 #include <QVariantList> 0019 0020 class KColorButton; 0021 class KComboBox; 0022 class KDateComboBox; 0023 class KTimeComboBox; 0024 class KUrlRequester; 0025 0026 class QCheckBox; 0027 class QLabel; 0028 class QSpinBox; 0029 class QTimeEdit; 0030 class QButtonGroup; 0031 class QGroupBox; 0032 0033 namespace Korganizer 0034 { 0035 /** 0036 @short Base class for GUI control elements used by @ref KPrefsDialog. 0037 @author Cornelius Schumacher 0038 @see KPrefsDialog 0039 0040 This class provides the interface for the GUI control elements used by 0041 KPrefsDialog. The control element consists of a set of widgets for handling 0042 a certain type of configuration information. 0043 */ 0044 class KPrefsWid : public QObject 0045 { 0046 Q_OBJECT 0047 public: 0048 /** 0049 This function is called to read value of the setting from the 0050 stored configuration and display it in the widget. 0051 */ 0052 virtual void readConfig() = 0; 0053 /** 0054 This function is called to write the current setting of the widget to the 0055 stored configuration. 0056 */ 0057 virtual void writeConfig() = 0; 0058 0059 /** 0060 Return a list of widgets used by this control element. 0061 */ 0062 virtual QList<QWidget *> widgets() const; 0063 0064 Q_SIGNALS: 0065 /** 0066 Emitted when widget value has changed. 0067 */ 0068 void changed(); 0069 }; 0070 0071 /** 0072 @short Widgets for bool settings in @ref KPrefsDialog. 0073 0074 This class provides a control element for configuring bool values. It is meant 0075 to be used by KPrefsDialog. The user is responsible for the layout management. 0076 */ 0077 class KPrefsWidBool : public KPrefsWid 0078 { 0079 Q_OBJECT 0080 public: 0081 /** 0082 Create a bool value control element consisting of a QCheckbox. 0083 0084 @param item The KConfigSkeletonItem representing the preferences entry. 0085 @param parent Parent widget. 0086 */ 0087 explicit KPrefsWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent = nullptr); 0088 0089 /** 0090 Create a bool value control element consisting of a QCheckbox. 0091 0092 @param item The KConfigCompilerSignallingItem representing the preferences entry. 0093 @param parent Parent widget. 0094 */ 0095 explicit KPrefsWidBool(KConfigCompilerSignallingItem *item, QWidget *parent = nullptr); 0096 0097 /** 0098 Return the QCheckbox used by this control element. 0099 */ 0100 QCheckBox *checkBox(); 0101 0102 void readConfig() override; 0103 void writeConfig() override; 0104 0105 QList<QWidget *> widgets() const override; 0106 0107 private: 0108 void init(QWidget *parent); 0109 KConfigSkeletonItem *mItem = nullptr; 0110 0111 QCheckBox *mCheck = nullptr; 0112 }; 0113 0114 /** 0115 @short Widgets for int settings in @ref KPrefsDialog. 0116 0117 This class provides a control element for configuring integer values. It is 0118 meant to be used by KPrefsDialog. The user is responsible for the layout 0119 management. 0120 */ 0121 class KPrefsWidInt : public KPrefsWid 0122 { 0123 Q_OBJECT 0124 public: 0125 /** 0126 Create a integer value control element consisting of a label and a 0127 spinbox. 0128 0129 @param item The KConfigSkeletonItem representing the preferences entry. 0130 @param parent Parent widget. 0131 */ 0132 explicit KPrefsWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent = nullptr); 0133 0134 /** 0135 Return QLabel used by this control element. 0136 */ 0137 QLabel *label() const; 0138 0139 /** 0140 Return the QSpinBox used by this control element. 0141 */ 0142 QSpinBox *spinBox(); 0143 0144 void readConfig() override; 0145 void writeConfig() override; 0146 0147 QList<QWidget *> widgets() const override; 0148 0149 private: 0150 KConfigSkeleton::ItemInt *mItem = nullptr; 0151 0152 QLabel *mLabel = nullptr; 0153 QSpinBox *mSpin = nullptr; 0154 }; 0155 0156 /** 0157 @short Widgets for time settings in @ref KPrefsDialog. 0158 0159 This class provides a control element for configuring time values. It is 0160 meant to be used by KPrefsDialog. The user is responsible for the layout 0161 management. 0162 */ 0163 class KPrefsWidTime : public KPrefsWid 0164 { 0165 Q_OBJECT 0166 public: 0167 /** 0168 Create a time value control element consisting of a label and a spinbox. 0169 0170 @param item The KConfigSkeletonItem representing the preferences entry. 0171 @param parent Parent widget. 0172 */ 0173 explicit KPrefsWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); 0174 0175 /** 0176 Return QLabel used by this widget. 0177 */ 0178 QLabel *label(); 0179 0180 /** 0181 Return KTimeComboBox used by this widget. 0182 */ 0183 KTimeComboBox *timeEdit(); 0184 0185 void readConfig() override; 0186 void writeConfig() override; 0187 0188 private: 0189 KConfigSkeleton::ItemDateTime *mItem = nullptr; 0190 0191 QLabel *mLabel = nullptr; 0192 KTimeComboBox *mTimeEdit = nullptr; 0193 }; 0194 0195 /** 0196 @short Widgets for duration settings in @ref KPrefsDialog. 0197 0198 This class provides a control element for configuring duration values. It is 0199 meant to be used by KPrefsDialog. The user is responsible for the layout 0200 management. 0201 */ 0202 class KPrefsWidDuration : public KPrefsWid 0203 { 0204 Q_OBJECT 0205 public: 0206 /** 0207 Create a duration value control element consisting of a label and a 0208 spinbox. 0209 0210 @param item The KConfigSkeletonItem representing the preferences entry. 0211 @param format display format. default is "hh:mm:ss" 0212 @param parent Parent widget. 0213 */ 0214 explicit KPrefsWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent = nullptr); 0215 0216 /** 0217 Return QLabel used by this widget. 0218 */ 0219 QLabel *label(); 0220 /** 0221 Return QSpinBox used by this widget. 0222 */ 0223 QTimeEdit *timeEdit(); 0224 0225 void readConfig() override; 0226 void writeConfig() override; 0227 0228 private: 0229 KConfigSkeleton::ItemDateTime *mItem = nullptr; 0230 0231 QLabel *mLabel = nullptr; 0232 QTimeEdit *mTimeEdit = nullptr; 0233 }; 0234 0235 /** 0236 @short Widgets for time settings in @ref KPrefsDialog. 0237 0238 This class provides a control element for configuring date values. It is 0239 meant to be used by KPrefsDialog. The user is responsible for the layout 0240 management. 0241 */ 0242 class KPrefsWidDate : public KPrefsWid 0243 { 0244 Q_OBJECT 0245 public: 0246 /** 0247 Create a time value control element consisting of a label and a date box. 0248 0249 @param item The KConfigSkeletonItem representing the preferences entry. 0250 @param parent Parent widget. 0251 */ 0252 explicit KPrefsWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); 0253 0254 /** 0255 Return QLabel used by this widget. 0256 */ 0257 QLabel *label(); 0258 0259 /** 0260 Return KDateComboBox used by this widget. 0261 */ 0262 KDateComboBox *dateEdit(); 0263 0264 void readConfig() override; 0265 void writeConfig() override; 0266 0267 private: 0268 KConfigSkeleton::ItemDateTime *mItem = nullptr; 0269 0270 QLabel *mLabel = nullptr; 0271 KDateComboBox *mDateEdit = nullptr; 0272 }; 0273 0274 /** 0275 @short Widgets for color settings in @ref KPrefsDialog. 0276 0277 This class provides a control element for configuring color values. It is 0278 meant to be used by KPrefsDialog. The user is responsible for the layout 0279 management. 0280 */ 0281 class KPrefsWidColor : public KPrefsWid 0282 { 0283 Q_OBJECT 0284 public: 0285 /** 0286 Create a color value control element consisting of a test field and a 0287 button for opening a color dialog. 0288 0289 @param item The KConfigSkeletonItem representing the preferences entry. 0290 @param parent Parent widget. 0291 */ 0292 explicit KPrefsWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent = nullptr); 0293 0294 /** 0295 Destruct color setting widget. 0296 */ 0297 ~KPrefsWidColor() override; 0298 0299 /** 0300 Return QLabel for the button 0301 */ 0302 QLabel *label(); 0303 /** 0304 Return button opening the color dialog. 0305 */ 0306 KColorButton *button(); 0307 0308 void readConfig() override; 0309 void writeConfig() override; 0310 0311 private: 0312 KConfigSkeleton::ItemColor *mItem = nullptr; 0313 0314 QLabel *mLabel = nullptr; 0315 KColorButton *mButton = nullptr; 0316 }; 0317 0318 /** 0319 @short Widgets for font settings in @ref KPrefsDialog. 0320 0321 This class provides a control element for configuring font values. It is meant 0322 to be used by KPrefsDialog. The user is responsible for the layout management. 0323 */ 0324 class KPrefsWidFont : public KPrefsWid 0325 { 0326 Q_OBJECT 0327 public: 0328 /** 0329 Create a font value control element consisting of a test field and a 0330 button for opening a font dialog. 0331 0332 @param item The KConfigSkeletonItem representing the preferences entry. 0333 @param parent Parent widget. 0334 @param sampleText Sample text for previewing the selected font. 0335 */ 0336 explicit KPrefsWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent = nullptr, const QString &sampleText = QString()); 0337 /** 0338 Destruct font setting widget. 0339 */ 0340 ~KPrefsWidFont() override; 0341 0342 /** 0343 Return QLabel. 0344 */ 0345 QLabel *label(); 0346 0347 /** 0348 Return QFrame used as preview field. 0349 */ 0350 QFrame *preview(); 0351 0352 /** 0353 Return button opening the font dialog. 0354 */ 0355 QPushButton *button(); 0356 0357 void readConfig() override; 0358 void writeConfig() override; 0359 0360 protected Q_SLOTS: 0361 void selectFont(); 0362 0363 private: 0364 KConfigSkeleton::ItemFont *mItem = nullptr; 0365 0366 QLabel *mLabel = nullptr; 0367 QLabel *mPreview = nullptr; 0368 QPushButton *mButton = nullptr; 0369 }; 0370 0371 /** 0372 @short Widgets for settings represented by a group of radio buttons in 0373 @ref KPrefsDialog. 0374 0375 This class provides a control element for configuring selections. It is meant 0376 to be used by KPrefsDialog. The user is responsible for the layout management. 0377 0378 The setting is interpreted as an int value, corresponding to the position of 0379 the radio button. The position of the button is defined by the sequence of 0380 @ref addRadio() calls, starting with 0. 0381 */ 0382 class KPrefsWidRadios : public KPrefsWid 0383 { 0384 Q_OBJECT 0385 public: 0386 /** 0387 Create a control element for selection of an option. It consists of a box 0388 with several radio buttons. 0389 0390 @param item The KConfigSkeletonItem representing the preferences entry. 0391 @param parent Parent widget. 0392 */ 0393 explicit KPrefsWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); 0394 ~KPrefsWidRadios() override; 0395 0396 /** 0397 Add a radio button. 0398 0399 @param value The enum value represented by this radio button. 0400 @param text Text of the button. 0401 @param toolTip ToolTip help for the button. 0402 @param whatsThis What's This help for the button. 0403 */ 0404 void addRadio(int value, const QString &text, const QString &toolTip = QString(), const QString &whatsThis = QString()); 0405 0406 /** 0407 Return the box widget used by this widget. 0408 */ 0409 QGroupBox *groupBox() const; 0410 0411 void readConfig() override; 0412 void writeConfig() override; 0413 0414 QList<QWidget *> widgets() const override; 0415 0416 private: 0417 KConfigSkeleton::ItemEnum *mItem = nullptr; 0418 0419 QGroupBox *mBox = nullptr; 0420 QButtonGroup *mGroup = nullptr; 0421 }; 0422 0423 /** 0424 @short Widgets for settings represented by a combo box in 0425 @ref KPrefsDialog. 0426 0427 This class provides a control element for configuring selections. It is meant 0428 to be used by KPrefsDialog. The user is responsible for the layout management. 0429 0430 The setting is interpreted as an int value, corresponding to the index in 0431 the combo box. 0432 */ 0433 class KPrefsWidCombo : public KPrefsWid 0434 { 0435 Q_OBJECT 0436 public: 0437 /** 0438 Create a control element for selection of an option. It consists of a 0439 combo box. 0440 0441 @param item The KConfigSkeletonItem representing the preferences entry. 0442 @param parent Parent widget. 0443 */ 0444 explicit KPrefsWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent); 0445 ~KPrefsWidCombo() override; 0446 0447 void readConfig() override; 0448 void writeConfig() override; 0449 0450 KComboBox *comboBox(); 0451 0452 QList<QWidget *> widgets() const override; 0453 /** 0454 Return QLabel used by this control element. 0455 */ 0456 QLabel *label() const; 0457 0458 private: 0459 KConfigSkeleton::ItemEnum *mItem = nullptr; 0460 KComboBox *mCombo = nullptr; 0461 QLabel *mLabel = nullptr; 0462 }; 0463 0464 /** 0465 @short Widgets for string settings in @ref KPrefsDialog. 0466 0467 This class provides a control element for configuring string values. It is 0468 meant to be used by KPrefsDialog. The user is responsible for the layout 0469 management. 0470 */ 0471 class KPrefsWidString : public KPrefsWid 0472 { 0473 Q_OBJECT 0474 public: 0475 /** 0476 Create a string value control element consisting of a test label and a 0477 line edit. 0478 0479 @param item The KConfigSkeletonItem representing the preferences entry. 0480 @param parent Parent widget. 0481 @param echomode Describes how a line edit should display its contents. 0482 */ 0483 explicit KPrefsWidString(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr, KLineEdit::EchoMode echomode = KLineEdit::Normal); 0484 /** 0485 Destructor. 0486 */ 0487 ~KPrefsWidString() override; 0488 0489 /** 0490 Return QLabel used by this widget. 0491 */ 0492 QLabel *label(); 0493 /** 0494 Return KLineEdit used by this widget. 0495 */ 0496 KLineEdit *lineEdit(); 0497 0498 void readConfig() override; 0499 void writeConfig() override; 0500 0501 QList<QWidget *> widgets() const override; 0502 0503 private: 0504 KConfigSkeleton::ItemString *mItem = nullptr; 0505 0506 QLabel *mLabel = nullptr; 0507 KLineEdit *mEdit = nullptr; 0508 }; 0509 0510 /** 0511 @short Widgets for string settings in @ref KPrefsDialog. 0512 0513 This class provides a control element for configuring string values. It is 0514 meant to be used by KPrefsDialog. The user is responsible for the layout 0515 management. 0516 */ 0517 class KPrefsWidPath : public KPrefsWid 0518 { 0519 Q_OBJECT 0520 public: 0521 /** 0522 Create a string value control element consisting of a test label and a 0523 line edit. 0524 0525 @param item The KConfigSkeletonItem representing the preferences entry. 0526 @param parent Parent widget. 0527 @param filter URLRequester filter 0528 @param mode Describes how a line edit should display its contents. 0529 */ 0530 explicit KPrefsWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent = nullptr, const QString &filter = QString(), KFile::Modes = KFile::File); 0531 0532 /** 0533 Destructor. 0534 */ 0535 ~KPrefsWidPath() override; 0536 0537 /** 0538 Return QLabel used by this widget. 0539 */ 0540 QLabel *label(); 0541 0542 /** 0543 Return KUrlRequester used by this widget. 0544 */ 0545 KUrlRequester *urlRequester(); 0546 0547 void readConfig() override; 0548 void writeConfig() override; 0549 0550 QList<QWidget *> widgets() const override; 0551 0552 private: 0553 KConfigSkeleton::ItemPath *mItem = nullptr; 0554 0555 QLabel *mLabel = nullptr; 0556 KUrlRequester *mURLRequester = nullptr; 0557 }; 0558 0559 /** 0560 @short Class for managing KPrefsWid objects. 0561 0562 This class manages standard configuration widgets provided bz the KPrefsWid 0563 subclasses. It handles creation, loading, saving and default values in a 0564 transparent way. The user has to add the widgets by the corresponding addWid 0565 functions and KPrefsWidManager handles the rest automatically. 0566 */ 0567 class KPrefsWidManager 0568 { 0569 public: 0570 /** 0571 Create a KPrefsWidManager object for a KPrefs object. 0572 0573 @param prefs KPrefs object used to access te configuration. 0574 */ 0575 explicit KPrefsWidManager(KConfigSkeleton *prefs); 0576 0577 /** 0578 Destructor. 0579 */ 0580 virtual ~KPrefsWidManager(); 0581 0582 KConfigSkeleton *prefs() const 0583 { 0584 return mPrefs; 0585 } 0586 0587 /** 0588 Register a custom KPrefsWid object. 0589 */ 0590 virtual void addWid(KPrefsWid *); 0591 0592 /** 0593 Register a @ref KPrefsWidBool object. 0594 0595 @param item The KConfigCompilerSignallingItem representing the preferences entry. 0596 @param parent Parent widget. 0597 */ 0598 KPrefsWidBool *addWidBool(KConfigCompilerSignallingItem *item, QWidget *parent = nullptr); 0599 0600 /** 0601 Register a @ref KPrefsWidBool object. 0602 0603 @param item The KConfigSkeletonItem representing the preferences entry. 0604 @param parent Parent widget. 0605 */ 0606 KPrefsWidBool *addWidBool(KConfigSkeleton::ItemBool *item, QWidget *parent = nullptr); 0607 0608 /** 0609 Register a @ref KPrefsWidInt object. 0610 0611 @param item The KConfigSkeletonItem representing the preferences entry. 0612 @param parent Parent widget. 0613 */ 0614 KPrefsWidInt *addWidInt(KConfigSkeleton::ItemInt *item, QWidget *parent = nullptr); 0615 0616 /** 0617 Register a @ref KPrefsWidDate object. 0618 0619 @param item The KConfigSkeletonItem representing the preferences entry. 0620 @param parent Parent widget. 0621 */ 0622 KPrefsWidDate *addWidDate(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); 0623 0624 /** 0625 Register a @ref KPrefsWidTime object. 0626 0627 @param item The KConfigSkeletonItem representing the preferences entry. 0628 @param parent Parent widget. 0629 */ 0630 KPrefsWidTime *addWidTime(KConfigSkeleton::ItemDateTime *item, QWidget *parent = nullptr); 0631 0632 /** 0633 Register a @ref KPrefsWidDuration object. 0634 0635 @param item The KConfigSkeletonItem representing the preferences entry. 0636 @param format display format. default is "hh:mm:ss" 0637 @param parent Parent widget. 0638 */ 0639 KPrefsWidDuration *addWidDuration(KConfigSkeleton::ItemDateTime *item, const QString &format, QWidget *parent = nullptr); 0640 0641 /** 0642 Register a @ref KPrefsWidColor object. 0643 0644 @param item The KConfigSkeletonItem representing the preferences entry. 0645 @param parent Parent widget. 0646 */ 0647 KPrefsWidColor *addWidColor(KConfigSkeleton::ItemColor *item, QWidget *parent = nullptr); 0648 0649 /** 0650 Register a @ref KPrefsWidRadios object. The choices represented by the 0651 given item object are automatically added as radio buttons. 0652 0653 @param item The KConfigSkeletonItem representing the preferences entry. 0654 @param parent Parent widget. 0655 */ 0656 KPrefsWidRadios *addWidRadios(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); 0657 0658 /** 0659 Register a @ref KPrefsWidCombo object. The choices represented by the 0660 given item object are automatically added to the combo box. 0661 0662 @param item The KConfigSkeletonItem representing the preferences entry. 0663 @param parent Parent widget. 0664 */ 0665 KPrefsWidCombo *addWidCombo(KConfigSkeleton::ItemEnum *item, QWidget *parent = nullptr); 0666 0667 /** 0668 Register a @ref KPrefsWidString object. 0669 0670 @param item The KConfigSkeletonItem representing the preferences entry. 0671 @param parent Parent widget. 0672 */ 0673 KPrefsWidString *addWidString(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr); 0674 0675 /** 0676 Register a path @ref KPrefsWidPath object. 0677 0678 @param item The KConfigSkeletonItem representing the preferences entry. 0679 @param parent Parent widget. 0680 @param filter URLRequester filter 0681 @param mode URLRequester mode 0682 */ 0683 KPrefsWidPath *addWidPath(KConfigSkeleton::ItemPath *item, QWidget *parent = nullptr, const QString &filter = QString(), KFile::Modes mode = KFile::File); 0684 0685 /** 0686 Register a password @ref KPrefsWidString object, with echomode set to KLineEdit::Password. 0687 0688 @param item The KConfigSkeletonItem representing the preferences entry. 0689 @param parent Parent widget. 0690 */ 0691 KPrefsWidString *addWidPassword(KConfigSkeleton::ItemString *item, QWidget *parent = nullptr); 0692 0693 /** 0694 Register a @ref KPrefsWidFont object. 0695 0696 @param item The KConfigSkeletonItem representing the preferences 0697 entry. 0698 @param parent Parent widget. 0699 @param sampleText Sample text for previewing the selected font. 0700 */ 0701 KPrefsWidFont *addWidFont(KConfigSkeleton::ItemFont *item, QWidget *parent = nullptr, const QString &sampleText = QString()); 0702 0703 /** Set all widgets to default values. */ 0704 void setWidDefaults(); 0705 0706 /** Read preferences from config file. */ 0707 void readWidConfig(); 0708 0709 /** Write preferences to config file. */ 0710 void writeWidConfig(); 0711 0712 private: 0713 KConfigSkeleton *mPrefs = nullptr; 0714 0715 QList<KPrefsWid *> mPrefsWids; 0716 }; 0717 0718 /** 0719 @short Base class for a preferences dialog. 0720 0721 This class provides the framework for a preferences dialog. You have to 0722 subclass it and add the code to create the actual configuration widgets and 0723 do the layout management. 0724 0725 KPrefsDialog provides functions to add subclasses of @ref KPrefsWid via 0726 KPrefsWidManager. For these widgets the reading, writing and setting to 0727 default values is handled automatically. Custom widgets have to be handled in 0728 the functions @ref usrReadConfig() and @ref usrWriteConfig(). 0729 */ 0730 class KPrefsDialog : public KPageDialog, public KPrefsWidManager 0731 { 0732 Q_OBJECT 0733 public: 0734 /** 0735 Create a KPrefsDialog for a KPrefs object. 0736 0737 @param prefs KPrefs object used to access te configuration. 0738 @param parent Parent widget. 0739 @param name Widget name. 0740 @param modal true, if dialog has to be modal, false for non-modal. 0741 */ 0742 explicit KPrefsDialog(KConfigSkeleton *prefs, QWidget *parent = nullptr, bool modal = false); 0743 0744 /** 0745 Destructor. 0746 */ 0747 ~KPrefsDialog() override; 0748 0749 void autoCreate(); 0750 0751 public Q_SLOTS: 0752 /** Set all widgets to default values. */ 0753 void setDefaults(); 0754 0755 /** Read preferences from config file. */ 0756 void readConfig(); 0757 0758 /** Write preferences to config file. */ 0759 void writeConfig(); 0760 0761 Q_SIGNALS: 0762 /** Emitted when the a changed configuration has been stored. */ 0763 void configChanged(); 0764 0765 protected Q_SLOTS: 0766 /** Apply changes to preferences */ 0767 void slotApply(); 0768 0769 /** Accept changes to preferences and close dialog */ 0770 void slotOk(); 0771 0772 /** Set preferences to default values */ 0773 void slotDefault(); 0774 0775 protected: 0776 /** Implement this to read custom configuration widgets. */ 0777 virtual void usrReadConfig() 0778 { 0779 } 0780 0781 /** Implement this to write custom configuration widgets. */ 0782 virtual void usrWriteConfig() 0783 { 0784 } 0785 }; 0786 0787 class KPrefsModule : public KCModule, public KPrefsWidManager 0788 { 0789 Q_OBJECT 0790 public: 0791 explicit KPrefsModule(KConfigSkeleton *, QObject *parent, const KPluginMetaData &data); 0792 0793 void addWid(KPrefsWid *) override; 0794 0795 void load() override; 0796 void save() override; 0797 void defaults() override; 0798 0799 public Q_SLOTS: 0800 void slotWidChanged(); 0801 0802 protected: 0803 /** Implement this to read custom configuration widgets. */ 0804 virtual void usrReadConfig() 0805 { 0806 } 0807 0808 /** Implement this to write custom configuration widgets. */ 0809 virtual void usrWriteConfig() 0810 { 0811 } 0812 }; 0813 }