Chris@424
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@424
|
2
|
Chris@424
|
3 /*
|
Chris@424
|
4 Sonic Visualiser
|
Chris@424
|
5 An audio file viewer and annotation editor.
|
Chris@424
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@424
|
7 This file copyright 2008 QMUL.
|
Chris@424
|
8
|
Chris@424
|
9 This program is free software; you can redistribute it and/or
|
Chris@424
|
10 modify it under the terms of the GNU General Public License as
|
Chris@424
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@424
|
12 License, or (at your option) any later version. See the file
|
Chris@424
|
13 COPYING included with this distribution for more information.
|
Chris@424
|
14 */
|
Chris@424
|
15
|
Chris@1407
|
16 #ifndef SV_SELECTABLE_LABEL_H
|
Chris@1407
|
17 #define SV_SELECTABLE_LABEL_H
|
Chris@424
|
18
|
Chris@424
|
19 #include <QLabel>
|
Chris@424
|
20
|
Chris@424
|
21 class SelectableLabel : public QLabel
|
Chris@424
|
22 {
|
Chris@424
|
23 Q_OBJECT
|
Chris@424
|
24
|
Chris@424
|
25 public:
|
Chris@424
|
26 SelectableLabel(QWidget *parent = 0);
|
Chris@424
|
27 virtual ~SelectableLabel();
|
Chris@424
|
28
|
Chris@424
|
29 void setSelectedText(QString);
|
Chris@424
|
30 void setUnselectedText(QString);
|
Chris@424
|
31
|
Chris@424
|
32 bool isSelected() const { return m_selected; }
|
Chris@424
|
33
|
Chris@424
|
34 signals:
|
Chris@424
|
35 void selectionChanged();
|
Chris@424
|
36 void doubleClicked();
|
Chris@424
|
37
|
Chris@424
|
38 public slots:
|
Chris@424
|
39 void setSelected(bool);
|
Chris@424
|
40 void toggle();
|
Chris@424
|
41
|
Chris@424
|
42 protected:
|
Chris@1406
|
43 void mousePressEvent(QMouseEvent *e) override;
|
Chris@1406
|
44 void mouseReleaseEvent(QMouseEvent *e) override;
|
Chris@1406
|
45 void mouseDoubleClickEvent(QMouseEvent *e) override;
|
Chris@1406
|
46 void enterEvent(QEvent *) override;
|
Chris@1406
|
47 void leaveEvent(QEvent *) override;
|
Chris@424
|
48 void setupStyle();
|
Chris@424
|
49 QString m_selectedText;
|
Chris@424
|
50 QString m_unselectedText;
|
Chris@424
|
51 bool m_selected;
|
Chris@441
|
52 bool m_swallowRelease;
|
Chris@424
|
53 };
|
Chris@424
|
54
|
Chris@424
|
55 #endif
|