[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - 2 commits - include/sfx2 sfx2/source vcl/Library_vclplug_kde5.mk vcl/unx
Katarina Behrens
Katarina.Behrens at cib.de
Wed May 2 11:18:06 UTC 2018
include/sfx2/infobar.hxx | 4 ++
include/sfx2/viewfrm.hxx | 2 +
sfx2/source/dialog/infobar.cxx | 34 +++++++++++++++++-----
sfx2/source/doc/objserv.cxx | 33 +++++++++++++--------
sfx2/source/view/viewfrm.cxx | 21 +++++++++++++
vcl/Library_vclplug_kde5.mk | 1
vcl/unx/kde5/KDE5SalData.cxx | 59 +++++++++++++++++++++++++++++++++++++++
vcl/unx/kde5/KDE5SalData.hxx | 33 +++++++++++++++++++++
vcl/unx/kde5/KDE5SalInstance.cxx | 6 ++-
9 files changed, 170 insertions(+), 23 deletions(-)
New commits:
commit 9cd8b3d2db27792673436ec0fdc6727b0b8e04fe
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Wed May 2 13:14:29 2018 +0200
KDE5SalData derives from Qt5Data
A step back since now mbNoFocusRects (= draw focus rectangle natively)
is set, but native drawing itself is not yet implemented and no focus
rectangles are draw
Change-Id: I4dde734d057f6c594eb11162990430697277f029
diff --git a/vcl/Library_vclplug_kde5.mk b/vcl/Library_vclplug_kde5.mk
index f82227722c55..0f6cffad5d3c 100644
--- a/vcl/Library_vclplug_kde5.mk
+++ b/vcl/Library_vclplug_kde5.mk
@@ -85,6 +85,7 @@ $(eval $(call gb_Library_add_libs,vclplug_kde5,\
))
$(eval $(call gb_Library_add_exception_objects,vclplug_kde5,\
+ vcl/unx/kde5/KDE5SalData \
vcl/unx/kde5/KDE5SalDisplay \
vcl/unx/kde5/KDE5SalFrame \
vcl/unx/kde5/KDE5SalGraphics \
diff --git a/vcl/unx/kde5/KDE5SalData.cxx b/vcl/unx/kde5/KDE5SalData.cxx
new file mode 100644
index 000000000000..f995fa549768
--- /dev/null
+++ b/vcl/unx/kde5/KDE5SalData.cxx
@@ -0,0 +1,59 @@
+/* -*- 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 <QtWidgets/QStyle>
+#include <QtWidgets/QApplication>
+
+#undef Region
+
+#include "KDE5SalData.hxx"
+
+KDE5SalData::KDE5SalData( SalInstance *pInstance )
+ : Qt5Data( pInstance )
+{
+}
+
+KDE5SalData::~KDE5SalData()
+{
+}
+
+void KDE5SalData::initNWF()
+{
+ ImplSVData *pSVData = ImplGetSVData();
+
+ // draw toolbars on separate lines
+ pSVData->maNWFData.mbDockingAreaSeparateTB = true;
+ // no borders for menu, theming does that
+ pSVData->maNWFData.mbFlatMenu = true;
+ // Qt theme engines may support a rollover menubar
+ pSVData->maNWFData.mbRolloverMenubar = true;
+
+ pSVData->maNWFData.mbNoFocusRects = true;
+
+ // Styled menus need additional space
+ QStyle *style = QApplication::style();
+ pSVData->maNWFData.mnMenuFormatBorderX =
+ style->pixelMetric( QStyle::PM_MenuPanelWidth ) +
+ style->pixelMetric( QStyle::PM_MenuHMargin );
+ pSVData->maNWFData.mnMenuFormatBorderY =
+ style->pixelMetric( QStyle::PM_MenuPanelWidth ) +
+ style->pixelMetric( QStyle::PM_MenuVMargin );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalData.hxx b/vcl/unx/kde5/KDE5SalData.hxx
new file mode 100644
index 000000000000..a72180694d7b
--- /dev/null
+++ b/vcl/unx/kde5/KDE5SalData.hxx
@@ -0,0 +1,33 @@
+/* -*- 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 <qt5/Qt5Data.hxx>
+
+class KDE5SalData : public Qt5Data
+{
+ public:
+ KDE5SalData( SalInstance *pInstance );
+ virtual ~KDE5SalData();
+
+ static void initNWF() ;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/kde5/KDE5SalInstance.cxx b/vcl/unx/kde5/KDE5SalInstance.cxx
index 86b42a9c5206..819889362443 100644
--- a/vcl/unx/kde5/KDE5SalInstance.cxx
+++ b/vcl/unx/kde5/KDE5SalInstance.cxx
@@ -25,8 +25,8 @@
#include <QtWidgets/QFrame>
#include <osl/process.h>
-#include <qt5/Qt5Data.hxx>
+#include "KDE5SalData.hxx"
#include "KDE5SalInstance.hxx"
#include "KDE5SalFrame.hxx"
#include "KDE5SalDisplay.hxx"
@@ -39,6 +39,8 @@ KDE5SalInstance::KDE5SalInstance(SalYieldMutex* pMutex)
ImplSVData* pSVData = ImplGetSVData();
delete pSVData->maAppData.mpToolkitName;
pSVData->maAppData.mpToolkitName = new OUString("kde5");
+
+ KDE5SalData::initNWF();
}
SalFrame* KDE5SalInstance::CreateFrame( SalFrame *pParent, SalFrameStyleFlags nState )
@@ -127,7 +129,7 @@ VCLPLUG_KDE5_PUBLIC SalInstance* create_SalInstance()
KDE5SalInstance* pInstance = new KDE5SalInstance(new SalYieldMutex());
// initialize SalData
- new Qt5Data(pInstance);
+ new KDE5SalData(pInstance);
pInstance->m_pQApplication.reset(pQApplication);
pInstance->m_pFakeArgvFreeable.reset(pFakeArgvFreeable);
commit a5fd4cb05a6fc9a231a9c4582e21c0d337afcc86
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date: Thu Apr 26 16:30:48 2018 +0200
tdf#117039: update infobar instead of removing and re-adding it
Apparently AppendInfoBar ends up calling back into SID_SIGNATURE
status function at some point, creating an endless recursion. I'm
too lazy to debug why so I'm cowardly avoiding it
Change-Id: Ib1e4b7f12fea197887b099e9a9f03b4e58884ec1
diff --git a/include/sfx2/infobar.hxx b/include/sfx2/infobar.hxx
index ac8c43e75b4b..4a9c39578b82 100644
--- a/include/sfx2/infobar.hxx
+++ b/include/sfx2/infobar.hxx
@@ -50,11 +50,14 @@ class SFX2_DLLPUBLIC SfxInfoBarWindow : public vcl::Window
{
private:
OUString m_sId;
+ InfoBarType m_eType;
VclPtr<FixedImage> m_pImage;
VclPtr<FixedText> m_pMessage;
VclPtr<Button> m_pCloseBtn;
std::vector< VclPtr<PushButton> > m_aActionBtns;
+ void SetForeAndBackgroundColors( InfoBarType eType );
+
public:
SfxInfoBarWindow( vcl::Window* parent, const OUString& sId,
const OUString& sMessage,
@@ -66,6 +69,7 @@ class SFX2_DLLPUBLIC SfxInfoBarWindow : public vcl::Window
const OUString& getId() const { return m_sId; }
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void Resize( ) override;
+ void Update( const OUString& sNewMessage, InfoBarType eType );
basegfx::BColor m_aBackgroundColor;
basegfx::BColor m_aForegroundColor;
diff --git a/include/sfx2/viewfrm.hxx b/include/sfx2/viewfrm.hxx
index 3c66418fa6fb..ef3892b3e30d 100644
--- a/include/sfx2/viewfrm.hxx
+++ b/include/sfx2/viewfrm.hxx
@@ -173,6 +173,8 @@ public:
const OUString& sMessage,
InfoBarType aInfoBarType);
void RemoveInfoBar(const OUString& sId);
+ void UpdateInfoBar(const OUString& sId,
+ const OUString& sMessage, InfoBarType eType);
bool HasInfoBarWithID(const OUString& sId);
SAL_DLLPRIVATE void GetDocNumber_Impl();
diff --git a/sfx2/source/dialog/infobar.cxx b/sfx2/source/dialog/infobar.cxx
index 2946a5da5aac..7c8743dd6e0a 100644
--- a/sfx2/source/dialog/infobar.cxx
+++ b/sfx2/source/dialog/infobar.cxx
@@ -172,19 +172,13 @@ SfxInfoBarWindow::SfxInfoBarWindow(vcl::Window* pParent, const OUString& sId,
WinBits nMessageStyle = WB_LEFT|WB_VCENTER) :
Window(pParent, 0),
m_sId(sId),
+ m_eType(ibType),
m_pImage(VclPtr<FixedImage>::Create(this, nMessageStyle)),
m_pMessage(VclPtr<FixedText>::Create(this, nMessageStyle)),
m_pCloseBtn(VclPtr<SfxCloseButton>::Create(this)),
m_aActionBtns()
{
- basegfx::BColor aBackgroundColor;
- basegfx::BColor aForegroundColor;
- basegfx::BColor aMessageColor;
- GetInfoBarColors(ibType,aBackgroundColor,aForegroundColor,aMessageColor);
- static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(aBackgroundColor);
- static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(aForegroundColor);
- m_pMessage->SetControlForeground(Color(aMessageColor));
-
+ SetForeAndBackgroundColors(m_eType);
float fScaleFactor = GetDPIScaleFactor();
long nWidth = pParent->GetSizePixel().getWidth();
SetPosSizePixel(Point(0, 0), Size(nWidth, INFO_BAR_BASE_HEIGHT * fScaleFactor));
@@ -216,6 +210,16 @@ SfxInfoBarWindow::~SfxInfoBarWindow()
disposeOnce();
}
+void SfxInfoBarWindow::SetForeAndBackgroundColors(InfoBarType eType)
+{
+ basegfx::BColor aMessageColor;
+ GetInfoBarColors(eType,m_aBackgroundColor,m_aForegroundColor,aMessageColor);
+
+ static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setBackgroundColor(m_aBackgroundColor);
+ static_cast<SfxCloseButton*>(m_pCloseBtn.get())->setForegroundColor(m_aForegroundColor);
+ m_pMessage->SetControlForeground(Color(aMessageColor));
+}
+
void SfxInfoBarWindow::dispose()
{
for ( auto it = m_aActionBtns.begin( ); it != m_aActionBtns.end( ); ++it )
@@ -295,6 +299,20 @@ void SfxInfoBarWindow::Resize()
}
+void SfxInfoBarWindow::Update( const OUString &sNewMessage, InfoBarType eType )
+{
+ if (m_eType != eType)
+ {
+ m_eType = eType;
+ SetForeAndBackgroundColors(m_eType);
+ m_pImage->SetImage(Image(BitmapEx(GetInfoBarIconName(eType))));
+ }
+
+ m_pMessage->SetText( sNewMessage );
+ Resize();
+ Invalidate();
+}
+
IMPL_LINK_NOARG(SfxInfoBarWindow, CloseHandler, Button*, void)
{
static_cast<SfxInfoBarContainerWindow*>(GetParent())->removeInfoBar(this);
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 5af4ef033706..0aa2c0974808 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1053,21 +1053,28 @@ void SfxObjectShell::GetState_Impl(SfxItemSet &rSet)
break;
}
- if ( pFrame->HasInfoBarWithID("signature") )
- pFrame->RemoveInfoBar("signature");
-
- if ( eState != SignatureState::NOSIGNATURES )
+ // new info bar
+ if ( !pFrame->HasInfoBarWithID("signature") )
+ {
+ if ( !sMessage.isEmpty() )
+ {
+ auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType);
+ if (pInfoBar == nullptr)
+ return;
+ VclPtrInstance<PushButton> xBtn(&(pFrame->GetWindow()));
+ xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW));
+ xBtn->SetSizePixel(xBtn->GetOptimalSize());
+ xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler));
+ pInfoBar->addButton(xBtn);
+ }
+ }
+ else // info bar exists already
{
- auto pInfoBar = pFrame->AppendInfoBar("signature", sMessage, aInfoBarType);
- if (pInfoBar == nullptr)
- return;
- VclPtrInstance<PushButton> xBtn(&(pFrame->GetWindow()));
- xBtn->SetText(SfxResId(STR_SIGNATURE_SHOW));
- xBtn->SetSizePixel(xBtn->GetOptimalSize());
- xBtn->SetClickHdl(LINK(this, SfxObjectShell, SignDocumentHandler));
- pInfoBar->addButton(xBtn);
+ if ( eState == SignatureState::NOSIGNATURES )
+ pFrame->RemoveInfoBar("signature");
+ else
+ pFrame->UpdateInfoBar("signature", sMessage, aInfoBarType);
}
-
}
rSet.Put( SfxUInt16Item( SID_SIGNATURE, static_cast<sal_uInt16>(GetDocumentSignatureState()) ) );
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index b640f5f4aff9..f0d938141aef 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -3090,6 +3090,27 @@ VclPtr<SfxInfoBarWindow> SfxViewFrame::AppendInfoBar(const OUString& sId,
return pInfoBar;
}
+void SfxViewFrame::UpdateInfoBar( const OUString& sId,
+ const OUString& sMessage,
+ InfoBarType eType )
+{
+ const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
+
+ // Make sure the InfoBar container is visible
+ if (!HasChildWindow(nId))
+ ToggleChildWindow(nId);
+
+ SfxChildWindow* pChild = GetChildWindow(nId);
+ if (pChild)
+ {
+ SfxInfoBarContainerWindow* pInfoBarContainer = static_cast<SfxInfoBarContainerWindow*>(pChild->GetWindow());
+ auto pInfoBar = pInfoBarContainer->getInfoBar(sId);
+
+ if (pInfoBar)
+ pInfoBar->Update(sMessage, eType);
+ }
+}
+
void SfxViewFrame::RemoveInfoBar( const OUString& sId )
{
const sal_uInt16 nId = SfxInfoBarContainerChild::GetChildWindowId();
More information about the Libreoffice-commits
mailing list