Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Nov 8, 2022
1 parent 035dae5 commit f54f32b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
30 changes: 29 additions & 1 deletion document.cpp
Expand Up @@ -1210,6 +1210,34 @@ void CDocument::wheelEvent (QWheelEvent *e)
}


void CDocument::contextMenuEvent (QContextMenuEvent *event)
{
QMenu *menu = new QMenu (this);

QAction *a = menu->addAction (tr("Copy"));
connect (a, SIGNAL(triggered()), this, SLOT(ed_copy()));

a = menu->addAction (tr("Cut"));
connect (a, SIGNAL(triggered()), this, SLOT(ed_cut()));

a = menu->addAction (tr("Paste"));
connect (a, SIGNAL(triggered()), this, SLOT(ed_paste()));

menu->addSeparator();

a = menu->addAction (tr("Undo"));
connect (a, SIGNAL(triggered()), this, SLOT(undo()));

a = menu->addAction (tr("Redo"));
connect (a, SIGNAL(triggered()), this, SLOT(redo()));

// menu->show();

menu->exec(event->globalPos());
delete menu;
}


CDocument::CDocument (CDox *hldr, QWidget *parent): QPlainTextEdit (parent)
{
holder = hldr;
Expand Down Expand Up @@ -1274,7 +1302,7 @@ CDocument::CDocument (CDox *hldr, QWidget *parent): QPlainTextEdit (parent)
//actCopy = new QAction (tr("Copy"), this);
//connect (actCopy, SIGNAL(triggered()), this, SLOT(ed_copy()));

setContextMenuPolicy (Qt::PreventContextMenu);
// setContextMenuPolicy (Qt::PreventContextMenu);

/*
set dots color, put to hl init
Expand Down
12 changes: 8 additions & 4 deletions document.h
Expand Up @@ -161,6 +161,9 @@ class CDocument: public QPlainTextEdit
void keyPressEvent (QKeyEvent *event);
void resizeEvent (QResizeEvent *event);
void wheelEvent (QWheelEvent *e);
void contextMenuEvent (QContextMenuEvent *event);


//QMenu* createStandardContextMenu();

public:
Expand Down Expand Up @@ -211,10 +214,6 @@ class CDocument: public QPlainTextEdit
QString get() const; //return selected text
void put (const QString &value); //replace selection or insert text at cursor

bool ed_copy();
bool ed_cut();
void ed_paste();

bool has_selection();


Expand Down Expand Up @@ -277,6 +276,11 @@ public slots:
void cb_cursorPositionChanged();
void updateLineNumberArea (const QRect &, int);
void slot_selectionChanged();

bool ed_copy();
bool ed_cut();
void ed_paste();

};


Expand Down
1 change: 0 additions & 1 deletion tea.cpp
Expand Up @@ -473,7 +473,6 @@ void CTEA::dropEvent (QDropEvent *event)
event->accept();
}


/*
===========================
Main window slots
Expand Down

0 comments on commit f54f32b

Please sign in to comment.