Add comment/uncomment actions to the context menu

pull/208/head
PlutonicOverkill 8 years ago
parent 80d1bb571c
commit 83ff7d162c

@ -7,6 +7,7 @@
#include <QString>
#include <QPainter>
#include <QTextDocumentFragment>
#include <QMenu>
#include "../../model/doc/document.hpp"
@ -284,6 +285,16 @@ void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy)
updateLineNumberAreaWidth(0);
}
void CSVWorld::ScriptEdit::commentSelection()
{
}
void CSVWorld::ScriptEdit::uncommentSelection()
{
}
void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
{
QPlainTextEdit::resizeEvent(e);
@ -292,6 +303,16 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
mLineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
{
QMenu *menu = createStandardContextMenu();
menu->addAction("Comment Selection", this, SLOT(commentSelection()));
menu->addAction("Uncomment Selection", this, SLOT(uncommentSelection()));
menu->exec(event->globalPos());
delete menu;
}
void CSVWorld::ScriptEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
{
QPainter painter(mLineNumberArea);

@ -77,6 +77,8 @@ namespace CSVWorld
virtual void resizeEvent(QResizeEvent *e);
virtual void contextMenuEvent(QContextMenuEvent *event);
private:
QVector<CSMWorld::UniversalId::Type> mAllowedTypes;
@ -111,6 +113,10 @@ namespace CSVWorld
void updateLineNumberAreaWidth(int newBlockCount);
void updateLineNumberArea(const QRect &, int);
void commentSelection();
void uncommentSelection();
};
class LineNumberArea : public QWidget

Loading…
Cancel
Save