void QCastViewGL::onCameraChangeAction() { QAction *pAct = qobject_cast< QAction* >(QObject::sender()); if (!pAct) return; QVariant v = pAct->data(); void* pc = v.value<void*>(); cogx::display::CDisplayCamera* pCamera = static_cast<cogx::display::CDisplayCamera*>(pc); //std::cout << pAct << " " << pAct->text().toStdString() << " " << pc << " " << pCamera << std::endl; if (pCamera) { // TODO: should check if it is valid -- is it in getCameras()? selectCamera(pCamera); } // Replace the action for the button. // Parent hierarchy: action -> menu -> button QMenu *pMenu = qobject_cast< QMenu* >(pAct->parent()); if (pMenu) { QToolButton* pBut = qobject_cast< QToolButton* >(pMenu->parent()); if (pBut) { QAction *pOldAct = pBut->defaultAction(); if (pOldAct && pOldAct->parent() == pAct->parent()) { //std::cout << "Changing default action" << std::endl; pBut->setDefaultAction(pAct); } } } }
void ActionEditor::setFormWindow( FormWindow *fw ) { listActions->clear(); formWindow = fw; if ( !formWindow || !::qt_cast<QMainWindow*>(formWindow->mainContainer()) ) { setEnabled( FALSE ); } else { setEnabled( TRUE ); for ( QAction *a = formWindow->actionList().first(); a; a = formWindow->actionList().next() ) { ActionItem *i = 0; if ( ::qt_cast<QAction*>(a->parent()) ) continue; i = new ActionItem( listActions, a ); i->setText( 0, a->name() ); i->setPixmap( 0, a->iconSet().pixmap() ); // make sure we don't duplicate the connection QObject::disconnect( a, SIGNAL( destroyed( QObject * ) ), this, SLOT( removeConnections( QObject * ) ) ); QObject::connect( a, SIGNAL( destroyed( QObject * ) ), this, SLOT( removeConnections( QObject* ) ) ); if ( ::qt_cast<QActionGroup*>(a) ) { insertChildActions( i ); } } if ( listActions->firstChild() ) { listActions->setCurrentItem( listActions->firstChild() ); listActions->setSelected( listActions->firstChild(), TRUE ); } } }
void ccViewer::doEnableGLFilter() { if (!m_glWindow) { ccLog::Warning("[GL filter] No active 3D view!"); return; } QAction *action = qobject_cast<QAction*>(sender()); if (!action) return; ccGLFilterPluginInterface* ccPlugin = qobject_cast<ccGLFilterPluginInterface*>(action->parent()); if (!ccPlugin) return; assert(ccPlugin->getType() == CC_GL_FILTER_PLUGIN); ccGlFilter* filter = ccPlugin->getFilter(); if (filter) { if (m_glWindow->areGLFiltersEnabled()) { m_glWindow->setGlFilter(filter); ccLog::Print("Note: go to << Display > Shaders & Filters > No filter >> to disable GL filter"); } else ccLog::Error("GL filters not supported!"); } else { ccLog::Error("Can't load GL filter (an error occurred)!"); } }
void LteMainWindow::onExecMiscAction() { QAction *action = qobject_cast<QAction*>(sender()); MiscInterface *ifMisc = qobject_cast<MiscInterface*>(action->parent()); ifMisc->onExec(this); }
void LteMainWindow::onExecLteAction() { QAction *action = qobject_cast<QAction*>(sender()); LteInterface *ifLte = qobject_cast<LteInterface*>(action->parent()); ifLte->onExec(this); }
void tst_QToolBar::insertWidget() { QToolBar tb; QWidget w(&tb); QAction action1(0); QAction action2(0); tb.addAction(&action1); tb.addAction(&action2); QAction *widget = tb.insertWidget(&action2, &w); QCOMPARE(tb.actions().count(), 3); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], widget); QCOMPARE(tb.actions()[2], &action2); // it should be possible to reuse the action returned by // addWidget() to place the widget somewhere else in the toolbar tb.removeAction(widget); QCOMPARE(tb.actions().count(), 2); QCOMPARE(tb.actions()[0], &action1); QCOMPARE(tb.actions()[1], &action2); tb.insertAction(&action1, widget); QCOMPARE(tb.actions().count(), 3); QCOMPARE(tb.actions()[0], widget); QCOMPARE(tb.actions()[1], &action1); QCOMPARE(tb.actions()[2], &action2); tb.clear(); QCOMPARE(tb.actions().count(), 0); { QToolBar tb; QPointer<QWidget> widget = new QWidget; QAction *action = tb.addWidget(widget); QVERIFY(action->parent() == &tb); QToolBar tb2; tb.removeAction(action); tb2.addAction(action); QVERIFY(widget && widget->parent() == &tb2); QVERIFY(action->parent() == &tb2); } }
void FilterScriptDialog::editSelectedFilterParameters() { //get the selected item int currentRow = ui->scriptListWidget->currentRow(); //return if no row was selected if(currentRow == -1) return; QString actionName = scriptPtr->actionList.at(currentRow).first; RichParameterSet oldParameterSet = scriptPtr->actionList.at(currentRow).second; //get the main window MainWindow *mainWindow = qobject_cast<MainWindow*>(parentWidget()); if(NULL == mainWindow){ qDebug() << "problem casting parent of filterscriptdialog to main window"; return; } //get a pointer to this action and filter from the main window so we can get the //description of the parameters from the filter QAction *action = mainWindow->pluginManager().actionFilterMap[actionName]; MeshFilterInterface *iFilter = qobject_cast<MeshFilterInterface *>(action->parent()); if(NULL == iFilter){ qDebug() << "null filter"; return; } //fill the paramter set with all the names and descriptions which are lost in the //filter script RichParameterSet newParameterSet; iFilter->initParameterSet(action, mainWindow->GLA()->meshDoc, newParameterSet); if(newParameterSet.paramList.size() == oldParameterSet.paramList.size()) { //now set values to be the old values RichParameterCopyConstructor cc; for(int i = 0; i < newParameterSet.paramList.size(); i++) { oldParameterSet.paramList[i]->accept(cc); newParameterSet.paramList[i]->val = cc.lastCreated->val; } } else qDebug() << "the size of the given list is not the same as the filter suggests it should be. your filter script may be out of date, or there is a bug in the filter script class"; //launch the dialog GenericParamDialog parameterDialog(this, &newParameterSet, "Edit Parameters", &mainWindow->GLA()->meshDoc); int result = parameterDialog.exec(); if(result == QDialog::Accepted){ //keep the changes scriptPtr->actionList[currentRow].second = newParameterSet; } }
void ConfigWindow::remove_pony() { // Get a pointer to Pony from sender() QAction *q = qobject_cast<QAction*>(QObject::sender()); Pony* p = static_cast<Pony*>(q->parent()->parent()); // QAction->QMenu->QMainWindow(Pony) ponies.remove(p->get_shared_ptr()); save_settings(); update_active_list(); }
void ItemDelegate::editorCancel() { QAction *action = qobject_cast<QAction*>( sender() ); Q_ASSERT(action != NULL); QObject *parent = action->parent(); Q_ASSERT(parent != NULL); QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() ); Q_ASSERT(editor != NULL); emit closeEditor(editor, QAbstractItemDelegate::RevertModelCache); }
void ItemDelegate::editorSave() { QAction *action = qobject_cast<QAction*>( sender() ); Q_ASSERT(action != NULL); QObject *parent = action->parent(); Q_ASSERT(parent != NULL); QPlainTextEdit *editor = qobject_cast<QPlainTextEdit*>( parent->parent() ); Q_ASSERT(editor != NULL); emit commitData(editor); emit closeEditor(editor); }
void ConfigWindow::remove_pony_all() { // Get a pointer to Pony from sender() QAction *q = qobject_cast<QAction*>(QObject::sender()); Pony* p = static_cast<Pony*>(q->parent()->parent()); // QAction->QMenu->QMainWindow(Pony) QString pony_name(p->name); // We must copy the name, because it will be deleted ponies.remove_if([&pony_name](const std::shared_ptr<Pony> &pony) { return pony->name == pony_name; }); save_settings(); update_active_list(); }
void LauncherContextualMenu::setFolded(int folded) { if (folded == m_folded) { return; } if (folded) { /* Remove all actions but the title. */ for (int i = actions().size(); i > 0; --i) { QAction* action = actions().at(i - 1); if (action != m_titleAction) { removeAction(action); if (action->parent() == this) { /* Delete the action only if we "own" it, otherwise let its parent take care of it. */ delete action; } } } } else { int prevWidth = width(); int left = x(), top = y(); addSeparator(); m_launcherItem->createMenuActions(); QRect screenGeometry = QApplication::desktop()->screenGeometry(this); if (QApplication::isRightToLeft()) { left -= width() - prevWidth; } if (height() <= screenGeometry.height()) { /* Adjust the position of the menu only if it fits entirely on the screen. */ int menuBottomEdge = y() + height(); int screenBottomEdge = screenGeometry.y() + screenGeometry.height(); if (menuBottomEdge > screenBottomEdge) { /* The menu goes offscreen, shift it upwards. */ m_arrowY += menuBottomEdge - screenBottomEdge; top = screenBottomEdge - height(); } } move(left, top); if (!transparencyAvailable()) { /* The arrow has moved relatively to the menu. */ updateMask(); } } m_folded = folded; Q_EMIT foldedChanged(m_folded); }
void MainWindow2::exportFile() { QAction* action = qobject_cast<QAction*>(sender()); ExportInterface* exportPlugin = qobject_cast<ExportInterface*>(action->parent()); if (exportPlugin) { //exportPlugin->exportFile(); } else { qDebug() << "exportPlugin is null"; } //const QImage image = iFilter->filterImage(action->text(), paintArea->image(), this); //paintArea->setImage(image); }
void CollocationsDialogController::sl_plusClicked() { if (task != NULL) { return; } QMenu m; AnnotationSettingsRegistry* asr = AppContext::getAnnotationsSettingsRegistry(); foreach(const QString& name, allNames) { if (usedNames.contains(name)) { continue; } QColor c = asr->getAnnotationSettings(name)->color; QAction* a = m.addAction(GUIUtils::createSquareIcon(c, 10), name, this, SLOT(sl_addName())); assert(a->parent() == &m); Q_UNUSED(a); } if (m.isEmpty()) { m.addAction(tr("No annotations left")); } m.exec(QCursor::pos()); }
void ClipboardBrowser::contextMenuAction() { QAction *act = qobject_cast<QAction *>(sender()); Q_ASSERT(act != NULL); QVariant actionData = act->data(); Q_ASSERT( actionData.isValid() ); int i = actionData.toInt(); if (i < 0 || i >= m_sharedData->commands.size()) return; Command cmd = m_sharedData->commands[i]; if ( cmd.outputTab.isEmpty() ) cmd.outputTab = m_id; bool isContextMenuAction = act->parent() == m_menu; if (isContextMenuAction && cmd.transform) { foreach (const QModelIndex &index, selectedIndexes()) emit requestActionDialog(*itemData(index.row()), cmd, index); } else {
void tst_QScriptEngineDebugger::action() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); #endif QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); QList<QScriptEngineDebugger::DebuggerAction> actions; actions << QScriptEngineDebugger::InterruptAction << QScriptEngineDebugger::ContinueAction << QScriptEngineDebugger::StepIntoAction << QScriptEngineDebugger::StepOverAction << QScriptEngineDebugger::StepOutAction << QScriptEngineDebugger::RunToCursorAction << QScriptEngineDebugger::RunToNewScriptAction << QScriptEngineDebugger::ToggleBreakpointAction << QScriptEngineDebugger::ClearDebugOutputAction << QScriptEngineDebugger::ClearErrorLogAction << QScriptEngineDebugger::ClearConsoleAction << QScriptEngineDebugger::FindInScriptAction << QScriptEngineDebugger::FindNextInScriptAction << QScriptEngineDebugger::FindPreviousInScriptAction << QScriptEngineDebugger::GoToLineAction; QList<QAction*> lst; for (int i = 0; i < actions.size(); ++i) { QScriptEngineDebugger::DebuggerAction da = actions.at(i); QAction *act = debugger.action(da); QVERIFY(act != 0); QCOMPARE(act, debugger.action(da)); QCOMPARE(act->parent(), (QObject*)&debugger); QVERIFY(lst.indexOf(act) == -1); lst.append(act); } }
void DesktopWindow::onStickToCurrentPos(bool toggled) { QAction* action = static_cast<QAction*>(sender()); Fm::FileMenu* menu = static_cast<Fm::FileMenu*>(action->parent()); QModelIndexList indexes = listView_->selectionModel()->selectedIndexes(); if(!indexes.isEmpty()) { FmFileInfo* file = menu->firstFile(); QByteArray name = fm_file_info_get_name(file); QModelIndex index = indexes.first(); if(toggled) { // remember to current custom position QRect itemRect = listView_->rectForIndex(index); customItemPos_[name] = itemRect.topLeft(); saveItemPositions(); } else { // cancel custom position and perform relayout QHash<QByteArray, QPoint>::iterator it = customItemPos_.find(name); if(it != customItemPos_.end()) { customItemPos_.erase(it); saveItemPositions(); relayoutItems(); } } } }
void ProxyAction::changeContexts(QList<int> contexts) { LOG_TRACE("Context update request on proxy action", text()); if (m_contextActions.isEmpty()) { LOG_TRACE("No backend actions stored here."); return; } m_contexts = contexts; QAction *oldAction = m_activeAction; m_activeAction = 0; for (int n = 0; n < m_contexts.size(); n++) { QAction *a = m_contextActions.value(m_contexts.at(n), 0); if (a) { m_activeAction = a; m_activeAction->setObjectName(a->text()); LOG_TRACE(QString("Backend action found: %1, shortcut: %2, proxy shortcut: %3") .arg(m_activeAction->text()) .arg(m_activeAction->shortcut().toString()) .arg(m_action->shortcut().toString())); break; } } if (m_activeAction == oldAction && m_initialized) { updateFrontend(); LOG_TRACE("New backend action is the same as the active action; nothing to be done."); return; } if (oldAction) { LOG_TRACE(QString("Disconnecting multi-context action from previous backend action in parent: %1") .arg(oldAction->parent() ? oldAction->parent()->objectName() : "Unspecified parent")); disconnect(oldAction, SIGNAL(changed()), this, SLOT(updateFrontend())); disconnect(m_action, SIGNAL(triggered(bool)), oldAction, SIGNAL(triggered(bool))); disconnect(m_action, SIGNAL(toggled(bool)), oldAction, SLOT(setChecked(bool))); } if (m_activeAction) { LOG_TRACE(QString("Connecting base action: %1, shortcut: %2, parent: %3") .arg(m_activeAction->text()) .arg(m_action->shortcut().toString()) .arg(m_activeAction->parent() ? m_activeAction->parent()->objectName() : "Unspecified parent")); connect(m_activeAction, SIGNAL(changed()), SLOT(updateFrontend())); connect(m_action, SIGNAL(triggered(bool)), m_activeAction, SIGNAL(triggered(bool))); connect(m_action, SIGNAL(toggled(bool)), m_activeAction, SLOT(setChecked(bool))); updateFrontend(); m_initialized = true; return; } else { LOG_TRACE("New backend action could not be found; action will be disabled in this context."); } m_action->setEnabled(false); }
/*! * \brief Adds new Op to nodegraph. * Adds new Op to main nodegraph. At first it casts the sender object to QAction, * then casts QAction parent to OpInterface and calls mainGraph->addOp(Op). * @see nodeGraph::addOp() */ void MainWindow::addOp() { QAction *action = qobject_cast<QAction *>(sender()); OpInterface *Op = qobject_cast<OpInterface *>(action->parent()); mainGraph->addOp(Op); }
void QFRDRTableDelegate::doEditExpression() { QAction *act = qobject_cast<QAction *>(sender()); QWidget* editor=qobject_cast<QWidget *>(act->parent()); emit closeEditorEnhanced(editor, QFRDRTableDelegate::EditEditExpression); }