diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index e359d318..afb332bf 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -2395,19 +2395,7 @@ bool QtWindow::eventFilter(QObject* obj, QEvent* event) } else if (prop == s_propWindowFlags) { QWidget* wid = (name == m_id || name == m_oldId) ? this : w.widget(); - // Set window flags from enclosed widget: - // custom window title/border/sysmenu config - ObjList* f = value.split(',',false); - int flags = Qt::CustomizeWindowHint | wid->windowFlags(); - // Clear settable flags - TokenDict* dict = s_windowFlags; - for (int i = 0; dict[i].token; i++) - flags &= ~dict[i].value; - // Set flags - for (ObjList* o = f->skipNull(); o; o = o->skipNext()) - flags |= lookup(o->get()->toString(),s_windowFlags,0); - TelEngine::destruct(f); - wid->setWindowFlags((Qt::WindowFlags)flags); + QtClient::applyWindowFlags(wid,value); } else if (prop == s_propHHeader) { // Show/hide the horizontal header @@ -3062,8 +3050,19 @@ bool QtDialog::show(const String& name, const String& title, const String& alias else QtClient::connectObjects(actions[i],SIGNAL(toggled(bool)),w,SLOT(toggled(bool))); } - if (params) + String* flags = 0; + String tmp; + QtClient::getProperty(widget,s_propWindowFlags,tmp); + if (tmp) + flags = &tmp; + if (params) { + if (!flags) + flags = params->getParam(s_propWindowFlags); + m_closable = params->getBoolValue("closable","true"); w->setParams(*params); + } + if (flags) + QtClient::applyWindowFlags(this,*flags); setWindowModality(Qt::WindowModal); QDialog::show(); return true; @@ -3088,13 +3087,19 @@ void QtDialog::action() // Delete the dialog void QtDialog::closeEvent(QCloseEvent* event) { - QDialog::closeEvent(event); - deleteLater(); + if (m_closable) { + QDialog::closeEvent(event); + deleteLater(); + } + else + event->ignore(); } // Destroy the dialog void QtDialog::reject() { + if (!m_closable) + return; QDialog::reject(); deleteLater(); } @@ -3858,6 +3863,26 @@ void QtClient::intList2str(String& str, QList list) str.append(String(list[i]),","); } +// Apply a comma separated list of window flags to a widget +void QtClient::applyWindowFlags(QWidget* w, const String& value) +{ + if (!w) + return; + // Set window flags from enclosed widget: + // custom window title/border/sysmenu config + ObjList* f = value.split(',',false); + int flags = Qt::CustomizeWindowHint | w->windowFlags(); + // Clear settable flags + TokenDict* dict = s_windowFlags; + for (int i = 0; dict[i].token; i++) + flags &= ~dict[i].value; + // Set flags + for (ObjList* o = f->skipNull(); o; o = o->skipNext()) + flags |= lookup(o->get()->toString(),s_windowFlags,0); + TelEngine::destruct(f); + w->setWindowFlags((Qt::WindowFlags)flags); +} + /** * QtDriver diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index 8e32e84e..d11db25f 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -474,6 +474,13 @@ public: */ static void intList2str(String& str, QList list); + /** + * Apply a comma separated list of window flags to a widget + * @param wid The widget + * @param str The list of flags + */ + static void applyWindowFlags(QWidget* w, const String& value); + protected: virtual void loadWindows(const char* file = 0); private: @@ -817,7 +824,7 @@ public: * @param parent Parent widget */ inline QtDialog(QWidget* parent) - : QDialog(parent) + : QDialog(parent), m_closable(true) {} /** @@ -883,6 +890,7 @@ protected: String m_notifyOnClose; // Action to notify when closed QString m_context; // Dialog context + bool m_closable; // Allow the dialog to be closed by the user }; /**