Sfoglia il codice sorgente

add removeSplitAct to context menu of VEditWindow

Signed-off-by: Le Tan <[email protected]>
Le Tan 9 anni fa
parent
commit
d8aa464653
2 ha cambiato i file con 12 aggiunte e 0 eliminazioni
  1. 11 0
      src/veditwindow.cpp
  2. 1 0
      src/veditwindow.h

+ 11 - 0
src/veditwindow.cpp

@@ -14,11 +14,14 @@ VEditWindow::VEditWindow(VNote *vnote, QWidget *parent)
 
     setTabsClosable(true);
     setMovable(true);
+    setContextMenuPolicy(Qt::CustomContextMenu);
 
     connect(this, &VEditWindow::tabCloseRequested,
             this, &VEditWindow::handleTabCloseRequest);
     connect(this, &VEditWindow::tabBarClicked,
             this, &VEditWindow::handleTabbarClicked);
+    connect(this, &VEditWindow::customContextMenuRequested,
+            this, &VEditWindow::contextMenuRequested);
 }
 
 void VEditWindow::setupCornerWidget()
@@ -294,3 +297,11 @@ void VEditWindow::mousePressEvent(QMouseEvent *event)
     emit getFocused();
     QTabWidget::mousePressEvent(event);
 }
+
+void VEditWindow::contextMenuRequested(QPoint pos)
+{
+    QMenu menu(this);
+
+    menu.addAction(removeSplitAct);
+    menu.exec(this->mapToGlobal(pos));
+}

+ 1 - 0
src/veditwindow.h

@@ -51,6 +51,7 @@ private slots:
     void splitWindow();
     void removeSplit();
     void handleTabbarClicked(int index);
+    void contextMenuRequested(QPoint pos);
 
 private:
     void setupCornerWidget();