2018-06-14 11:49:22 +00:00
|
|
|
#include "DebugOptionsWidget.h"
|
|
|
|
#include "ui_DebugOptionsWidget.h"
|
2018-06-15 13:07:18 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QTimer>
|
2018-06-14 11:49:22 +00:00
|
|
|
#include <QComboBox>
|
2018-06-15 13:07:18 +00:00
|
|
|
#include <QShortcut>
|
|
|
|
#include <QFontDialog>
|
2018-06-14 11:49:22 +00:00
|
|
|
#include "PreferencesDialog.h"
|
|
|
|
|
|
|
|
#include "utils/Helpers.h"
|
|
|
|
#include "utils/Configuration.h"
|
|
|
|
|
|
|
|
DebugOptionsWidget::DebugOptionsWidget(PreferencesDialog */*dialog*/, QWidget *parent)
|
|
|
|
: QDialog(parent),
|
|
|
|
ui(new Ui::DebugOptionsWidget)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
updateDebugPlugin();
|
2018-06-15 13:07:18 +00:00
|
|
|
setupDebugArgs();
|
2018-06-14 11:49:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugOptionsWidget::~DebugOptionsWidget() {}
|
|
|
|
|
|
|
|
void DebugOptionsWidget::updateDebugPlugin()
|
|
|
|
{
|
|
|
|
disconnect(ui->pluginComboBox, SIGNAL(currentIndexChanged(const QString &)), this,
|
|
|
|
SLOT(on_pluginComboBox_currentIndexChanged(const QString &)));
|
|
|
|
|
|
|
|
QStringList plugins = Core()->getDebugPlugins();
|
|
|
|
for (QString str : plugins)
|
|
|
|
ui->pluginComboBox->addItem(str);
|
|
|
|
|
|
|
|
QString plugin = Core()->getActiveDebugPlugin();
|
|
|
|
ui->pluginComboBox->setCurrentText(plugin);
|
|
|
|
|
|
|
|
connect(ui->pluginComboBox, SIGNAL(currentIndexChanged(const QString &)), this,
|
|
|
|
SLOT(on_pluginComboBox_currentIndexChanged(const QString &)));
|
|
|
|
}
|
|
|
|
|
2018-06-15 13:07:18 +00:00
|
|
|
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("");});
|
|
|
|
}
|
|
|
|
|
2018-06-14 11:49:22 +00:00
|
|
|
void DebugOptionsWidget::on_pluginComboBox_currentIndexChanged(const QString &plugin)
|
|
|
|
{
|
|
|
|
Core()->setDebugPlugin(plugin);
|
|
|
|
}
|