Added debug option to define program arguments

This commit is contained in:
mandlebro 2018-06-15 14:07:18 +01:00 committed by xarkes
parent ac4751eb4a
commit cd1656fc30
3 changed files with 105 additions and 46 deletions

View File

@ -1,9 +1,10 @@
#include <QLabel>
#include <QFontDialog>
#include "DebugOptionsWidget.h"
#include "ui_DebugOptionsWidget.h"
#include <QLabel>
#include <QTimer>
#include <QComboBox>
#include <QShortcut>
#include <QFontDialog>
#include "PreferencesDialog.h"
#include "utils/Helpers.h"
@ -16,6 +17,7 @@ DebugOptionsWidget::DebugOptionsWidget(PreferencesDialog */*dialog*/, QWidget *p
ui->setupUi(this);
updateDebugPlugin();
setupDebugArgs();
}
DebugOptionsWidget::~DebugOptionsWidget() {}
@ -36,6 +38,30 @@ void DebugOptionsWidget::updateDebugPlugin()
SLOT(on_pluginComboBox_currentIndexChanged(const QString &)));
}
void DebugOptionsWidget::setupDebugArgs()
{
// add Enter shortcut to confirm changes
QShortcut *enterPress = new QShortcut(QKeySequence(Qt::Key_Return), this);
enterPress->setContext(Qt::WidgetWithChildrenShortcut);
connect(enterPress, &QShortcut::activated, this, &DebugOptionsWidget::updateDebugArgs);
QString currentArgs = Core()->getConfig("dbg.args");
ui->debugArgs->setText(currentArgs);
ui->debugArgs->setPlaceholderText(currentArgs);
connect(ui->updateArgsButton, &QAbstractButton::clicked, this, &DebugOptionsWidget::updateDebugArgs);
}
void DebugOptionsWidget::updateDebugArgs()
{
QString newArgs = ui->debugArgs->text();
Core()->setConfig("dbg.args", newArgs);
ui->debugArgs->setText(newArgs);
ui->debugArgs->setPlaceholderText(newArgs);
// flash green for 200 ms
ui->debugArgs->setStyleSheet("border: 1px solid green;");
QTimer::singleShot(200, [this](){ ui->debugArgs->setStyleSheet("");});
}
void DebugOptionsWidget::on_pluginComboBox_currentIndexChanged(const QString &plugin)
{
Core()->setDebugPlugin(plugin);

View File

@ -24,6 +24,7 @@ private:
private slots:
void updateDebugPlugin();
void setupDebugArgs();
void updateDebugArgs();
void on_pluginComboBox_currentIndexChanged(const QString &index);
};

View File

@ -1,45 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DebugOptionsWidget</class>
<widget class="QWidget" name="DebugOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>442</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Debug</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="pluginLabel">
<property name="text">
<string>Debug Plugin:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="pluginComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
<class>DebugOptionsWidget</class>
<widget class="QWidget" name="DebugOptionsWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>442</width>
<height>225</height>
</rect>
</property>
<property name="windowTitle">
<string>Debug</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="pluginSelectionLayout">
<item>
<widget class="QLabel" name="pluginLabel">
<property name="text">
<string>Debug Plugin:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="pluginComboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="argSelectionLayout">
<item>
<widget class="QLabel" name="argsLabel">
<property name="text">
<string>Program Arguments:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="debugArgs">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="updateArgsButton">
<property name="text">
<string>Confirm</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>