void WebPuppeteerTab::reload(bool force_no_cache) { if (force_no_cache) { triggerAction(QWebPage::ReloadAndBypassCache); } else { triggerAction(QWebPage::Reload); } }
void MainWindow::transferStarted() { const QString action = SettingsManager::getValue(QLatin1String("Browser/TransferStartingAction")).toString(); if (action == QLatin1String("openTab")) { triggerAction(ActionsManager::TransfersAction); } else if (action == QLatin1String("openBackgroundTab")) { const QUrl url(QLatin1String("about:transfers")); if (!SessionsManager::hasUrl(url, false)) { m_windowsManager->open(url, (WindowsManager::NewTabOpen | WindowsManager::BackgroundOpen)); } } else if (action == QLatin1String("openPanel")) { QVariantMap parameters; parameters[QLatin1String("isChecked")] = true; triggerAction(ActionsManager::ShowSidebarAction, parameters); m_sidebar->selectPanel(QLatin1String("transfers")); } }
/*! \reimp */ void QSlider::mousePressEvent(QMouseEvent *ev) { Q_D(QSlider); if (d->maximum == d->minimum || (ev->buttons() ^ ev->button())) { ev->ignore(); return; } #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) setEditFocus(true); #endif ev->accept(); if ((ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()) { QStyleOptionSlider opt; initStyleOption(&opt); const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); const QPoint center = sliderRect.center() - sliderRect.topLeft(); // to take half of the slider off for the setSliderPosition call we use the center - topLeft setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center))); triggerAction(SliderMove); setRepeatAction(SliderNoAction); d->pressedControl = QStyle::SC_SliderHandle; update(); } else if ((ev->button() & style()->styleHint(QStyle::SH_Slider_PageSetButtons)) == ev->button()) { QStyleOptionSlider opt; initStyleOption(&opt); d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider, &opt, ev->pos(), this); SliderAction action = SliderNoAction; if (d->pressedControl == QStyle::SC_SliderGroove) { const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft())); d->pressValue = pressValue; if (pressValue > d->value) action = SliderPageStepAdd; else if (pressValue < d->value) action = SliderPageStepSub; if (action) { triggerAction(action); setRepeatAction(action); } } } else { ev->ignore(); return; } if (d->pressedControl == QStyle::SC_SliderHandle) { QStyleOptionSlider opt; initStyleOption(&opt); setRepeatAction(SliderNoAction); QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); d->clickOffset = d->pick(ev->pos() - sr.topLeft()); update(sr); setSliderDown(true); } }
void QgsActionMenu::reloadActions() { clear(); delete mActions; mActions = new QgsAttributeAction( *mLayer->actions() ); for ( int idx = 0; idx < mActions->size(); ++idx ) { const QgsAction& qaction( mActions->at( idx ) ); QAction* action = new QAction( qaction.icon(), qaction.name(), this ); action->setData( QVariant::fromValue<ActionData>( ActionData( idx, mFeatureId, mLayer ) ) ); action->setIcon( qaction.icon() ); // Only enable items on supported platforms if ( !qaction.runable() ) { action->setEnabled( false ); action->setToolTip( tr( "Not supported on your platform" ) ); } else { action->setToolTip( qaction.action() ); } connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) ); addAction( action ); } QList<QgsMapLayerAction*> mapLayerActions = QgsMapLayerActionRegistry::instance()->mapLayerActions( mLayer, QgsMapLayerAction::SingleFeature ); if ( !mapLayerActions.isEmpty() ) { //add a separator between user defined and standard actions addSeparator(); for ( int i = 0; i < mapLayerActions.size(); ++i ) { QgsMapLayerAction* qaction = mapLayerActions.at( i ); QAction* action = new QAction( qaction->icon(), qaction->text(), this ); action->setData( QVariant::fromValue<ActionData>( ActionData( qaction, mFeatureId, mLayer ) ) ); addAction( action ); connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) ); } } emit reinit(); }
void WebContentsWidget::keyPressEvent(QKeyEvent *event) { QWidget::keyPressEvent(event); if (m_scrollMode == MoveScroll) { triggerAction(ActionsManager::EndScrollAction); event->accept(); return; } if (event->key() == Qt::Key_Escape) { if (m_webWidget->getLoadingState() == WindowsManager::OngoingLoadingState) { triggerAction(ActionsManager::StopAction); ActionsManager::triggerAction(ActionsManager::ActivateAddressFieldAction, this); event->accept(); } else if (!m_quickFindQuery.isEmpty()) { m_quickFindQuery = QString(); m_webWidget->findInPage(QString()); event->accept(); } else if (m_webWidget->hasSelection()) { m_webWidget->clearSelection(); event->accept(); } else { MainWindow *window = MainWindow::findMainWindow(this); if (window && window->isFullScreen()) { window->triggerAction(ActionsManager::FullScreenAction); } } } }
void QAbstractSlider::wheelEvent(QWheelEvent * e) { Q_D(QAbstractSlider); e->ignore(); if (e->orientation() != d->orientation && !rect().contains(e->pos())) return; static qreal offset = 0; static QAbstractSlider *offset_owner = 0; if (offset_owner != this){ offset_owner = this; offset = 0; } int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep); if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) step = d->pageStep; offset += e->delta() * step / 120; if (d->invertedControls) offset = -offset; if (qAbs(offset) < 1) return; int prevValue = d->value; d->position = d->value + int(offset); // value will be updated by triggerAction() triggerAction(SliderMove); if (prevValue == d->value) { offset = 0; } else { offset -= int(offset); e->accept(); } }
bool Tester::Internal::Plugin::initialize(const QStringList &arguments, QString *errorString) { // Register objects in the plugin manager's object pool // Load settings // Add actions to menus // Connect to other plugins' signals // In the initialize method, a plugin can be sure that the plugins it // depends on have initialized their members. Q_UNUSED(arguments) Q_UNUSED(errorString) Core::Command *cmd = Core::ActionManager::registerAction(Controller->startAction(), Constants::ACTION_ID, Core::Context(Core::Constants::C_GLOBAL)); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+Meta+A"))); connect(Controller->startAction(), SIGNAL(triggered()), this, SLOT(triggerAction())); Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); menu->menu()->setTitle(tr("TesterPlugin")); menu->addAction(cmd); Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); MonitoringViewFactory = new Tester::Internal::MonitoringViewFactory; MonitoringViewFactory->setController(Controller); addAutoReleasedObject(MonitoringViewFactory); Mode = new Tester::Internal::Mode(this); Mode->setController(Controller); addAutoReleasedObject(Mode); return true; }
void MainWindow::updateShortcuts() { for (int i = 0; i < m_actionShortcuts.count(); ++i) { qDeleteAll(m_actionShortcuts[i].second); } m_actionShortcuts.clear(); const QVector<ActionDefinition> definitions = ActionsManager::getActionDefinitions(); QList<QKeySequence> standardShortcuts; standardShortcuts << QKeySequence(QKeySequence::Copy) << QKeySequence(QKeySequence::Cut) << QKeySequence(QKeySequence::Delete) << QKeySequence(QKeySequence::Paste) << QKeySequence(QKeySequence::Redo) << QKeySequence(QKeySequence::SelectAll) << QKeySequence(QKeySequence::Undo); for (int i = 0; i < definitions.count(); ++i) { QVector<QShortcut*> shortcuts; shortcuts.reserve(definitions[i].shortcuts.count()); for (int j = 0; j < definitions[i].shortcuts.count(); ++j) { if (!standardShortcuts.contains(definitions[i].shortcuts[j])) { QShortcut *shortcut = new QShortcut(definitions[i].shortcuts[j], this); shortcuts.append(shortcut); connect(shortcut, SIGNAL(activated()), this, SLOT(triggerAction())); } } m_actionShortcuts.append(qMakePair(i, shortcuts)); } }
/*! \reimp */ void QxtStars::mousePressEvent(QMouseEvent* event) { if (qxt_d().readOnly) { event->ignore(); return; } QAbstractSlider::mousePressEvent(event); if (maximum() == minimum() || (event->buttons() ^ event->button())) { event->ignore(); return; } event->accept(); QStyleOptionSlider opt = qxt_d().getStyleOption(); const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this); const QPoint center = sliderRect.center() - sliderRect.topLeft(); const int pos = qxt_d().pixelPosToRangeValue(qxt_d().pick(event->pos() - center)); setSliderPosition(pos); triggerAction(SliderMove); setRepeatAction(SliderNoAction); qxt_d().snapBackPosition = pos; update(); }
void PLSelItem::addAction( ItemAction act, const QString& tooltip ) { if( lblAction ) return; //might change later QIcon icon; switch( act ) { case ADD_ACTION: icon = QIcon( ":/buttons/playlist/playlist_add" ); break; case RM_ACTION: icon = QIcon( ":/buttons/playlist/playlist_remove" ); break; default: return; } lblAction = new SelectorActionButton(); lblAction->setIcon( icon ); lblAction->setMinimumWidth( lblAction->sizeHint().width() + 6 ); if( !tooltip.isEmpty() ) lblAction->setToolTip( tooltip ); layout->addWidget( lblAction, 0 ); lblAction->hide(); CONNECT( lblAction, clicked(), this, triggerAction() ); }
void HudSlider::mousePressEvent(QGraphicsSceneMouseEvent* event) { if (!d->hasValidRange()) { return; } const int pos = d->positionForX(event->pos().x()); if (d->mHandleRect.contains(event->pos())) { switch (event->button()) { case Qt::LeftButton: d->mIsDown = true; break; case Qt::MiddleButton: setSliderPosition(pos); triggerAction(QAbstractSlider::SliderMove); break; default: break; } } else { d->mRepeatX = event->pos().x(); d->mRepeatAction = pos < d->mSliderPosition ? QAbstractSlider::SliderPageStepSub : QAbstractSlider::SliderPageStepAdd; doRepeatAction(FIRST_REPEAT_DELAY); } update(); }
void ConfigurablePage::_triggerTimeout() { if(isLoading) { twlog_crit(GRABBER_STAGE_NETWORK " " GRABBER_DEBUG_TIMEOUT_ERROR " global timeout expired"); triggerAction(QWebPage::Stop, true); } }
// PROTECTED FUNCTIONS void CSliderMultiPos::keyPressEvent(QKeyEvent* event){ SliderAction action = SliderNoAction; QSlider::keyPressEvent(event); switch( event->key() ){ case Qt::Key_Left : action = !invertedAppearance() ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Right : action = !invertedAppearance() ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Up : action = invertedControls() ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Down : action = invertedControls() ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Home : action = SliderToMinimum; break; case Qt::Key_End : action = SliderToMaximum; break; default : event->ignore(); break; } if( action ){ triggerAction(action ); } }
void TestGui::testDatabaseSettings() { triggerAction("actionChangeDatabaseSettings"); QWidget* dbSettingsWidget = m_dbWidget->findChild<QWidget*>("databaseSettingsWidget"); QSpinBox* transformRoundsSpinBox = dbSettingsWidget->findChild<QSpinBox*>("transformRoundsSpinBox"); transformRoundsSpinBox->setValue(100); QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter); // wait for modified timer QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*")); QCOMPARE(m_db->transformRounds(), Q_UINT64_C(100)); triggerAction("actionDatabaseSave"); QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save")); checkDatabase(); }
// Based on code from qslider.cpp void Slider::mousePressEvent( QMouseEvent *e ) { qDebug("pressed (%d, %d)", e->pos().x(), e->pos().y()); if( e->button() == Qt::LeftButton ) { qDebug( "Left button" ); QStyleOptionSlider opt; initStyleOption( &opt ); const QRect sliderRect = style()->subControlRect( QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this ); const QPoint center = sliderRect.center() - sliderRect.topLeft(); // to take half of the slider off for the setSliderPosition call we use the center - topLeft if ( ! sliderRect.contains( e->pos() ) ) { qDebug( "accept" ); e->accept(); int v = pixelPosToRangeValue( pick( e->pos() - center ) ); setSliderPosition( v ); triggerAction( SliderMove ); setRepeatAction( SliderNoAction ); emit sliderMoved( v );//TODO: ok? emit sliderPressed(); //TODO: ok? } else { QSlider::mousePressEvent( e ); } } else { QSlider::mousePressEvent( e ); } }
void QWebPage_QtDShell::__override_triggerAction(int action0, bool checked1, bool static_call) { if (static_call) { QWebPage::triggerAction((QWebPage::WebAction )action0, (bool )checked1); } else { triggerAction((QWebPage::WebAction )action0, (bool )checked1); } }
void ThumbSlider::mouseReleaseEvent(QMouseEvent *event) { killTimer(timerId); setValue(0); count = 0; triggerAction(SliderNoAction); }
void QtWebKitWebWidget::triggerAction() { QAction *action = qobject_cast<QAction*>(sender()); if (action) { triggerAction(static_cast<WindowAction>(action->data().toInt())); } }
void WebWidget::contextMenuEvent(QContextMenuEvent *event) { if (m_scrollMode == MoveScroll) { triggerAction(ActionsManager::EndScrollAction); } event->accept(); }
void WebWidget::triggerAction() { Action *action = qobject_cast<Action*>(sender()); if (action) { triggerAction(action->getIdentifier(), (action->isCheckable() && action->isChecked())); } }
void TransfersContentsWidget::triggerAction() { QAction *action = qobject_cast<QAction*>(sender()); if (action) { triggerAction(static_cast<ActionIdentifier>(action->data().toInt())); } }
void MainWindow::triggerAction() { QShortcut *shortcut = qobject_cast<QShortcut*>(sender()); if (shortcut) { for (int i = 0; i < m_actionShortcuts.count(); ++i) { if (m_actionShortcuts[i].second.contains(shortcut)) { const ActionDefinition definition = ActionsManager::getActionDefinition(m_actionShortcuts[i].first); if (definition.identifier >= 0) { if (definition.isCheckable) { Action *action = getAction(m_actionShortcuts[i].first); if (action) { action->toggle(); } } else { triggerAction(m_actionShortcuts[i].first); } } return; } } return; } Action *action = qobject_cast<Action*>(sender()); if (action) { triggerAction(action->getIdentifier(), action->data().toMap()); } }
void ThumbSlider::mouseMoveEvent(QMouseEvent *event) { if (event->buttons() && Qt::LeftButton) { int value = QStyle::sliderValueFromPosition(minimum(), maximum(), event->x(), width(), false); setSliderPosition(value); triggerAction(SliderMove); } }
void WebPage::handleUnsupportedContent(QNetworkReply *reply) { QVariant contentMimeType = reply->header(QNetworkRequest::ContentTypeHeader); if(!contentMimeType.isNull()) { triggerAction(QWebPage::Stop); UnsupportedContentHandler *handler = new UnsupportedContentHandler(this, reply); if (reply->isFinished()) handler->renderNonHtmlContent(); else handler->waitForReplyToFinish(); } }
void Window::timerEvent(QTimerEvent *event) { if (event->timerId() == m_suspendTimer) { killTimer(m_suspendTimer); m_suspendTimer = 0; triggerAction(ActionsManager::SuspendTabAction); } }
void HudSlider::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if (!d->hasValidRange()) { return; } if (d->mIsDown) { setSliderPosition(d->positionForX(event->pos().x())); triggerAction(QAbstractSlider::SliderMove); update(); } }
void TestGui::testSave() { m_db->metadata()->setName("Save"); // wait for modified timer QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*")); triggerAction("actionDatabaseSave"); QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save")); checkDatabase(); }
void TestGui::testOpenDatabase() { fileDialog()->setNextFileName(QString(KEEPASSX_TEST_DATA_DIR).append("/NewDatabase.kdbx")); triggerAction("actionDatabaseOpen"); QWidget* databaseOpenWidget = m_mainWindow->findChild<QWidget*>("databaseOpenWidget"); QLineEdit* editPassword = databaseOpenWidget->findChild<QLineEdit*>("editPassword"); QVERIFY(editPassword); QTest::keyClicks(editPassword, "a"); QTest::keyClick(editPassword, Qt::Key_Enter); }
void TestGui::testOpenDatabase() { fileDialog()->setNextFileName(m_orgDbFile.fileName()); triggerAction("actionDatabaseOpen"); QWidget* databaseOpenWidget = m_mainWindow->findChild<QWidget*>("databaseOpenWidget"); QLineEdit* editPassword = databaseOpenWidget->findChild<QLineEdit*>("editPassword"); QVERIFY(editPassword); QTest::keyClicks(editPassword, "a"); QTest::keyClick(editPassword, Qt::Key_Enter); }
void HudSlider::wheelEvent(QGraphicsSceneWheelEvent* event) { if (!d->hasValidRange()) { return; } int step = qMin(QApplication::wheelScrollLines() * d->mSingleStep, d->mPageStep); if ((event->modifiers() & Qt::ControlModifier) || (event->modifiers() & Qt::ShiftModifier)) { step = d->mPageStep; } setSliderPosition(d->mSliderPosition + event->delta() * step / 120); triggerAction(QAbstractSlider::SliderMove); }