| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #ifndef AUTOHIDEWIDGET_H
|
|---|
| 20 | #define AUTOHIDEWIDGET_H
|
|---|
| 21 |
|
|---|
| 22 | #include <QWidget>
|
|---|
| 23 |
|
|---|
| 24 | class QTimer;
|
|---|
| 25 | class QPropertyAnimation;
|
|---|
| 26 |
|
|---|
| 27 | class AutohideWidget : public QWidget
|
|---|
| 28 | {
|
|---|
| 29 | Q_OBJECT
|
|---|
| 30 |
|
|---|
| 31 | public:
|
|---|
| 32 | enum Activation { Anywhere = 1, Bottom = 2 };
|
|---|
| 33 |
|
|---|
| 34 | AutohideWidget(QWidget * parent = 0);
|
|---|
| 35 | ~AutohideWidget();
|
|---|
| 36 |
|
|---|
| 37 | void setInternalWidget(QWidget * w);
|
|---|
| 38 | QWidget * internalWidget() { return internal_widget; };
|
|---|
| 39 |
|
|---|
| 40 | public slots:
|
|---|
| 41 | void show();
|
|---|
| 42 | void activate();
|
|---|
| 43 | void deactivate();
|
|---|
| 44 | void setAutoHide(bool b);
|
|---|
| 45 | void setAnimated(bool b) { use_animation = b; };
|
|---|
| 46 | void setMargin(int margin) { spacing = margin; };
|
|---|
| 47 | void setPercWidth(int s) { perc_width = s;}
|
|---|
| 48 | void setActivationArea(Activation m) { activation_area = m; }
|
|---|
| 49 | void setHideDelay(int ms);
|
|---|
| 50 |
|
|---|
| 51 | public:
|
|---|
| 52 | bool isActive() { return turned_on; };
|
|---|
| 53 | bool autoHide() { return auto_hide; };
|
|---|
| 54 | bool isAnimated() { return use_animation; };
|
|---|
| 55 | int margin() { return spacing; };
|
|---|
| 56 | int percWidth() { return perc_width; };
|
|---|
| 57 | Activation activationArea() { return activation_area; }
|
|---|
| 58 | int hideDelay();
|
|---|
| 59 |
|
|---|
| 60 | protected:
|
|---|
| 61 | bool eventFilter(QObject * obj, QEvent * event);
|
|---|
| 62 |
|
|---|
| 63 | private slots:
|
|---|
| 64 | void checkUnderMouse();
|
|---|
| 65 | void showAnimated();
|
|---|
| 66 |
|
|---|
| 67 | private:
|
|---|
| 68 | void installFilter(QObject *o);
|
|---|
| 69 | void resizeAndMove();
|
|---|
| 70 |
|
|---|
| 71 | private:
|
|---|
| 72 | bool turned_on;
|
|---|
| 73 | bool auto_hide;
|
|---|
| 74 | bool use_animation;
|
|---|
| 75 | int spacing;
|
|---|
| 76 | int perc_width;
|
|---|
| 77 | Activation activation_area;
|
|---|
| 78 | QWidget * internal_widget;
|
|---|
| 79 | QTimer * timer;
|
|---|
| 80 | #if QT_VERSION >= 0x040600
|
|---|
| 81 | QPropertyAnimation * animation;
|
|---|
| 82 | #endif
|
|---|
| 83 | };
|
|---|
| 84 |
|
|---|
| 85 | #endif
|
|---|
| 86 |
|
|---|