OSDN Git Service

Ver0.09pre
authorMasayuki Satoh <miyabi.satoh@gmail.com>
Sat, 23 Aug 2014 15:00:57 +0000 (00:00 +0900)
committerMasayuki Satoh <miyabi.satoh@gmail.com>
Sat, 23 Aug 2014 15:00:57 +0000 (00:00 +0900)
simpletextview.cpp

index 2588732..c6eb52a 100644 (file)
@@ -122,6 +122,20 @@ void SimpleTextView::keyPressEvent(QKeyEvent *event)
     }
 
     if (!ksq.isEmpty()) {
+        foreach (QObject *obj, this->children()) {
+            QAction *action = qobject_cast<QAction*>(obj);
+            if (action && action->isEnabled()) {
+                foreach (const QKeySequence &keySeq, action->shortcuts()) {
+                    if (ksq == keySeq.toString()) {
+                        qDebug() << "emit " << ksq << " " << action->objectName();
+                        emit action->triggered();
+                        event->accept();
+                        return;
+                    }
+                }
+            }
+        }
+
         foreach (QObject *obj, getMainWnd()->children()) {
             QAction *action = qobject_cast<QAction*>(obj);
             if (action && action->isEnabled()) {