#include "happlication.h" #include #include #include #include #ifdef Q_QDOC HApplication::HApplication(int &argc, char **argv) :QApplication(argc, argv) { dialogList.clear(); } #else HApplication::HApplication(int &argc, char **argv, int flag) :QApplication(argc, argv, flag) { windowList.clear(); } #endif HApplication::~HApplication() { } bool HApplication::notify(QObject *obj, QEvent * event) { if(event->type() == QEvent::ShowToParent){ if(obj->isWidgetType()){ if(obj->inherits("QMainWindow") || obj->inherits("QDialog")){ QWidget *wdg = qobject_cast(obj); //Add pop-up window to container windowList.append(wdg); } } } if(obj->isWidgetType() && event->type() != QEvent::ShowToParent){ QWidget *wdg = qobject_cast(obj); //Processing Topping Display handleWindowStaysOnTopHint(wdg, event); } return QApplication::notify(obj, event); } void HApplication::handleWindowStaysOnTopHint(QWidget *wdg, QEvent *event){ //Determine event type if(event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::KeyRelease || event->type() == QEvent::KeyPress || event->type() == QEvent::Wheel || event->type() == QEvent::Move || event->type() == QEvent::FocusIn){ if(windowList.isEmpty()){ return; } for(int i = 1; i < windowList.size(); i++){ QWidget *m_wdg = windowList.at(i); //Show the elements outside the main window again m_wdg->showNormal(); //Top m_wdg->raise(); } } //Remove closed windows from the container if(!wdg->isVisible() && windowList.contains(wdg)){ for(int i = 0; i < windowList.size(); i++){ QWidget *m_wdg = windowList.at(i); if(wdg == m_wdg){ windowList.removeAt(i); break; } } } } QVector HApplication::getAlreadyShowWindowList(){ return windowList; }