Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
FrmTermWidget.cpp
1#include "FrmTermWidget.h"
2#include <QDebug>
3#include <QMenu>
4#include <QApplication>
5#include <QDesktopServices>
6#include <QLoggingCategory>
7
8Q_DECLARE_LOGGING_CATEGORY(Terminal)
9
10CFrmTermWidget::CFrmTermWidget(QWidget *parent) : QTermWidget(0, parent)
11{
12 setContextMenuPolicy(Qt::CustomContextMenu);
13 bool check = connect(this, SIGNAL(customContextMenuRequested(const QPoint &)),
14 this, SLOT(slotCustomContextMenuCall(const QPoint &)));
15 Q_ASSERT(check);
16
17 check = connect(this, SIGNAL(urlActivated(const QUrl&, bool)),
18 this, SLOT(slotActivateUrl(const QUrl&, bool)));
19 Q_ASSERT(check);
20}
21
22CFrmTermWidget::~CFrmTermWidget()
23{
24 qDebug(Terminal) << "CFrmTermWidget::~CFrmTermWidget()";
25}
26
27void CFrmTermWidget::slotCustomContextMenuCall(const QPoint & pos)
28{
29 QMenu menu;
30
31 menu.addAction(tr("Copy selection to clipboard"), this, SLOT(copyClipboard()));
32 menu.addAction(tr("Paste clipboard"), this, SLOT(pasteClipboard()));
33 menu.addAction(tr("Paste selection"), this, SLOT(pasteSelection()));
34 menu.addSeparator();
35 menu.addAction(tr("Zoom in"), this, SLOT(zoomIn()));
36 menu.addAction(tr("Zoom out"), this, SLOT(zoomOut()));
37 menu.addAction(tr("Zoom reset"), this, SIGNAL(sigZoomReset()));
38 menu.addSeparator();
39 menu.addAction(tr("Clear"), this, SLOT(clear()));
40
41 menu.exec(mapToGlobal(pos));
42}
43
44void CFrmTermWidget::slotActivateUrl(const QUrl& url, bool fromContextMenu)
45{
46 if (QApplication::keyboardModifiers() & Qt::ControlModifier || fromContextMenu) {
47 QDesktopServices::openUrl(url);
48 }
49}