add "Clear" to context menu of log viewer in qdbusviewer
authorTasuku Suzuki <stasuku@gmail.com>
Sat, 21 Dec 2013 07:15:32 +0000 (16:15 +0900)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 10 Jan 2014 01:02:59 +0000 (02:02 +0100)
Change-Id: Id4da5fcfdbe462e22a4227699c3e13ecf0cd363a
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
src/qdbus/qdbusviewer/logviewer.cpp [new file with mode: 0644]
src/qdbus/qdbusviewer/logviewer.h [new file with mode: 0644]
src/qdbus/qdbusviewer/qdbusviewer.cpp
src/qdbus/qdbusviewer/qdbusviewer.pro

diff --git a/src/qdbus/qdbusviewer/logviewer.cpp b/src/qdbus/qdbusviewer/logviewer.cpp
new file mode 100644 (file)
index 0000000..a230eb6
--- /dev/null
@@ -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 (file)
index 0000000..d8dec0e
--- /dev/null
@@ -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
index 403e954..ac0c141 100644 (file)
@@ -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);
index 23c6ba0..1cd2f8f 100644 (file)
@@ -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