Fix doc path
[opentx.git] / companion / src / simulation / widgets / sliderwidget.h
blob1ed285ba8f4539da186d17edc5c280b15796c248
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _SLIDERWIDGET_H_
22 #define _SLIDERWIDGET_H_
24 #include <QtGui>
25 #include <QSlider>
26 #include <QToolTip>
28 class SliderWidget : public QSlider
30 Q_OBJECT
32 public:
34 explicit SliderWidget(QWidget * parent = 0):
35 QSlider(parent)
37 m_toolTip = tr("<p>Value (input): <b>%1</b></p>") % tr("Right-double-click to reset to center.");
40 protected:
42 bool event(QEvent *event)
44 if (event->type() == QEvent::ToolTip) {
45 QHelpEvent * helpEvent = static_cast<QHelpEvent *>(event);
46 if (helpEvent) {
47 QToolTip::showText(helpEvent->globalPos(), m_toolTip.arg(this->value()));
48 return true;
51 return QWidget::event(event);
54 void mousePressEvent(QMouseEvent * event)
56 if (event->button() == Qt::RightButton && event->type() == QEvent::MouseButtonDblClick) {
57 setValue(0);
58 emit sliderMoved(0);
59 event->accept();
61 QSlider::mousePressEvent(event);
64 QString m_toolTip;
67 #endif // _SLIDERWIDGET_H_