File indexing completed on 2024-04-28 05:48:31
0001 // 0002 // configview.h 0003 // 0004 // Description: View for configuring the set of targets to be used with the debugger 0005 // 0006 // 0007 // SPDX-FileCopyrightText: 2010 Ian Wakeling <ian.wakeling@ntlworld.com> 0008 // SPDX-FileCopyrightText: 2012 Kåre Särs <kare.sars@iki.fi> 0009 // 0010 // SPDX-License-Identifier: LGPL-2.0-only 0011 0012 #pragma once 0013 0014 #include <KTextEditor/MainWindow> 0015 #include <QJsonObject> 0016 #include <QWidget> 0017 0018 #include <optional> 0019 0020 class AdvancedGDBSettings; 0021 class QPushButton; 0022 class QComboBox; 0023 class QFrame; 0024 class QSpinBox; 0025 class QResizeEvent; 0026 class QBoxLayout; 0027 class QCheckBox; 0028 class QLineEdit; 0029 class QLabel; 0030 class KSelectAction; 0031 class QToolButton; 0032 class KActionCollection; 0033 class KConfigGroup; 0034 class KatePluginGDB; 0035 0036 struct GDBTargetConf { 0037 QString targetName; 0038 QString executable; 0039 QString workDir; 0040 QString arguments; 0041 QString gdbCmd; 0042 QStringList customInit; 0043 QStringList srcPaths; 0044 }; 0045 0046 struct DAPAdapterSettings { 0047 int index; 0048 QJsonObject settings; 0049 QStringList variables; 0050 }; 0051 0052 struct DAPTargetConf { 0053 QString targetName; 0054 QString debugger; 0055 QString debuggerProfile; 0056 QVariantHash variables; 0057 std::optional<DAPAdapterSettings> dapSettings; 0058 }; 0059 0060 class ConfigView : public QWidget 0061 { 0062 Q_OBJECT 0063 public: 0064 enum TargetStringOrder { NameIndex = 0, ExecIndex, WorkDirIndex, ArgsIndex, GDBIndex, CustomStartIndex }; 0065 0066 ConfigView(QWidget *parent, KTextEditor::MainWindow *mainWin, KatePluginGDB *plugin); 0067 ~ConfigView() override; 0068 0069 public: 0070 void registerActions(KActionCollection *actionCollection); 0071 0072 void readConfig(const KConfigGroup &config); 0073 void writeConfig(KConfigGroup &config); 0074 0075 const GDBTargetConf currentGDBTarget() const; 0076 const DAPTargetConf currentDAPTarget(bool full = false) const; 0077 bool takeFocusAlways() const; 0078 bool showIOTab() const; 0079 bool debuggerIsGDB() const; 0080 QUrl dapConfigPath; 0081 0082 Q_SIGNALS: 0083 void showIO(bool show); 0084 0085 void configChanged(); 0086 0087 private Q_SLOTS: 0088 void slotTargetEdited(const QString &newText); 0089 void slotTargetSelected(int index); 0090 void slotAddTarget(); 0091 void slotCopyTarget(); 0092 void slotDeleteTarget(); 0093 void slotAdvancedClicked(); 0094 void slotBrowseExec(); 0095 void slotBrowseDir(); 0096 0097 protected: 0098 void resizeEvent(QResizeEvent *event) override; 0099 0100 private: 0101 void saveCurrentToIndex(int index); 0102 int loadFromIndex(int index); 0103 void setAdvancedOptions(); 0104 struct Field { 0105 QLabel *label; 0106 QLineEdit *input; 0107 }; 0108 Field &getDapField(const QString &fieldName); 0109 void refreshUI(); 0110 void readDAPSettings(); 0111 0112 private: 0113 KTextEditor::MainWindow *m_mainWindow; 0114 0115 QComboBox *m_clientCombo; 0116 0117 QComboBox *m_targetCombo; 0118 int m_currentTarget = 0; 0119 QToolButton *m_addTarget; 0120 QToolButton *m_copyTarget; 0121 QToolButton *m_deleteTarget; 0122 QFrame *m_line; 0123 0124 QLineEdit *m_executable; 0125 QToolButton *m_browseExe; 0126 0127 QLineEdit *m_workingDirectory; 0128 QToolButton *m_browseDir; 0129 QSpinBox *m_processId; 0130 0131 QLineEdit *m_arguments; 0132 0133 QCheckBox *m_takeFocus; 0134 QCheckBox *m_redirectTerminal; 0135 QPushButton *m_advancedSettings; 0136 QBoxLayout *m_checBoxLayout; 0137 0138 bool m_useBottomLayout; 0139 QLabel *m_execLabel; 0140 QLabel *m_workDirLabel; 0141 QLabel *m_argumentsLabel; 0142 QLabel *m_processIdLabel; 0143 KSelectAction *m_targetSelectAction = nullptr; 0144 0145 QHash<QString, Field> m_dapFields; 0146 QHash<QString, QHash<QString, DAPAdapterSettings>> m_dapAdapterSettings; 0147 0148 AdvancedGDBSettings *m_advanced; 0149 QUrl m_dapConfigPath; 0150 };