xcb: implement and deprecate QWidget::setWindowIconText()
This is a little-used feature which only affects how minimized icons are displayed on certain older window managers, and is not necessary even then. It has not been implemented in Qt 5 until now. Task-number: QTBUG-44659 Change-Id: Ie6ead7a6f922878b349a096d905bf7f675dc2f31 Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
This commit is contained in:
parent
653bdcca8e
commit
8b0fcd8718
@ -150,7 +150,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
\value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent).
|
\value HoverLeave The mouse cursor leaves a hover widget (QHoverEvent).
|
||||||
\value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent).
|
\value HoverMove The mouse cursor moves inside a hover widget (QHoverEvent).
|
||||||
\value IconDrag The main icon of a window has been dragged away (QIconDragEvent).
|
\value IconDrag The main icon of a window has been dragged away (QIconDragEvent).
|
||||||
\value IconTextChange Widget's icon text has been changed.
|
\value IconTextChange Widget's icon text has been changed. (Deprecated)
|
||||||
\value InputMethod An input method is being used (QInputMethodEvent).
|
\value InputMethod An input method is being used (QInputMethodEvent).
|
||||||
\value InputMethodQuery A input method query event (QInputMethodQueryEvent)
|
\value InputMethodQuery A input method query event (QInputMethodQueryEvent)
|
||||||
\value KeyboardLayoutChange The keyboard layout has changed.
|
\value KeyboardLayoutChange The keyboard layout has changed.
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
EnabledChange = 98, // enabled state has changed
|
EnabledChange = 98, // enabled state has changed
|
||||||
ActivationChange = 99, // window activation has changed
|
ActivationChange = 99, // window activation has changed
|
||||||
StyleChange = 100, // style has changed
|
StyleChange = 100, // style has changed
|
||||||
IconTextChange = 101, // icon text has changed
|
IconTextChange = 101, // icon text has changed. Deprecated.
|
||||||
ModifiedChange = 102, // modified state has changed
|
ModifiedChange = 102, // modified state has changed
|
||||||
MouseTrackingChange = 109, // mouse tracking state has changed
|
MouseTrackingChange = 109, // mouse tracking state has changed
|
||||||
|
|
||||||
|
@ -69,6 +69,13 @@ public:
|
|||||||
return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
|
return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
|
||||||
|
static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
|
||||||
|
static void setWmWindowIconText(QWindow *window, const QString &text)
|
||||||
|
{
|
||||||
|
return QXcbFunctionsHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text);
|
||||||
|
}
|
||||||
|
|
||||||
typedef void (*SetParentRelativeBackPixmap)(const QWindow *window);
|
typedef void (*SetParentRelativeBackPixmap)(const QWindow *window);
|
||||||
static const QByteArray setParentRelativeBackPixmapIdentifier() { return QByteArrayLiteral("XcbSetParentRelativeBackPixmap"); }
|
static const QByteArray setParentRelativeBackPixmapIdentifier() { return QByteArrayLiteral("XcbSetParentRelativeBackPixmap"); }
|
||||||
static void setParentRelativeBackPixmap(const QWindow *window)
|
static void setParentRelativeBackPixmap(const QWindow *window)
|
||||||
|
@ -331,6 +331,9 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio
|
|||||||
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier())
|
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier())
|
||||||
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic));
|
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic));
|
||||||
|
|
||||||
|
if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier())
|
||||||
|
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic));
|
||||||
|
|
||||||
if (function == QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier())
|
if (function == QXcbWindowFunctions::setParentRelativeBackPixmapIdentifier())
|
||||||
return QFunctionPointer(QXcbWindowFunctions::SetParentRelativeBackPixmap(QXcbWindow::setParentRelativeBackPixmapStatic));
|
return QFunctionPointer(QXcbWindowFunctions::SetParentRelativeBackPixmap(QXcbWindow::setParentRelativeBackPixmapStatic));
|
||||||
|
|
||||||
|
@ -1393,10 +1393,22 @@ void QXcbWindow::setWindowTitle(const QString &title)
|
|||||||
xcb_flush(xcb_connection());
|
xcb_flush(xcb_connection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QXcbWindow::setWindowIconText(const QString &title)
|
||||||
|
{
|
||||||
|
const QByteArray ba = title.toUtf8();
|
||||||
|
Q_XCB_CALL(xcb_change_property(xcb_connection(),
|
||||||
|
XCB_PROP_MODE_REPLACE,
|
||||||
|
m_window,
|
||||||
|
atom(QXcbAtom::_NET_WM_ICON_NAME),
|
||||||
|
atom(QXcbAtom::UTF8_STRING),
|
||||||
|
8,
|
||||||
|
ba.length(),
|
||||||
|
ba.constData()));
|
||||||
|
}
|
||||||
|
|
||||||
void QXcbWindow::setWindowIcon(const QIcon &icon)
|
void QXcbWindow::setWindowIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
QVector<quint32> icon_data;
|
QVector<quint32> icon_data;
|
||||||
|
|
||||||
if (!icon.isNull()) {
|
if (!icon.isNull()) {
|
||||||
QList<QSize> availableSizes = icon.availableSizes();
|
QList<QSize> availableSizes = icon.availableSizes();
|
||||||
if (availableSizes.isEmpty()) {
|
if (availableSizes.isEmpty()) {
|
||||||
@ -1561,6 +1573,12 @@ void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmW
|
|||||||
window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes)));
|
window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text)
|
||||||
|
{
|
||||||
|
if (window->handle())
|
||||||
|
static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text);
|
||||||
|
}
|
||||||
|
|
||||||
QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
|
QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
|
||||||
{
|
{
|
||||||
QXcbWindowFunctions::WmWindowTypes result(0);
|
QXcbWindowFunctions::WmWindowTypes result(0);
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
|
QPoint mapFromGlobal(const QPoint &pos) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
|
void setWindowTitle(const QString &title) Q_DECL_OVERRIDE;
|
||||||
|
void setWindowIconText(const QString &title);
|
||||||
void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
|
void setWindowIcon(const QIcon &icon) Q_DECL_OVERRIDE;
|
||||||
void raise() Q_DECL_OVERRIDE;
|
void raise() Q_DECL_OVERRIDE;
|
||||||
void lower() Q_DECL_OVERRIDE;
|
void lower() Q_DECL_OVERRIDE;
|
||||||
@ -142,6 +143,8 @@ public:
|
|||||||
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
|
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
|
||||||
void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types);
|
void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types);
|
||||||
|
|
||||||
|
static void setWindowIconTextStatic(QWindow *window, const QString &text);
|
||||||
|
|
||||||
static void setParentRelativeBackPixmapStatic(QWindow *window);
|
static void setParentRelativeBackPixmapStatic(QWindow *window);
|
||||||
void setParentRelativeBackPixmap();
|
void setParentRelativeBackPixmap();
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@
|
|||||||
|
|
||||||
#include "qwindowcontainer_p.h"
|
#include "qwindowcontainer_p.h"
|
||||||
|
|
||||||
|
#include <QtPlatformHeaders/qxcbwindowfunctions.h>
|
||||||
|
|
||||||
// widget/widget data creation count
|
// widget/widget data creation count
|
||||||
//#define QWIDGET_EXTRA_DEBUG
|
//#define QWIDGET_EXTRA_DEBUG
|
||||||
@ -704,7 +705,7 @@ void QWidget::setAutoFillBackground(bool enabled)
|
|||||||
close().
|
close().
|
||||||
|
|
||||||
\row \li Top-level windows \li
|
\row \li Top-level windows \li
|
||||||
\l windowModified, \l windowTitle, \l windowIcon, \l windowIconText,
|
\l windowModified, \l windowTitle, \l windowIcon,
|
||||||
\l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
|
\l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
|
||||||
\l maximized, showMaximized(), \l fullScreen, showFullScreen(),
|
\l maximized, showMaximized(), \l fullScreen, showFullScreen(),
|
||||||
showNormal().
|
showNormal().
|
||||||
@ -5934,7 +5935,7 @@ void QWidget::unsetLocale()
|
|||||||
window title, if set. This is done by the QPA plugin, so it is shown to the
|
window title, if set. This is done by the QPA plugin, so it is shown to the
|
||||||
user, but isn't part of the windowTitle string.
|
user, but isn't part of the windowTitle string.
|
||||||
|
|
||||||
\sa windowIcon, windowIconText, windowModified, windowFilePath
|
\sa windowIcon, windowModified, windowFilePath
|
||||||
*/
|
*/
|
||||||
QString QWidget::windowTitle() const
|
QString QWidget::windowTitle() const
|
||||||
{
|
{
|
||||||
@ -6029,7 +6030,11 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title)
|
|||||||
|
|
||||||
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
|
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
|
||||||
{
|
{
|
||||||
Q_UNUSED(iconText);
|
Q_Q(QWidget);
|
||||||
|
// ### The QWidget property is deprecated, but the XCB window function is not.
|
||||||
|
// It should remain available for the rare application that needs it.
|
||||||
|
if (QWindow *window = q->windowHandle())
|
||||||
|
QXcbWindowFunctions::setWmWindowIconText(window, iconText);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -6039,6 +6044,9 @@ void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
|
|||||||
new \a iconText as an argument.
|
new \a iconText as an argument.
|
||||||
|
|
||||||
\since 5.2
|
\since 5.2
|
||||||
|
\obsolete
|
||||||
|
|
||||||
|
This signal is deprecated.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void QWidget::setWindowIconText(const QString &iconText)
|
void QWidget::setWindowIconText(const QString &iconText)
|
||||||
@ -6089,7 +6097,7 @@ void QWidget::setWindowTitle(const QString &title)
|
|||||||
has been set, windowIcon() returns the application icon
|
has been set, windowIcon() returns the application icon
|
||||||
(QApplication::windowIcon()).
|
(QApplication::windowIcon()).
|
||||||
|
|
||||||
\sa windowIconText, windowTitle
|
\sa windowTitle
|
||||||
*/
|
*/
|
||||||
QIcon QWidget::windowIcon() const
|
QIcon QWidget::windowIcon() const
|
||||||
{
|
{
|
||||||
@ -6149,10 +6157,15 @@ void QWidgetPrivate::setWindowIcon_sys()
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
\property QWidget::windowIconText
|
\property QWidget::windowIconText
|
||||||
\brief the widget's icon text
|
\brief the text to be displayed on the icon of a minimized window
|
||||||
|
|
||||||
This property only makes sense for windows. If no icon
|
This property only makes sense for windows. If no icon
|
||||||
text has been set, this functions returns an empty string.
|
text has been set, this accessor returns an empty string.
|
||||||
|
It is only implemented on the X11 platform, and only certain
|
||||||
|
window managers use this window property.
|
||||||
|
|
||||||
|
\obsolete
|
||||||
|
This property is deprecated.
|
||||||
|
|
||||||
\sa windowIcon, windowTitle
|
\sa windowIcon, windowTitle
|
||||||
*/
|
*/
|
||||||
|
@ -165,7 +165,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
|
|||||||
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
|
Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
|
||||||
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow)
|
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle NOTIFY windowTitleChanged DESIGNABLE isWindow)
|
||||||
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow)
|
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon NOTIFY windowIconChanged DESIGNABLE isWindow)
|
||||||
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow)
|
Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText NOTIFY windowIconTextChanged DESIGNABLE isWindow) // deprecated
|
||||||
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
|
Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
|
||||||
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
|
Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
|
||||||
#ifndef QT_NO_TOOLTIP
|
#ifndef QT_NO_TOOLTIP
|
||||||
|
@ -50,6 +50,8 @@ PropertyWatcher::PropertyWatcher(QObject *subject, QString annotation, QWidget *
|
|||||||
if (prop.isReadable()) {
|
if (prop.isReadable()) {
|
||||||
PropertyField* field = new PropertyField(m_subject, prop);
|
PropertyField* field = new PropertyField(m_subject, prop);
|
||||||
m_layout->addRow(prop.name(), field);
|
m_layout->addRow(prop.name(), field);
|
||||||
|
if (!qstrcmp(prop.name(), "name"))
|
||||||
|
setWindowIconText(prop.read(subject).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QPushButton *updateButton = new QPushButton("update");
|
QPushButton *updateButton = new QPushButton("update");
|
||||||
|
Loading…
Reference in New Issue
Block a user