CuteLogger
Fast and simple logging solution for Qt based applications
scrubbar.h
1 /*
2  * Copyright (c) 2011 Meltytech, LLC
3  * Author: Dan Dennedy <dan@dennedy.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef SCRUBBAR_H
20 #define SCRUBBAR_H
21 
22 #include <QWidget>
23 
24 class ScrubBar : public QWidget
25 {
26  Q_OBJECT
27 
28  enum controls {
29  CONTROL_NONE,
30  CONTROL_HEAD,
31  CONTROL_IN,
32  CONTROL_OUT
33  };
34 
35 public:
36  explicit ScrubBar(QWidget *parent = 0);
37 
38  virtual void mousePressEvent(QMouseEvent *event);
39  virtual void mouseReleaseEvent(QMouseEvent *event);
40  virtual void mouseMoveEvent(QMouseEvent *event);
41  void setScale(int maximum);
42  void setFramerate(double fps);
43  int position() const;
44  void setInPoint(int in);
45  void setOutPoint(int out);
46  void setMarkers(const QList<int> &);
47  QList<int> markers() const
48  {
49  return m_markers;
50  }
51  void setMargin(int margin)
52  {
53  m_margin = margin;
54  }
55 
56 signals:
57  void seeked(int);
58  void inChanged(int);
59  void outChanged(int);
60 
61 public slots:
62  bool onSeek(int value);
63 
64 protected:
65  virtual void paintEvent(QPaintEvent *e);
66  virtual void resizeEvent(QResizeEvent *);
67  virtual bool event(QEvent *event);
68 
69 private:
70  int m_cursorPosition;
71  int m_head;
72  double m_scale;
73  double m_fps;
74  int m_interval;
75  int m_max;
76  int m_in;
77  int m_out;
78  int m_margin;
79  enum controls m_activeControl;
80  QPixmap m_pixmap;
81  int m_timecodeWidth;
82  int m_secondsPerTick;
83  QList<int> m_markers;
84 
85  void updatePixmap();
86 };
87 
88 #endif // SCRUBBAR_H