void AQWebApplication::finish() { if (!initDone_ || finish_) return; finish_ = true; disconnect(guiSocket_, SIGNAL(readyRead()), this, SLOT(recvWebEvents())); #ifndef AQ_USE_NOTIFY removeEventFilter(eventFilter_); #endif sendGuiEvent("ds" + AQ_MSG_SEP + QString::number(AQ_WID(desktop_), 36)); recvWebEvents(); processEvents(); processWebEvents(); processAQEvents(); QPtrDictIterator<AQWidgetInfo> it(createdWidgets_); AQWidgetInfo *wInfo; for (; it.current(); ++it) { wInfo = it.current(); sendGuiEvent("ds" + AQ_MSG_SEP + wInfo->wid_); wInfo->clear(); delete wInfo; } createdWidgets_.clear(); closeConnection(); }
void ColorPickerWidget::closeEventFilter() { m_filterActive = false; releaseMouse(); releaseKeyboard(); removeEventFilter(this); }
void IOWindow::OnDetectButtonPressed() { installEventFilter(BlockUserInputFilter::Instance()); grabKeyboard(); grabMouse(); std::thread([this] { auto* btn = m_type == IOWindow::Type::Input ? m_detect_button : m_test_button; const auto old_label = btn->text(); btn->setText(QStringLiteral("...")); const auto expr = MappingCommon::DetectExpression( m_reference, g_controller_interface.FindDevice(m_devq).get(), m_devq, MappingCommon::Quote::Off); btn->setText(old_label); if (!expr.isEmpty()) { const auto list = m_option_list->findItems(expr, Qt::MatchFixedString); if (list.size() > 0) m_option_list->setCurrentItem(list[0]); } releaseMouse(); releaseKeyboard(); removeEventFilter(BlockUserInputFilter::Instance()); }) .detach(); }
bool SlideBar::eventFilter(QObject* obj, QEvent* event) { // Update the widget position when the parent is moved or resized if (event->type() == QEvent::Resize || event->type() == QEvent::Move) { this->updatePosition(); } else if (event->type() == QEvent::WindowActivate) { auto activeWindow = qApp->activeWindow(); SLM_ASSERT("No active window", activeWindow); activeWindow->installEventFilter(this); this->updatePosition(); } else if (event->type() == QEvent::WindowDeactivate) { auto mainFrame = dynamic_cast< ::fwGuiQt::QtMainFrame*>(obj); if(mainFrame) { mainFrame->removeEventFilter(this); } } return QObject::eventFilter(obj, event); }
bool MenuButton::eventFilter(QObject *o, QEvent *e) { if (QEvent::Show==e->type()) { if (qobject_cast<QMenu *>(o)) { QMenu *mnu=static_cast<QMenu *>(o); QPoint p=parentWidget()->mapToGlobal(pos()); int newPos=isRightToLeft() ? p.x() : ((p.x()+width())-mnu->width()); if (newPos<0) { newPos=0; } else { QDesktopWidget *dw=QApplication::desktop(); if (dw) { QRect geo=dw->availableGeometry(this); int maxWidth=geo.x()+geo.width(); if (maxWidth>0 && (newPos+mnu->width())>maxWidth) { newPos=maxWidth-mnu->width(); } } } mnu->move(newPos, mnu->y()); } else if (o==this) { setMinimumWidth(height()); removeEventFilter(this); } } return ToolButton::eventFilter(o, e); }
void Screenshot::initUI() { setWindowFlags(Qt::X11BypassWindowManagerHint | Qt::WindowStaysOnTopHint| Qt::FramelessWindowHint); setAttribute(Qt::WA_TranslucentBackground); QPoint curPos = this->cursor().pos(); DScreenWindowsUtil* swUtil = DScreenWindowsUtil::instance(curPos); QRect bgRect = swUtil->backgroundRect(); this->move(bgRect.x(), bgRect.y()); this->setFixedSize(bgRect.size()); m_eventContainer = new EventContainer(this); m_window = new MainWindow(m_eventContainer); setCentralWidget(m_window); this->installEventFilter(this); connect(m_window, &MainWindow::releaseEvent, this, [=]{ qDebug() << "release event !!!"; m_keyboardReleased = true; m_keyboardGrabbed = this->windowHandle()->setKeyboardGrabEnabled(false); qDebug() << "keyboardGrabbed:" << m_keyboardGrabbed; removeEventFilter(this); }); connect(m_window, &MainWindow::hideScreenshotUI, this, [=]{ this->hide(); }); }
FlowViewWindow::~FlowViewWindow() { removeEventFilter(this); delete ui; playbackTimer->stop(); delete playbackTimer; }
void ShortcutKeyWidget::focusOutEvent(QFocusEvent *e) { if ((e->reason() == Qt::TabFocusReason) || (e->reason() == Qt::BacktabFocusReason)) return; setPalette(parentWidget()->palette()); clearFocus(); disconnect(GlobalShortcutEngine::engine, SIGNAL(buttonPressed(bool)), this, SLOT(updateKeys(bool))); displayKeys(); removeEventFilter(this); }
void GroupWidget::contextMenuEvent(QContextMenuEvent* event) { if (!active) { setBackgroundRole(QPalette::Highlight); } installEventFilter(this); // Disable leave event. QMenu menu(this); QAction* openChatWindow = nullptr; QAction* removeChatWindow = nullptr; // TODO: Move to model ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId); const bool notAlone = contentDialog != nullptr && contentDialog->chatroomWidgetCount() > 1; if (contentDialog == nullptr || notAlone) { openChatWindow = menu.addAction(tr("Open chat in new window")); } if (contentDialog && contentDialog->hasContactWidget(groupId)) { removeChatWindow = menu.addAction(tr("Remove chat from this window")); } menu.addSeparator(); QAction* setTitle = menu.addAction(tr("Set title...")); QAction* quitGroup = menu.addAction(tr("Quit group", "Menu to quit a groupchat")); QAction* selectedItem = menu.exec(event->globalPos()); removeEventFilter(this); if (!active) { setBackgroundRole(QPalette::Window); } if (!selectedItem) { return; } if (selectedItem == quitGroup) { emit removeGroup(groupId); } else if (selectedItem == openChatWindow) { emit newWindowOpened(this); } else if (selectedItem == removeChatWindow) { // TODO: move to model ContentDialog* contentDialog = ContentDialogManager::getInstance()->getGroupDialog(groupId); contentDialog->removeGroup(groupId); } else if (selectedItem == setTitle) { editName(); } }
//----------------------------------------------------------------------------- // Function: ~AssistedLineEdit() //----------------------------------------------------------------------------- AssistedLineEdit::~AssistedLineEdit() { // Remove the event filter. if (mainWnd_ != 0) { removeEventFilter(this); mainWnd_->removeEventFilter(this); } delete contentAssist_; }
bool DetectMainSceneActivated::eventFilter(QObject* /*watched*/, QEvent* event) { if (event->type() != QEvent::WindowActivate) return false; // We use this roundabout way to show the prompt. It can only be shown once the Scene is activated. auto mainScene = Visualization::VisualizationManager::instance().mainScene(); QApplication::postEvent(mainScene, new SetCursorEvent(mainScene->sceneHandlerItem())); QApplication::postEvent(mainScene, new ShowCommandPromptEvent(mainScene)); QApplication::postEvent(mainScene, new Visualization::CustomSceneEvent([=](){delete this;})); mainScene->removeEventFilter(this); return false; }
void MappingButton::Detect() { if (m_parent->GetDevice() == nullptr || !m_reference->IsInput()) return; installEventFilter(BlockUserInputFilter::Instance()); grabKeyboard(); grabMouse(); // Make sure that we don't block event handling std::thread thread([this] { const auto dev = m_parent->GetDevice(); setText(QStringLiteral("...")); // Avoid that the button press itself is registered as an event Common::SleepCurrentThread(100); const auto expr = MappingCommon::DetectExpression( m_reference, dev.get(), m_parent->GetController()->GetDefaultDevice()); releaseMouse(); releaseKeyboard(); removeEventFilter(BlockUserInputFilter::Instance()); if (!expr.isEmpty()) { m_reference->SetExpression(expr.toStdString()); m_parent->SaveSettings(); Update(); if (m_parent->IsIterativeInput()) m_parent->NextButton(this); } else { OnButtonTimeout(); } }); thread.detach(); }
void MarbleWidget::setInputEnabled( bool enabled ) { //if input is set as enabled if ( enabled ) { if ( !d->m_inputhandler ) { d->setInputHandler(); } else { installEventFilter( d->m_inputhandler ); } } else // input is disabled { mDebug() << "MarbleWidget::disableInput"; removeEventFilter( d->m_inputhandler ); setCursor( Qt::ArrowCursor ); } }
FrameInfoWindow::~FrameInfoWindow() { removeEventFilter(this); delete ui; }
Ui::DetachedVideoWindow::~DetachedVideoWindow() { removeEventFilter(event_filter_); delete event_filter_; }
void FramePlaybackWindow::closeEvent(QCloseEvent *event) { Q_UNUSED(event); removeEventFilter(this); writeSettings(); }
void SplashScreen::sl_close(){ if(AppContext::getTaskScheduler() == qobject_cast<TaskScheduler*>(sender())){ removeEventFilter(this); close(); } }
KonvergoWindow::~KonvergoWindow() { removeEventFilter(m_eventFilter); }
DetView::~DetView() { removeEventFilter(editor); }
DBCSignalEditor::~DBCSignalEditor() { removeEventFilter(this); delete ui; }
ColorPickerWidget::~ColorPickerWidget() { delete m_grabRectFrame; if (m_filterActive) removeEventFilter(this); }
MainWindow::MainWindow() { scene = new GraphicsScene(this); QGraphicsView *graphicsView = new QGraphicsView(scene); #if 0 QGraphicsVideoItem* videoItem = new QGraphicsVideoItem; videoItem->setSize(QSizeF(500, 480)); scene->addItem(videoItem); #endif //installEventFilter( scene ); textItem = new GraphicsTextItem(); QFont font; font.setPointSize(font.pointSize() * 2); font.setBold(true); textItem->setFont(font); textItem->setPlainText("Qt Everywhere!"); textItem->setDefaultTextColor(Qt::black); #if 0 QTextDocument* document = new QTextDocument; QTextCharFormat charFormat; charFormat.setFont(QFont("times", 24)); QPen outlinePen = QPen (QColor(255, 0, 0), 1, Qt::SolidLine); charFormat.setTextOutline(outlinePen); //字体轮廓 QTextCursor cursor = QTextCursor(document); cursor.insertText("Test", charFormat); textItem->setDocument(document); //textItem->setTextInteractionFlags(Qt::TextEditable); #endif textItem->setTextInteractionFlags(Qt::TextEditorInteraction); textItem->setZValue(1000.0); textItem->setPos(50, 300); scene->addItem(textItem); QWidget *tabAnimations = new QWidget; //tabAnimations->setMinimumHeight(200); //tabAnimations->setMaximumHeight(200); QHBoxLayout* hboxAnimations = new QHBoxLayout; hboxAnimations->addWidget(graphicsView); { QLabel *lbl = new QLabel(tr("Text duration:")); hboxAnimations->addWidget(lbl); } { QComboBox* m_durationTextCombo = new QComboBox(); //m_durationTextCombo->setEditable(true); for (int i = 2; i < 30; i = i + 2) m_durationTextCombo->addItem(QString().setNum(i)); hboxAnimations->addWidget(m_durationTextCombo); } { QToolButton *addPhotos = new QToolButton(); addPhotos->setText("Add photos"); hboxAnimations->addWidget(addPhotos); removeEventFilter(addPhotos); } { m_lineEdit = new LineEdit(this,scene); hboxAnimations->addWidget(m_lineEdit); //removeEventFilter(m_lineEdit); //m_lineEdit->installEventFilter( this ); } connect(m_lineEdit, SIGNAL(selectedTextSignal(const QString&)), scene, SLOT(activeVideoText(const QString&))); tabAnimations->setLayout(hboxAnimations); setCentralWidget(tabAnimations); setWindowTitle(tr("Character Map")); }
void FriendWidget::contextMenuEvent(QContextMenuEvent * event) { if (!active) setBackgroundRole(QPalette::Highlight); installEventFilter(this); // Disable leave event. QPoint pos = event->globalPos(); ToxId id = FriendList::findFriend(friendId)->getToxId(); QString dir = Settings::getInstance().getAutoAcceptDir(id); QMenu menu; QAction* openChatWindow = nullptr; QAction* removeChatWindow = nullptr; ContentDialog* contentDialog = ContentDialog::getFriendDialog(friendId); bool notAlone = contentDialog != nullptr && contentDialog->chatroomWidgetCount() > 1; if (contentDialog == nullptr || notAlone) openChatWindow = menu.addAction(tr("Open chat in new window")); if (contentDialog != nullptr && contentDialog->hasFriendWidget(friendId, this)) removeChatWindow = menu.addAction(tr("Remove chat from this window")); menu.addSeparator(); QMenu* inviteMenu = menu.addMenu(tr("Invite to group","Menu to invite a friend to a groupchat")); QAction* newGroupAction = inviteMenu->addAction(tr("To new group")); inviteMenu->addSeparator(); QMap<QAction*, Group*> groupActions; for (Group* group : GroupList::getAllGroups()) { int maxNameLen = 30; QString name = group->getGroupWidget()->getName(); if ( name.length() > maxNameLen ) { name = name.left(maxNameLen).trimmed() + ".."; } QAction* groupAction = inviteMenu->addAction(tr("Invite to group '%1'").arg(name)); groupActions[groupAction] = group; } int circleId = Settings::getInstance().getFriendCircleID(FriendList::findFriend(friendId)->getToxId()); CircleWidget *circleWidget = CircleWidget::getFromID(circleId); QMenu* circleMenu = nullptr; QAction* newCircleAction = nullptr; QAction *removeCircleAction = nullptr; QMap<QAction*, int> circleActions; FriendListWidget *friendList; if (circleWidget == nullptr) friendList = qobject_cast<FriendListWidget*>(FriendList::findFriend(friendId)->getFriendWidget()->parentWidget()); else friendList = qobject_cast<FriendListWidget*>(circleWidget->parentWidget()); circleMenu = menu.addMenu(tr("Move to circle...", "Menu to move a friend into a different circle")); newCircleAction = circleMenu->addAction(tr("To new circle")); if (circleId != -1) removeCircleAction = circleMenu->addAction(tr("Remove from circle '%1'").arg(Settings::getInstance().getCircleName(circleId))); circleMenu->addSeparator(); QList<QAction*> circleActionList; for (int i = 0; i < Settings::getInstance().getCircleCount(); ++i) { if (i != circleId) { circleActionList.push_back(new QAction(tr("Move to circle \"%1\"").arg(Settings::getInstance().getCircleName(i)), circleMenu)); circleActions[circleActionList.back()] = i; } } std::sort(circleActionList.begin(), circleActionList.end(), [](const QAction* lhs, const QAction* rhs) -> bool { QCollator collator; collator.setNumericMode(true); return collator.compare(lhs->text(), rhs->text()) < 0; }); circleMenu->addActions(circleActionList); QAction* setAlias = menu.addAction(tr("Set alias...")); menu.addSeparator(); QAction* autoAccept = menu.addAction(tr("Auto accept files from this friend", "context menu entry")); autoAccept->setCheckable(true); autoAccept->setChecked(!dir.isEmpty()); menu.addSeparator(); QAction* removeFriendAction = nullptr; if (contentDialog == nullptr || !contentDialog->hasFriendWidget(friendId, this)) removeFriendAction = menu.addAction(tr("Remove friend", "Menu to remove the friend from our friendlist")); menu.addSeparator(); QAction* aboutWindow = menu.addAction(tr("Show details")); QAction* selectedItem = menu.exec(pos); removeEventFilter(this); if (!active) setBackgroundRole(QPalette::Window); if (selectedItem) { if (selectedItem == setAlias) { nameLabel->editBegin(); } else if (selectedItem == removeFriendAction) { emit removeFriend(friendId); return; } else if (selectedItem == openChatWindow) { emit chatroomWidgetClicked(this, true); return; } else if (selectedItem == removeChatWindow) { ContentDialog* contentDialog = ContentDialog::getFriendDialog(friendId); contentDialog->removeFriend(friendId); return; } else if (selectedItem == autoAccept) { if (!autoAccept->isChecked()) { qDebug() << "not checked"; dir = QDir::homePath(); autoAccept->setChecked(false); Settings::getInstance().setAutoAcceptDir(id, ""); } else if (autoAccept->isChecked()) { dir = QFileDialog::getExistingDirectory(0, tr("Choose an auto accept directory","popup title"), dir, QFileDialog::DontUseNativeDialog); autoAccept->setChecked(true); qDebug() << "setting auto accept dir for" << friendId << "to" << dir; Settings::getInstance().setAutoAcceptDir(id, dir); } } else if (selectedItem == aboutWindow) { AboutUser *aboutUser = new AboutUser(id, Widget::getInstance()); aboutUser->setFriend(FriendList::findFriend(friendId)); aboutUser->show(); } else if (selectedItem == newGroupAction) { int groupId = Core::getInstance()->createGroup(); Core::getInstance()->groupInviteFriend(friendId, groupId); } else if (selectedItem == newCircleAction) { if (circleWidget != nullptr) circleWidget->updateStatus(); if (friendList != nullptr) friendList->addCircleWidget(FriendList::findFriend(friendId)->getFriendWidget()); else Settings::getInstance().setFriendCircleID(id, Settings::getInstance().addCircle()); } else if (groupActions.contains(selectedItem)) { Group* group = groupActions[selectedItem]; Core::getInstance()->groupInviteFriend(friendId, group->getGroupId()); } else if (removeCircleAction != nullptr && selectedItem == removeCircleAction) { if (friendList != nullptr) friendList->moveWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus(), true); else Settings::getInstance().setFriendCircleID(id, -1); if (circleWidget) { circleWidget->updateStatus(); Widget::getInstance()->searchCircle(circleWidget); } } else if (circleActions.contains(selectedItem)) { CircleWidget* circle = CircleWidget::getFromID(circleActions[selectedItem]); if (circle != nullptr) { circle->addFriendWidget(FriendList::findFriend(friendId)->getFriendWidget(), FriendList::findFriend(friendId)->getStatus()); circle->setExpanded(true); Widget::getInstance()->searchCircle(circle); Settings::getInstance().savePersonal(); } else Settings::getInstance().setFriendCircleID(id, circleActions[selectedItem]); if (circleWidget != nullptr) { circleWidget->updateStatus(); Widget::getInstance()->searchCircle(circleWidget); } } } }
TransparentScrollBar::~TransparentScrollBar() { removeEventFilter(scrollButton_); removeEventFilter(view_); removeEventFilter(this); }
void EditorFileDialog::focusOutEvent(QFocusEvent *event) { removeEventFilter(this); QLineEdit::focusOutEvent(event); }
void QNXNFCEventFilter::uninstallEventFilter() { removeEventFilter(this); }