/*! \reimp */ void QToolButton::actionEvent(QActionEvent *event) { Q_D(QToolButton); QAction *action = event->action(); switch (event->type()) { case QEvent::ActionChanged: if (action == d->defaultAction) setDefaultAction(action); // update button state break; case QEvent::ActionAdded: connect(action, SIGNAL(triggered()), this, SLOT(_q_actionTriggered())); break; case QEvent::ActionRemoved: if (d->defaultAction == action) d->defaultAction = 0; #ifndef QT_NO_MENU if (action == d->menuAction) d->menuAction = 0; #endif action->disconnect(this); break; default: ; } QAbstractButton::actionEvent(event); }
void DesktopViewProxy::documentChanged() { // Remove existing linking for toggling canvas, in order // to over-ride the window state behaviour QAction* toggleJustTheCanvasAction = d->desktopWindow->actionCollection()->action("view_show_just_the_canvas"); toggleJustTheCanvasAction->disconnect(d->desktopWindow); connect(toggleJustTheCanvasAction, SIGNAL(toggled(bool)), this, SLOT(toggleShowJustTheCanvas(bool))); }
DesktopViewProxy::DesktopViewProxy(MainWindow* mainWindow, KisMainWindow* parent) : QObject(parent) , d(new Private(mainWindow, parent)) { Q_ASSERT(parent); // "There MUST be a KisMainWindow assigned, otherwise everything will blow up"); // Hide this one... as it doesn't work at all well and release happens :P QAction* closeAction = d->desktopWindow->actionCollection()->action("file_close"); closeAction->setVisible(false); // Concept is simple - simply steal all the actions we require to work differently, and reconnect them to local functions QAction* newAction = d->desktopWindow->actionCollection()->action("file_new"); newAction->disconnect(d->desktopWindow); connect(newAction, SIGNAL(triggered(bool)), this, SLOT(fileNew())); QAction* openAction = d->desktopWindow->actionCollection()->action("file_open"); openAction->disconnect(d->desktopWindow); connect(openAction, SIGNAL(triggered(bool)), this, SLOT(fileOpen())); QAction* saveAction = d->desktopWindow->actionCollection()->action("file_save"); saveAction->disconnect(d->desktopWindow); connect(saveAction, SIGNAL(triggered(bool)), this, SLOT(fileSave())); QAction* saveasAction = d->desktopWindow->actionCollection()->action("file_save_as"); saveasAction->disconnect(d->desktopWindow); connect(saveasAction, SIGNAL(triggered(bool)), this, SLOT(fileSaveAs())); QAction* reloadAction = d->desktopWindow->actionCollection()->action("file_reload_file"); reloadAction->disconnect(d->desktopWindow); connect(reloadAction, SIGNAL(triggered(bool)), this, SLOT(reload())); QAction* loadExistingAsNewAction = d->desktopWindow->actionCollection()->action("file_import_file"); //Hide the "Load existing as new" action. It serves little purpose and currently //does the same as open. We cannot just remove it from the action collection though //since that causes a crash in KisMainWindow. loadExistingAsNewAction->setVisible(false); // Recent files need a touch more work, as they aren't simply an action. KRecentFilesAction* recent = qobject_cast<KRecentFilesAction*>(d->desktopWindow->actionCollection()->action("file_open_recent")); recent->disconnect(d->desktopWindow); connect(recent, SIGNAL(urlSelected(QUrl)), this, SLOT(slotFileOpenRecent(QUrl))); recent->clear(); recent->loadEntries(KGlobal::config()->group("RecentFiles")); connect(d->desktopWindow, SIGNAL(documentSaved()), this, SIGNAL(documentSaved())); // XXX: Shortcut editor is untested in Gemini since refactoring. connect(KisActionRegistry::instance(), SIGNAL(shortcutsUpdated()), this, SLOT(updateShortcuts())); }
void QVLCMenu::CreateAndConnect( QMenu *menu, const char *psz_var, QString text, QString help, int i_item_type, vlc_object_t *p_obj, vlc_value_t val, int i_val_type, bool checked ) { QAction *action = FindActionWithVar( menu, psz_var ); bool b_new = false; if( !action ) { action = new QAction( text, menu ); menu->addAction( action ); b_new = true; } action->setToolTip( help ); action->setEnabled( p_obj != NULL ); if( i_item_type == ITEM_CHECK ) { action->setCheckable( true ); } else if( i_item_type == ITEM_RADIO ) { action->setCheckable( true ); if( !currentGroup ) currentGroup = new QActionGroup( menu ); currentGroup->addAction( action ); } action->setChecked( checked ); MenuItemData *itemData = new MenuItemData( THEDP->menusMapper, p_obj, i_val_type, val, psz_var ); /* remove previous signal-slot connection(s) if any */ action->disconnect( ); CONNECT( action, triggered(), THEDP->menusMapper, map() ); THEDP->menusMapper->setMapping( action, itemData ); if( b_new ) menu->addAction( action ); }
void Shell::slotPartDisconnect(KParts::BrowserExtension *be) { //if we got here then the part has no browserExtension, so we need to remove the actions //from the collection KParts::BrowserExtension::ActionSlotMap *slotmap = KParts::BrowserExtension::actionSlotMapPtr(); KParts::BrowserExtension::ActionSlotMap::const_iterator it = slotmap->constBegin(); KParts::BrowserExtension::ActionSlotMap::const_iterator itEnd = slotmap->constEnd(); //iterate over the slotmap deactivating as we go... also copied from kongmainwindow.cpp for (; it != itEnd ; ++it) { QAction *act = actionCollection()->action(it.key().data()); if (act && be->metaObject()->indexOfSlot(it.key() + "()") != -1) { act->disconnect(be); act->setDisabled(true); } } }
KopeteSystemTray::KopeteSystemTray(QWidget* parent) : KStatusNotifierItem(parent) { kDebug(14010) ; setCategory(Communications); setToolTip("kopete", "Kopete", KGlobal::mainComponent().aboutData()->shortDescription()); setStatus(Passive); mIsBlinkIcon = false; mBlinkTimer = new QTimer(this); mBlinkTimer->setObjectName("mBlinkTimer"); mKopeteIcon = "kopete"; connect(contextMenu(), SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowMenu())); connect(mBlinkTimer, SIGNAL(timeout()), this, SLOT(slotBlink())); connect(Kopete::ChatSessionManager::self() , SIGNAL(newEvent(Kopete::MessageEvent*)), this, SLOT(slotNewEvent(Kopete::MessageEvent*))); connect(Kopete::BehaviorSettings::self(), SIGNAL(configChanged()), this, SLOT(slotConfigChanged())); connect(Kopete::AccountManager::self(), SIGNAL(accountOnlineStatusChanged(Kopete::Account *, const Kopete::OnlineStatus &, const Kopete::OnlineStatus &)), this, SLOT(slotReevaluateAccountStates())); // the slot called by default by the quit action, KSystemTray::maybeQuit(), // just closes the parent window, which is hard to distinguish in that window's closeEvent() // from a click on the window's close widget // in the quit case, we want to quit the application // in the close widget click case, we only want to hide the parent window // so instead, we make it call our general purpose quit slot on the window, which causes a window close and everything else we need // KDE4 - app will have to listen for quitSelected instead QAction *quit = actionCollection()->action( "file_quit" ); quit->disconnect(); KopeteWindow *myParent = static_cast<KopeteWindow *>( parent ); connect( quit, SIGNAL(activated()), myParent, SLOT(slotQuit()) ); setIconByName(mKopeteIcon); setAttentionMovieByName( QLatin1String( "newmessage" ) ); slotReevaluateAccountStates(); slotConfigChanged(); }
void MenuButton::actionEvent(QActionEvent *event) { QAction *action = event->action(); switch (event->type()) { case QEvent::ActionChanged: if (action == _action) setAction(action); // update button state break; case QEvent::ActionRemoved: if (_action == action) _action = 0; action->disconnect(this); break; default: ; } QWidget::actionEvent(event); }
QDockWidget* DockHost::createDock(QWidget* parent, QWidget* widget, const QString &title) { static int counter = 0; QDockWidget* dock = new QDockWidget(parent); dock->setObjectName(QString("dock%1").arg(++counter)); dock->setWidget(widget); dock->setWindowTitle(title); QObject::connect(dock, &QDockWidget::topLevelChanged, this, &DockHost::onDockTopLevelChanged); QObject::connect(dock, &QDockWidget::visibilityChanged, this, &DockHost::onDockVisibilityChanged); QObject::connect(dock, &QDockWidget::featuresChanged, this, &DockHost::onDockFeaturesChanged); QAction* action = dock->toggleViewAction(); action->disconnect(); QObject::connect(action, &QAction::triggered, this, &DockHost::onDockActionTriggered); dock->installEventFilter(this); widgets << widget; return dock; }
QDockWidget* DockHost::createDock(QWidget* parent, QWidget* widget, const QString& title) { static int counter = 0; QDockWidget* dock = new QDockWidget(parent); dock->setObjectName(QString("dock%1").arg(++counter)); QMargins widgetMargins = widget->layout()->contentsMargins(); widgetMargins.setTop(widgetMargins.top() + 2); widget->layout()->setContentsMargins(widgetMargins); dock->setWidget(widget); dock->setWindowTitle(title); QObject::connect(dock, &QDockWidget::topLevelChanged, this, &DockHost::onDockTopLevelChanged); QAction* action = dock->toggleViewAction(); action->disconnect(); QObject::connect(action, &QAction::triggered, this, &DockHost::onDockActionTriggered); dock->installEventFilter(this); widgets << widget; return dock; }