Skip to content
Browse files

Notepad plugin: Resize correctly after edit mode

Thanks to Patrik Bachan for investigating (#529)
  • Loading branch information...
1 parent ac6626f commit c08d204ebc68047ad94fc94897b55b247ae5fcdb @amoskvin amoskvin committed Jan 8, 2013
View
1 razorqt-desktop/desktop-razor/plugin-notepad/CMakeLists.txt
@@ -14,6 +14,7 @@ set(HW_SOURCES
)
set(HW_MOCS
+ notepad.h
notepadwin.h
)
View
24 razorqt-desktop/desktop-razor/plugin-notepad/notepad.cpp
@@ -43,12 +43,14 @@ Notepad::Notepad(DesktopScene *scene, const QString &configId, RazorSettings *co
int pos = m_config->value("pos", 0).toInt();
m_config->endGroup();
- m_proxy = new QGraphicsProxyWidget(this);
- win = new NotepadWin(this, &Notepad::save);
- win->setTextAndPos(text, pos);
+ mProxy = new QGraphicsProxyWidget(this);
+ mWin = new NotepadWin(this, &Notepad::save);
+ mWin->setTextAndPos(text, pos);
- m_proxy->setWidget(win);
- m_proxy->show();
+ mProxy->setWidget(mWin);
+ mProxy->show();
+
+ connect(this, SIGNAL(pluginResized(QSizeF)), SLOT(setSize(QSizeF)));
}
Notepad::~Notepad()
@@ -65,10 +67,16 @@ QString Notepad::instanceInfo()
return QObject::tr("Notepad:") + " " + m_configId;
}
+void Notepad::setSize(const QSizeF &size)
+{
+ mWin->resize(size.width(), size.height());
+ mProxy->resize(size);
+}
+
void Notepad::setSizeAndPosition(const QPointF &position, const QSizeF &size)
{
DesktopWidgetPlugin::setSizeAndPosition(position, size);
- m_proxy->resize(size);
+ setSize(size);
}
void Notepad::save()
@@ -79,8 +87,8 @@ void Notepad::save()
m_config->setValue("y", pos().y());
m_config->setValue("w", m_boundingRect.width());
m_config->setValue("h", m_boundingRect.height());
- m_config->setValue("text", win->text());
- m_config->setValue("pos", win->pos());
+ m_config->setValue("text", mWin->text());
+ m_config->setValue("pos", mWin->pos());
m_config->endGroup();
}
View
10 razorqt-desktop/desktop-razor/plugin-notepad/notepad.h
@@ -38,8 +38,7 @@
class Notepad : public DesktopWidgetPlugin
{
- NotepadWin *win;
- QGraphicsProxyWidget * m_proxy;
+ Q_OBJECT
public:
Notepad(DesktopScene *scene, const QString &configId, RazorSettings *config);
~Notepad();
@@ -50,6 +49,13 @@ class Notepad : public DesktopWidgetPlugin
void setSizeAndPosition(const QPointF &position, const QSizeF &size);
void save();
void configure();
+
+private slots:
+ void setSize(const QSizeF &size);
+
+private:
+ NotepadWin *mWin;
+ QGraphicsProxyWidget *mProxy;
};
EXPORT_RAZOR_DESKTOP_WIDGET_PLUGIN_H
View
1 razorqt-desktop/desktop-razor/plugin-notepad/notepadwin.h
@@ -85,7 +85,6 @@ class NotepadWin : public QWidget
private slots:
void save();
-public slots:
void onSelectionChanged();
void setBold();
void setItalic();

0 comments on commit c08d204

Please sign in to comment.
Something went wrong with that request. Please try again.