void SkinStyle::createWidgetsContainer(QWidget * widget, const QString & objectName) { QWidget * container = new QWidget(widget->parentWidget()); container->setObjectName(objectName); QHBoxLayout * layout = new QHBoxLayout(); container->setLayout(layout); QObjectList objects = widget->children(); for (int i = 0; i < objects.size(); i++) { QObject * object = objects.at(i); if (object->isWidgetType()) { if (!object->inherits("QToolBarHandle") && !object->inherits("QToolBarExtension")) { QWidget * w = qobject_cast < QWidget * > (object); addWidgetToLayout(w, layout); w->show(); } } else if (object->inherits("QAction")) { QAction * a = qobject_cast < QAction * > (object); QWidget * w = new QWidget(container); w->addAction(a); addWidgetToLayout(w, layout); } else if (object->inherits("QLayout")) { QLayout * l = qobject_cast < QLayout * > (object); layout->addLayout(l); } } container->show(); }
void SoftkeysActionBoxModule::addAction(QAction *action) { QWidget *p = this; while (p->parentWidget() && !p->isWindow()) { p = p->parentWidget(); } p->addAction(action); }
void MyAction::addActionToParent() { if (parent()) { if (parent()->inherits("QWidget")) { QWidget *w = static_cast<QWidget*> (parent()); w->addAction(this); } } }
void HelpQuery::textChanged(const QString& ss) { QString s = ss.toLower(); QWidget* menu = static_cast<QWidget*>(parent()); if (s.isEmpty()) { if (!emptyState) { // restore old menu entries QList<QAction*> al = menu->actions(); for (QAction* a : al) { if (a != this) menu->removeAction(a); } for (QAction* a : actions) { if (a != this) menu->addAction(a); } } emptyState = true; return; } if (emptyState) actions = menu->actions(); for (QAction* a : menu->actions()) { if (a != this) menu->removeAction(a); } emptyState = false; if (!mscore->helpEngine()) return; QMap<QString,QUrl>list = mscore->helpEngine()->linksForIdentifier(s); // QMap<QString,QUrl>list = mscore->helpEngine()->indexModel()->linksForKeyword(s); int k = 0; for (auto i = list.begin(); i != list.end(); ++i) { QAction* action = new QAction(i.key(), this); action->setData(i.value()); // printf("add action <%s> <%s>\n", qPrintable(i.key()), qPrintable(i.value().toString())); menu->addAction(action); connect(action, SIGNAL(triggered()), mapper, SLOT(map())); mapper->setMapping(action, action); if (++k > 10) break; } }
void KdmLabel::doPlugActions( bool plug ) { if (action) { QWidget *w = themer()->widget(); if (plug) w->addAction( action ); else w->removeAction( action ); } }
void Application::parseArgs( const QStringList &args ) { QStringList params = args; params.removeAll("-capi"); params.removeAll("-cng"); params.removeAll("-pkcs11"); params.removeAll("-noNativeFileDialog"); QWidget *w = new MainWindow(); #ifdef Q_OS_MAC w->installEventFilter( d->bar ); #endif w->addAction( d->closeAction ); w->activateWindow(); w->show(); w->raise(); if( !params.isEmpty() ) QMetaObject::invokeMethod( w, "open", Q_ARG(QStringList,params) ); }
StelAction::StelAction(const QString& actionId, const QString& groupId, const QString& text, const QString& primaryKey, const QString& altKey, bool global): QObject(StelApp::getInstance().getStelActionManager()), group(groupId), text(text), global(global), keySequence(primaryKey), altKeySequence(altKey), defaultKeySequence(primaryKey), defaultAltKeySequence(altKey), target(NULL), boolProperty(NULL) #ifndef USE_QUICKVIEW ,qAction(NULL) #endif { setObjectName(actionId); // Check the global conf for custom shortcuts. QSettings* conf = StelApp::getInstance().getSettings(); QString confShortcut = conf->value("shortcuts/" + actionId).toString(); if (!confShortcut.isEmpty()) { QStringList shortcuts = confShortcut.split(" "); if (shortcuts.size() > 2) qWarning() << actionId << ": does not support more than two shortcuts per action"; setShortcut(shortcuts[0]); if (shortcuts.size() > 1) setAltShortcut(shortcuts[1]); } #ifndef USE_QUICKVIEW QWidget* mainView = &StelMainView::getInstance(); qAction = new QAction(this); onChanged(); mainView->addAction(qAction); connect(qAction, SIGNAL(triggered()), this, SLOT(trigger())); connect(this, SIGNAL(changed()), this, SLOT(onChanged())); #endif }
void QWidgetProto::addAction(QAction *action) { QWidget *item = qscriptvalue_cast<QWidget*>(thisObject()); if (item) item->addAction(action); }