1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  */
10 
11 #include <Qt5MainWindow.hxx>
12 #include <Qt5MainWindow.moc>
13 #include <Qt5AccessibleWidget.hxx>
14 
15 #include <QtGui/QAccessible>
16 #include <QtGui/QCloseEvent>
17 
Qt5MainWindow(Qt5Frame & rFrame,Qt::WindowFlags f)18 Qt5MainWindow::Qt5MainWindow(Qt5Frame& rFrame, Qt::WindowFlags f)
19     : QMainWindow(nullptr, f)
20     , m_rFrame(rFrame)
21 {
22     QAccessible::installFactory(Qt5AccessibleWidget::customFactory);
23 }
24 
closeEvent(QCloseEvent * pEvent)25 void Qt5MainWindow::closeEvent(QCloseEvent* pEvent)
26 {
27     bool bRet = false;
28     bRet = m_rFrame.CallCallback(SalEvent::Close, nullptr);
29 
30     if (bRet)
31         pEvent->accept();
32     // SalEvent::Close returning false may mean that user has vetoed
33     // closing the frame ("you have unsaved changes" dialog for example)
34     // We shouldn't process the event in such case
35     else
36         pEvent->ignore();
37 }
38 
moveEvent(QMoveEvent * pEvent)39 void Qt5MainWindow::moveEvent(QMoveEvent* pEvent)
40 {
41     m_rFrame.maGeometry.nX = pEvent->pos().x();
42     m_rFrame.maGeometry.nY = pEvent->pos().y();
43     m_rFrame.CallCallback(SalEvent::Move, nullptr);
44 }
45