1 // 2 // configview.h 3 // 4 // Description: View for configuring the set of targets to be used with the debugger 5 // 6 // 7 // SPDX-FileCopyrightText: 2010 Ian Wakeling <ian.wakeling@ntlworld.com> 8 // SPDX-FileCopyrightText: 2012 Kåre Särs <kare.sars@iki.fi> 9 // 10 // SPDX-License-Identifier: LGPL-2.0-only 11 12 #ifndef CONFIGVIEW_H 13 #define CONFIGVIEW_H 14 15 #include "advanced_settings.h" 16 17 #include <QBoxLayout> 18 #include <QCheckBox> 19 #include <QComboBox> 20 #include <QLabel> 21 #include <QLineEdit> 22 #include <QResizeEvent> 23 #include <QToolButton> 24 #include <QWidget> 25 26 #include <QList> 27 28 #include <KActionCollection> 29 #include <KConfigGroup> 30 #include <KSelectAction> 31 #include <KTextEditor/MainWindow> 32 33 struct GDBTargetConf { 34 QString targetName; 35 QString executable; 36 QString workDir; 37 QString arguments; 38 QString gdbCmd; 39 QStringList customInit; 40 QStringList srcPaths; 41 }; 42 43 class ConfigView : public QWidget 44 { 45 Q_OBJECT 46 public: 47 enum TargetStringOrder { NameIndex = 0, ExecIndex, WorkDirIndex, ArgsIndex, GDBIndex, CustomStartIndex }; 48 49 ConfigView(QWidget *parent, KTextEditor::MainWindow *mainWin); 50 ~ConfigView() override; 51 52 public: 53 void registerActions(KActionCollection *actionCollection); 54 55 void readConfig(const KConfigGroup &config); 56 void writeConfig(KConfigGroup &config); 57 58 const GDBTargetConf currentTarget() const; 59 bool takeFocusAlways() const; 60 bool showIOTab() const; 61 62 Q_SIGNALS: 63 void showIO(bool show); 64 65 void configChanged(); 66 67 private Q_SLOTS: 68 void slotTargetEdited(const QString &newText); 69 void slotTargetSelected(int index); 70 void slotAddTarget(); 71 void slotCopyTarget(); 72 void slotDeleteTarget(); 73 void slotAdvancedClicked(); 74 void slotBrowseExec(); 75 void slotBrowseDir(); 76 77 protected: 78 void resizeEvent(QResizeEvent *event) override; 79 80 private: 81 void saveCurrentToIndex(int index); 82 void loadFromIndex(int index); 83 void setAdvancedOptions(); 84 85 private: 86 KTextEditor::MainWindow *m_mainWindow; 87 QComboBox *m_targetCombo; 88 int m_currentTarget = 0; 89 QToolButton *m_addTarget; 90 QToolButton *m_copyTarget; 91 QToolButton *m_deleteTarget; 92 QFrame *m_line; 93 94 QLineEdit *m_executable; 95 QToolButton *m_browseExe; 96 97 QLineEdit *m_workingDirectory; 98 QToolButton *m_browseDir; 99 100 QLineEdit *m_arguments; 101 102 QCheckBox *m_takeFocus; 103 QCheckBox *m_redirectTerminal; 104 QPushButton *m_advancedSettings; 105 QBoxLayout *m_checBoxLayout; 106 107 bool m_useBottomLayout; 108 QLabel *m_execLabel; 109 QLabel *m_workDirLabel; 110 QLabel *m_argumentsLabel; 111 KSelectAction *m_targetSelectAction = nullptr; 112 113 AdvancedGDBSettings *m_advanced; 114 }; 115 116 #endif 117