Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain file information when closing and reopening #176

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ Source/.vs/
Source/.vscode/
.vscode/
.idea/*
.DS_Store
.DS_Store
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what is .cache?

And, as always, these unrelated changes should at the very least have their own commit and description. Perhaps it can even have a dedicated PR to avoid getting the change blocked by other potentially controversial changes.

.cache
4 changes: 3 additions & 1 deletion Source/GUI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ MainWindow::MainWindow()
GUICommon::changeApplicationStyle(
static_cast<GUICommon::ApplicationStyle>(SConfig::getInstance().getTheme()));

m_watcher->setWatchFile(SConfig::getInstance().getWatchFile());
m_watcher->restoreWatchModel(SConfig::getInstance().getWatchModel());
m_actAutoHook->setChecked(SConfig::getInstance().getAutoHook());

Expand All @@ -63,7 +64,7 @@ void MainWindow::makeMenus()
m_actOpenWatchList = new QAction(tr("&Open..."), this);
m_actSaveWatchList = new QAction(tr("&Save"), this);
m_actSaveAsWatchList = new QAction(tr("&Save as..."), this);
m_actClearWatchList = new QAction(tr("&Clear the watch list"), this);
m_actClearWatchList = new QAction(tr("&Reset watch list"), this);
m_actImportFromCT = new QAction(tr("&Import from Cheat Engine's CT file..."), this);
m_actExportAsCSV = new QAction(tr("&Export as CSV..."), this);
QAction* const actOpenConfigDir{new QAction(tr("Open Configuration Directory..."), this)};
Expand Down Expand Up @@ -545,6 +546,7 @@ void MainWindow::onQuit()
void MainWindow::closeEvent(QCloseEvent* event)
{
SConfig::getInstance().setAutoHook(m_actAutoHook->isChecked());
SConfig::getInstance().setWatchFile(m_watcher->getWatchFile());
SConfig::getInstance().setWatchModel(m_watcher->saveWatchModel());
SConfig::getInstance().setMainWindowGeometry(saveGeometry());
SConfig::getInstance().setMainWindowState(saveState());
Expand Down
13 changes: 12 additions & 1 deletion Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void MemWatchWidget::onMemWatchContextMenuRequested(const QPoint& pos)
contextMenu->addSeparator();
}

if (!node || node->isGroup())
if (node == m_watchModel->getRootNode() || node->isGroup())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, this change (which relates to #175) should land in its own PR.

{
QAction* const addGroup{new QAction(tr("Add gro&up"), this)};
connect(addGroup, &QAction::triggered, this, &MemWatchWidget::onAddGroup);
Expand Down Expand Up @@ -853,6 +853,7 @@ void MemWatchWidget::clearWatchList()
return;

m_watchModel->clearRoot();
m_watchListFile = "";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid constructing another object for the sake of clearing the member:

- m_watchListFile = "";
+ m_watchListFile.clear();

}

void MemWatchWidget::importFromCTFile()
Expand Down Expand Up @@ -984,6 +985,16 @@ QString MemWatchWidget::saveWatchModel()
return saveDoc.toJson();
}

QString MemWatchWidget::getWatchFile() const
{
return m_watchListFile;
}

void MemWatchWidget::setWatchFile(const QString& path)
{
m_watchListFile = path;
}

void MemWatchWidget::updateExpansionState(const MemWatchTreeNode* const node)
{
QSignalBlocker signalBlocker(*m_watchView);
Expand Down
2 changes: 2 additions & 0 deletions Source/GUI/MemWatcher/MemWatchWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class MemWatchWidget : public QWidget
bool warnIfUnsavedChanges();
void restoreWatchModel(const QString& json);
QString saveWatchModel();
QString getWatchFile() const;
void setWatchFile(const QString& path);

signals:
void mustUnhook();
Expand Down
10 changes: 10 additions & 0 deletions Source/GUI/Settings/SConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ QString SConfig::getSettingsFilepath() const
return m_settings->fileName();
}

QString SConfig::getWatchFile() const
{
return value("watchFile", QString{}).toString();
}

QString SConfig::getWatchModel() const
{
return value("watchModel", QString{}).toString();
Expand Down Expand Up @@ -133,6 +138,11 @@ u32 SConfig::getMEM2Size() const
return value("memorySettings/MEM2Size", 64u * 1024 * 1024).toUInt();
}

void SConfig::setWatchFile(const QString& path)
{
setValue("watchFile", path);
}

void SConfig::setWatchModel(const QString& json)
{
setValue("watchModel", json);
Expand Down
2 changes: 2 additions & 0 deletions Source/GUI/Settings/SConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class SConfig
QByteArray getMainWindowState() const;
QByteArray getSplitterState() const;

QString getWatchFile() const;
QString getWatchModel() const;
bool getAutoHook() const;

Expand All @@ -47,6 +48,7 @@ class SConfig
void setMainWindowState(QByteArray const&);
void setSplitterState(QByteArray const&);

void setWatchFile(const QString& path);
void setWatchModel(const QString& json);
void setAutoHook(bool enabled);

Expand Down
Loading