summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTasuku Suzuki <stasuku@gmail.com>2013-12-21 16:15:32 +0900
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-10 02:02:59 +0100
commit372392cf6e14ececbaff8aa54d2a7230ad17ba5f (patch)
tree598f8c824548440a35e481be681c437652c97f5a
parent2aba84b72e3ff110209da3ba1bdca07d3d21522c (diff)
add "Clear" to context menu of log viewer in qdbusviewer
Change-Id: Id4da5fcfdbe462e22a4227699c3e13ecf0cd363a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r--src/qdbus/qdbusviewer/logviewer.cpp59
-rw-r--r--src/qdbus/qdbusviewer/logviewer.h57
-rw-r--r--src/qdbus/qdbusviewer/qdbusviewer.cpp5
-rw-r--r--src/qdbus/qdbusviewer/qdbusviewer.pro4
4 files changed, 121 insertions, 4 deletions
diff --git a/src/qdbus/qdbusviewer/logviewer.cpp b/src/qdbus/qdbusviewer/logviewer.cpp
new file mode 100644
index 000000000..a230eb65f
--- /dev/null
+++ b/src/qdbus/qdbusviewer/logviewer.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Tasuku Suzuki <stasuku@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "logviewer.h"
+
+#include <QtGui/QContextMenuEvent>
+#include <QtWidgets/QMenu>
+
+LogViewer::LogViewer(QWidget *parent)
+ : QTextBrowser(parent)
+{
+}
+
+void LogViewer::contextMenuEvent(QContextMenuEvent *event)
+{
+ QMenu *menu = createStandardContextMenu();
+ QAction *action = menu->addAction(tr("Clear"));
+ connect(action, SIGNAL(triggered()), this, SLOT(clear()));
+ menu->exec(event->globalPos());
+ delete menu;
+}
diff --git a/src/qdbus/qdbusviewer/logviewer.h b/src/qdbus/qdbusviewer/logviewer.h
new file mode 100644
index 000000000..d8dec0ecd
--- /dev/null
+++ b/src/qdbus/qdbusviewer/logviewer.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Tasuku Suzuki <stasuku@gmail.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the tools applications of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef LOGVIEWER_H
+#define LOGVIEWER_H
+
+#include <QtWidgets/QTextBrowser>
+
+class LogViewer : public QTextBrowser
+{
+ Q_OBJECT
+public:
+ explicit LogViewer(QWidget *parent = 0);
+
+protected:
+ virtual void contextMenuEvent(QContextMenuEvent *event);
+};
+
+#endif // LOGVIEWER_H
diff --git a/src/qdbus/qdbusviewer/qdbusviewer.cpp b/src/qdbus/qdbusviewer/qdbusviewer.cpp
index 403e954d7..ac0c141b4 100644
--- a/src/qdbus/qdbusviewer/qdbusviewer.cpp
+++ b/src/qdbus/qdbusviewer/qdbusviewer.cpp
@@ -42,7 +42,7 @@
#include "qdbusviewer.h"
#include "qdbusmodel.h"
#include "propertydialog.h"
-
+#include "logviewer.h"
#include <QtWidgets/QTreeWidget>
#include <QtCore/QStringListModel>
@@ -50,7 +50,6 @@
#include <QtCore/QMetaProperty>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QListView>
-#include <QtWidgets/QTextBrowser>
#include <QtWidgets/QAction>
#include <QtWidgets/QShortcut>
#include <QtWidgets/QVBoxLayout>
@@ -115,7 +114,7 @@ QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent) :
QSplitter *topSplitter = new QSplitter(Qt::Vertical, this);
layout->addWidget(topSplitter);
- log = new QTextBrowser;
+ log = new LogViewer;
connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl)));
QSplitter *splitter = new QSplitter(topSplitter);
diff --git a/src/qdbus/qdbusviewer/qdbusviewer.pro b/src/qdbus/qdbusviewer/qdbusviewer.pro
index 23c6ba027..1cd2f8f4d 100644
--- a/src/qdbus/qdbusviewer/qdbusviewer.pro
+++ b/src/qdbus/qdbusviewer/qdbusviewer.pro
@@ -1,10 +1,12 @@
HEADERS = qdbusviewer.h \
qdbusmodel.h \
- propertydialog.h
+ propertydialog.h \
+ logviewer.h
SOURCES = qdbusviewer.cpp \
qdbusmodel.cpp \
propertydialog.cpp \
+ logviewer.cpp \
main.cpp
RESOURCES += qdbusviewer.qrc