Skip to content

Commit

Permalink
fixed state save in QuickNote plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolcha committed Sep 10, 2024
1 parent e4f748c commit fe29596
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions plugins/quick_note/quick_note_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ void DoubleClickWidget::mouseDoubleClickEvent(QMouseEvent* event)
}


void QuickNotePlugin::initState(StateClient* st)
{
_state = st;
loadState(*st);
}

void QuickNotePlugin::saveState(StateClient& st) const
{
st.setValue("last_text", _last_text);
Expand Down Expand Up @@ -80,6 +86,7 @@ void QuickNotePlugin::onWidgetClicked()
QLineEdit::Normal, _last_text, &ok);
if (ok && !str.isEmpty()) {
_last_text = str;
_state->setValue("last_text", str);
_widget->setText(std::move(str));
}
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/quick_note/quick_note_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class QuickNotePlugin : public WidgetPluginBase
Q_OBJECT

public:
void initState(StateClient* st) override;
void saveState(StateClient& st) const override;
void loadState(const StateClient& st) override;

Expand All @@ -27,6 +28,7 @@ private slots:

private:
QString _last_text;
StateClient* _state = nullptr;
std::shared_ptr<GraphicsTextWidget> _widget;
};

Expand Down

0 comments on commit fe29596

Please sign in to comment.