summaryrefslogtreecommitdiff
path: root/vcl/qt5
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 09:22:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-08-04 11:21:22 +0200
commitf45ff1a7147e6a9479c669f082dd74349c6bcb4b (patch)
tree9ec5eee03fe7bbc5e026318efd6dcca3502d4696 /vcl/qt5
parent58937aa4a50ecd681382f03331340da4c843b01e (diff)
loplugin:flatten in vcl
Change-Id: I271cc67ecf34acbf0edbda960e33315fb6a1f9dc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100041 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/qt5')
-rw-r--r--vcl/qt5/Qt5FilePicker.cxx50
-rw-r--r--vcl/qt5/Qt5Frame.cxx164
-rw-r--r--vcl/qt5/Qt5Menu.cxx84
3 files changed, 149 insertions, 149 deletions
diff --git a/vcl/qt5/Qt5FilePicker.cxx b/vcl/qt5/Qt5FilePicker.cxx
index d648a5d94b75..5e0f88412056 100644
--- a/vcl/qt5/Qt5FilePicker.cxx
+++ b/vcl/qt5/Qt5FilePicker.cxx
@@ -823,31 +823,31 @@ void SAL_CALL Qt5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
css::uno::Reference<css::awt::XWindow> xParentWindow;
if (args.getLength() > 1)
args[1] >>= xParentWindow;
- if (xParentWindow.is())
- {
- css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysWinPeer(xParentWindow,
- css::uno::UNO_QUERY);
- if (xSysWinPeer.is())
- {
- // the sal_*Int8 handling is strange, but it's public API - no way around
- css::uno::Sequence<sal_Int8> aProcessIdent(16);
- rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray()));
- uno::Any aAny = xSysWinPeer->getWindowHandle(
- aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW);
- css::awt::SystemDependentXWindow xSysWin;
- aAny >>= xSysWin;
-
- const auto& pFrames = pSalInst->getFrames();
- const long aWindowHandle = xSysWin.WindowHandle;
- const auto it = std::find_if(pFrames.begin(), pFrames.end(),
- [&aWindowHandle](auto pFrame) -> bool {
- const SystemEnvData* pData = pFrame->GetSystemData();
- return pData && long(pData->aWindow) == aWindowHandle;
- });
- if (it != pFrames.end())
- m_pParentWidget = static_cast<Qt5Frame*>(*it)->asChild();
- }
- }
+ if (!xParentWindow.is())
+ return;
+
+ css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysWinPeer(xParentWindow,
+ css::uno::UNO_QUERY);
+ if (!xSysWinPeer.is())
+ return;
+
+ // the sal_*Int8 handling is strange, but it's public API - no way around
+ css::uno::Sequence<sal_Int8> aProcessIdent(16);
+ rtl_getGlobalProcessId(reinterpret_cast<sal_uInt8*>(aProcessIdent.getArray()));
+ uno::Any aAny
+ = xSysWinPeer->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_XWINDOW);
+ css::awt::SystemDependentXWindow xSysWin;
+ aAny >>= xSysWin;
+
+ const auto& pFrames = pSalInst->getFrames();
+ const long aWindowHandle = xSysWin.WindowHandle;
+ const auto it
+ = std::find_if(pFrames.begin(), pFrames.end(), [&aWindowHandle](auto pFrame) -> bool {
+ const SystemEnvData* pData = pFrame->GetSystemData();
+ return pData && long(pData->aWindow) == aWindowHandle;
+ });
+ if (it != pFrames.end())
+ m_pParentWidget = static_cast<Qt5Frame*>(*it)->asChild();
}
void SAL_CALL Qt5FilePicker::cancel() { m_pFileDialog->reject(); }
diff --git a/vcl/qt5/Qt5Frame.cxx b/vcl/qt5/Qt5Frame.cxx
index ed3368ac3970..f008f4538bd7 100644
--- a/vcl/qt5/Qt5Frame.cxx
+++ b/vcl/qt5/Qt5Frame.cxx
@@ -547,35 +547,35 @@ void Qt5Frame::SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt1
}
}
- if (nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y))
+ if (!(nFlags & (SAL_FRAME_POSSIZE_X | SAL_FRAME_POSSIZE_Y)))
+ return;
+
+ if (m_pParent)
{
- if (m_pParent)
- {
- const SalFrameGeometry& aParentGeometry = m_pParent->maGeometry;
- if (QGuiApplication::isRightToLeft())
- nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - maGeometry.nWidth - 1;
- else
- nX += aParentGeometry.nX;
- nY += aParentGeometry.nY;
-
- Qt5MainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
- if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible())
- nY += round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF());
- }
+ const SalFrameGeometry& aParentGeometry = m_pParent->maGeometry;
+ if (QGuiApplication::isRightToLeft())
+ nX = aParentGeometry.nX + aParentGeometry.nWidth - nX - maGeometry.nWidth - 1;
+ else
+ nX += aParentGeometry.nX;
+ nY += aParentGeometry.nY;
- if (!(nFlags & SAL_FRAME_POSSIZE_X))
- nX = maGeometry.nX;
- else if (!(nFlags & SAL_FRAME_POSSIZE_Y))
- nY = maGeometry.nY;
+ Qt5MainWindow* pTopLevel = m_pParent->GetTopLevelWindow();
+ if (pTopLevel && pTopLevel->menuBar() && pTopLevel->menuBar()->isVisible())
+ nY += round(pTopLevel->menuBar()->geometry().height() * devicePixelRatioF());
+ }
- // assume the reposition happened
- // needed for calculations and will eventually be corrected by events later
- maGeometry.nX = nX;
- maGeometry.nY = nY;
+ if (!(nFlags & SAL_FRAME_POSSIZE_X))
+ nX = maGeometry.nX;
+ else if (!(nFlags & SAL_FRAME_POSSIZE_Y))
+ nY = maGeometry.nY;
- m_bDefaultPos = false;
- asChild()->move(round(nX / devicePixelRatioF()), round(nY / devicePixelRatioF()));
- }
+ // assume the reposition happened
+ // needed for calculations and will eventually be corrected by events later
+ maGeometry.nX = nX;
+ maGeometry.nY = nY;
+
+ m_bDefaultPos = false;
+ asChild()->move(round(nX / devicePixelRatioF()), round(nY / devicePixelRatioF()));
}
void Qt5Frame::GetClientSize(long& rWidth, long& rHeight)
@@ -600,25 +600,25 @@ SalFrame* Qt5Frame::GetParent() const { return m_pParent; }
void Qt5Frame::SetModal(bool bModal)
{
- if (isWindow())
- {
- auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
- assert(pSalInst);
- pSalInst->RunInMainThread([this, bModal]() {
+ if (!isWindow())
+ return;
- QWidget* const pChild = asChild();
- const bool bWasVisible = pChild->isVisible();
+ auto* pSalInst(static_cast<Qt5Instance*>(GetSalData()->m_pInstance));
+ assert(pSalInst);
+ pSalInst->RunInMainThread([this, bModal]() {
- // modality change is only effective if the window is hidden
- if (bWasVisible)
- pChild->hide();
+ QWidget* const pChild = asChild();
+ const bool bWasVisible = pChild->isVisible();
- pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal);
+ // modality change is only effective if the window is hidden
+ if (bWasVisible)
+ pChild->hide();
- if (bWasVisible)
- pChild->show();
- });
- }
+ pChild->setWindowModality(bModal ? Qt::WindowModal : Qt::NonModal);
+
+ if (bWasVisible)
+ pChild->show();
+ });
}
bool Qt5Frame::GetModal() const { return isWindow() && windowHandle()->isModal(); }
@@ -1189,52 +1189,52 @@ void Qt5Frame::EndSetClipRegion() { m_bNullRegion = false; }
void Qt5Frame::SetScreenNumber(unsigned int nScreen)
{
- if (isWindow())
+ if (!isWindow())
+ return;
+
+ QWindow* const pWindow = windowHandle();
+ if (!pWindow)
+ return;
+
+ QList<QScreen*> screens = QApplication::screens();
+ if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll)
{
- QWindow* const pWindow = windowHandle();
- if (pWindow)
- {
- QList<QScreen*> screens = QApplication::screens();
- if (static_cast<int>(nScreen) < screens.size() || m_bFullScreenSpanAll)
- {
- QRect screenGeo;
-
- if (!m_bFullScreenSpanAll)
- {
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- screenGeo = QApplication::desktop()->screenGeometry(nScreen);
- SAL_WNODEPRECATED_DECLARATIONS_POP
- pWindow->setScreen(QApplication::screens()[nScreen]);
- }
- else // special case: fullscreen over all available screens
- {
- assert(m_bFullScreen);
- // left-most screen
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0));
- SAL_WNODEPRECATED_DECLARATIONS_POP
- // entire virtual desktop
- screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry();
- pWindow->setScreen(QApplication::screens()[nLeftScreen]);
- pWindow->setGeometry(screenGeo);
- nScreen = nLeftScreen;
- }
-
- // setScreen by itself has no effect, explicitly move the widget to
- // the new screen
- asChild()->move(screenGeo.topLeft());
- }
- else
- {
- // index outta bounds, use primary screen
- QScreen* primaryScreen = QApplication::primaryScreen();
- pWindow->setScreen(primaryScreen);
- nScreen = static_cast<sal_uInt32>(screenNumber(primaryScreen));
- }
+ QRect screenGeo;
- maGeometry.nDisplayScreenNumber = nScreen;
+ if (!m_bFullScreenSpanAll)
+ {
+ SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ screenGeo = QApplication::desktop()->screenGeometry(nScreen);
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+ pWindow->setScreen(QApplication::screens()[nScreen]);
+ }
+ else // special case: fullscreen over all available screens
+ {
+ assert(m_bFullScreen);
+ // left-most screen
+ SAL_WNODEPRECATED_DECLARATIONS_PUSH
+ int nLeftScreen = QApplication::desktop()->screenNumber(QPoint(0, 0));
+ SAL_WNODEPRECATED_DECLARATIONS_POP
+ // entire virtual desktop
+ screenGeo = QApplication::screens()[nLeftScreen]->availableVirtualGeometry();
+ pWindow->setScreen(QApplication::screens()[nLeftScreen]);
+ pWindow->setGeometry(screenGeo);
+ nScreen = nLeftScreen;
}
+
+ // setScreen by itself has no effect, explicitly move the widget to
+ // the new screen
+ asChild()->move(screenGeo.topLeft());
}
+ else
+ {
+ // index outta bounds, use primary screen
+ QScreen* primaryScreen = QApplication::primaryScreen();
+ pWindow->setScreen(primaryScreen);
+ nScreen = static_cast<sal_uInt32>(screenNumber(primaryScreen));
+ }
+
+ maGeometry.nDisplayScreenNumber = nScreen;
}
void Qt5Frame::SetApplicationID(const OUString& rWMClass)
diff --git a/vcl/qt5/Qt5Menu.cxx b/vcl/qt5/Qt5Menu.cxx
index 98615247035a..f7c2e480118c 100644
--- a/vcl/qt5/Qt5Menu.cxx
+++ b/vcl/qt5/Qt5Menu.cxx
@@ -356,21 +356,21 @@ void Qt5Menu::RemoveItem(unsigned nPos)
{
SolarMutexGuard aGuard;
- if (nPos < maItems.size())
- {
- Qt5MenuItem* pItem = maItems[nPos];
- pItem->mpAction.reset();
- pItem->mpMenu.reset();
+ if (nPos >= maItems.size())
+ return;
- maItems.erase(maItems.begin() + nPos);
+ Qt5MenuItem* pItem = maItems[nPos];
+ pItem->mpAction.reset();
+ pItem->mpMenu.reset();
- // Recalculate action groups if necessary:
- // if separator between two QActionGroups was removed,
- // it may be needed to merge them
- if (nPos > 0)
- {
- ReinitializeActionGroup(nPos - 1);
- }
+ maItems.erase(maItems.begin() + nPos);
+
+ // Recalculate action groups if necessary:
+ // if separator between two QActionGroups was removed,
+ // it may be needed to merge them
+ if (nPos > 0)
+ {
+ ReinitializeActionGroup(nPos - 1);
}
}
@@ -421,26 +421,26 @@ void Qt5Menu::SetFrame(const SalFrame* pFrame)
mpFrame->SetMenu(this);
Qt5MainWindow* pMainWindow = mpFrame->GetTopLevelWindow();
- if (pMainWindow)
+ if (!pMainWindow)
+ return;
+
+ mpQMenuBar = pMainWindow->menuBar();
+ if (mpQMenuBar)
{
- mpQMenuBar = pMainWindow->menuBar();
- if (mpQMenuBar)
+ mpQMenuBar->clear();
+ QPushButton* pButton
+ = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
+ if (pButton && ((mpCloseButton != pButton) || !maCloseButtonConnection))
{
- mpQMenuBar->clear();
- QPushButton* pButton
- = static_cast<QPushButton*>(mpQMenuBar->cornerWidget(Qt::TopRightCorner));
- if (pButton && ((mpCloseButton != pButton) || !maCloseButtonConnection))
- {
- maCloseButtonConnection
- = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument);
- mpCloseButton = pButton;
- }
+ maCloseButtonConnection
+ = connect(pButton, &QPushButton::clicked, this, &Qt5Menu::slotCloseDocument);
+ mpCloseButton = pButton;
}
+ }
- mpQMenu = nullptr;
+ mpQMenu = nullptr;
- DoFullMenuUpdate(mpVCLMenu);
- }
+ DoFullMenuUpdate(mpVCLMenu);
}
void Qt5Menu::DoFullMenuUpdate(Menu* pMenuBar)
@@ -578,21 +578,21 @@ const Qt5Frame* Qt5Menu::GetFrame() const
void Qt5Menu::slotMenuTriggered(Qt5MenuItem* pQItem)
{
- if (pQItem)
- {
- Qt5Menu* pSalMenu = pQItem->mpParentMenu;
- Qt5Menu* pTopLevel = pSalMenu->GetTopLevel();
+ if (!pQItem)
+ return;
- Menu* pMenu = pSalMenu->GetMenu();
- auto mnId = pQItem->mnId;
-
- // HACK to allow HandleMenuCommandEvent to "not-set" the checked button
- // LO expects a signal before an item state change, so reset the check item
- if (pQItem->mpAction->isCheckable()
- && (!pQItem->mpActionGroup || pQItem->mpActionGroup->actions().size() <= 1))
- pQItem->mpAction->setChecked(!pQItem->mpAction->isChecked());
- pTopLevel->GetMenu()->HandleMenuCommandEvent(pMenu, mnId);
- }
+ Qt5Menu* pSalMenu = pQItem->mpParentMenu;
+ Qt5Menu* pTopLevel = pSalMenu->GetTopLevel();
+
+ Menu* pMenu = pSalMenu->GetMenu();
+ auto mnId = pQItem->mnId;
+
+ // HACK to allow HandleMenuCommandEvent to "not-set" the checked button
+ // LO expects a signal before an item state change, so reset the check item
+ if (pQItem->mpAction->isCheckable()
+ && (!pQItem->mpActionGroup || pQItem->mpActionGroup->actions().size() <= 1))
+ pQItem->mpAction->setChecked(!pQItem->mpAction->isChecked());
+ pTopLevel->GetMenu()->HandleMenuCommandEvent(pMenu, mnId);
}
void Qt5Menu::slotMenuAboutToShow(Qt5MenuItem* pQItem)