diff options
author | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2020-05-12 00:58:40 +0800 |
commit | a7407edaf81c685d4a389785a405a53a5de4b148 (patch) | |
tree | e6e4f2d85f2172c94ac83a6e8f01e1e90a78ede9 /qmidiplayer-desktop/qmpsettingswindow.hpp | |
parent | 437b7b16c322a8e53ac55a5f831098494d9a7073 (diff) | |
download | QMidiPlayer-a7407edaf81c685d4a389785a405a53a5de4b148.tar.xz |
Format EVERYTHING.
Hopefully this will make the source code less horrendous and actually
readable.
The command used was:
```
astyle --suffix=none --style=allman --attach-extern-c --attach-closing-while --indent-switches --indent-after-parens --pad-oper --pad-header --unpad-paren --align-pointer=name --recursive './*.cpp,*.hpp'
```
Diffstat (limited to 'qmidiplayer-desktop/qmpsettingswindow.hpp')
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.hpp | 162 |
1 files changed, 86 insertions, 76 deletions
diff --git a/qmidiplayer-desktop/qmpsettingswindow.hpp b/qmidiplayer-desktop/qmpsettingswindow.hpp index 5243ca9..c564c01 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.hpp +++ b/qmidiplayer-desktop/qmpsettingswindow.hpp @@ -17,98 +17,108 @@ #include "qmpcustomizewindow.hpp" #include "qmpdevpropdialog.hpp" -namespace Ui { - class qmpSettingsWindow; +namespace Ui +{ +class qmpSettingsWindow; } class QLineEdit; class QToolButton; -class QFileEdit:public QWidget +class QFileEdit : public QWidget { - Q_OBJECT - private: - QLineEdit *le; - QToolButton *tb; - private slots: - void chooseFile(); - public: - QFileEdit(QWidget* par=nullptr); - QString text(); - void setText(const QString& s); + Q_OBJECT +private: + QLineEdit *le; + QToolButton *tb; +private slots: + void chooseFile(); +public: + QFileEdit(QWidget *par = nullptr); + QString text(); + void setText(const QString &s); }; -class QHexSpinBox:public QSpinBox +class QHexSpinBox: public QSpinBox { - Q_OBJECT - public: - QHexSpinBox(QWidget *parent=0):QSpinBox(parent) - { - setPrefix("0x"); - setDisplayIntegerBase(16); - setRange(-0x80000000,0x7FFFFFFF); - } - protected: - QString textFromValue(int value)const - { - return QString::number(u(value),16).toUpper(); - } - int valueFromText(const QString &text)const - { - return i(text.toUInt(nullptr,16)); - } - QValidator::State validate(QString &input,int &pos)const - { - QString t=input; - if(t.startsWith("0x"))t.remove(0,2); - pos-=t.size()-t.trimmed().size();t=t.trimmed(); - if(t.isEmpty())return QValidator::Intermediate; - input=QString("0x")+t.toUpper(); - bool okay;t.toUInt(&okay,16); - if(!okay)return QValidator::Invalid; - return QValidator::Acceptable; - } - inline unsigned int u(int i)const - {return reinterpret_cast<unsigned&>(i);} - inline int i(unsigned int u)const - {return reinterpret_cast<int&>(u);} + Q_OBJECT +public: + QHexSpinBox(QWidget *parent = nullptr) : QSpinBox(parent) + { + setPrefix("0x"); + setDisplayIntegerBase(16); + setRange(-0x80000000, 0x7FFFFFFF); + } +protected: + QString textFromValue(int value)const + { + return QString::number(u(value), 16).toUpper(); + } + int valueFromText(const QString &text)const + { + return i(text.toUInt(nullptr, 16)); + } + QValidator::State validate(QString &input, int &pos)const + { + QString t = input; + if (t.startsWith("0x")) + t.remove(0, 2); + pos -= t.size() - t.trimmed().size(); + t = t.trimmed(); + if (t.isEmpty()) + return QValidator::Intermediate; + input = QString("0x") + t.toUpper(); + bool okay; + t.toUInt(&okay, 16); + if (!okay) + return QValidator::Invalid; + return QValidator::Acceptable; + } + inline unsigned int u(int i)const + { + return reinterpret_cast<unsigned &>(i); + } + inline int i(unsigned int u)const + { + return reinterpret_cast<int &>(u); + } }; class qmpDevicePriorityDialog; -class qmpSettingsWindow:public QDialog +class qmpSettingsWindow : public QDialog { - Q_OBJECT + Q_OBJECT - public: - explicit qmpSettingsWindow(qmpSettings *qmpsettings,QWidget *parent=nullptr); - ~qmpSettingsWindow(); - void closeEvent(QCloseEvent *event); - void hideEvent(QHideEvent *event); - void updatePluginList(qmpPluginManager *pmgr); - void postInit(); - void registerCustomizeWidgetOptions(); - void registerSoundFontOption(); - void registerPluginOption(qmpPluginManager *pmgr); - void registerExtraMidiOptions(); - signals: - void dialogClosing(); +public: + explicit qmpSettingsWindow(qmpSettings *qmpsettings, QWidget *parent = nullptr); + ~qmpSettingsWindow(); + void closeEvent(QCloseEvent *event); + void hideEvent(QHideEvent *event); + void updatePluginList(qmpPluginManager *pmgr); + void postInit(); + void registerCustomizeWidgetOptions(); + void registerSoundFontOption(); + void registerPluginOption(qmpPluginManager *pmgr); + void registerExtraMidiOptions(); +signals: + void dialogClosing(); - private slots: - void on_buttonBox_accepted(); - void on_buttonBox_rejected(); +private slots: + void on_buttonBox_accepted(); + void on_buttonBox_rejected(); - private: - Ui::qmpSettingsWindow *ui; - std::map<std::string,qmpOption> customOptions; - std::map<std::string,QGridLayout*> customOptPages; - void saveOption(std::string key=std::string()); - void loadOption(std::string key=std::string()); - void setupWidgets(); - QGridLayout* pageForTab(std::string tab); - qmpCustomizeWindow *cwt,*cwa; - qmpDevPropDialog *dps; - qmpDevicePriorityDialog *devpriod; - qmpSettings *settings; +private: + Ui::qmpSettingsWindow *ui; + std::map<std::string, qmpOption> customOptions; + std::map<std::string, QGridLayout *> customOptPages; + void saveOption(std::string key = std::string()); + void loadOption(std::string key = std::string()); + void setupWidgets(); + QGridLayout *pageForTab(std::string tab); + qmpCustomizeWindow *cwt, *cwa; + qmpDevPropDialog *dps; + qmpDevicePriorityDialog *devpriod; + qmpSettings *settings; }; #endif // QMPSETTINGSWINDOW_H |