Ignore:
Timestamp:
Aug 31, 2016, 5:31:04 PM (9 years ago)
Author:
Silvan Scherrer
Message:

smplayer: update trunk to version 16.8.0

Location:
smplayer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • smplayer/trunk

  • smplayer/trunk/src/autohidewidget.cpp

    r176 r181  
    2222#include <QVBoxLayout>
    2323#include <QMouseEvent>
     24
     25
    2426#include <QDebug>
    2527
    2628#if QT_VERSION >= 0x040600
    2729#include <QPropertyAnimation>
     30
     31
     32
     33
     34
     35
    2836#endif
    2937
     
    4654        setLayoutDirection(Qt::LeftToRight);
    4755
    48         parent->installEventFilter(this);
    49         installFilter(parent);
     56        QWidget * widget_to_watch = parent;
     57        widget_to_watch->installEventFilter(this);
     58        installFilter(widget_to_watch);
    5059
    5160        timer = new QTimer(this);
     
    6675
    6776void AutohideWidget::setInternalWidget(QWidget * w) {
     77
    6878        layout()->addWidget(w);
    6979        internal_widget = w;
     
    8797                        w->installEventFilter(this);
    8898                        installFilter(children[n]);
    89                 }
    90         }
     99                        #ifdef HANDLE_TAP_EVENT
     100                        //w->grabGesture(Qt::TapGesture);
     101                        #endif
     102                }
     103        }
     104}
     105
     106bool AutohideWidget::visiblePopups() {
     107        //qDebug() << "AutohideWidget::visiblePopups: internal_widget:" << internal_widget;
     108        if (!internal_widget) return false;
     109
     110        // Check if any of the menus in the internal widget is visible
     111        QObjectList children = internal_widget->children();
     112        foreach(QObject * child, children) {
     113                if (child->isWidgetType()) {
     114                        //qDebug() << "AutohideWidget::visiblePopups:" << child << "child name:" << child->objectName();
     115                        QWidget *w = static_cast<QWidget *>(child);
     116
     117                        QList<QAction *> actions = w->actions();
     118                        foreach(QAction * action, actions) {
     119                                //qDebug() << "AutohideWidget::visiblePopups: action:" << action;
     120
     121                                QList<QWidget *> aw = action->associatedWidgets();
     122                                //qDebug() << "AutohideWidget::visiblePopups: aw:" << aw;
     123
     124                                QMenu * menu = 0;
     125                                foreach(QWidget * widget, aw) {
     126                                        //qDebug() << "AutohideWidget::visiblePopups: widget:" << widget;
     127                                        if ((menu = qobject_cast<QMenu *>(widget))) {
     128                                                //qDebug() << "AutohideWidget::visiblePopups: menu:" << menu << "visible:" << menu->isVisible();
     129                                                if (menu->isVisible()) return true;
     130                                        }
     131                                }
     132
     133                                menu = action->menu();
     134                                if (menu) {
     135                                        //qDebug() << "AutohideWidget::visiblePopups: menu:" << menu << "visible:" << menu->isVisible();
     136                                        if (menu->isVisible()) return true;
     137                                }
     138                        }
     139                }
     140        }
     141        return false;
    91142}
    92143
     
    123174        if (auto_hide) {
    124175                //qDebug("AutohideWidget::checkUnderMouse");
    125                 if ((isVisible()) && (!underMouse())) hide();
     176                if (isVisible() && !underMouse() && !visiblePopups()) {
     177                        hide();
     178                }
    126179        }
    127180}
     
    141194        if (turned_on) {
    142195                //qDebug() << "AutohideWidget::eventFilter: obj:" << obj << "type:" << event->type();
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
    143209                if (event->type() == QEvent::MouseMove) {
    144210                        //qDebug() << "AutohideWidget::eventFilter: mouse move" << obj;
     
    157223                        }
    158224                }
     225
     226
     227
     228
     229
    159230        }
    160231
Note: See TracChangeset for help on using the changeset viewer.