void QQuickMenuItem::bindToAction(QQuickAction *action) { m_boundAction = action; connect(m_boundAction, SIGNAL(destroyed(QObject*)), this, SLOT(unbindFromAction(QObject*))); connect(m_boundAction, SIGNAL(triggered()), this, SIGNAL(triggered())); connect(m_boundAction, SIGNAL(toggled(bool)), this, SLOT(updateChecked())); connect(m_boundAction, SIGNAL(exclusiveGroupChanged()), this, SIGNAL(exclusiveGroupChanged())); connect(m_boundAction, SIGNAL(enabledChanged()), this, SLOT(updateEnabled())); connect(m_boundAction, SIGNAL(textChanged()), this, SLOT(updateText())); connect(m_boundAction, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut())); connect(m_boundAction, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged())); connect(m_boundAction, SIGNAL(iconNameChanged()), this, SLOT(updateIcon())); connect(m_boundAction, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged())); connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon())); connect(m_boundAction, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged())); if (m_boundAction->parent() != this) { updateText(); updateShortcut(); updateEnabled(); updateIcon(); if (checkable()) updateChecked(); } }
void Action::updateState() { const ActionsManager::ActionDefinition definition(getDefinition()); ActionsManager::ActionDefinition::State state; if (m_executor.isValid()) { state = m_executor.getActionState(m_identifier, m_parameters); } else if (definition.isValid()) { state = definition.getDefaultState(); state.isEnabled = false; } if (m_flags.testFlag(IsOverridingTextFlag)) { state.text = QCoreApplication::translate("actions", m_overrideText.toUtf8().constData()); } if (definition.isValid() && definition.flags.testFlag(ActionsManager::ActionDefinition::RequiresParameters) && m_parameters.isEmpty()) { state.isEnabled = false; } updateShortcut(); setState(state); }
void QQuickMenuItem::unbindFromAction(QObject *o) { if (!o) return; if (o == m_boundAction) m_boundAction = 0; QQuickAction *action = qobject_cast<QQuickAction *>(o); if (!action) return; disconnect(action, SIGNAL(destroyed(QObject*)), this, SLOT(unbindFromAction(QObject*))); disconnect(action, SIGNAL(triggered()), this, SIGNAL(triggered())); disconnect(action, SIGNAL(toggled(bool)), this, SLOT(updateChecked())); disconnect(action, SIGNAL(exclusiveGroupChanged()), this, SIGNAL(exclusiveGroupChanged())); disconnect(action, SIGNAL(enabledChanged()), this, SLOT(updateEnabled())); disconnect(action, SIGNAL(textChanged()), this, SLOT(updateText())); disconnect(action, SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut())); disconnect(action, SIGNAL(checkableChanged()), this, SIGNAL(checkableChanged())); disconnect(action, SIGNAL(iconNameChanged()), this, SLOT(updateIcon())); disconnect(action, SIGNAL(iconNameChanged()), this, SIGNAL(iconNameChanged())); disconnect(action, SIGNAL(iconSourceChanged()), this, SLOT(updateIcon())); disconnect(action, SIGNAL(iconSourceChanged()), this, SIGNAL(iconSourceChanged())); }
QQuickMenuItem::QQuickMenuItem(QObject *parent) : QQuickMenuText(parent, QQuickMenuItemType::Item), m_boundAction(0) { connect(this, SIGNAL(__textChanged()), this, SIGNAL(textChanged())); connect(action(), SIGNAL(shortcutChanged(QVariant)), this, SLOT(updateShortcut())); connect(action(), SIGNAL(triggered()), this, SIGNAL(triggered())); connect(action(), SIGNAL(toggled(bool)), this, SLOT(updateChecked())); if (platformItem()) connect(platformItem(), SIGNAL(activated()), this, SLOT(trigger())); }
void KAction::updateShortcut( int i ) { int id = itemId( i ); QWidget* w = container( i ); if ( ::qt_cast<QPopupMenu *>( w ) ) { QPopupMenu* menu = static_cast<QPopupMenu*>(w); updateShortcut( menu, id ); } else if ( ::qt_cast<QMenuBar *>( w ) ) static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); }
bool KAction::setShortcut( const KShortcut& cut ) { bool bChanged = (d->m_cut != cut); d->m_cut = cut; KAccel* const kaccel = kaccelCurrent(); bool bInsertRequired = true; // Apply new shortcut to all existing KAccel objects const QValueList<KAccel*> & accelList = d->m_kaccelList; QValueList<KAccel*>::const_iterator itr = accelList.constBegin(); const QValueList<KAccel*>::const_iterator itrEnd = accelList.constEnd(); for( ; itr != itrEnd; ++itr) { // Check whether shortcut has already been plugged into // the current kaccel object. if( (*itr) == kaccel ) bInsertRequired = false; if( bChanged ) updateKAccelShortcut( *itr ); } // Only insert action into KAccel if it has a valid name, if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) insertKAccel( kaccel ); if( bChanged ) { #ifndef KDE_NO_COMPAT // KDE 4: remove if ( d->m_kaccel ) d->m_kaccel->setShortcut( name(), cut ); #endif // KDE 4: remove end int len = containerCount(); for( int i = 0; i < len; ++i ) updateShortcut( i ); } return true; }
UIConfig::UIConfig(QWidget *parent) : QDialog(parent), ui(new Ui::UIConfig) { ui->setupUi(this); _removing_thumbnails = false; settings = new QSettings("settings.ini", QSettings::IniFormat); timeoutValueEditor = new UIListEditor(this); timeoutValueEditor->setModal(true); dialogFolderShortcut = new DialogFolderShortcut(this); dialogFolderShortcut->setModal(true); userAgentStrings.insert("Wget", "Wget/1.12"); userAgentStrings.insert("Opera", "Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14"); userAgentStrings.insert("Firefox", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"); userAgentStrings.insert("Chrome", "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"); loadSettings(); loadShortcuts(); connect(timeoutValueEditor, SIGNAL(valuesChanged()), this, SLOT(loadSettings())); connect(ui->cbUseProxy, SIGNAL(toggled(bool)), this, SLOT(toggleProxy(bool))); connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(editShortcutItem(QListWidgetItem*))); connect(folderShortcuts, SIGNAL(shortcutsChanged()), this, SLOT(loadShortcuts())); connect(dialogFolderShortcut, SIGNAL(shortcutChanged(QString,QString,QString)), folderShortcuts, SLOT(updateShortcut(QString,QString,QString))); connect(dialogFolderShortcut, SIGNAL(editCanceled()), this, SLOT(loadShortcuts())); connect(ui->btnDeleteAllThumbnails, SIGNAL(clicked()), this, SIGNAL(deleteAllThumbnails())); connect(ui->btnDeleteAllThumbnails, SIGNAL(clicked()), this, SLOT(thumbnailDeletionStarted())); }
int KAction::plug( QWidget *w, int index ) { //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; if (!w ) { kdWarning(129) << "KAction::plug called with 0 argument\n"; return -1; } // Ellis: print warning if there is a shortcut, but no KAccel available (often due to no widget available in the actioncollection) // David: Well, it doesn't matter much, things still work (e.g. Undo in koffice) via QAccel. // We should probably re-enable the warning for things that only KAccel can do, though - e.g. WIN key (mapped to Meta). #if 0 //ndef NDEBUG KAccel* kaccel = kaccelCurrent(); if( !d->m_cut.isNull() && !kaccel ) { kdDebug(129) << "KAction::plug(): has no KAccel object; this = " << this << " name = " << name() << " parentCollection = " << m_parentCollection << endl; // ellis } #endif // Check if action is permitted if (kapp && !kapp->authorizeKAction(name())) return -1; plugShortcut(); if ( ::qt_cast<QPopupMenu *>( w ) ) { QPopupMenu* menu = static_cast<QPopupMenu*>( w ); int id; // Don't insert shortcut into menu if it's already in a KAccel object. int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); if ( d->hasIcon() ) { KInstance *instance; if ( m_parentCollection ) instance = m_parentCollection->instance(); else instance = KGlobal::instance(); id = menu->insertItem( d->iconSet( KIcon::Small, 0, instance ), d->text(), this,//dsweet SLOT( slotPopupActivated() ), keyQt, -1, index ); } else id = menu->insertItem( d->text(), this, SLOT( slotPopupActivated() ), keyQt, -1, index ); // If the shortcut is already in a KAccel object, then // we need to set the menu item's shortcut text. if ( d->m_kaccelList.count() || d->m_kaccel ) updateShortcut( menu, id ); // call setItemEnabled only if the item really should be disabled, // because that method is slow and the item is per default enabled if ( !d->isEnabled() ) menu->setItemEnabled( id, false ); if ( !d->whatsThis().isEmpty() ) menu->setWhatsThis( id, whatsThisWithIcon() ); addContainer( menu, id ); connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); if ( m_parentCollection ) m_parentCollection->connectHighlight( menu, this ); return d->m_containers.count() - 1; } else if ( ::qt_cast<KToolBar *>( w ) ) { KToolBar *bar = static_cast<KToolBar *>( w ); int id_ = getToolButtonID(); KInstance *instance; if ( m_parentCollection ) instance = m_parentCollection->instance(); else instance = KGlobal::instance(); if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly { bar->insertButton( iconSet().pixmap(), id_, SIGNAL( buttonClicked(int, Qt::ButtonState) ), this, SLOT( slotButtonClicked(int, Qt::ButtonState) ), d->isEnabled(), d->plainText(), index ); } else {