diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controlpushbutton.h | 15 | ||||
-rw-r--r-- | src/widget/wbasewidget.cpp | 63 | ||||
-rw-r--r-- | src/widget/wbasewidget.h | 7 | ||||
-rw-r--r-- | src/widget/wlabel.cpp | 12 | ||||
-rw-r--r-- | src/widget/wlabel.h | 4 | ||||
-rw-r--r-- | src/widget/wlibrary.cpp | 7 | ||||
-rw-r--r-- | src/widget/wlibrary.h | 4 | ||||
-rw-r--r-- | src/widget/wlibrarysidebar.cpp | 7 | ||||
-rw-r--r-- | src/widget/wlibrarysidebar.h | 4 | ||||
-rw-r--r-- | src/widget/wpushbutton.cpp | 18 | ||||
-rw-r--r-- | src/widget/wpushbutton.h | 1 | ||||
-rw-r--r-- | src/widget/wsearchlineedit.cpp | 7 | ||||
-rw-r--r-- | src/widget/wsearchlineedit.h | 2 | ||||
-rw-r--r-- | src/widget/wslidercomposed.cpp | 10 | ||||
-rw-r--r-- | src/widget/wslidercomposed.h | 1 | ||||
-rw-r--r-- | src/widget/wspinny.cpp | 7 | ||||
-rw-r--r-- | src/widget/wspinny.h | 2 | ||||
-rw-r--r-- | src/widget/wwidget.cpp | 7 | ||||
-rw-r--r-- | src/widget/wwidget.h | 5 | ||||
-rw-r--r-- | src/widget/wwidgetgroup.cpp | 15 | ||||
-rw-r--r-- | src/widget/wwidgetgroup.h | 3 | ||||
-rw-r--r-- | src/widget/wwidgetstack.cpp | 7 | ||||
-rw-r--r-- | src/widget/wwidgetstack.h | 4 |
23 files changed, 211 insertions, 1 deletions
diff --git a/src/controlpushbutton.h b/src/controlpushbutton.h index e50c2a5835..08e9d559c9 100644 --- a/src/controlpushbutton.h +++ b/src/controlpushbutton.h @@ -36,6 +36,21 @@ class ControlPushButton : public ControlObject { LONGPRESSLATCHING, }; + static QString buttonModeToString(int mode) { + switch(mode) { + case ControlPushButton::PUSH: + return "PUSH"; + case ControlPushButton::TOGGLE: + return "TOGGLE"; + case ControlPushButton::POWERWINDOW: + return "POWERWINDOW"; + case ControlPushButton::LONGPRESSLATCHING: + return "LONGPRESSLATCHING"; + default: + return "UNKNOWN"; + } + } + ControlPushButton(ConfigKey key); virtual ~ControlPushButton(); diff --git a/src/widget/wbasewidget.cpp b/src/widget/wbasewidget.cpp index b5c233f121..7da722e7b7 100644 --- a/src/widget/wbasewidget.cpp +++ b/src/widget/wbasewidget.cpp @@ -3,6 +3,7 @@ #include "widget/wbasewidget.h" #include "controlobjectslave.h" +#include "util/cmdlineargs.h" #include "util/debug.h" ControlWidgetConnection::ControlWidgetConnection(WBaseWidget* pBaseWidget, @@ -255,3 +256,65 @@ void WBaseWidget::setControlParameterRightUp(double v) { pControlConnection->setControlParameterUp(v); } } + +void WBaseWidget::updateTooltip() { + // If we are in developer mode, update the tooltip. + if (CmdlineArgs::Instance().getDeveloper()) { + QStringList debug; + fillDebugTooltip(&debug); + + QString base = baseTooltip(); + if (!base.isEmpty()) { + debug.append(QString("Tooltip: \"%1\"").arg(base)); + } + m_pWidget->setToolTip(debug.join("\n")); + } +} + +template <> +QString toDebugString(const QSizePolicy::Policy& policy) { + switch (policy) { + case QSizePolicy::Fixed: + return "Fixed"; + case QSizePolicy::Minimum: + return "Minimum"; + case QSizePolicy::Maximum: + return "Maximum"; + case QSizePolicy::Preferred: + return "Preferred"; + case QSizePolicy::Expanding: + return "Expanding"; + case QSizePolicy::MinimumExpanding: + return "MinimumExpanding"; + case QSizePolicy::Ignored: + return "Ignored"; + default: + break; + } + return QString::number(static_cast<int>(policy)); +} + +void WBaseWidget::fillDebugTooltip(QStringList* debug) { + QSizePolicy policy = m_pWidget->sizePolicy(); + *debug << QString("ClassName: %1").arg(m_pWidget->metaObject()->className()) + << QString("ObjectName: %1").arg(m_pWidget->objectName()) + << QString("Position: %1").arg(toDebugString(m_pWidget->pos())) + << QString("SizePolicy: %1,%2").arg(toDebugString(policy.horizontalPolicy()), + toDebugString(policy.verticalPolicy())) + << QString("Size: %1").arg(toDebugString(m_pWidget->size())) + << QString("SizeHint: %1").arg(toDebugString(m_pWidget->sizeHint())) + << QString("MinimumSizeHint: %1").arg(toDebugString(m_pWidget->minimumSizeHint())); + + foreach (ControlWidgetConnection* pControlConnection, m_leftConnections) { + *debug << QString("LeftConnection: %1").arg(pControlConnection->toDebugString()); + } + foreach (ControlWidgetConnection* pControlConnection, m_rightConnections) { + *debug << QString("RightConnection: %1").arg(pControlConnection->toDebugString()); + } + foreach (ControlWidgetConnection* pControlConnection, m_connections) { + *debug << QString("Connection: %1").arg(pControlConnection->toDebugString()); + } + if (m_pDisplayConnection) { + *debug << QString("DisplayConnection: %1").arg(m_pDisplayConnection->toDebugString()); + } +} diff --git a/src/widget/wbasewidget.h b/src/widget/wbasewidget.h index f06e53a934..d29acea6b8 100644 --- a/src/widget/wbasewidget.h +++ b/src/widget/wbasewidget.h @@ -154,6 +154,13 @@ class WBaseWidget { void setControlParameterRightDown(double v); void setControlParameterRightUp(double v); + // Tooltip handling. We support "debug tooltips" which are basically a way + // to expose debug information about widgets via the tooltip. To enable + // this, when widgets should call updateTooltip before they are about to + // display a tooltip. + void updateTooltip(); + virtual void fillDebugTooltip(QStringList* debug); + private: QWidget* m_pWidget; bool m_bDisabled; diff --git a/src/widget/wlabel.cpp b/src/widget/wlabel.cpp index aac4f1bb59..8e789afa54 100644 --- a/src/widget/wlabel.cpp +++ b/src/widget/wlabel.cpp @@ -63,3 +63,15 @@ void WLabel::setup(QDomNode node, const SkinContext& context) { } } } + +bool WLabel::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QLabel::event(pEvent); +} + +void WLabel::fillDebugTooltip(QStringList* debug) { + WBaseWidget::fillDebugTooltip(debug); + *debug << QString("Text: \"%1\"").arg(text()); +} diff --git a/src/widget/wlabel.h b/src/widget/wlabel.h index f4225d6d04..994168f471 100644 --- a/src/widget/wlabel.h +++ b/src/widget/wlabel.h @@ -19,6 +19,7 @@ #define WLABEL_H #include <QLabel> +#include <QEvent> #include "widget/wbasewidget.h" #include "skin/skincontext.h" @@ -32,6 +33,9 @@ class WLabel : public QLabel, public WBaseWidget { virtual void setup(QDomNode node, const SkinContext& context); protected: + bool event(QEvent* pEvent); + void fillDebugTooltip(QStringList* debug); + QString m_qsText; // Foreground and background colors. QColor m_qFgColor; diff --git a/src/widget/wlibrary.cpp b/src/widget/wlibrary.cpp index 7ac79d580d..b6b1111d15 100644 --- a/src/widget/wlibrary.cpp +++ b/src/widget/wlibrary.cpp @@ -55,3 +55,10 @@ void WLibrary::search(const QString& name) { LibraryView* WLibrary::getActiveView() const { return dynamic_cast<LibraryView*>(currentWidget()); } + +bool WLibrary::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QStackedWidget::event(pEvent); +} diff --git a/src/widget/wlibrary.h b/src/widget/wlibrary.h index 698200f3f4..e2c4955bdc 100644 --- a/src/widget/wlibrary.h +++ b/src/widget/wlibrary.h @@ -8,6 +8,7 @@ #include <QMutex> #include <QStackedWidget> #include <QString> +#include <QEvent> #include "library/libraryview.h" #include "widget/wbasewidget.h" @@ -38,6 +39,9 @@ class WLibrary : public QStackedWidget, public WBaseWidget { void search(const QString&); + protected: + bool event(QEvent* pEvent); + private: QMutex m_mutex; QMap<QString, QWidget*> m_viewMap; diff --git a/src/widget/wlibrarysidebar.cpp b/src/widget/wlibrarysidebar.cpp index 4632206002..f650eb3462 100644 --- a/src/widget/wlibrarysidebar.cpp +++ b/src/widget/wlibrarysidebar.cpp @@ -179,3 +179,10 @@ void WLibrarySidebar::selectIndex(const QModelIndex& index) { } scrollTo(index); } + +bool WLibrarySidebar::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QTreeView::event(pEvent); +} diff --git a/src/widget/wlibrarysidebar.h b/src/widget/wlibrarysidebar.h index d7f86c13da..f30da03d81 100644 --- a/src/widget/wlibrarysidebar.h +++ b/src/widget/wlibrarysidebar.h @@ -10,6 +10,7 @@ #include <QPoint> #include <QTimerEvent> #include <QTreeView> +#include <QEvent> #include "widget/wbasewidget.h" @@ -32,6 +33,9 @@ class WLibrarySidebar : public QTreeView, public WBaseWidget { signals: void rightClicked(const QPoint&, const QModelIndex&); + protected: + bool event(QEvent* pEvent); + private: QBasicTimer m_expandTimer; QModelIndex m_hoverIndex; diff --git a/src/widget/wpushbutton.cpp b/src/widget/wpushbutton.cpp index df90309bd6..4f23d37b3d 100644 --- a/src/widget/wpushbutton.cpp +++ b/src/widget/wpushbutton.cpp @@ -29,6 +29,7 @@ #include "controlobject.h" #include "controlpushbutton.h" #include "control/controlbehavior.h" +#include "util/debug.h" const int PB_SHORTKLICKTIME = 200; @@ -344,3 +345,20 @@ void WPushButton::mouseReleaseEvent(QMouseEvent * e) { update(); } } + +void WPushButton::fillDebugTooltip(QStringList* debug) { + WWidget::fillDebugTooltip(debug); + *debug << QString("NumberStates: %1").arg(m_iNoStates) + << QString("LeftCurrentState: %1").arg( + static_cast<int>(getControlParameterLeft()) % + (m_iNoStates > 0 ? m_iNoStates : 1)) + << QString("Pressed: %1").arg(toDebugString(m_bPressed)) + << QString("LeftButtonMode: %1") + .arg(ControlPushButton::buttonModeToString(m_leftButtonMode)) + << QString("RightButtonMode: %1") + .arg(ControlPushButton::buttonModeToString(m_rightButtonMode)) + << QString("LeftClickForcePush: %1") + .arg(toDebugString(m_bLeftClickForcePush)) + << QString("RightClickForcePush: %1") + .arg(toDebugString(m_bRightClickForcePush)); +} diff --git a/src/widget/wpushbutton.h b/src/widget/wpushbutton.h index 868c29e90f..50186f6cb3 100644 --- a/src/widget/wpushbutton.h +++ b/src/widget/wpushbutton.h @@ -61,6 +61,7 @@ class WPushButton : public WWidget { virtual void mousePressEvent(QMouseEvent *e); virtual void mouseReleaseEvent(QMouseEvent *e); virtual void focusOutEvent(QFocusEvent* e); + void fillDebugTooltip(QStringList* debug); private: // Associates a pixmap of a given state of the button with the widget diff --git a/src/widget/wsearchlineedit.cpp b/src/widget/wsearchlineedit.cpp index 9c88f5b166..6a52d32fc7 100644 --- a/src/widget/wsearchlineedit.cpp +++ b/src/widget/wsearchlineedit.cpp @@ -185,3 +185,10 @@ void WSearchLineEdit::updateCloseButton(const QString& text) { m_clearButton->setVisible(!text.isEmpty() && !m_place); } + +bool WSearchLineEdit::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QLineEdit::event(pEvent); +} diff --git a/src/widget/wsearchlineedit.h b/src/widget/wsearchlineedit.h index 938cd84ecd..771440df70 100644 --- a/src/widget/wsearchlineedit.h +++ b/src/widget/wsearchlineedit.h @@ -7,6 +7,7 @@ #include <QTimer> #include <QDomNode> #include <QColor> +#include <QEvent> #include "configobject.h" #include "skin/skincontext.h" @@ -25,6 +26,7 @@ class WSearchLineEdit : public QLineEdit, public WBaseWidget { void resizeEvent(QResizeEvent*); virtual void focusInEvent(QFocusEvent*); virtual void focusOutEvent(QFocusEvent*); + bool event(QEvent* pEvent); signals: void search(const QString& text); diff --git a/src/widget/wslidercomposed.cpp b/src/widget/wslidercomposed.cpp index 1806833c22..5ec66f3237 100644 --- a/src/widget/wslidercomposed.cpp +++ b/src/widget/wslidercomposed.cpp @@ -23,6 +23,7 @@ #include "defs.h" #include "widget/wpixmapstore.h" +#include "util/debug.h" WSliderComposed::WSliderComposed(QWidget * parent) : WWidget(parent), @@ -229,3 +230,12 @@ void WSliderComposed::onConnectedControlValueChanged(double dValue) { update(); } } + +void WSliderComposed::fillDebugTooltip(QStringList* debug) { + WWidget::fillDebugTooltip(debug); + int sliderLength = m_bHorizontal ? width() : height(); + *debug << QString("Horizontal: %1").arg(toDebugString(m_bHorizontal)) + << QString("SliderPosition: %1").arg(m_iPos) + << QString("SliderLength: %1").arg(sliderLength) + << QString("HandleLength: %1").arg(m_iHandleLength); +} diff --git a/src/widget/wslidercomposed.h b/src/widget/wslidercomposed.h index 414524c3ea..c82c33dfcf 100644 --- a/src/widget/wslidercomposed.h +++ b/src/widget/wslidercomposed.h @@ -52,6 +52,7 @@ class WSliderComposed : public WWidget { inline bool isHorizontal() const { return m_bHorizontal; }; public slots: void onConnectedControlValueChanged(double); + void fillDebugTooltip(QStringList* debug); private: void unsetPixmaps(); diff --git a/src/widget/wspinny.cpp b/src/widget/wspinny.cpp index 3df51bc6f9..8c5abd8cc5 100644 --- a/src/widget/wspinny.cpp +++ b/src/widget/wspinny.cpp @@ -477,6 +477,13 @@ void WSpinny::hideEvent(QHideEvent* event) { m_qImage.fill(qRgba(0,0,0,0)); } +bool WSpinny::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QGLWidget::event(pEvent); +} + /** DRAG AND DROP **/ void WSpinny::dragEnterEvent(QDragEnterEvent * event) { diff --git a/src/widget/wspinny.h b/src/widget/wspinny.h index d3048d3d05..8753ac825d 100644 --- a/src/widget/wspinny.h +++ b/src/widget/wspinny.h @@ -5,6 +5,7 @@ #include <QGLWidget> #include <QShowEvent> #include <QHideEvent> +#include <QEvent> #include "widget/wwidget.h" #include "vinylcontrol/vinylsignalquality.h" @@ -43,6 +44,7 @@ class WSpinny : public QGLWidget, public WBaseWidget, public VinylSignalQualityL void mouseReleaseEvent(QMouseEvent * e); void showEvent(QShowEvent* event); void hideEvent(QHideEvent* event); + bool event(QEvent* pEvent); double calculateAngle(double playpos); int calculateFullRotations(double playpos); diff --git a/src/widget/wwidget.cpp b/src/widget/wwidget.cpp index 9f21af1819..c76ac6f4a7 100644 --- a/src/widget/wwidget.cpp +++ b/src/widget/wwidget.cpp @@ -33,3 +33,10 @@ void WWidget::onConnectedControlValueChanged(double value) { Q_UNUSED(value); update(); } + +bool WWidget::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QWidget::event(pEvent); +} diff --git a/src/widget/wwidget.h b/src/widget/wwidget.h index c036eac5be..49821e83f6 100644 --- a/src/widget/wwidget.h +++ b/src/widget/wwidget.h @@ -19,8 +19,8 @@ #define WWIDGET_H #include <QWidget> +#include <QEvent> #include <QString> -#include <QDomNode> #include "configobject.h" #include "widget/wbasewidget.h" @@ -45,6 +45,9 @@ public: Q_PROPERTY(double value READ getControlParameterDisplay); virtual void onConnectedControlValueChanged(double value); + + protected: + bool event(QEvent* pEvent); }; #endif diff --git a/src/widget/wwidgetgroup.cpp b/src/widget/wwidgetgroup.cpp index 4d9bd634d3..edc3e8d521 100644 --- a/src/widget/wwidgetgroup.cpp +++ b/src/widget/wwidgetgroup.cpp @@ -6,6 +6,7 @@ #include "widget/wwidget.h" #include "widget/wpixmapstore.h" +#include "util/debug.h" WWidgetGroup::WWidgetGroup(QWidget* pParent) : QFrame(pParent), @@ -150,3 +151,17 @@ void WWidgetGroup::resizeEvent(QResizeEvent* re) { // Paint things styled by style sheet QFrame::resizeEvent(re); } + +bool WWidgetGroup::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QFrame::event(pEvent); +} + +void WWidgetGroup::fillDebugTooltip(QStringList* debug) { + WBaseWidget::fillDebugTooltip(debug); + *debug << QString("LayoutAlignment: %1").arg(toDebugString(layoutAlignment())) + << QString("LayoutContentsMargins: %1").arg(toDebugString(layoutContentsMargins())) + << QString("LayoutSpacing: %1").arg(layoutSpacing()); +} diff --git a/src/widget/wwidgetgroup.h b/src/widget/wwidgetgroup.h index d3037b7d0c..ecbce79faa 100644 --- a/src/widget/wwidgetgroup.h +++ b/src/widget/wwidgetgroup.h @@ -8,6 +8,7 @@ #include <QResizeEvent> #include <QString> #include <QWidget> +#include <QEvent> #include "widget/wbasewidget.h" #include "widget/wpixmapstore.h" @@ -48,6 +49,8 @@ class WWidgetGroup : public QFrame, public WBaseWidget { protected: virtual void paintEvent(QPaintEvent* pe); virtual void resizeEvent(QResizeEvent* re); + bool event(QEvent* pEvent); + void fillDebugTooltip(QStringList* debug); private: // Associated background pixmap diff --git a/src/widget/wwidgetstack.cpp b/src/widget/wwidgetstack.cpp index 15339e71a1..6cdfbef234 100644 --- a/src/widget/wwidgetstack.cpp +++ b/src/widget/wwidgetstack.cpp @@ -102,3 +102,10 @@ void WWidgetStack::addWidgetWithControl(QWidget* pWidget, ControlObject* pContro pListener, SLOT(onCurrentWidgetChanged(int))); } } + +bool WWidgetStack::event(QEvent* pEvent) { + if (pEvent->type() == QEvent::ToolTip) { + updateTooltip(); + } + return QFrame::event(pEvent); +} diff --git a/src/widget/wwidgetstack.h b/src/widget/wwidgetstack.h index ea0505382c..e97ed70940 100644 --- a/src/widget/wwidgetstack.h +++ b/src/widget/wwidgetstack.h @@ -5,6 +5,7 @@ #include <QObject> #include <QSignalMapper> #include <QStackedWidget> +#include <QEvent> #include "controlobject.h" #include "controlobjectthread.h" @@ -49,6 +50,9 @@ class WWidgetStack : public QStackedWidget, public WBaseWidget { void addWidgetWithControl(QWidget* pWidget, ControlObject* pControl); + protected: + bool event(QEvent* pEvent); + private slots: void onNextControlChanged(double v); void onPrevControlChanged(double v); |