Kaydet (Commit) e3169172 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Thorsten Behrens

KF5 add QWidget to Kf5Frame

Change-Id: I53845519d0dda324c9544f057b18c6afd4cf858a
üst c33b45c7
...@@ -11,6 +11,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kf5)) ...@@ -11,6 +11,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/unx/kf5))
$(call gb_CustomTarget_get_target,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)/Kf5Timer.moc \
$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/Kf5Widget.moc \
$(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/%.moc : \ $(call gb_CustomTarget_get_workdir,vcl/unx/kf5)/%.moc : \
$(SRCDIR)/vcl/unx/kf5/%.hxx \ $(SRCDIR)/vcl/unx/kf5/%.hxx \
......
...@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_kf5,\ ...@@ -87,6 +87,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_kf5,\
vcl/unx/kf5/Kf5Printer \ vcl/unx/kf5/Kf5Printer \
vcl/unx/kf5/Kf5Timer \ vcl/unx/kf5/Kf5Timer \
vcl/unx/kf5/Kf5VirtualDevice \ vcl/unx/kf5/Kf5VirtualDevice \
vcl/unx/kf5/Kf5Widget \
)) ))
ifeq ($(OS),LINUX) ifeq ($(OS),LINUX)
......
...@@ -19,14 +19,61 @@ ...@@ -19,14 +19,61 @@
#include "Kf5Frame.hxx" #include "Kf5Frame.hxx"
Kf5Frame::Kf5Frame::Kf5Frame( Kf5Instance* pInstance, #include "Kf5Instance.hxx"
SalFrame* pParent, #include "Kf5Widget.hxx"
SalFrameStyleFlags nSalFrameStyle )
{ #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() Kf5Frame::~Kf5Frame()
{ {
Kf5Instance *pInst = static_cast<Kf5Instance*>( GetSalData()->m_pInstance );
pInst->eraseFrame( this );
} }
SalGraphics* Kf5Frame::AcquireGraphics() SalGraphics* Kf5Frame::AcquireGraphics()
...@@ -38,7 +85,6 @@ void Kf5Frame::ReleaseGraphics( SalGraphics* pGraphics ) ...@@ -38,7 +85,6 @@ void Kf5Frame::ReleaseGraphics( SalGraphics* pGraphics )
{ {
} }
bool Kf5Frame::PostEvent(ImplSVEvent* pData) bool Kf5Frame::PostEvent(ImplSVEvent* pData)
{ {
return false; return false;
......
...@@ -21,16 +21,24 @@ ...@@ -21,16 +21,24 @@
#include <salframe.hxx> #include <salframe.hxx>
#include <memory>
class Kf5Instance; 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: public:
Kf5Frame( Kf5Instance* pInstance, Kf5Frame( Kf5Frame* pParent, SalFrameStyleFlags nSalFrameStyle );
SalFrame* pParent,
SalFrameStyleFlags nSalFrameStyle );
virtual ~Kf5Frame() override; virtual ~Kf5Frame() override;
Kf5Widget* GetQWidget() const { return m_pQWidget.get(); }
virtual SalGraphics* AcquireGraphics() override; virtual SalGraphics* AcquireGraphics() override;
virtual void ReleaseGraphics( SalGraphics* pGraphics ) override; virtual void ReleaseGraphics( SalGraphics* pGraphics ) override;
......
...@@ -63,12 +63,13 @@ Kf5Instance::~Kf5Instance() ...@@ -63,12 +63,13 @@ Kf5Instance::~Kf5Instance()
SalFrame* Kf5Instance::CreateChildFrame( SystemParentData* /*pParent*/, SalFrameStyleFlags nStyle ) 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 ) 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 ) void Kf5Instance::DestroyFrame( SalFrame* pFrame )
......
/* -*- 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: */
/* -*- 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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment