logic: remember graph zoom level on restart (issue #801) (#1099)

This commit is contained in:
miltolstoy
2020-10-23 19:25:44 +02:00
committed by GitHub
parent a37681e58b
commit ad9d8d7930
3 changed files with 18 additions and 1 deletions
+10
View File
@@ -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);
+3
View File
@@ -181,6 +181,9 @@ public:
FilePath getLastFilepickerLocation() const;
void setLastFilepickerLocation(const FilePath& path);
float getGraphZoomLevel() const;
void setGraphZoomLevel(float zoomLevel);
// network
int getPluginPort() const;
void setPluginPort(const int pluginPort);
+5 -1
View File
@@ -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)
@@ -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();