Skip to content

Commit ad5665b

Browse files
committed
fix: shortcuts while editing text item
- while editing a text item, secondary shortcuts like Shift+Ins have not been processed properly - instead they have been routed to the board controller - add UBApplication::enableEditingShortcuts to enable/disable global action shortcuts for cut/copy/paste - disable these shortcuts while a text item is selected - reorder and cleanup includes in UBGraphicsTextItemDelegate Signed-off-by: letsfindaway <me@letsfindaway.de>
1 parent 627c1dd commit ad5665b

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/core/UBApplication.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,7 @@ int UBApplication::exec(const QString& pFileToImport)
321321

322322
mainWindow->setAttribute(Qt::WA_NativeWindow, true);
323323

324-
mainWindow->actionCopy->setShortcuts(QKeySequence::Copy);
325-
mainWindow->actionPaste->setShortcuts(QKeySequence::Paste);
326-
mainWindow->actionCut->setShortcuts(QKeySequence::Cut);
324+
enableEditingShortcuts(true);
327325

328326
UBThumbnailUI::_private::initCatalog();
329327

@@ -745,6 +743,22 @@ void UBApplication::cleanup()
745743
documentController = NULL;
746744
}
747745

746+
void UBApplication::enableEditingShortcuts(bool enable)
747+
{
748+
if (enable)
749+
{
750+
mainWindow->actionCopy->setShortcuts(QKeySequence::Copy);
751+
mainWindow->actionPaste->setShortcuts(QKeySequence::Paste);
752+
mainWindow->actionCut->setShortcuts(QKeySequence::Cut);
753+
}
754+
else
755+
{
756+
mainWindow->actionCopy->setShortcuts({});
757+
mainWindow->actionPaste->setShortcuts({});
758+
mainWindow->actionCut->setShortcuts({});
759+
}
760+
}
761+
748762
QString UBApplication::urlFromHtml(QString html)
749763
{
750764
QString _html;

src/core/UBApplication.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class UBApplication : public SingleApplication
6868

6969
void cleanup();
7070

71+
void enableEditingShortcuts(bool enable);
72+
7173
static QPointer<QUndoStack> undoStack;
7274

7375
static UBDisplayManager* displayManager;

src/domain/UBGraphicsTextItemDelegate.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,20 @@
3030
#include <QtGui>
3131
#include <QtSvg>
3232

33-
#include "core/UBApplication.h"
34-
#include "UBGraphicsGroupContainerItem.h"
3533
#include "UBGraphicsTextItemDelegate.h"
3634
#include "UBGraphicsScene.h"
37-
#include "gui/UBResources.h"
3835

39-
#include "domain/UBGraphicsTextItem.h"
40-
#include "domain/UBGraphicsDelegateFrame.h"
36+
#include "core/UBApplication.h"
4137
#include "core/UBSettings.h"
4238

4339
#include "board/UBBoardController.h"
4440
#include "board/UBBoardView.h"
4541

42+
#include "domain/UBGraphicsTextItem.h"
43+
#include "domain/UBGraphicsDelegateFrame.h"
44+
45+
#include "gui/UBResources.h"
46+
4647
#include "core/memcheck.h"
4748

4849
const int UBGraphicsTextItemDelegate::sMinPixelSize = 8;
@@ -849,6 +850,10 @@ QVariant UBGraphicsTextItemDelegate::itemChange(QGraphicsItem::GraphicsItemChang
849850
saveTextCursorFormats();
850851
}
851852
}
853+
854+
// disable global editing shortcuts while text item is selected
855+
// so that they are passed to the item
856+
UBApplication::app()->enableEditingShortcuts(!value.toBool());
852857
}
853858

854859
return UBGraphicsItemDelegate::itemChange(change, value);

0 commit comments

Comments
 (0)