summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-10-27 13:15:37 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2017-11-06 12:05:31 +0100
commite3169172ac73ecb21a61c8a7fc73c6c7503f0d2b (patch)
tree5d02f1e43cc00f462c804a95dc811e8c6f9412ed
parentc33b45c7e14bf47b857630ce05d38a09ffc7e886 (diff)
KF5 add QWidget to Kf5Frame
Change-Id: I53845519d0dda324c9544f057b18c6afd4cf858a
-rw-r--r--vcl/CustomTarget_kf5_moc.mk1
-rw-r--r--vcl/Library_vclplug_kf5.mk1
-rw-r--r--vcl/unx/kf5/Kf5Frame.cxx56
-rw-r--r--vcl/unx/kf5/Kf5Frame.hxx16
-rw-r--r--vcl/unx/kf5/Kf5Instance.cxx5
-rw-r--r--vcl/unx/kf5/Kf5Widget.cxx34
-rw-r--r--vcl/unx/kf5/Kf5Widget.hxx40
7 files changed, 142 insertions, 11 deletions
diff --git a/vcl/CustomTarget_kf5_moc.mk b/vcl/CustomTarget_kf5_moc.mk
index 5be8f629ceec..f636ef5d125c 100644
--- a/vcl/CustomTarget_kf5_moc.mk
+++ b/vcl/CustomTarget_kf5_moc.mk
@@ -11,6 +11,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kf5))
$(call gb_CustomTarget_get_target,vcl/unx/kf5) : \
$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Timer.moc \
+ $(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Widget.moc \
$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/%.moc : \
$(SRCDIR)/vcl/unx/kf5/%.hxx \
diff --git a/vcl/Library_vclplug_kf5.mk b/vcl/Library_vclplug_kf5.mk
index 416a6d53d072..cc518612d0bd 100644
--- a/vcl/Library_vclplug_kf5.mk
+++ b/vcl/Library_vclplug_kf5.mk
@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_kf5,\
vcl/unx/kf5/Kf5Printer \
vcl/unx/kf5/Kf5Timer \
vcl/unx/kf5/Kf5VirtualDevice \
+ vcl/unx/kf5/Kf5Widget \
))
ifeq ($(OS),LINUX)
diff --git a/vcl/unx/kf5/Kf5Frame.cxx b/vcl/unx/kf5/Kf5Frame.cxx
index c6326b564557..652fd281d2e8 100644
--- a/vcl/unx/kf5/Kf5Frame.cxx
+++ b/vcl/unx/kf5/Kf5Frame.cxx
@@ -19,14 +19,61 @@
#include "Kf5Frame.hxx"
-Kf5Frame::Kf5Frame::Kf5Frame( Kf5Instance* pInstance,
- SalFrame* pParent,
- SalFrameStyleFlags nSalFrameStyle )
-{
+#include "Kf5Instance.hxx"
+#include "Kf5Widget.hxx"
+
+#include <QtGui/QWindow>
+
+Kf5Frame::Kf5Frame( Kf5Frame* pParent, SalFrameStyleFlags nStyle )
+{
+ Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
+ pInst->insertFrame( this );
+
+ if( nStyle & SalFrameStyleFlags::DEFAULT ) // ensure default style
+ {
+ nStyle |= SalFrameStyleFlags::MOVEABLE | SalFrameStyleFlags::SIZEABLE | SalFrameStyleFlags::CLOSEABLE;
+ nStyle &= ~SalFrameStyleFlags::FLOAT;
+ }
+
+ m_nStyle = nStyle;
+ m_pParent = pParent;
+
+ Qt::WindowFlags aWinFlags;
+ if ( !(nStyle & SalFrameStyleFlags::SYSTEMCHILD) )
+ {
+ if( nStyle & SalFrameStyleFlags::INTRO )
+ aWinFlags |= Qt::SplashScreen;
+ else if( nStyle & (SalFrameStyleFlags::FLOAT |
+ SalFrameStyleFlags::TOOLTIP) )
+ aWinFlags |= Qt::ToolTip;
+ else if( (nStyle & SalFrameStyleFlags::FLOAT) &&
+ ! (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+ aWinFlags |= Qt::Popup;
+ else if( nStyle & SalFrameStyleFlags::DIALOG && pParent )
+ aWinFlags |= Qt::Dialog;
+ else if( nStyle & SalFrameStyleFlags::TOOLWINDOW )
+ aWinFlags |= Qt::Tool;
+ else if( (nStyle & SalFrameStyleFlags::OWNERDRAWDECORATION) )
+ aWinFlags |= Qt::Window | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus;
+ else
+ aWinFlags |= Qt::Window;
+ }
+
+ m_pQWidget.reset( new Kf5Widget( *this, pParent ? pParent->GetQWidget() : nullptr, aWinFlags ) );
+
+ if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
+ {
+ QWindow *pParentWindow = pParent->GetQWidget()->window()->windowHandle();
+ QWindow *pChildWindow = m_pQWidget->window()->windowHandle();
+ if ( pParentWindow != pChildWindow )
+ pChildWindow->setTransientParent( pParentWindow );
+ }
}
Kf5Frame::~Kf5Frame()
{
+ Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
+ pInst->eraseFrame( this );
}
SalGraphics* Kf5Frame::AcquireGraphics()
@@ -38,7 +85,6 @@ void Kf5Frame::ReleaseGraphics( SalGraphics* pGraphics )
{
}
-
bool Kf5Frame::PostEvent(ImplSVEvent* pData)
{
return false;
diff --git a/vcl/unx/kf5/Kf5Frame.hxx b/vcl/unx/kf5/Kf5Frame.hxx
index d08040b23c71..da89db7a1648 100644
--- a/vcl/unx/kf5/Kf5Frame.hxx
+++ b/vcl/unx/kf5/Kf5Frame.hxx
@@ -21,16 +21,24 @@
#include <salframe.hxx>
+#include <memory>
+
class Kf5Instance;
+class Kf5Widget;
-class VCL_DLLPUBLIC Kf5Frame : public SalFrame
+class Kf5Frame
+ : public SalFrame
{
+ std::unique_ptr< Kf5Widget > m_pQWidget;
+ SalFrameStyleFlags m_nStyle;
+ Kf5Frame *m_pParent;
+
public:
- Kf5Frame( Kf5Instance* pInstance,
- SalFrame* pParent,
- SalFrameStyleFlags nSalFrameStyle );
+ Kf5Frame( Kf5Frame* pParent, SalFrameStyleFlags nSalFrameStyle );
virtual ~Kf5Frame() override;
+ Kf5Widget* GetQWidget() const { return m_pQWidget.get(); }
+
virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
diff --git a/vcl/unx/kf5/Kf5Instance.cxx b/vcl/unx/kf5/Kf5Instance.cxx
index 4fb218b1ede1..f4ff9b800b60 100644
--- a/vcl/unx/kf5/Kf5Instance.cxx
+++ b/vcl/unx/kf5/Kf5Instance.cxx
@@ -63,12 +63,13 @@ Kf5Instance::~Kf5Instance()
SalFrame* Kf5Instance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle )
{
- return new Kf5Frame( this, nullptr, nStyle );
+ return new Kf5Frame( nullptr, nStyle );
}
SalFrame* Kf5Instance::CreateFrame( SalFrame* pParent, SalFrameStyleFlags nStyle )
{
- return new Kf5Frame( this, pParent, nStyle );
+ assert( !pParent || dynamic_cast<Kf5Frame*>( pParent ) );
+ return new Kf5Frame( static_cast<Kf5Frame*>( pParent ), nStyle );
}
void Kf5Instance::DestroyFrame( SalFrame* pFrame )
diff --git a/vcl/unx/kf5/Kf5Widget.cxx b/vcl/unx/kf5/Kf5Widget.cxx
new file mode 100644
index 000000000000..f2b3c5fb3be2
--- /dev/null
+++ b/vcl/unx/kf5/Kf5Widget.cxx
@@ -0,0 +1,34 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include "Kf5Widget.hxx"
+#include <Kf5Widget.moc>
+
+Kf5Widget::Kf5Widget( Kf5Frame &rFrame, QWidget *parent, Qt::WindowFlags f )
+ : QWidget( parent, f )
+ , m_pFrame( &rFrame )
+{
+ create();
+}
+
+Kf5Widget::~Kf5Widget()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kf5/Kf5Widget.hxx b/vcl/unx/kf5/Kf5Widget.hxx
new file mode 100644
index 000000000000..8f792ca76f96
--- /dev/null
+++ b/vcl/unx/kf5/Kf5Widget.hxx
@@ -0,0 +1,40 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#pragma once
+
+#include <QtWidgets/QWidget>
+
+class Kf5Frame;
+
+class Kf5Widget
+ : public QWidget
+{
+ Q_OBJECT
+
+ Kf5Frame *m_pFrame;
+
+public:
+ Kf5Widget( Kf5Frame &rFrame,
+ QWidget *parent = Q_NULLPTR,
+ Qt::WindowFlags f = Qt::WindowFlags() );
+ virtual ~Kf5Widget() override;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */