diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index d8b9bf83..2f85c1c3 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -447,6 +447,20 @@ static const TokenDict s_qVarType[] = { {0,0} }; +// Qt alignment flags translation +static const TokenDict s_qAlign[] = { + {"left", Qt::AlignLeft}, + {"right", Qt::AlignRight}, + {"hcenter", Qt::AlignHCenter}, + {"justify", Qt::AlignJustify}, + {"top", Qt::AlignTop}, + {"bottom", Qt::AlignBottom}, + {"vcenter", Qt::AlignVCenter}, + {"center", Qt::AlignCenter}, + {"absolute", Qt::AlignAbsolute}, + {0,0} +}; + // Handler for QT library messages static void qtMsgHandler(QtMsgType type, const char* text) { @@ -2827,6 +2841,12 @@ void QtWindow::doInit() // Stretch last column bool b = QtClient::getBoolProperty(tables[i],"_yate_horizontalstretch",true); hdr->setStretchLastSection(b); + String tmp; + QtClient::getProperty(tables[i],"_yate_horizontalheader_align",tmp); + if (tmp) { + int def = hdr->defaultAlignment(); + hdr->setDefaultAlignment((Qt::Alignment)QtClient::str2align(tmp,def)); + } if (!QtClient::getBoolProperty(tables[i],"_yate_horizontalheader",true)) hdr->hide(); // Vertical header @@ -3904,6 +3924,22 @@ void QtClient::applyWindowFlags(QWidget* w, const String& value) w->setWindowFlags((Qt::WindowFlags)flags); } +// Build a QT Alignment mask from a comma separated list of flags +int QtClient::str2align(const String& flags, int initVal) +{ + ObjList* list = flags.split(',',false); + for (ObjList* o = list->skipNull(); o; o = o->skipNext()) { + int val = ::lookup((static_cast(o->get()))->c_str(),s_qAlign); + if (0 != (val & Qt::AlignHorizontal_Mask)) + initVal &= ~Qt::AlignHorizontal_Mask; + if (0 != (val & Qt::AlignVertical_Mask)) + initVal &= ~Qt::AlignVertical_Mask; + initVal |= val; + } + TelEngine::destruct(list); + return initVal; +} + /** * QtDriver diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index d11db25f..06b15da1 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -481,6 +481,14 @@ public: */ static void applyWindowFlags(QWidget* w, const String& value); + /** + * Build a QT Alignment mask from a comma separated list of flags + * @param flags The flags list + * @param initVal Initial value for the returned mask + * @return QT Alignment mask + */ + static int str2align(const String& flags, int initVal = 0); + protected: virtual void loadWindows(const char* file = 0); private: