diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index b2deb45d..c5ff206b 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -1948,6 +1948,17 @@ bool QtWindow::removeMenu(const NamedList& params) return true; } +// Set an element's image +bool QtWindow::setImage(const String& name, const String& image) +{ + if (!name) + return false; + if (name == m_id) + return QtClient::setImage(this,image); + QObject* obj = qFindChild(wndWidget(),QtClient::setUtf8(name)); + return obj && QtClient::setImage(obj,image); +} + // Set a property for this window or for a widget owned by it bool QtWindow::setProperty(const String& name, const String& item, const String& value) { diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index 2dc8e036..8754ffbb 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -514,6 +514,14 @@ public: */ virtual bool removeMenu(const NamedList& params); + /** + * Set an element's image + * @param name Name of the element + * @param image Image to set + * @return True on success + */ + virtual bool setImage(const String& name, const String& image); + /** * Set a property for this window or for a widget owned by it * @param name Name of the element diff --git a/engine/Client.cpp b/engine/Client.cpp index 6a00b019..de319158 100644 --- a/engine/Client.cpp +++ b/engine/Client.cpp @@ -66,6 +66,7 @@ public: createObject, buildMenu, removeMenu, + setImage, setProperty, getProperty, openUrl @@ -401,6 +402,8 @@ bool Window::setParams(const NamedList& params) ok = setCheck(n,s->toBoolean()) && ok; else if (n.startSkip("select:",false)) ok = setSelect(n,*s) && ok; + else if (n.startSkip("image:",false)) + ok = setImage(n,*s) && ok; else if (n.startSkip("property:",false)) { // Set property: object_name:property_name=value int pos = n.find(':'); @@ -753,6 +756,9 @@ void ClientThreadProxy::process() case removeMenu: m_rval = m_params && client->removeMenu(*m_params,m_wnd,m_skip); break; + case setImage: + m_rval = client->setImage(m_name,m_text,m_wnd,m_skip); + break; case setProperty: m_rval = client->setProperty(m_name,m_item,m_text,m_wnd,m_skip); break; @@ -1733,6 +1739,28 @@ bool Client::removeMenu(const NamedList& params, Window* wnd, Window* skip) return ok; } +// Set an element's image +bool Client::setImage(const String& name, const String& image, Window* wnd, Window* skip) +{ + if (!valid()) + return false; + if (needProxy()) { + ClientThreadProxy proxy(ClientThreadProxy::setImage,name,image,wnd,skip); + return proxy.execute(); + } + if (wnd) + return wnd->setImage(name,image); + ++s_changing; + bool ok = false; + for (ObjList* o = m_windows.skipNull(); o; o = o->skipNext()) { + wnd = static_cast(o->get()); + if (wnd != skip) + ok = wnd->setImage(name,image) || ok; + } + --s_changing; + return ok; +} + // Set a property bool Client::setProperty(const String& name, const String& item, const String& value, Window* wnd, Window* skip) diff --git a/yatecbase.h b/yatecbase.h index 75e774f5..a1549d86 100644 --- a/yatecbase.h +++ b/yatecbase.h @@ -344,6 +344,14 @@ public: */ virtual bool removeMenu(const NamedList& params) = 0; + /** + * Set an element's image + * @param name Name of the element + * @param image Image to set + * @return True on success + */ + virtual bool setImage(const String& name, const String& image) = 0; + /** * Set a property for this window or for a widget owned by it * @param name Name of the element @@ -1150,6 +1158,17 @@ public: */ bool removeMenu(const NamedList& params, Window* wnd = 0, Window* skip = 0); + /** + * Set an element's image + * @param name Name of the element + * @param image Image to set + * @param wnd Optional target window + * @param skip Optional window to skip if wnd is 0 + * @return True on success + */ + virtual bool setImage(const String& name, const String& image, + Window* wnd = 0, Window* skip = 0); + /** * Set a property * @param name Name of the element