diff --git a/toonz/sources/include/toonzqt/schematicnode.h b/toonz/sources/include/toonzqt/schematicnode.h index e4564408..bc85196b 100644 --- a/toonz/sources/include/toonzqt/schematicnode.h +++ b/toonz/sources/include/toonzqt/schematicnode.h @@ -43,19 +43,23 @@ protected: void focusOutEvent(QFocusEvent *fe) override; void keyPressEvent(QKeyEvent *ke) override; +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) void contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) override; +#endif signals: void focusOut(); protected slots: void onContentsChanged(); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) void onPopupHide(); void onCut(); void onCopy(); void onPaste(); void onDelete(); void onSelectAll(); +#endif }; //======================================================== diff --git a/toonz/sources/toonzqt/schematicnode.cpp b/toonz/sources/toonzqt/schematicnode.cpp index 415ce131..ecc87fca 100644 --- a/toonz/sources/toonzqt/schematicnode.cpp +++ b/toonz/sources/toonzqt/schematicnode.cpp @@ -20,11 +20,13 @@ #include "toonzqt/menubarcommand.h" #include "toonzqt/gutil.h" +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #define ACCEL_KEY(k) \ (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \ ? QLatin1Char('\t') + \ QKeySequence(k).toString(QKeySequence::NativeText) \ : QString()) +#endif //======================================================== // @@ -43,6 +45,7 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height) setFlag(QGraphicsItem::ItemIsFocusable, true); setTextInteractionFlags(Qt::TextEditorInteraction); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) popup = new QMenu(); popup->setObjectName(QLatin1String("qt_edit_menu")); @@ -69,14 +72,20 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height) this, SLOT(onSelectAll())); actionSelectAll->setObjectName(QStringLiteral("select-all")); + connect(popup, SIGNAL(aboutToHide()), this, SLOT(onPopupHide())); +#endif + connect(document(), SIGNAL(contentsChanged()), this, SLOT(onContentsChanged())); - connect(popup, SIGNAL(aboutToHide()), this, SLOT(onPopupHide())); } //-------------------------------------------------------- -SchematicName::~SchematicName() { delete popup; } +SchematicName::~SchematicName() { +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) + delete popup; +#endif +} //-------------------------------------------------------- @@ -154,6 +163,7 @@ bool SchematicName::eventFilter(QObject *object, QEvent *event) { void SchematicName::focusInEvent(QFocusEvent *fe) { QGraphicsTextItem::focusInEvent(fe); qApp->installEventFilter(this); +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) if (!m_refocus) { QTextDocument *doc = document(); QTextCursor cursor(doc->begin()); @@ -161,10 +171,16 @@ void SchematicName::focusInEvent(QFocusEvent *fe) { setTextCursor(cursor); m_curName = toPlainText(); } +#else + QTextDocument *doc = document(); + QTextCursor cursor(doc->begin()); + cursor.select(QTextCursor::Document); +#endif } //-------------------------------------------------------- +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) void SchematicName::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) { QClipboard *clipboard = QApplication::clipboard(); QTextCursor cursor = textCursor(); @@ -269,6 +285,7 @@ void SchematicName::onSelectAll() { cursor.select(QTextCursor::Document); setTextCursor(cursor); } +#endif //======================================================== //