File indexing completed on 2024-04-28 09:38:53

0001 /***************************************************************************
0002  *   Copyright (C) 2005 by David Saxton                                    *
0003  *   david@bluehaze.org                                                    *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  ***************************************************************************/
0010 
0011 #ifndef SETTINGSDLG_H
0012 #define SETTINGSDLG_H
0013 
0014 #include <KConfigDialog>
0015 #include <QMap>
0016 #include <QValidator>
0017 
0018 class AsmFormattingWidget;
0019 class GeneralOptionsWidget;
0020 class GpasmSettingsWidget;
0021 class GplinkSettingsWidget;
0022 class LogicWidget;
0023 class PicProgrammerConfigWidget;
0024 class PicProgrammerSettings;
0025 class SDCCOptionsWidget;
0026 
0027 /**
0028 @author David Saxton
0029 */
0030 class SettingsDlg : public KConfigDialog
0031 {
0032     Q_OBJECT
0033 public:
0034     SettingsDlg(QWidget *parent, const char *name, KCoreConfigSkeleton *config);
0035     ~SettingsDlg() override;
0036 
0037     static int refreshRateToSliderValue(int refreshRate);
0038     static int sliderValueToRefreshRate(int sliderValue);
0039 
0040     virtual void show();
0041 
0042 public slots:
0043     void slotUpdateRefreshRateLabel(int sliderValue);
0044     void slotUpdatePicProgrammerDescription();
0045     void slotAddProgrammerConfig();
0046     void slotRemoveProgrammerConfig();
0047     void slotSaveCurrentProgrammerConfig();
0048 
0049 protected slots:
0050     void slotUpdateSettings();
0051     void slotUpdateWidgets();
0052 
0053 protected:
0054     void updateSettings() override;
0055     void updateWidgets() override;
0056     void updateWidgetsDefault() override;
0057     bool hasChanged() override;
0058     bool isDefault() override;
0059 
0060     PicProgrammerSettings *m_pPicProgrammerSettings;
0061 
0062     GeneralOptionsWidget *m_generalOptionsWidget;
0063     GpasmSettingsWidget *m_gpasmSettingsWidget;
0064     SDCCOptionsWidget *m_sdccOptionsWidget;
0065     AsmFormattingWidget *m_asmFormattingWidget;
0066     LogicWidget *m_logicWidget;
0067     PicProgrammerConfigWidget *m_picProgrammerConfigWidget;
0068     GplinkSettingsWidget *m_gplinkSettingsWidget;
0069 };
0070 
0071 class NameValidator : public QValidator
0072 {
0073 public:
0074     NameValidator(QStringList unallowed)
0075         : QValidator(nullptr)
0076     {
0077         m_unallowed = unallowed;
0078     }
0079 
0080     State validate(QString &input, int &) const override
0081     {
0082         return (input.isEmpty() || m_unallowed.contains(input.toLower())) ? Intermediate : Acceptable;
0083     }
0084 
0085 protected:
0086     QStringList m_unallowed;
0087 };
0088 
0089 #endif