1/*
2 * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#include "debuggeneralwidget.h"
18#include "ui_debuggeneralwidget.h"
19#include "../settings.h"
20#include "../mainwindow.h"
21
22DebugGeneralWidget::DebugGeneralWidget(const QString& name, const QString& group, QWidget *parent) :
23 SettingsWidget(name,group,parent),
24 ui(new Ui::DebugGeneralWidget)
25{
26 ui->setupUi(this);
27}
28
29DebugGeneralWidget::~DebugGeneralWidget()
30{
31 delete ui;
32}
33
34void DebugGeneralWidget::doLoad()
35{
36 ui->chkOnlyMono->setChecked(pSettings->debugger().onlyShowMono());
37 ui->cbFont->setCurrentFont(QFont(pSettings->debugger().fontName()));
38 ui->sbFontSize->setValue(pSettings->debugger().fontSize());
39 ui->grpEnableDebugConsole->setChecked(pSettings->debugger().enableDebugConsole());
40 ui->chkShowDetailLog->setChecked(pSettings->debugger().showDetailLog());
41 if (pSettings->debugger().useIntelStyle()) {
42 ui->rbIntel->setChecked(true);
43 } else {
44 ui->rbATT->setChecked(true);
45 }
46 ui->chkShowCPUWhenSignaled->setChecked(pSettings->debugger().openCPUInfoWhenSignaled());
47 ui->chkBlendMode->setChecked(pSettings->debugger().blendMode());
48 ui->chkSkipSystemLib->setChecked(pSettings->debugger().skipSystemLibraries());
49 ui->chkSkipProjectLib->setChecked(pSettings->debugger().skipProjectLibraries());
50 ui->chkSkipCustomLib->setChecked(pSettings->debugger().skipCustomLibraries());
51 ui->chkAutosaveBreakpoints->setChecked(pSettings->debugger().autosaveBreakpoints());
52 ui->chkAutosaveWatches->setChecked(pSettings->debugger().autosaveWatches());
53#ifdef Q_OS_WIN
54 ui->grpUseGDBServer->setCheckable(true);
55 ui->grpUseGDBServer->setChecked(pSettings->debugger().useGDBServer());
56#endif
57 ui->spinGDBServerPort->setValue(pSettings->debugger().GDBServerPort());
58 ui->spinMemoryViewRows->setValue(pSettings->debugger().memoryViewRows());
59 ui->spinMemoryViewColumns->setValue(pSettings->debugger().memoryViewColumns());
60}
61
62void DebugGeneralWidget::doSave()
63{
64 pSettings->debugger().setOnlyShowMono(ui->chkOnlyMono->isChecked());
65 pSettings->debugger().setFontName(ui->cbFont->currentFont().family());
66 pSettings->debugger().setFontSize(ui->sbFontSize->value());
67 pSettings->debugger().setEnableDebugConsole(ui->grpEnableDebugConsole->isChecked());
68 pSettings->debugger().setShowDetailLog(ui->chkShowDetailLog->isChecked());
69 pSettings->debugger().setOpenCPUInfoWhenSignaled(ui->chkShowCPUWhenSignaled);
70 pSettings->debugger().setUseIntelStyle(ui->rbIntel->isChecked());
71 pSettings->debugger().setBlendMode(ui->chkBlendMode->isChecked());
72 pSettings->debugger().setSkipSystemLibraries(ui->chkSkipSystemLib->isChecked());
73 pSettings->debugger().setSkipProjectLibraries(ui->chkSkipProjectLib->isChecked());
74 pSettings->debugger().setSkipCustomLibraries(ui->chkSkipCustomLib->isChecked());
75 pSettings->debugger().setAutosaveBreakpoints(ui->chkAutosaveBreakpoints->isChecked());
76 pSettings->debugger().setAutosaveWatches(ui->chkAutosaveWatches->isChecked());
77#ifdef Q_OS_WIN
78 pSettings->debugger().setUseGDBServer(ui->grpUseGDBServer->isChecked());
79#endif
80 pSettings->debugger().setGDBServerPort(ui->spinGDBServerPort->value());
81 pSettings->debugger().setMemoryViewRows(ui->spinMemoryViewRows->value());
82 pSettings->debugger().setMemoryViewColumns(ui->spinMemoryViewColumns->value());
83 pSettings->debugger().save();
84 pMainWindow->updateDebuggerSettings();
85}
86
87void DebugGeneralWidget::on_chkOnlyMono_stateChanged(int)
88{
89 if (ui->chkOnlyMono->isChecked()) {
90 ui->cbFont->setFontFilters(QFontComboBox::FontFilter::MonospacedFonts);
91 } else {
92 ui->cbFont->setFontFilters(QFontComboBox::FontFilter::AllFonts);
93 }
94}
95