Skip to content

Commit a516809

Browse files
committed
feat(qt): add /clearhistory command
1 parent eeb9cc1 commit a516809

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/qt/rpcconsole.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,23 @@ void RPCConsole::WriteCommandHistory()
691691
settings.endArray();
692692
}
693693

694+
void RPCConsole::ClearCommandHistory()
695+
{
696+
// Overwrite existing history entries with dummy data before clearing
697+
for (int i = 0; i < history.size(); ++i) {
698+
history[i] = QString(history[i].size(), 'x');
699+
}
700+
WriteCommandHistory();
701+
702+
// Clear the history list
703+
history.clear();
704+
historyPtr = 0;
705+
cmdBeforeBrowsing.clear();
706+
707+
// Write empty history to settings
708+
WriteCommandHistory();
709+
}
710+
694711
RPCConsole::~RPCConsole()
695712
{
696713
QSettings settings;
@@ -1182,6 +1199,26 @@ void RPCConsole::on_lineEdit_returnPressed()
11821199
return;
11831200
}
11841201

1202+
// Special command to clear command history
1203+
if (cmd == QLatin1String("/clearhistory")) {
1204+
QMessageBox::StandardButton reply = QMessageBox::question(this,
1205+
tr("Clear Command History"),
1206+
tr("This will permanently clear your command history and console output.<br><br>"
1207+
"While this action is irreversible, complete removal from memory and disk "
1208+
"cannot be guaranteed due to system limitations.<br><br>"
1209+
"Are you sure you want to proceed?"),
1210+
QMessageBox::Yes | QMessageBox::No,
1211+
QMessageBox::No);
1212+
1213+
if (reply == QMessageBox::Yes) {
1214+
ClearCommandHistory();
1215+
clear(false); // Clear console output too
1216+
message(CMD_REPLY, tr("Command history and console output cleared."));
1217+
}
1218+
ui->lineEdit->clear();
1219+
return;
1220+
}
1221+
11851222
if (m_is_executing) {
11861223
return;
11871224
}

src/qt/rpcconsole.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ public Q_SLOTS:
166166
void startExecutor();
167167
void setTrafficGraphRange(int mins);
168168
void WriteCommandHistory();
169+
void ClearCommandHistory();
169170

170171
enum ColumnWidths
171172
{

0 commit comments

Comments
 (0)