mirror of
https://github.com/epasveer/seer.git
synced 2026-08-29 08:34:42 +08:00
Merge pull request #425 from epasveer/421-add-a-hot-key-for-restart
421 add a hot key for restart
This commit is contained in:
+33
-5
@@ -1452,12 +1452,40 @@ void SeerGdbWidget::handleGdbTerminateExecutable (bool confirm) {
|
||||
if (isGdbRuning() == true) {
|
||||
|
||||
if (confirm) {
|
||||
int result = QMessageBox::warning(this, "Seer",
|
||||
QString("Terminate current session?"),
|
||||
QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Cancel);
|
||||
|
||||
if (result == QMessageBox::Cancel) {
|
||||
break;
|
||||
QSettings settings;
|
||||
bool prompt = true;
|
||||
|
||||
settings.beginGroup("mainwindow"); {
|
||||
prompt = settings.value("promptterminate", prompt).toBool();
|
||||
} settings.endGroup();
|
||||
|
||||
if (prompt) {
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle("Seer");
|
||||
msgBox.setText("Terminate current session?");
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
|
||||
// Add "Don't ask again" checkbox
|
||||
QCheckBox* dontAskAgainBox = new QCheckBox("Don't ask again", &msgBox);
|
||||
msgBox.setCheckBox(dontAskAgainBox);
|
||||
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
|
||||
int result = msgBox.exec();
|
||||
|
||||
// Save preference if checked
|
||||
if (dontAskAgainBox->isChecked()) {
|
||||
settings.beginGroup("mainwindow"); {
|
||||
settings.setValue("promptterminate", false);
|
||||
} settings.endGroup();
|
||||
}
|
||||
|
||||
if (result == QMessageBox::Cancel) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,8 @@ SeerKeySettings SeerKeySettings::populate () {
|
||||
keySettings.add("Stepi", SeerKeySetting("Stepi", QKeySequence::fromString("Ctrl+F6"), "Execute the next instruction. Step into functions."));
|
||||
keySettings.add("Finish", SeerKeySetting("Finish", QKeySequence::fromString("F7"), "Finish the current function."));
|
||||
keySettings.add("Interrupt", SeerKeySetting("Interrupt", QKeySequence::fromString("Ctrl+I"), "Interrupt the executing program."));
|
||||
keySettings.add("Terminate", SeerKeySetting("Terminate", QKeySequence::fromString("Alt+T"), "Terminate the debugging session."));
|
||||
keySettings.add("Restart", SeerKeySetting("Restart", QKeySequence::fromString("Alt+R"), "Restart the debugging session."));
|
||||
keySettings.add("Debug", SeerKeySetting("Debug", QKeySequence::fromString("Alt+D"), "Open the debug dialog."));
|
||||
keySettings.add("Arguments", SeerKeySetting("Arguments", QKeySequence::fromString("Alt+A"), "Open the argument dialog."));
|
||||
keySettings.add("Quit", SeerKeySetting("Quit", QKeySequence::fromString("Alt+Q"), "Quit Seer."));
|
||||
@@ -78,7 +80,6 @@ SeerKeySettings SeerKeySettings::populate () {
|
||||
keySettings.add("SearchLine", SeerKeySetting("SearchLine", QKeySequence::fromString("Ctrl+L"), "Seach for line number in the code editor."));
|
||||
keySettings.add("AlternateDir", SeerKeySetting("AlternateDir", QKeySequence::fromString("Ctrl+O"), "Look for source file in an alternate directory."));
|
||||
keySettings.add("ToggleBreakpoint", SeerKeySetting("ToggleBreakpoint", QKeySequence::fromString("Ctrl+B"), "Toggle the breakpoint status of current line."));
|
||||
|
||||
keySettings.add("ToggleRecordDirection", SeerKeySetting("ToggleRecordDirection", QKeySequence::fromString("Ctrl+D"), "Toggle the record playback direction."));
|
||||
keySettings.add("ReverseContinue", SeerKeySetting("ReverseContinue", QKeySequence::fromString("Shift+F8"), "Continue execution of the program in reverse."));
|
||||
keySettings.add("ReverseNext", SeerKeySetting("ReverseNext", QKeySequence::fromString("Shift+F5"), "Execute the previous line. Step over functions."));
|
||||
|
||||
+58
-10
@@ -451,8 +451,8 @@ void SeerMainWindow::launchExecutable (const QString& launchMode, const QString&
|
||||
actionGdbTerminate->setVisible(false);
|
||||
actionGdbLaunch->setVisible(false);
|
||||
|
||||
actionControlRestart->setVisible(false);
|
||||
actionControlTerminate->setVisible(false);
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlTerminate->setVisible(true);
|
||||
actionControlInterrupt->setVisible(true);
|
||||
|
||||
if (launchMode == "run") {
|
||||
@@ -860,6 +860,48 @@ void SeerMainWindow::handleTerminateExecutable () {
|
||||
|
||||
void SeerMainWindow::handleRestartExecutable () {
|
||||
|
||||
// Prompt if there's already a gdb running.
|
||||
if (gdbWidget->isGdbRuning() == true) {
|
||||
|
||||
QSettings settings;
|
||||
bool prompt = true;
|
||||
|
||||
settings.beginGroup("mainwindow"); {
|
||||
prompt = settings.value("promptrestart", prompt).toBool();
|
||||
} settings.endGroup();
|
||||
|
||||
if (prompt) {
|
||||
|
||||
// This QMessageBox with a checkbox and load/save from QSettings
|
||||
// is begging for a helper object!
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle("Seer");
|
||||
msgBox.setText("Restart current session?");
|
||||
msgBox.setIcon(QMessageBox::Question);
|
||||
|
||||
// Add "Don't ask again" checkbox
|
||||
QCheckBox* dontAskAgainBox = new QCheckBox("Don't ask again", &msgBox);
|
||||
msgBox.setCheckBox(dontAskAgainBox);
|
||||
|
||||
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
|
||||
int result = msgBox.exec();
|
||||
|
||||
// Save preference if checked
|
||||
if (dontAskAgainBox->isChecked()) {
|
||||
settings.beginGroup("mainwindow"); {
|
||||
settings.setValue("promptrestart", false);
|
||||
} settings.endGroup();
|
||||
}
|
||||
|
||||
if (result == QMessageBox::Cancel) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gdbWidget->isGdbRuning() == false && gdbWidget->hasBackupLaunchMode()) {
|
||||
gdbWidget->restoreLaunchMode();
|
||||
}
|
||||
@@ -939,7 +981,8 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
// Launch and Restart. Applies to all.
|
||||
actionGdbLaunch->setVisible(false);
|
||||
actionGdbRestart->setVisible(false);
|
||||
actionControlRestart->setVisible(false);
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlTerminate->setVisible(true);
|
||||
|
||||
// Run mode
|
||||
if (gdbWidget->executableLaunchMode() == "run" || gdbWidget->executableLaunchMode() == "start" ||
|
||||
@@ -948,7 +991,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbTerminate->setVisible(true);
|
||||
actionGdbTerminate->setText("Terminate");
|
||||
actionGdbTerminate->setToolTip("Terminate the current debugging session.");
|
||||
actionControlTerminate->setVisible(true);
|
||||
actionControlTerminate->setText("Terminate");
|
||||
actionControlTerminate->setToolTip("Terminate the current debugging session.");
|
||||
|
||||
@@ -958,7 +1000,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbTerminate->setVisible(true);
|
||||
actionGdbTerminate->setText("Detach");
|
||||
actionGdbTerminate->setToolTip("Detach from the current debugging session.");
|
||||
actionControlTerminate->setVisible(true);
|
||||
actionControlTerminate->setText("Detach");
|
||||
actionControlTerminate->setToolTip("Detach from the current debugging session.");
|
||||
|
||||
@@ -968,7 +1009,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbTerminate->setVisible(true);
|
||||
actionGdbTerminate->setText("Disconnect");
|
||||
actionGdbTerminate->setToolTip("Disconnect from the current debugging session.");
|
||||
actionControlTerminate->setVisible(true);
|
||||
actionControlTerminate->setText("Disconnect");
|
||||
actionControlTerminate->setToolTip("Disconnect from the current debugging session.");
|
||||
|
||||
@@ -993,7 +1033,8 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
|
||||
// Hide terminate. Applies to all.
|
||||
actionGdbTerminate->setVisible(false);
|
||||
actionControlTerminate->setVisible(false);
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlTerminate->setVisible(true);
|
||||
|
||||
if (gdbWidget->backupLaunchMode() == "run" || gdbWidget->backupLaunchMode() == "start" ||
|
||||
gdbWidget->backupLaunchMode() == "rr" || gdbWidget->backupLaunchMode() == "corefile") {
|
||||
@@ -1001,7 +1042,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbRestart->setVisible(true);
|
||||
actionGdbRestart->setText("Restart");
|
||||
actionGdbRestart->setToolTip("Restart the current debugging session.");
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlRestart->setText("Restart");
|
||||
actionControlRestart->setToolTip("Restart the current debugging session.");
|
||||
|
||||
@@ -1009,7 +1049,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbRestart->setVisible(true);
|
||||
actionGdbRestart->setText("Reattach");
|
||||
actionGdbRestart->setToolTip("Reattach the current debugging session.");
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlRestart->setText("Reattach");
|
||||
actionControlRestart->setToolTip("Reattach the current debugging session.");
|
||||
|
||||
@@ -1017,7 +1056,6 @@ void SeerMainWindow::handleGdbStateChanged () {
|
||||
actionGdbRestart->setVisible(true);
|
||||
actionGdbRestart->setText("Reconnect");
|
||||
actionGdbRestart->setToolTip("Reconnect the current debugging session.");
|
||||
actionControlRestart->setVisible(true);
|
||||
actionControlRestart->setText("Reconnect");
|
||||
actionControlRestart->setToolTip("Reconnect the current debugging session.");
|
||||
|
||||
@@ -1778,6 +1816,7 @@ const SeerKeySettings SeerMainWindow::keySettings () const {
|
||||
void SeerMainWindow::refreshShortCuts () {
|
||||
|
||||
// Dynamically change tool tip for 'Restart' depending on debug mode.
|
||||
|
||||
if (_keySettings.has("Restart")) {
|
||||
|
||||
SeerKeySetting setting = _keySettings.get("Restart");
|
||||
@@ -1787,6 +1826,15 @@ void SeerMainWindow::refreshShortCuts () {
|
||||
actionControlRestart->setShortcut(setting._sequence);
|
||||
}
|
||||
|
||||
if (_keySettings.has("Terminate")) {
|
||||
|
||||
SeerKeySetting setting = _keySettings.get("Terminate");
|
||||
|
||||
actionGdbTerminate->setToolTip(setting._description);
|
||||
actionGdbTerminate->setText(setting._action + " (" + setting._sequence.toString() + ")");
|
||||
actionControlTerminate->setShortcut(setting._sequence);
|
||||
}
|
||||
|
||||
if (_keySettings.has("Next")) {
|
||||
|
||||
SeerKeySetting setting = _keySettings.get("Next");
|
||||
|
||||
@@ -336,10 +336,13 @@
|
||||
<normaloff>:/seer/resources/RelaxLightIcons/view-refresh.svg</normaloff>:/seer/resources/RelaxLightIcons/view-refresh.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Restart the debugging session</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Start the program in GDB. Honor breakpoints, if any.</string>
|
||||
<string>Restart the debugging session. Honor breakpoints, if any.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionControlContinue">
|
||||
@@ -716,13 +719,13 @@
|
||||
<normaloff>:/seer/resources/RelaxLightIcons/system-shutdown.svg</normaloff>:/seer/resources/RelaxLightIcons/system-shutdown.svg</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Terminate</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
<string>Terminate the debugging session</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string/>
|
||||
<string>Terminate the debugging session.</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::NoRole</enum>
|
||||
|
||||
@@ -110,4 +110,5 @@ int main() {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user