[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-06-27 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Frame.hxx |1 +
 vcl/qt5/Qt5Frame.cxx |   12 
 2 files changed, 13 insertions(+)

New commits:
commit 588a4b353d712cadc88830c994156a4b318a9f2d
Author: Katarina Behrens 
Date:   Wed Jun 27 10:41:03 2018 +0200

Implement native modality for modal dialogs

instead of hack with hiding the window and showing it again (otherwise
modality change has no effect and worse yet, weird things happen)
it would be much easier to use QDialog

Change-Id: Ie7029ca66380495c4aad246d02f4b96cb55eb01e

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 268441ea688a..96446c28a358 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -107,6 +107,7 @@ public:
 virtual void GetClientSize(long& rWidth, long& rHeight) override;
 virtual void GetWorkArea(tools::Rectangle& rRect) override;
 virtual SalFrame* GetParent() const override;
+virtual void SetModal(bool bModal) override;
 virtual void SetWindowState(const SalFrameState* pState) override;
 virtual bool GetWindowState(SalFrameState* pState) override;
 virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 9c5b8edbc5be..b47b64ab1cb8 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -345,6 +345,18 @@ void Qt5Frame::GetWorkArea(tools::Rectangle& rRect)
 
 SalFrame* Qt5Frame::GetParent() const { return m_pParent; }
 
+void Qt5Frame::SetModal(bool bModal)
+{
+if (m_pQWidget->isWindow())
+{
+// modality change is only effective if the window is hidden
+m_pQWidget->windowHandle()->hide();
+m_pQWidget->windowHandle()->setModality(bModal ? Qt::WindowModal : 
Qt::NonModal);
+// and shown again
+m_pQWidget->windowHandle()->show();
+}
+}
+
 void Qt5Frame::SetWindowState(const SalFrameState* pState)
 {
 if (!m_pQWidget->isWindow() || !pState || isChild(true, false))
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-25 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Menu.hxx |3 ++-
 vcl/qt5/Qt5Menu.cxx |   21 ++---
 2 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 08c2927e0587428d2c242ffcdf142d39f23df092
Author: Katarina Behrens 
Date:   Fri May 25 16:04:24 2018 +0200

Dispatch commands from menus for real

Change-Id: I01997caa22e14c1350bd83100edb74397ebab5d7

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index 408d97e76520..37887045506f 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -42,6 +42,7 @@ public:
 virtual voidSetSubMenu( SalMenuItem* pSalMenuItem, 
SalMenu* pSubMenu, unsigned nPos ) override;
 virtual voidSetFrame( const SalFrame* pFrame ) override;
 const Qt5Frame* GetFrame() const;
+Qt5Menu*GetTopLevel();
 virtual voidCheckItem( unsigned nPos, bool bCheck ) 
override;
 virtual voidEnableItem( unsigned nPos, bool bEnable ) 
override;
 virtual voidShowItem( unsigned nPos, bool bShow ) override;
@@ -56,7 +57,7 @@ public:
 Qt5MenuItem*GetItemAtPos( unsigned nPos ) { return 
maItems[ nPos ]; }
 
 private slots:
-void DispatchCommand();
+void DispatchCommand( Qt5MenuItem* pQItem );
 };
 
 class Qt5MenuItem : public SalMenuItem
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index f7ebc5617d8c..91de0defccff 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -114,7 +114,8 @@ void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* 
pParentMenu )
 // leaf menu
 QAction *pAction = pQMenu->addAction( toQString(aText) );
 pAction->setShortcut( toQString( 
nAccelKey.GetName(GetFrame()->GetWindow()) ) );
-connect( pAction, ::triggered, this, 
::DispatchCommand );
+connect( pAction, ::triggered, this,
+ [this, pSalMenuItem]{ 
DispatchCommand(pSalMenuItem); } );
 }
 }
 }
@@ -156,6 +157,14 @@ void Qt5Menu::GetSystemMenuData( SystemMenuData* pData )
 {
 }
 
+Qt5Menu* Qt5Menu::GetTopLevel()
+{
+Qt5Menu *pMenu = this;
+while (pMenu->mpParentSalMenu)
+pMenu = pMenu->mpParentSalMenu;
+return pMenu;
+}
+
 const Qt5Frame* Qt5Menu::GetFrame() const
 {
 SolarMutexGuard aGuard;
@@ -165,9 +174,15 @@ const Qt5Frame* Qt5Menu::GetFrame() const
 return pMenu ? pMenu->mpFrame : nullptr;
 }
 
