From 372392cf6e14ececbaff8aa54d2a7230ad17ba5f Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Sat, 21 Dec 2013 16:15:32 +0900 Subject: [PATCH] add "Clear" to context menu of log viewer in qdbusviewer Change-Id: Id4da5fcfdbe462e22a4227699c3e13ecf0cd363a Reviewed-by: Oswald Buddenhagen Reviewed-by: Friedemann Kleint --- src/qdbus/qdbusviewer/logviewer.cpp | 59 +++++++++++++++++++++++++++++++++++ src/qdbus/qdbusviewer/logviewer.h | 57 +++++++++++++++++++++++++++++++++ src/qdbus/qdbusviewer/qdbusviewer.cpp | 5 ++- src/qdbus/qdbusviewer/qdbusviewer.pro | 4 ++- 4 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 src/qdbus/qdbusviewer/logviewer.cpp create mode 100644 src/qdbus/qdbusviewer/logviewer.h diff --git a/src/qdbus/qdbusviewer/logviewer.cpp b/src/qdbus/qdbusviewer/logviewer.cpp new file mode 100644 index 0000000..a230eb6 --- /dev/null +++ b/src/qdbus/qdbusviewer/logviewer.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Tasuku Suzuki +** 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 +#include + +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 0000000..d8dec0e --- /dev/null +++ b/src/qdbus/qdbusviewer/logviewer.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Tasuku Suzuki +** 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 + +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 403e954..ac0c141 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 #include @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -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 23c6ba0..1cd2f8f 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 -- 2.7.4