Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
logic: remember graph zoom level on restart (issue #801) (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
miltolstoy authored Oct 23, 2020
1 parent a37681e commit ad9d8d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/lib/settings/ApplicationSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,16 @@ void ApplicationSettings::setLastFilepickerLocation(const FilePath& path)
setValue<std::wstring>("user/last_filepicker_location", path.wstr());
}

float ApplicationSettings::getGraphZoomLevel() const
{
return getValue<float>("user/graph_zoom_level", 1.0f);
}

void ApplicationSettings::setGraphZoomLevel(float zoomLevel)
{
setValue<float>("user/graph_zoom_level", zoomLevel);
}

int ApplicationSettings::getPluginPort() const
{
return getValue<int>("network/plugin_port", 6666);
Expand Down
3 changes: 3 additions & 0 deletions src/lib/settings/ApplicationSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ class ApplicationSettings: public Settings
FilePath getLastFilepickerLocation() const;
void setLastFilepickerLocation(const FilePath& path);

float getGraphZoomLevel() const;
void setGraphZoomLevel(float zoomLevel);

// network
int getPluginPort() const;
void setPluginPort(const int pluginPort);
Expand Down
6 changes: 5 additions & 1 deletion src/lib_gui/qt/graphics/QtGraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
QtGraphicsView::QtGraphicsView(GraphFocusHandler* focusHandler, QWidget* parent)
: QGraphicsView(parent)
, m_focusHandler(focusHandler)
, m_zoomFactor(1.0f)
, m_zoomFactor(ApplicationSettings::getInstance()->getGraphZoomLevel())
, m_appZoomFactor(1.0f)
, m_zoomInButtonSpeed(20.0f)
, m_zoomOutButtonSpeed(-20.0f)
Expand Down Expand Up @@ -835,6 +835,10 @@ void QtGraphicsView::setZoomFactor(float zoomFactor)
{
m_zoomFactor = zoomFactor;

std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
settings->setGraphZoomLevel(zoomFactor);
settings->save();

m_zoomState->setText(QString::number(int(m_zoomFactor * 100)) + "%");
updateTransform();

Expand Down

0 comments on commit ad9d8d7

Please sign in to comment.