Save and restore Magnet Tool's Size setting

This commit is contained in:
manongjohn 2023-09-23 12:37:57 -04:00
parent 4712c37d55
commit 88210e5f2e

View file

@ -11,11 +11,14 @@
#include "tproperty.h" #include "tproperty.h"
#include "drawutil.h" #include "drawutil.h"
#include "tcurveutil.h" #include "tcurveutil.h"
#include "tenv.h"
#include "toonz/tobjecthandle.h" #include "toonz/tobjecthandle.h"
#include "toonz/txshlevelhandle.h" #include "toonz/txshlevelhandle.h"
#include "toonz/tstageobject.h" #include "toonz/tstageobject.h"
TEnv::IntVar MagnetSize("MagnetToolSize", 20);
using namespace ToolUtils; using namespace ToolUtils;
// For Qt translation support // For Qt translation support
@ -109,7 +112,7 @@ void drawQuadratic(const TQuadratic &quad, double pixelSize) {
class MagnetTool final : public TTool { class MagnetTool final : public TTool {
Q_DECLARE_TR_FUNCTIONS(MagnetTool) Q_DECLARE_TR_FUNCTIONS(MagnetTool)
bool m_active; bool m_active, m_firstTime;
TPointD m_startingPos; TPointD m_startingPos;
@ -438,6 +441,10 @@ lefrightButtonDown(p);
} }
void onActivate() override { void onActivate() override {
if (!m_firstTime) {
m_firstTime = true;
m_toolSize.setValue(MagnetSize);
}
// getApplication()->editImageOrSpline(); // getApplication()->editImageOrSpline();
} }
@ -451,6 +458,7 @@ lefrightButtonDown(p);
bool onPropertyChanged(std::string propertyName) override { bool onPropertyChanged(std::string propertyName) override {
if (propertyName == m_toolSize.getName()) { if (propertyName == m_toolSize.getName()) {
MagnetSize = m_toolSize.getValue();
invalidate(); invalidate();
} }