1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A MIDI and audio sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7 
8     Other copyrights also apply to some parts of this work.  Please
9     see the AUTHORS file and individual file headers for details.
10 
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16 */
17 
18 #ifndef RG_LABEL_H
19 #define RG_LABEL_H
20 
21 #include <QLabel>
22 #include <QWheelEvent>
23 
24 
25 class QWidget;
26 class QWheelEvent;
27 class QMouseEvent;
28 
29 
30 namespace Rosegarden
31 {
32 
33 /// Interactive QLabel Widget
34 class Label : public QLabel
35 {
36     Q_OBJECT
37 public:
38     explicit Label(const QString &text, QWidget *parent=nullptr, Qt::WindowFlags f=Qt::WindowFlags()) :
QLabel(text,parent,f)39         QLabel(text, parent, f)  { }
40 
41     // ??? Non-standard.  Used by Ui_RosegardenTransport.
42     Label(QWidget *parent = nullptr, const char *name=nullptr):
QLabel(name,parent)43         QLabel(name, parent) {;}
44 
45 signals:
46     void clicked();
47     void doubleClicked();
48     void scrollWheel(int);
49 
50 protected:
mouseReleaseEvent(QMouseEvent *)51     void mouseReleaseEvent(QMouseEvent * /*e*/) override
52         { emit clicked(); }
53 
mouseDoubleClickEvent(QMouseEvent *)54     void mouseDoubleClickEvent(QMouseEvent * /*e*/) override
55         { emit doubleClicked(); }
56 
wheelEvent(QWheelEvent * e)57     void wheelEvent(QWheelEvent *e) override {
58         // We'll handle this.  Don't pass to parent.
59         e->accept();
60 
61         emit scrollWheel(e->angleDelta().y());
62     }
63 
64 };
65 
66 
67 }
68 
69 #endif
70