本文整理汇总了C++中KActionMenu::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ KActionMenu::setEnabled方法的具体用法?C++ KActionMenu::setEnabled怎么用?C++ KActionMenu::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KActionMenu
的用法示例。
在下文中一共展示了KActionMenu::setEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupHistoryActions
void TabBar::setupHistoryActions()
{
MainWindow *w = Application::instance()->mainWindow();
MainView *mv = qobject_cast<MainView *>(parent());
QAction *openLastClosedTabAction = w->actionByName( QL1S("open_last_closed_tab") );
openLastClosedTabAction->setEnabled( mv->recentlyClosedTabs().size() > 0 );
// update closed tabs menu
KActionMenu *am = qobject_cast<KActionMenu *>( w->actionByName( QL1S("closed_tab_menu") ));
if (!am)
return;
bool isEnabled = ( mv->recentlyClosedTabs().size() > 0 );
am->setEnabled(isEnabled);
if (am->menu())
am->menu()->clear();
if(!isEnabled)
return;
Q_FOREACH(const HistoryItem &item, mv->recentlyClosedTabs())
{
KAction *a = new KAction(Application::iconManager()->iconForUrl(item.url), item.title, this);
a->setData(item.url);
connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab()));
am->addAction(a);
}
}
示例2: KActionMenu
KActionMenu *TabBar::setupHistoryActions()
{
MainWindow *w = rApp->mainWindow();
MainView *mv = qobject_cast<MainView *>(parent());
QAction *openLastClosedTabAction = w->actionByName(QL1S("open_last_closed_tab"));
bool closedTabsAvailable = (mv->recentlyClosedTabs().size() > 0);
openLastClosedTabAction->setEnabled(closedTabsAvailable);
KActionMenu *am = new KActionMenu(KIcon("tab-new"), i18n("Closed Tabs"), this);
am->setDelayed(false);
am->setEnabled(closedTabsAvailable);
if (am->menu())
am->menu()->clear();
if (!closedTabsAvailable)
return am;
for (int i = 0; i < mv->recentlyClosedTabs().count(); ++i)
{
TabHistory item = mv->recentlyClosedTabs().at(i);
KAction *a = new KAction(rApp->iconManager()->iconForUrl(item.url), item.title, this);
a->setData(i);
connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab()));
am->addAction(a);
}
return am;
}
示例3: KMainWindow
/**
* Constructor. Connect all of the object and the job control.
*/
KAudioCreator::KAudioCreator( QWidget* parent, const char* name) :
KMainWindow(parent, name)
{
janusWidget = new KJanusWidget(this, name, KJanusWidget::Tabbed);
setCentralWidget(janusWidget);
QVBox *frame = janusWidget->addVBoxPage(i18n("&CD Tracks"), QString::null, SmallIcon("cdaudio_unmount", 32));
tracks = new TracksImp(frame, "Tracks");
ripper = new Ripper ( frame, "Rip" );
encoder = new Encoder( frame, "Encoder" );
frame = janusWidget->addVBoxPage( i18n("&Jobs"), QString::null, SmallIcon( "run", 32 ) );
jobQue = new JobQueImp( frame, "Que" );
resize(500, 440);
/*KAction *eject = */new KAction( i18n("&Eject CD"), 0, tracks,
SLOT( eject() ), actionCollection(), "eject" );
(void)new KAction( i18n("&Configure KAudioCreator..."), 0, this,
SLOT( showSettings() ), actionCollection(), "configure_kaudiocreator" );
KAction *selectAll = new KAction( i18n( "Select &All Tracks"), 0, tracks,
SLOT( selectAllTracks() ), actionCollection(), "select_all" ) ;
KAction *deselectAll = new KAction( i18n( "Deselect &All Tracks"), 0, tracks,
SLOT( deselectAllTracks() ), actionCollection(), "deselect_all" );
selectAll->setEnabled( false );
deselectAll->setEnabled( false );
KActionMenu *actActionMenu = new KActionMenu( i18n("Rip &Selection"), "rip", actionCollection(), "rip" );
actActionMenu->setDelayed(true); //needed for checking "all accounts"
actActionMenu->setEnabled( false );
connect( actActionMenu, SIGNAL( activated() ), tracks, SLOT( startSession() ) );
ripMenu = actActionMenu->popupMenu();
connect( ripMenu, SIGNAL( activated(int) ), this, SLOT( slotRipSelection(int)) );
connect( ripMenu, SIGNAL( aboutToShow() ), this, SLOT( getRipMenu()) );
KAction *rip = new KAction( i18n( "Rip &Selection" ), 0, tracks,
SLOT( startSession() ), actionCollection(), "rip_selected" );
rip->setEnabled( false );
connect( jobQue, SIGNAL( removeJob(int) ), this, SLOT( updateStatus() ) );
connect( jobQue, SIGNAL( removeJob(int) ), ripper, SLOT( removeJob(int) ) );
connect( jobQue, SIGNAL( removeJob(int) ), encoder, SLOT( removeJob(int)) );
connect( ripper, SIGNAL( updateProgress(int, int) ) , jobQue, SLOT( updateProgress(int,int) ) );
connect( ripper, SIGNAL( addJob(Job*, const QString &) ), jobQue, SLOT( addJob(Job*, const QString &)) );
connect( ripper, SIGNAL( eject(const QString &) ) , tracks, SLOT( ejectDevice(const QString &)) );
connect( ripper, SIGNAL( encodeWav(Job *) ) , encoder, SLOT( encodeWav(Job *)) );
connect( ripper, SIGNAL( jobsChanged() ) , this, SLOT( updateStatus() ) );
connect( encoder, SIGNAL( updateProgress(int, int) ) , jobQue, SLOT( updateProgress(int,int)) );
connect( encoder, SIGNAL( addJob(Job*, const QString&)), jobQue, SLOT( addJob(Job*, const QString &)) );
connect( encoder, SIGNAL( jobsChanged() ) , this, SLOT( updateStatus() ) );
connect( tracks, SIGNAL( hasCD(bool) ) , this, SLOT( hasCD(bool) ) );
connect( tracks, SIGNAL( ripTrack(Job *) ), ripper, SLOT( ripTrack(Job *)) );
connect( tracks, SIGNAL( hasTracks(bool) ), rip, SLOT( setEnabled(bool)) );
connect( tracks, SIGNAL( hasTracks(bool) ), actActionMenu, SLOT( setEnabled(bool)) );
connect( tracks, SIGNAL( hasTracks(bool) ), deselectAll, SLOT( setEnabled(bool)) );
connect( tracks, SIGNAL( hasTracks(bool) ), selectAll, SLOT( setEnabled(bool)) );
(void)new KAction(i18n("Remove &Completed Jobs"), 0, jobQue,
SLOT(clearDoneJobs()), actionCollection(), "clear_done_jobs" );
KAction *edit = new KAction(i18n("&Edit Album..."), 0, tracks,
SLOT(editInformation()), actionCollection(), "edit_cd");
connect(tracks, SIGNAL(hasCD(bool)), edit, SLOT(setEnabled(bool)));
edit->setEnabled( false );
(void)new KAction(i18n("Encode &File..."), 0, this,
SLOT(encodeFile()), actionCollection(), "encode_file");
KAction *cddb = new KAction(i18n("&CDDB Lookup"), 0, tracks,
SLOT(performCDDB()), actionCollection(), "cddb_now");
connect(tracks, SIGNAL(hasCD(bool)), cddb, SLOT(setEnabled(bool)));
cddb->setEnabled( false );
KStdAction::configureNotifications(this, SLOT(configureNotifications()),
actionCollection());
KStdAction::quit( this, SLOT(close()), actionCollection(), "quit" );
// Init statusbar
statusBar()->insertItem(i18n("No Audio CD detected"), 0 );
hasCD(tracks->hasCD());
setupGUI();
}
示例4: initMainWidget
void ActionManagerImpl::initMainWidget(MainWidget* mainWidget)
{
if (d->mainWidget)
return;
d->mainWidget = mainWidget;
KActionCollection* coll = actionCollection();
// Feed/Feed Group popup menu
KAction* action = coll->addAction("feed_homepage");
action->setText(i18n("&Open Homepage"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenHomepage()));
action->setShortcuts(KShortcut( "Ctrl+H" ));
action = coll->addAction("reload_all_tabs");
action->setIcon(KIcon("view-refresh"));
action->setText(i18n("Reload All Tabs"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotReloadAllTabs()));
action->setShortcuts(KShortcut( "Shift+F5" ));
action = coll->addAction("feed_add");
action->setIcon(KIcon("feed-subscribe"));
action->setText(i18n("&Add Feed..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedAdd()));
action->setShortcuts(KShortcut( "Insert" ));
action = coll->addAction("feed_add_group");
action->setIcon(KIcon("folder-new"));
action->setText(i18n("Ne&w Folder..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedAddGroup()));
action->setShortcuts(KShortcut( "Shift+Insert" ));
action = coll->addAction("feed_remove");
action->setIcon(KIcon("edit-delete"));
action->setText(i18n("&Delete Feed"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedRemove()));
action->setShortcuts(KShortcut( "Alt+Delete" ));
action = coll->addAction("feed_modify");
action->setIcon(KIcon("document-properties"));
action->setText(i18n("&Edit Feed..."));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFeedModify()));
action->setShortcuts(KShortcut( "F2" ));
// toolbar / View
action = coll->addAction("normal_view");
action->setIcon(KIcon("view-split-top-bottom"));
action->setText(i18n("&Normal View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotNormalView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+1" ));
action = coll->addAction("widescreen_view");
action->setIcon(KIcon("view-split-left-right"));
action->setText(i18n("&Widescreen View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotWidescreenView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+2" ));
action = coll->addAction("combined_view");
action->setIcon(KIcon("view-list-text"));
action->setText(i18n("C&ombined View"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotCombinedView()));
action->setShortcuts(KShortcut( "Ctrl+Shift+3" ));
// toolbar / feed menu
action = coll->addAction("feed_fetch");
action->setIcon(KIcon("go-down"));
action->setText(i18n("&Fetch Feed"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFetchCurrentFeed()));
action->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Reload));
action = coll->addAction("feed_fetch_all");
action->setIcon(KIcon("go-bottom"));
action->setText(i18n("Fe&tch All Feeds"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotFetchAllFeeds()));
action->setShortcuts(KShortcut( "Ctrl+L" ));
KAction *stopAction = coll->addAction("feed_stop");
stopAction->setIcon(KIcon("process-stop"));
stopAction->setText(i18n("C&ancel Feed Fetches"));
connect(stopAction, SIGNAL(triggered(bool)), Kernel::self()->fetchQueue(), SLOT(slotAbort()));
stopAction->setShortcut(QKeySequence(Qt::Key_Escape));
stopAction->setEnabled(false);
action = coll->addAction("feed_mark_all_as_read");
action->setIcon(KIcon("mail-mark-read"));
action->setText(i18n("&Mark Feed as Read"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotMarkAllRead()));
action->setShortcuts(KShortcut( "Ctrl+R" ));
action = coll->addAction("feed_mark_all_feeds_as_read");
action->setIcon(KIcon("mail-mark-read"));
action->setText(i18n("Ma&rk All Feeds as Read"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotMarkAllFeedsRead()));
action->setShortcuts(KShortcut( "Ctrl+Shift+R" ));
// Settings menu
KToggleAction *sqf = coll->add<KToggleAction>("show_quick_filter");
sqf->setText(i18n("Show Quick Filter"));
//.........这里部分代码省略.........