-void Qt5Menu::DispatchCommand()
+void Qt5Menu::DispatchCommand( Qt5MenuItem *pQItem )
 {
-SAL_WARN("vcl.qt5", "menu triggered");
+if ( pQItem )
+{
+Qt5Menu* pSalMenu = pQItem->mpParentMenu;
+Qt5Menu* pTopLevel = pSalMenu->GetTopLevel();
+pTopLevel->GetMenu()->HandleMenuCommandEvent(pSalMenu->GetMenu(), 
pQItem->mnId);
+SAL_WARN("vcl.qt5", "menu triggered " << pQItem->mnId );
+}
 }
 
 void Qt5Menu::NativeItemText( OUString& rItemText )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-23 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Menu.hxx |6 +
 vcl/qt5/Qt5Menu.cxx |   50 
 2 files changed, 32 insertions(+), 24 deletions(-)

New commits:
commit 718982237e15948e4e3d45d63b8a25de049af271
Author: Katarina Behrens 
Date:   Wed May 23 10:51:30 2018 +0200

Native leaf menus and submenus are now visible

Change-Id: Ieaac0966b167d82c8bdeb60f3ce4b9cc8589ec62

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index aa3948ce6d2d..38dcc3688b1f 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -12,6 +12,7 @@
 #include 
 
 class MenuItemList;
+class QMenu;
 class QMenuBar;
 class Qt5MenuItem;
 class Qt5Frame;
@@ -24,12 +25,9 @@ private:
 Qt5Menu* mpParentSalMenu;
 Qt5Frame*mpFrame;
 bool mbMenuBar;
-
 QMenuBar*mpQMenuBar;
 
-void ActivateAllSubMenus( Menu* pMenuBar );
-void Update();
-
+void DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu = nullptr );
 void NativeItemText( OUString  );
 
 public:
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 586130925356..65bf726252df 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -53,6 +53,16 @@ void Qt5Menu::RemoveItem( unsigned nPos )
 
 void Qt5Menu::SetSubMenu( SalMenuItem* pSalMenuItem, SalMenu* pSubMenu, 
unsigned nPos )
 {
+SolarMutexGuard aGuard;
+Qt5MenuItem *pItem = static_cast< Qt5MenuItem* >( pSalMenuItem );
+Qt5Menu *pQSubMenu = static_cast< Qt5Menu* >( pSubMenu );
+
+if ( pQSubMenu == nullptr )
+return;
+
+pQSubMenu->mpParentSalMenu = this;
+pItem->mpSubMenu = pQSubMenu;
+
 }
 
 void Qt5Menu::SetFrame( const SalFrame* pFrame )
@@ -68,26 +78,10 @@ void Qt5Menu::SetFrame( const SalFrame* pFrame )
 if( pMainWindow )
 mpQMenuBar = pMainWindow->menuBar();
 
-ActivateAllSubMenus( mpVCLMenu );
-
-Update();
+DoFullMenuUpdate( mpVCLMenu );
 }
 
