Skip to content

Commit

Permalink
DisassemblerHooks: Added Clear Recent Files (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dax89 committed Aug 8, 2021
1 parent 7f4100a commit 44e0ec3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions hooks/disassemblerhooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ void DisassemblerHooks::loadRecents()
this->load(action->data().toString());
});
}

if(recents.empty()) return;

mnurecents->addSeparator();
QAction* action = mnurecents->addAction("Clear");

connect(action, &QAction::triggered, this, [=]() {
this->clearRecents();
});
}

void DisassemblerHooks::clearRecents()
{
REDasmSettings settings;
settings.clearRecentFiles();
this->loadRecents();

if(!m_disassemblerdocks) this->close(true); // Recreate Welcome Tab
}

void DisassemblerHooks::load(const QString& filepath)
Expand Down
1 change: 1 addition & 0 deletions hooks/disassemblerhooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class DisassemblerHooks: public QObject
void showLoaders(const QString& filepath, RDBuffer* buffer);
void showWelcome();
void loadRecents();
void clearRecents();
void hook();

private:
Expand Down
1 change: 1 addition & 0 deletions redasmsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ void REDasmSettings::saveState(const QMainWindow *mainwindow)
this->setValue(CURRENT_WINDOW_STATE, mainwindow->saveState());
}

void REDasmSettings::clearRecentFiles() { this->setValue("recent_files", QStringList()); }
QStringList REDasmSettings::recentFiles() const { return this->value("recent_files").toStringList(); }

void REDasmSettings::updateRecentFiles(const QString &s)
Expand Down
1 change: 1 addition & 0 deletions redasmsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class REDasmSettings : public QSettings
bool restoreState(QMainWindow* mainwindow);
void defaultState(QMainWindow* mainwindow);
void saveState(const QMainWindow* mainwindow);
void clearRecentFiles();
void updateRecentFiles(const QString& s = QString());
void changeTheme(const QString& theme);
void changeFont(const QFont &font);
Expand Down

0 comments on commit 44e0ec3

Please sign in to comment.