From 42d519e60c96194ecc1fab32df506541938d8177 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Mon, 29 Aug 2011 18:42:57 +0300 Subject: [PATCH] SANKORE-186: Sankore hotkey Alt+F4 doesn't remove sankore from active processes --- src/core/UBApplication.cpp | 10 +++++++++- src/core/UBApplication.h | 2 ++ src/domain/UBGraphicsScene.cpp | 4 ++-- src/domain/UBGraphicsScene.h | 2 +- src/gui/UBMainWindow.cpp | 7 +++++++ src/gui/UBMainWindow.h | 4 ++++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index b1942ce1..0e431005 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -233,7 +233,8 @@ int UBApplication::exec(const QString& pFileToImport) connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument())); connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing())); - + connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*))); + boardController = new UBBoardController(mainWindow); boardController->init(); @@ -379,6 +380,13 @@ void UBApplication::toolBarDisplayTextChanged(QVariant display) } +void UBApplication::closeEvent(QCloseEvent *event) +{ + Q_UNUSED(event); + + closing(); +} + void UBApplication::closing() { diff --git a/src/core/UBApplication.h b/src/core/UBApplication.h index 29371970..88fe7969 100644 --- a/src/core/UBApplication.h +++ b/src/core/UBApplication.h @@ -99,6 +99,8 @@ class UBApplication : public QtSingleApplication void toolBarPositionChanged(QVariant topOrBottom); void toolBarDisplayTextChanged(QVariant display); + void closeEvent(QCloseEvent *event); + /** * Used on Windows platform to open file in running application. On MacOS X opening file is done through the * FileOpen event that is handle in eventFilter method. diff --git a/src/domain/UBGraphicsScene.cpp b/src/domain/UBGraphicsScene.cpp index fdc5bf82..24de0b36 100644 --- a/src/domain/UBGraphicsScene.cpp +++ b/src/domain/UBGraphicsScene.cpp @@ -238,7 +238,7 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre } else if (currentTool == UBStylusTool::Magnifier) { - CreateMagnifierQWidgets(QCursor::pos() /*scenePos*/); + CreateMagnifierQWidgets(); magniferControlViewWidget->grabNMove(QCursor::pos(), true); magniferDisplayViewWidget->grabNMove(scenePos, true); magniferControlViewWidget->show(); @@ -424,7 +424,7 @@ void UBGraphicsScene::drawPointer(const QPointF &pPoint) } // call this function when user press mouse button in Magnifier mode -void UBGraphicsScene::CreateMagnifierQWidgets(const QPoint & globalPos) +void UBGraphicsScene::CreateMagnifierQWidgets() { UBApplication::app()->setOverrideCursor( QCursor( Qt::BlankCursor ) ); diff --git a/src/domain/UBGraphicsScene.h b/src/domain/UBGraphicsScene.h index 8092baf3..520ea3cb 100644 --- a/src/domain/UBGraphicsScene.h +++ b/src/domain/UBGraphicsScene.h @@ -289,7 +289,7 @@ class UBGraphicsScene: public UBCoreGraphicsScene, public UBItem void drawEraser(const QPointF& pEndPoint); void drawPointer(const QPointF& pEndPoint); - void CreateMagnifierQWidgets(const QPoint &point); + void CreateMagnifierQWidgets(); void DisposeMagnifierQWidgets(); diff --git a/src/gui/UBMainWindow.cpp b/src/gui/UBMainWindow.cpp index 284698cc..0a068648 100644 --- a/src/gui/UBMainWindow.cpp +++ b/src/gui/UBMainWindow.cpp @@ -40,6 +40,7 @@ UBMainWindow::UBMainWindow(QWidget *parent, Qt::WindowFlags flags) actionQuit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); #elif defined(Q_WS_WIN) actionPreferences->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Return)); + // this code, because it unusable, system key combination can`t be triggered, even we add it manually actionQuit->setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4)); #else actionQuit->setShortcut(QKeySequence(Qt::ALT + Qt::Key_F4)); @@ -118,6 +119,12 @@ void UBMainWindow::keyPressEvent(QKeyEvent *event) */ } +void UBMainWindow::closeEvent(QCloseEvent *event) +{ + event->ignore(); + emit closeEvent_Signal(event); +} + void UBMainWindow::onExportDone() { // HACK : When opening the file save dialog during the document exportation, diff --git a/src/gui/UBMainWindow.h b/src/gui/UBMainWindow.h index 87e9510c..a08220a9 100644 --- a/src/gui/UBMainWindow.h +++ b/src/gui/UBMainWindow.h @@ -42,12 +42,16 @@ class UBMainWindow : public QMainWindow, public Ui::MainWindow void addDocumentsWidget(QWidget *pWidget); void switchToDocumentsWidget(); + signals: + void closeEvent_Signal( QCloseEvent *event ); + public slots: void onExportDone(); protected: virtual void keyPressEvent(QKeyEvent *event); + virtual void closeEvent (QCloseEvent *event); virtual QMenu* createPopupMenu () {