-void Qt5Menu::ActivateAllSubMenus( Menu* pMenuBar )
-{
-for (Qt5MenuItem* pSalItem : maItems)
-{
-if ( pSalItem->mpSubMenu != nullptr )
-{
-pMenuBar->HandleMenuActivateEvent(pSalItem->mpSubMenu->GetMenu());
-pSalItem->mpSubMenu->ActivateAllSubMenus(pMenuBar);
-pSalItem->mpSubMenu->Update();
-
pMenuBar->HandleMenuDeActivateEvent(pSalItem->mpSubMenu->GetMenu());
-}
-}
-}
-
-void Qt5Menu::Update()
+void Qt5Menu::DoFullMenuUpdate( Menu* pMenuBar, QMenu* pParentMenu )
 {
 Menu* pVCLMenu = mpVCLMenu;
 
@@ -99,11 +93,27 @@ void Qt5Menu::Update()
 Qt5MenuItem *pSalMenuItem = GetItemAtPos( nItem );
 sal_uInt16 nId = pSalMenuItem->mnId;
 OUString aText = pVCLMenu->GetItemText( nId );
+QMenu* pQMenu = pParentMenu;
+NativeItemText( aText );
 
 if (mbMenuBar && mpQMenuBar)
+// top-level menu
+pQMenu = mpQMenuBar->addMenu( toQString(aText) );
+else
+{
+if( pSalMenuItem->mpSubMenu )
+// submenu
+pQMenu = pQMenu->addMenu( toQString(aText) );
+else
+// leaf menu
+pQMenu->addAction( toQString(aText) );
+}
+
+if ( pSalMenuItem->mpSubMenu != nullptr )
 {
- NativeItemText( aText );
- mpQMenuBar->addMenu( toQString(aText) );
+
pMenuBar->HandleMenuActivateEvent(pSalMenuItem->mpSubMenu->GetMenu());
+pSalMenuItem->mpSubMenu->DoFullMenuUpdate( pMenuBar, pQMenu );
+
pMenuBar->HandleMenuDeActivateEvent(pSalMenuItem->mpSubMenu->GetMenu());
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-17 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Tools.hxx |6 ++
 vcl/qt5/Qt5Graphics_GDI.cxx  |2 +-
 vcl/qt5/Qt5Graphics_Text.cxx |2 +-
 vcl/qt5/Qt5Painter.cxx   |4 ++--
 4 files changed, 10 insertions(+), 4 deletions(-)

New commits:
commit 14b000986d1bc98bb3ecb7ada5b10f33ee7bdefe
Author: Katarina Behrens 
Date:   Thu May 17 12:55:55 2018 +0200

Unify Color -> QColor conversion

this also resolves build failures on 32bit platforms

Change-Id: I53fa2faae52a8cb322644c5bd5e5e84d71110d8e

diff --git a/vcl/inc/qt5/Qt5Tools.hxx b/vcl/inc/qt5/Qt5Tools.hxx
index d632a5ed8ce5..06c02572473c 100644
--- a/vcl/inc/qt5/Qt5Tools.hxx
+++ b/vcl/inc/qt5/Qt5Tools.hxx
@@ -26,6 +26,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -55,6 +56,11 @@ inline QSize toQSize(const Size& rSize) { return 
QSize(rSize.Width(), rSize.Heig
 
 inline Size toSize(const QSize& rSize) { return Size(rSize.width(), 
rSize.height()); }
 
+inline QColor toQColor(const Color& rColor)
+{
+return QColor( rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue(), 
rColor.GetTransparency() );
+}
+
 static constexpr QImage::Format Qt5_DefaultFormat32 = QImage::Format_ARGB32;
 
 inline QImage::Format getBitFormat(sal_uInt16 nBitCount)
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index fe1b98112b33..8c1445970f62 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -172,7 +172,7 @@ void Qt5Graphics::drawPixel(long nX, long nY)
 void Qt5Graphics::drawPixel(long nX, long nY, SalColor nSalColor)
 {
 Qt5Painter aPainter(*this);
-aPainter.setPen(QColor(QRgb(nSalColor)));
+aPainter.setPen(toQColor(nSalColor));
 aPainter.setPen(Qt::SolidLine);
 aPainter.drawPoint(nX, nY);
 aPainter.update(nX, nY, 1, 1);
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index b31975e6f527..a7d005d426cd 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -185,7 +185,7 @@ void Qt5Graphics::DrawTextLayout(const CommonSalLayout 
 )
 aGlyphRun.setRawFont( aRawFont );
 
 Qt5Painter aPainter(*this);
-QColor aColor = QColor::fromRgb(QRgb(m_aTextColor));
+QColor aColor = toQColor(m_aTextColor);
 aPainter.setPen(aColor);
 aPainter.drawGlyphRun( QPointF(), aGlyphRun );
 }
diff --git a/vcl/qt5/Qt5Painter.cxx b/vcl/qt5/Qt5Painter.cxx
index 5bf0db22b3f0..88e9b10b1885 100644
--- a/vcl/qt5/Qt5Painter.cxx
+++ b/vcl/qt5/Qt5Painter.cxx
@@ -37,7 +37,7 @@ Qt5Painter::Qt5Painter(Qt5Graphics& rGraphics, bool 
bPrepareBrush, sal_uInt8 nTr
 setClipRegion(rGraphics.m_aClipRegion);
 if (SALCOLOR_NONE != rGraphics.m_aLineColor)
 {
-QColor aColor = QColor::fromRgb(QRgb(rGraphics.m_aLineColor));
+QColor aColor = toQColor(rGraphics.m_aLineColor);
 aColor.setAlpha(nTransparency);
 setPen(aColor);
 }
@@ -45,7 +45,7 @@ Qt5Painter::Qt5Painter(Qt5Graphics& rGraphics, bool 
bPrepareBrush, sal_uInt8 nTr
 setPen(Qt::NoPen);
 if (bPrepareBrush && SALCOLOR_NONE != rGraphics.m_aFillColor)
 {
-QColor aColor = QColor::fromRgb(QRgb(rGraphics.m_aFillColor));
+QColor aColor = toQColor(rGraphics.m_aFillColor);
 aColor.setAlpha(nTransparency);
 setBrush(Qt::SolidPattern);
 setBrush(aColor);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-16 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Menu.hxx |1 +
 vcl/qt5/Qt5Menu.cxx |   19 +++
 vcl/qt5/Qt5Widget.cxx   |1 -
 3 files changed, 20 insertions(+), 1 deletion(-)

New commits:
commit f93a07b5215f68f7c54a7012c2c4c2e2de0c2012
Author: Katarina Behrens 
Date:   Wed May 16 11:37:09 2018 +0200

Top-level native menubar items are now visible

Change-Id: I6746b4a41a99c75234e64ab48ce81ea97333da04

diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index 1c0f03b3342c..1d1048881fbc 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -28,6 +28,7 @@ private:
 QMenuBar*mpQMenuBar;
 
 void ActivateAllSubMenus( Menu* pMenuBar );
+void Update();
 
 public:
 Qt5Menu( bool bMenuBar );
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 4869a78b8a05..b82b525462c0 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -69,6 +69,8 @@ void Qt5Menu::SetFrame( const SalFrame* pFrame )
 mpQMenuBar = pMainWindow->menuBar();
 
 ActivateAllSubMenus( mpVCLMenu );
+
+Update();
 }
 
 void Qt5Menu::ActivateAllSubMenus( Menu* pMenuBar )
@@ -85,6 +87,23 @@ void Qt5Menu::ActivateAllSubMenus( Menu* pMenuBar )
 }
 }
 
+void Qt5Menu::Update()
+{
+Menu* pVCLMenu = mpVCLMenu;
+
+for ( sal_Int32 nItem = 0; nItem < static_cast(GetItemCount()); 
nItem++ )
+{
+Qt5MenuItem *pSalMenuItem = GetItemAtPos( nItem );
+sal_uInt16 nId = pSalMenuItem->mnId;
+OUString aText = pVCLMenu->GetItemText( nId );
+
+if (mbMenuBar && mpQMenuBar)
+{
+ mpQMenuBar->addMenu( toQString(aText) );
+}
+}
+}
+
 void Qt5Menu::ShowItem( unsigned nPos, bool bCheck )
 {
 }
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 8d910434b600..5331d32000a8 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -464,7 +464,6 @@ private:
 : QMainWindow(Q_NULLPTR, f), maMixin()
 {
 Init();
-ParentClassT::menuBar()->addMenu("ExperimentMenu");
 }
 
 void Init()
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-15 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Frame.hxx |3 +++
 vcl/inc/qt5/Qt5Menu.hxx  |5 +
 vcl/qt5/Qt5Frame.cxx |6 +-
 vcl/qt5/Qt5Menu.cxx  |   28 +++-
 4 files changed, 40 insertions(+), 2 deletions(-)

New commits:
commit 8521eb0cbeed45a7c366b252968b8f9935afbda3
Author: Katarina Behrens 
Date:   Tue May 15 16:29:15 2018 +0200

Expose menu bar of the main window

and some addional work on activating menus

Change-Id: I0c4d87dc158f3253aa97d151385fce14551c11b9

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 8772ee7bbfcc..1f881d706881 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -28,6 +28,7 @@
 
 class Qt5Graphics;
 class Qt5Instance;
+class Qt5Menu;
 class QWidget;
 class QPaintDevice;
 class QImage;
@@ -55,6 +56,8 @@ class VCLPLUG_QT5_PUBLIC Qt5Frame : public SalFrame
 Qt5Frame* m_pParent;
 PointerStyle m_ePointerStyle;
 
+Qt5Menu* m_pSalMenu;
+
 bool m_bDefaultSize;
 bool m_bDefaultPos;
 
diff --git a/vcl/inc/qt5/Qt5Menu.hxx b/vcl/inc/qt5/Qt5Menu.hxx
index cf7a715f5911..1c0f03b3342c 100644
--- a/vcl/inc/qt5/Qt5Menu.hxx
+++ b/vcl/inc/qt5/Qt5Menu.hxx
@@ -12,6 +12,7 @@
 #include 
 
 class MenuItemList;
+class QMenuBar;
 class Qt5MenuItem;
 class Qt5Frame;
 
@@ -24,6 +25,10 @@ private:
 Qt5Frame*mpFrame;
 bool mbMenuBar;
 
+QMenuBar*mpQMenuBar;
+
+void ActivateAllSubMenus( Menu* pMenuBar );
+
 public:
 Qt5Menu( bool bMenuBar );
 virtual ~Qt5Menu() override;
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index ec210c15ade0..4a36bee27776 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -24,6 +24,7 @@
 #include "Qt5Graphics.hxx"
 #include "Qt5Widget.hxx"
 #include "Qt5Data.hxx"
+#include 
 
 #include 
 #include 
@@ -233,7 +234,10 @@ void Qt5Frame::SetIcon(sal_uInt16 nIcon)
 m_pQWidget->window()->setWindowIcon(aIcon);
 }
 
-void Qt5Frame::SetMenu(SalMenu* /*pMenu*/) {}
+void Qt5Frame::SetMenu(SalMenu* pMenu)
+{
+m_pSalMenu = static_cast( pMenu );
+}
 
 void Qt5Frame::DrawMenuBar() {}
 
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 5a3753b6433a..4869a78b8a05 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -10,6 +10,8 @@
 #include "Qt5Frame.hxx"
 #include "Qt5Menu.hxx"
 
+#include 
+
 #include 
 
 Qt5Menu::Qt5Menu( bool bMenuBar ) :
@@ -55,8 +57,32 @@ void Qt5Menu::SetSubMenu( SalMenuItem* pSalMenuItem, 
SalMenu* pSubMenu, unsigned
 
 void Qt5Menu::SetFrame( const SalFrame* pFrame )
 {
-
+SolarMutexGuard aGuard;
+assert(mbMenuBar);
 mpFrame = const_cast( static_cast( pFrame ) );
+
+mpFrame->SetMenu( this );
+
+QWidget* pWidget = mpFrame->GetQWidget();
+QMainWindow* pMainWindow = dynamic_cast(pWidget);
+if( pMainWindow )
+mpQMenuBar = pMainWindow->menuBar();
+
+ActivateAllSubMenus( mpVCLMenu );
+}
+
+void Qt5Menu::ActivateAllSubMenus( Menu* pMenuBar )
+{
+for (Qt5MenuItem* pSalItem : maItems)
+{
+if ( pSalItem->mpSubMenu != nullptr )
+{
+pMenuBar->HandleMenuActivateEvent(pSalItem->mpSubMenu->GetMenu());
+pSalItem->mpSubMenu->ActivateAllSubMenus(pMenuBar);
+pSalItem->mpSubMenu->Update();
+
pMenuBar->HandleMenuDeActivateEvent(pSalItem->mpSubMenu->GetMenu());
+}
+}
 }
 
 void Qt5Menu::ShowItem( unsigned nPos, bool bCheck )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-15 Thread Katarina Behrens
Rebased ref, commits from common ancestor:
commit 625696ad3cb8b3d406676de1364830b72a530cfd
Author: Katarina Behrens 
Date:   Mon May 14 15:39:30 2018 +0200

Templatize Qt5Widget class

to distinguish between QMainWindow (top-level SalFrame) and QWidget
(everything else). The former are going to receive a native menu

Change-Id: I9023d1e464345f96f13967f5e2c8b0716890fbc9

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 4b0a99113536..8772ee7bbfcc 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -28,7 +28,6 @@
 
 class Qt5Graphics;
 class Qt5Instance;
-class Qt5Widget;
 class QWidget;
 class QPaintDevice;
 class QImage;
@@ -36,7 +35,7 @@ class SvpSalGraphics;
 
 class VCLPLUG_QT5_PUBLIC Qt5Frame : public SalFrame
 {
-friend class Qt5Widget;
+friend class VclQtMixinBase;
 
 std::unique_ptr m_pQWidget;
 
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 7e7ed8240802..c95bc94c1f0c 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -21,43 +21,8 @@
 
 #include 
 
-class Qt5Frame;
-class Qt5Object;
-class QFocusEvent;
-class QKeyEvent;
-class QMouseEvent;
-class QMoveEvent;
-class QPaintEvent;
-class QResizeEvent;
-class QShowEvent;
-class QWheelEvent;
+#include  "Qt5Frame.hxx"
 
-class Qt5Widget : public QWidget
-{
-Q_OBJECT
-
-Qt5Frame* m_pFrame;
-
-bool handleKeyEvent(QKeyEvent*, bool);
-void handleMouseButtonEvent(QMouseEvent*, bool);
-
-virtual void focusInEvent(QFocusEvent*) override;
-virtual void focusOutEvent(QFocusEvent*) override;
-virtual void keyPressEvent(QKeyEvent*) override;
-virtual void keyReleaseEvent(QKeyEvent*) override;
-virtual void mouseMoveEvent(QMouseEvent*) override;
-virtual void mousePressEvent(QMouseEvent*) override;
-virtual void mouseReleaseEvent(QMouseEvent*) override;
-virtual void moveEvent(QMoveEvent*) override;
-virtual void paintEvent(QPaintEvent*) override;
-virtual void resizeEvent(QResizeEvent*) override;
-virtual void showEvent(QShowEvent*) override;
-virtual void wheelEvent(QWheelEvent*) override;
-virtual void closeEvent(QCloseEvent*) override;
-
-public:
-Qt5Widget(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f 
= Qt::WindowFlags());
-virtual ~Qt5Widget() override;
-};
+QWidget* createQt5Widget(Qt5Frame , QWidget* parent, Qt::WindowFlags f);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index cb599b6822a7..7dee36de35d3 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -193,7 +193,7 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 
 vcl::Window *pWindow = ::Application::GetActiveTopWindow();
 assert( pWindow );
-Qt5Widget *pTransientParent = nullptr;
+QWidget *pTransientParent = nullptr;
 QWindow *pTransientWindow = nullptr;
 if( pWindow )
 {
@@ -201,7 +201,7 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 assert( pFrame );
 if( pFrame )
 {
-pTransientParent = static_cast( pFrame->GetQWidget() 
);
+pTransientParent = pFrame->GetQWidget();
 pTransientWindow = pTransientParent->window()->windowHandle();
 }
 }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2af95ee039dd..ec210c15ade0 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -90,7 +90,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 aWinFlags |= Qt::Window;
 }
 
-m_pQWidget.reset(new Qt5Widget(*this, pParent ? pParent->GetQWidget() : 
nullptr, aWinFlags));
+m_pQWidget.reset(createQt5Widget(*this, pParent ? pParent->GetQWidget() : 
nullptr, aWinFlags));
 
 if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
 {
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index bb3ca8aaa44b..8d910434b600 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -32,43 +32,61 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
 
-Qt5Widget::Qt5Widget(Qt5Frame& rFrame, QWidget* parent, Qt::WindowFlags f)
-: QWidget(parent, f)
-, m_pFrame()
+class VclQtMixinBase
 {
-create();
-setMouseTracking(true);
-setFocusPolicy(Qt::StrongFocus);
-}
-
-Qt5Widget::~Qt5Widget() {}
-
-void Qt5Widget::paintEvent(QPaintEvent* pEvent)
+public:
+VclQtMixinBase( Qt5Frame *pFrame) { m_pFrame = pFrame; }
+
+void mixinFocusInEvent(QFocusEvent*);
+void mixinFocusOutEvent(QFocusEvent*);
+void mixinKeyPressEvent(QKeyEvent*);
+void mixinKeyReleaseEvent(QKeyEvent*);
+void mixinMouseMoveEvent(QMouseEvent*);
+void mixinMousePressEvent(QMouseEvent*);
+void mixinMouseReleaseEvent(QMouseEvent*);
+void mixinMoveEvent(QMoveEvent*);
+void mixinPaintEvent(QPaintEvent*, QWidget* widget);
+void 

[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-05-14 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Frame.hxx  |3 
 vcl/inc/qt5/Qt5Widget.hxx |   40 
 vcl/qt5/Qt5FilePicker.cxx |4 
 vcl/qt5/Qt5Frame.cxx  |2 
 vcl/qt5/Qt5Widget.cxx |  209 ++
 5 files changed, 180 insertions(+), 78 deletions(-)

New commits:
commit 60945431deaaf853ebcbbc8121c194c13a087f66
Author: Katarina Behrens 
Date:   Mon May 14 15:39:30 2018 +0200

Templatize Qt5Widget class

to distinguish between QMainWindow (top-level SalFrame) and QWidget
(everything else). The former are going to receive a native menu

Change-Id: I9023d1e464345f96f13967f5e2c8b0716890fbc9

diff --git a/vcl/inc/qt5/Qt5Frame.hxx b/vcl/inc/qt5/Qt5Frame.hxx
index 4b0a99113536..8772ee7bbfcc 100644
--- a/vcl/inc/qt5/Qt5Frame.hxx
+++ b/vcl/inc/qt5/Qt5Frame.hxx
@@ -28,7 +28,6 @@
 
 class Qt5Graphics;
 class Qt5Instance;
-class Qt5Widget;
 class QWidget;
 class QPaintDevice;
 class QImage;
@@ -36,7 +35,7 @@ class SvpSalGraphics;
 
 class VCLPLUG_QT5_PUBLIC Qt5Frame : public SalFrame
 {
-friend class Qt5Widget;
+friend class VclQtMixinBase;
 
 std::unique_ptr m_pQWidget;
 
diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 7e7ed8240802..376ccf58ac18 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -20,44 +20,10 @@
 #pragma once
 
 #include 
+#include 
 
-class Qt5Frame;
-class Qt5Object;
-class QFocusEvent;
-class QKeyEvent;
-class QMouseEvent;
-class QMoveEvent;
-class QPaintEvent;
-class QResizeEvent;
-class QShowEvent;
-class QWheelEvent;
+#include  "Qt5Frame.hxx"
 
-class Qt5Widget : public QWidget
-{
-Q_OBJECT
-
-Qt5Frame* m_pFrame;
-
-bool handleKeyEvent(QKeyEvent*, bool);
-void handleMouseButtonEvent(QMouseEvent*, bool);
-
-virtual void focusInEvent(QFocusEvent*) override;
-virtual void focusOutEvent(QFocusEvent*) override;
-virtual void keyPressEvent(QKeyEvent*) override;
-virtual void keyReleaseEvent(QKeyEvent*) override;
-virtual void mouseMoveEvent(QMouseEvent*) override;
-virtual void mousePressEvent(QMouseEvent*) override;
-virtual void mouseReleaseEvent(QMouseEvent*) override;
-virtual void moveEvent(QMoveEvent*) override;
-virtual void paintEvent(QPaintEvent*) override;
-virtual void resizeEvent(QResizeEvent*) override;
-virtual void showEvent(QShowEvent*) override;
-virtual void wheelEvent(QWheelEvent*) override;
-virtual void closeEvent(QCloseEvent*) override;
-
-public:
-Qt5Widget(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f 
= Qt::WindowFlags());
-virtual ~Qt5Widget() override;
-};
+QWidget* createQt5Widget(Qt5Frame , QWidget* parent, Qt::WindowFlags f);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index cb599b6822a7..7dee36de35d3 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -193,7 +193,7 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 
 vcl::Window *pWindow = ::Application::GetActiveTopWindow();
 assert( pWindow );
-Qt5Widget *pTransientParent = nullptr;
+QWidget *pTransientParent = nullptr;
 QWindow *pTransientWindow = nullptr;
 if( pWindow )
 {
@@ -201,7 +201,7 @@ sal_Int16 SAL_CALL Qt5FilePicker::execute()
 assert( pFrame );
 if( pFrame )
 {
-pTransientParent = static_cast( pFrame->GetQWidget() 
);
+pTransientParent = pFrame->GetQWidget();
 pTransientWindow = pTransientParent->window()->windowHandle();
 }
 }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index 2af95ee039dd..ec210c15ade0 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -90,7 +90,7 @@ Qt5Frame::Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags 
nStyle, bool bUseCairo)
 aWinFlags |= Qt::Window;
 }
 
-m_pQWidget.reset(new Qt5Widget(*this, pParent ? pParent->GetQWidget() : 
nullptr, aWinFlags));
+m_pQWidget.reset(createQt5Widget(*this, pParent ? pParent->GetQWidget() : 
nullptr, aWinFlags));
 
 if (pParent && !(pParent->m_nStyle & SalFrameStyleFlags::PLUG))
 {
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index bb3ca8aaa44b..3359be6d0055 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -27,48 +27,66 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 
-Qt5Widget::Qt5Widget(Qt5Frame& rFrame, QWidget* parent, Qt::WindowFlags f)
-: QWidget(parent, f)
-, m_pFrame()
+class VclQtMixinBase
 {
-create();
-setMouseTracking(true);
-setFocusPolicy(Qt::StrongFocus);
-}
-
-Qt5Widget::~Qt5Widget() {}
-
-void Qt5Widget::paintEvent(QPaintEvent* pEvent)
+public:
+VclQtMixinBase( Qt5Frame *pFrame) { m_pFrame = pFrame; }
+
+void mixinFocusInEvent(QFocusEvent*);
+void mixinFocusOutEvent(QFocusEvent*);
+void 

[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-04-18 Thread Katarina Behrens
Rebased ref, commits from common ancestor:
commit 03b28bf39f4b41e1e0abf85dba15a24d358a06db
Author: Katarina Behrens 
Date:   Mon Apr 16 13:30:23 2018 +0200

Frames can now be closed by clicking top-right corner [x]

Change-Id: I4f841bfd8fe819a322af1ecaa95d17273d3031ec

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 83077796298f..7e7ed8240802 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -53,6 +53,7 @@ class Qt5Widget : public QWidget
 virtual void resizeEvent(QResizeEvent*) override;
 virtual void showEvent(QShowEvent*) override;
 virtual void wheelEvent(QWheelEvent*) override;
+virtual void closeEvent(QCloseEvent*) override;
 
 public:
 Qt5Widget(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f 
= Qt::WindowFlags());
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 6b082eef1c1f..bb3ca8aaa44b 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -173,6 +173,11 @@ void Qt5Widget::showEvent(QShowEvent*)
 m_pFrame->CallCallback(SalEvent::Paint, );
 }
 
+void Qt5Widget::closeEvent(QCloseEvent* /*pEvent*/)
+{
+m_pFrame->CallCallback(SalEvent::Close, nullptr);
+}
+
 static sal_uInt16 GetKeyCode(int keyval)
 {
 sal_uInt16 nCode = 0;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: Branch 'feature/qt5+kde5' - vcl/inc vcl/qt5

2018-04-16 Thread Katarina Behrens
 vcl/inc/qt5/Qt5Widget.hxx |1 +
 vcl/qt5/Qt5Widget.cxx |5 +
 2 files changed, 6 insertions(+)

New commits:
commit c06a42cffdb54e9a8399a293293f0e8111adc336
Author: Katarina Behrens 
Date:   Mon Apr 16 13:30:23 2018 +0200

Frames can now be closed by clicking top-right corner [x]

Change-Id: I4f841bfd8fe819a322af1ecaa95d17273d3031ec

diff --git a/vcl/inc/qt5/Qt5Widget.hxx b/vcl/inc/qt5/Qt5Widget.hxx
index 83077796298f..7e7ed8240802 100644
--- a/vcl/inc/qt5/Qt5Widget.hxx
+++ b/vcl/inc/qt5/Qt5Widget.hxx
@@ -53,6 +53,7 @@ class Qt5Widget : public QWidget
 virtual void resizeEvent(QResizeEvent*) override;
 virtual void showEvent(QShowEvent*) override;
 virtual void wheelEvent(QWheelEvent*) override;
+virtual void closeEvent(QCloseEvent*) override;
 
 public:
 Qt5Widget(Qt5Frame& rFrame, QWidget* parent = Q_NULLPTR, Qt::WindowFlags f 
= Qt::WindowFlags());
diff --git a/vcl/qt5/Qt5Widget.cxx b/vcl/qt5/Qt5Widget.cxx
index 6b082eef1c1f..b52d48fbcb67 100644
--- a/vcl/qt5/Qt5Widget.cxx
+++ b/vcl/qt5/Qt5Widget.cxx
@@ -173,6 +173,11 @@ void Qt5Widget::showEvent(QShowEvent*)
 m_pFrame->CallCallback(SalEvent::Paint, );
 }
 
+void Qt5Widget::closeEvent(QCloseEvent* pEvent)
+{
+m_pFrame->CallCallback(SalEvent::Close, nullptr);
+}
+
 static sal_uInt16 GetKeyCode(int keyval)
 {
 sal_uInt16 nCode = 0;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits