1*bb02e0acSNicolas Bonnefon /* 2*bb02e0acSNicolas Bonnefon * Copyright (C) 2009, 2010 Nicolas Bonnefon and other contributors 3*bb02e0acSNicolas Bonnefon * 4*bb02e0acSNicolas Bonnefon * This file is part of glogg. 5*bb02e0acSNicolas Bonnefon * 6*bb02e0acSNicolas Bonnefon * glogg is free software: you can redistribute it and/or modify 7*bb02e0acSNicolas Bonnefon * it under the terms of the GNU General Public License as published by 8*bb02e0acSNicolas Bonnefon * the Free Software Foundation, either version 3 of the License, or 9*bb02e0acSNicolas Bonnefon * (at your option) any later version. 10*bb02e0acSNicolas Bonnefon * 11*bb02e0acSNicolas Bonnefon * glogg is distributed in the hope that it will be useful, 12*bb02e0acSNicolas Bonnefon * but WITHOUT ANY WARRANTY; without even the implied warranty of 13*bb02e0acSNicolas Bonnefon * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*bb02e0acSNicolas Bonnefon * GNU General Public License for more details. 15*bb02e0acSNicolas Bonnefon * 16*bb02e0acSNicolas Bonnefon * You should have received a copy of the GNU General Public License 17*bb02e0acSNicolas Bonnefon * along with glogg. If not, see <http://www.gnu.org/licenses/>. 18*bb02e0acSNicolas Bonnefon */ 19*bb02e0acSNicolas Bonnefon 20*bb02e0acSNicolas Bonnefon #ifndef MANUACTIONTOOLTIPBEHAVIOR_H 21*bb02e0acSNicolas Bonnefon #define MANUACTIONTOOLTIPBEHAVIOR_H 22*bb02e0acSNicolas Bonnefon 23*bb02e0acSNicolas Bonnefon #include <QObject> 24*bb02e0acSNicolas Bonnefon #include <QPoint> 25*bb02e0acSNicolas Bonnefon 26*bb02e0acSNicolas Bonnefon class QAction; 27*bb02e0acSNicolas Bonnefon class QMenu; 28*bb02e0acSNicolas Bonnefon class QTimerEvent; 29*bb02e0acSNicolas Bonnefon 30*bb02e0acSNicolas Bonnefon 31*bb02e0acSNicolas Bonnefon // Provides a behavior to show an action's tooltip after mouse is unmoved for 32*bb02e0acSNicolas Bonnefon // a specified number of 'ms'. E.g. used for tooltips with full-path for recent 33*bb02e0acSNicolas Bonnefon // files in the file menu. Not thread-safe. 34*bb02e0acSNicolas Bonnefon class MenuActionToolTipBehavior : public QObject 35*bb02e0acSNicolas Bonnefon { 36*bb02e0acSNicolas Bonnefon Q_OBJECT; 37*bb02e0acSNicolas Bonnefon 38*bb02e0acSNicolas Bonnefon public: 39*bb02e0acSNicolas Bonnefon MenuActionToolTipBehavior(QAction *action, QMenu *parentMenu, 40*bb02e0acSNicolas Bonnefon QObject *parent); 41*bb02e0acSNicolas Bonnefon 42*bb02e0acSNicolas Bonnefon // Time in ms that mouse needs to stay unmoved for tooltip to be shown 43*bb02e0acSNicolas Bonnefon int toolTipDelay(); /* ms */ 44*bb02e0acSNicolas Bonnefon void setToolTipDelay(int ms); 45*bb02e0acSNicolas Bonnefon 46*bb02e0acSNicolas Bonnefon private: 47*bb02e0acSNicolas Bonnefon void timerEvent(QTimerEvent *event); 48*bb02e0acSNicolas Bonnefon void showToolTip(const QPoint &position); 49*bb02e0acSNicolas Bonnefon 50*bb02e0acSNicolas Bonnefon private slots: 51*bb02e0acSNicolas Bonnefon void onActionHovered(); 52*bb02e0acSNicolas Bonnefon 53*bb02e0acSNicolas Bonnefon private: 54*bb02e0acSNicolas Bonnefon QAction *action; 55*bb02e0acSNicolas Bonnefon QMenu *parentMenu; 56*bb02e0acSNicolas Bonnefon int toolTipDelayMs; 57*bb02e0acSNicolas Bonnefon int timerId; 58*bb02e0acSNicolas Bonnefon QPoint hoverPoint; 59*bb02e0acSNicolas Bonnefon }; 60*bb02e0acSNicolas Bonnefon 61*bb02e0acSNicolas Bonnefon #endif 62