WinRT: Set WindowTitle in application switcher
Add platform backend for QWinRTWindow::setWindowTitle. Task-number: QTBUG-40736 Change-Id: I0b03c9b5977368b38ba63044b00178c3f2bb0b86 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
parent
1b80e7a9d3
commit
a31ad5b73a
@ -40,6 +40,14 @@
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QOpenGLContext>
|
||||
|
||||
#include <qfunctions_winrt.h>
|
||||
#include <windows.ui.viewmanagement.h>
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace ABI::Windows::UI::ViewManagement;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Microsoft::WRL::Wrappers;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QWinRTWindow::QWinRTWindow(QWindow *window)
|
||||
@ -48,6 +56,7 @@ QWinRTWindow::QWinRTWindow(QWindow *window)
|
||||
{
|
||||
setWindowFlags(window->flags());
|
||||
setWindowState(window->windowState());
|
||||
setWindowTitle(window->title());
|
||||
handleContentOrientationChange(window->contentOrientation());
|
||||
setGeometry(window->geometry());
|
||||
}
|
||||
@ -94,6 +103,24 @@ void QWinRTWindow::setVisible(bool visible)
|
||||
m_screen->removeWindow(window());
|
||||
}
|
||||
|
||||
void QWinRTWindow::setWindowTitle(const QString &title)
|
||||
{
|
||||
ComPtr<IApplicationViewStatics2> statics;
|
||||
HRESULT hr;
|
||||
|
||||
hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(),
|
||||
IID_PPV_ARGS(&statics));
|
||||
RETURN_VOID_IF_FAILED("Could not get ApplicationViewStatics");
|
||||
|
||||
ComPtr<IApplicationView> view;
|
||||
hr = statics->GetForCurrentView(&view);
|
||||
RETURN_VOID_IF_FAILED("Could not access currentView");
|
||||
|
||||
HStringReference str(reinterpret_cast<LPCWSTR>(title.utf16()), title.length());
|
||||
hr = view->put_Title(str.Get());
|
||||
RETURN_VOID_IF_FAILED("Unable to set window title");
|
||||
}
|
||||
|
||||
void QWinRTWindow::raise()
|
||||
{
|
||||
if (!window()->isTopLevel())
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
bool isExposed() const;
|
||||
void setGeometry(const QRect &rect);
|
||||
void setVisible(bool visible);
|
||||
void setWindowTitle(const QString &title);
|
||||
void raise();
|
||||
void lower();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user