Allow window flags to be specified for dialogs. Added optional dialog closable flag to prevent a dialog to be closed by the user.
git-svn-id: http://yate.null.ro/svn/yate/trunk@3948 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
70ed9ca5cd
commit
c3154dff79
|
@ -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<int> 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
|
||||
|
|
|
@ -474,6 +474,13 @@ public:
|
|||
*/
|
||||
static void intList2str(String& str, QList<int> 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
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue