本文整理汇总了C++中KToggleAction类的典型用法代码示例。如果您正苦于以下问题:C++ KToggleAction类的具体用法?C++ KToggleAction怎么用?C++ KToggleAction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KToggleAction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: actionCollection
void
KMixDockWidget::contextMenuAboutToShow( KPopupMenu* /* menu */ )
{
KAction* showAction = actionCollection()->action("minimizeRestore");
if ( parentWidget() && showAction )
{
if ( parentWidget()->isVisible() )
{
showAction->setText( i18n("Hide Mixer Window") );
}
else
{
showAction->setText( i18n("Show Mixer Window") );
}
}
// Enable/Disable "Muted" menu item
MixDevice *md = 0;
if ( _dockAreaPopup != 0 )
{
md = _dockAreaPopup->dockDevice();
KToggleAction *dockMuteAction = static_cast<KToggleAction*>(actionCollection()->action("dock_mute"));
//kdDebug(67100) << "---> md=" << md << "dockMuteAction=" << dockMuteAction << "isMuted=" << md->isMuted() << endl;
if ( md != 0 && dockMuteAction != 0 ) {
dockMuteAction->setChecked( md->isMuted() );
}
}
}
示例2: KMainWindow
MyMainWindow::MyMainWindow() : KMainWindow(0)
{
text = new QLabel(i18n("<h1>Hello, World!</h1>"), this);
setCentralWidget(text);
QPopupMenu *filePopup = new QPopupMenu(this);
KAction *quitAction = KStdAction::quit(this, SLOT(fileQuit()), actionCollection());
clearAction = new KAction(i18n("&Clear"), "stop", Qt::CTRL + Qt::Key_X, this, SLOT(fileClear()), actionCollection(), "file_clear");
KToggleAction *toolbarAction = new KToggleAction(i18n("Show &Toolbar"), 0, actionCollection(), "settings_show_toolbar");
toolbarAction->setChecked(true);
connect(toolbarAction, SIGNAL(toggled(bool)), this, SLOT(toggleToolBar(bool)));
QPopupMenu *settingsMenu = new QPopupMenu();
toolbarAction->plug(settingsMenu);
clearAction->plug(filePopup);
clearAction->plug(toolBar());
quitAction->plug(filePopup);
quitAction->plug(toolBar());
menuBar()->insertItem(i18n("&File"), filePopup);
menuBar()->insertSeparator();
menuBar()->insertItem("&Settings", settingsMenu);
menuBar()->insertSeparator();
menuBar()->insertItem(i18n("&Help"), helpMenu());
}
示例3: KToggleAction
// obsolete
KToggleAction *showToolbar(const QObject *recvr, const char *slot, KActionCollection *parent, const char *_name)
{
KToggleAction *ret;
ret = new KToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent, _name ? _name : name(ShowToolbar));
ret->setChecked(true);
return ret;
}
示例4: QObject
ToggleViewGUIClient::ToggleViewGUIClient( KonqMainWindow *mainWindow )
: QObject( mainWindow )
{
m_mainWindow = mainWindow;
KService::List offers = KServiceTypeTrader::self()->query( "Browser/View" );
KService::List::Iterator it = offers.begin();
while ( it != offers.end() )
{
QVariant prop = (*it)->property( "X-KDE-BrowserView-Toggable" );
QVariant orientation = (*it)->property( "X-KDE-BrowserView-ToggableView-Orientation" );
if ( !prop.isValid() || !prop.toBool() ||
!orientation.isValid() || orientation.toString().isEmpty() )
{
offers.erase( it );
it = offers.begin();
}
else
++it;
}
m_empty = ( offers.count() == 0 );
if ( m_empty )
return;
KService::List::ConstIterator cIt = offers.constBegin();
KService::List::ConstIterator cEnd = offers.constEnd();
for (; cIt != cEnd; ++cIt )
{
QString description = i18n( "Show %1" , (*cIt)->name() );
QString name = (*cIt)->desktopEntryName();
//kDebug() << "ToggleViewGUIClient: name=" << name;
KToggleAction *action = new KToggleAction( description, this );
mainWindow->actionCollection()->addAction( name.toLatin1(), action );
// HACK
if ( (*cIt)->icon() != "unknown" )
action->setIcon( KIcon((*cIt)->icon()) );
connect( action, SIGNAL(toggled(bool)),
this, SLOT(slotToggleView(bool)) );
m_actions.insert( name, action );
QVariant orientation = (*cIt)->property( "X-KDE-BrowserView-ToggableView-Orientation" );
bool horizontal = orientation.toString().toLower() == "horizontal";
m_mapOrientation.insert( name, horizontal );
}
connect( m_mainWindow, SIGNAL(viewAdded(KonqView*)),
this, SLOT(slotViewAdded(KonqView*)) );
connect( m_mainWindow, SIGNAL(viewRemoved(KonqView*)),
this, SLOT(slotViewRemoved(KonqView*)) );
}
示例5: enableToolbar
void KMMainView::enableToolbar(bool on)
{
KToggleAction *act = (KToggleAction *)m_actions->action("view_toolbar");
m_toolbar->setEnabled(on);
act->setEnabled(on);
if(on && act->isChecked())
m_toolbar->show();
else
m_toolbar->hide();
}
示例6: KToggleAction
/**
* Display a `custom context menu' to show hidden files & folder (or not). The last
* setting is saved in the global config file. This override the default context menu
* provided by KFileTreeView
*/
void FileView::slotContextMenuRequest(const QPoint& pt)
{
QMenu menu;
KToggleAction *showHiddenAction = new KToggleAction(i18n("Show Hidden Folders"), &menu);
showHiddenAction->setChecked(Config().getShowHiddenFiles());
connect(showHiddenAction, SIGNAL(toggled(bool)),
this, SLOT(slotShowHiddenFiles(bool)));
menu.addAction(showHiddenAction);
menu.exec(m_pFileTree->mapToGlobal(pt));
}
示例7: KToggleAction
void MainWindow::addActionCloneToCollection(const QString &actionName, QAction *action)
{
// XXX This is a dirty hack to avoid the warning "Attempt to use QAction with KXMLGUIFactory"
KToggleAction *actionClone = new KToggleAction(this);
actionCollection()->addAction(actionName, actionClone);
actionClone->setText(action->text());
actionClone->setIcon(action->icon());
connect(action, SIGNAL(toggled(bool)), actionClone, SLOT(setChecked(bool)));
connect(actionClone, SIGNAL(triggered()), action, SLOT(trigger()));
}
示例8: qDeleteAll
void KStars::repopulateFOV() {
// Read list of all FOVs
qDeleteAll( data()->availFOVs );
data()->availFOVs = FOV::readFOVs();
data()->syncFOV();
// Iterate through FOVs
fovActionMenu->menu()->clear();
foreach(FOV* fov, data()->availFOVs) {
KToggleAction *kta = actionCollection()->add<KToggleAction>( fov->name() );
kta->setText( fov->name() );
if( Options::fOVNames().contains( fov->name() ) ) {
kta->setChecked(true);
}
fovActionMenu->addAction( kta );
connect( kta, SIGNAL( toggled( bool ) ), this, SLOT( slotTargetSymbol(bool) ) );
}
示例9: SLOT
void SayayinShell::setupActions()
{
KStandardAction::openNew(this, SLOT(fileNew()), actionCollection());
KStandardAction::open(this, SLOT(fileOpen()), actionCollection());
KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection());
KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
KToggleAction* toggleMenu = KStandardAction::showMenubar(this, SLOT(toggleMenu()), actionCollection());
toggleMenu->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_M));
createStandardStatusBarAction();
setStandardToolBarMenuEnabled(true);
//KStandardAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
//KStandardAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
}
示例10: SLOT
void KBlocksWin::setupGUILayout()
{
QAction *action;
action = KStandardGameAction::gameNew(this, SLOT(singleGame()), actionCollection());
action->setText(i18n("Single Game"));
actionCollection()->addAction(QStringLiteral("newGame"), action);
action = new QAction(this);
action->setText(i18n("Human vs AI"));
actionCollection()->addAction(QStringLiteral("pve_step"), action);
connect(action, &QAction::triggered, this, &KBlocksWin::pveStepGame);
m_pauseAction = KStandardGameAction::pause(this, SLOT(pauseGame()), actionCollection());
actionCollection()->addAction(QStringLiteral("pauseGame"), m_pauseAction);
m_pauseAction->setEnabled(false);
action = KStandardGameAction::highscores(this, SLOT(showHighscore()), actionCollection());
actionCollection()->addAction(QStringLiteral("showHighscores"), action);
action = KStandardGameAction::quit(this, SLOT(close()), actionCollection());
actionCollection()->addAction(QStringLiteral("quit"), action);
KStandardAction::preferences(this, SLOT(configureSettings()), actionCollection());
KToggleAction *soundAction = new KToggleAction(i18n("&Play sounds"), this);
soundAction->setChecked(Settings::sounds());
actionCollection()->addAction(QStringLiteral("sounds"), soundAction);
connect(soundAction, &KToggleAction::triggered, this, &KBlocksWin::setSoundsEnabled);
// TODO
mScore = new QLabel(i18n("Points: 0 - Lines: 0 - Level: 0"));
statusBar()->addPermanentWidget(mScore);
connect(mpGameScene, &KBlocksScene::scoreChanged, this, &KBlocksWin::onScoreChanged);
connect(mpGameScene, &KBlocksScene::isHighscore, this, &KBlocksWin::onIsHighscore);
Kg::difficulty()->addStandardLevelRange(
KgDifficultyLevel::Easy, KgDifficultyLevel::Hard
);
KgDifficultyGUI::init(this);
connect(Kg::difficulty(), &KgDifficulty::currentLevelChanged, this, &KBlocksWin::levelChanged);
setupGUI();
}
示例11: QString
void GUIClient::registerToolView (ToolView *tv)
{
QString aname = QString("kate_mdi_toolview_") + tv->id;
// try to read the action shortcut
KShortcut sc;
KSharedConfig::Ptr cfg = KGlobal::config();
sc = KShortcut( cfg->group("Shortcuts").readEntry( aname, QString() ) );
KToggleAction *a = new ToggleToolViewAction(i18n("Show %1", tv->text), tv, this );
a->setShortcut(sc, KAction::ActiveShortcut); // no DefaultShortcut! see bug #144945
actionCollection()->addAction( aname.toLatin1(), a );
m_toolViewActions.append(a);
m_toolMenu->addAction(a);
m_toolToAction.insert (tv, a);
updateActions();
}
示例12: KToggleAction
KToggleAction* K3b::createToggleAction( QObject* parent,
const QString& text, const QString& icon, const
QKeySequence& shortcut, QObject* receiver, const char* slot,
KActionCollection* actionCollection,
const QString& actionName )
{
KToggleAction* action = new KToggleAction( parent );
action->setText( text );
if( !icon.isEmpty() ) {
action->setIcon( QIcon::fromTheme( icon ) );
}
action->setShortcut( shortcut );
if( receiver ) {
QObject::connect( action, SIGNAL(triggered(bool)),
receiver, slot );
}
if( actionCollection ) {
actionCollection->addAction( actionName, action );
}
return action;
}
示例13: contextMenu
/**
* Creates the right-click menu
*/
void KMixDockWidget::createMenuActions()
{
QMenu *menu = contextMenu();
if (!menu)
return; // We do not use a menu
shared_ptr<MixDevice> md = Mixer::getGlobalMasterMD();
if ( md.get() != 0 && md->hasMuteSwitch() ) {
// Put "Mute" selector in context menu
#ifdef X_KMIX_KF5_BUILD
KToggleAction *action = new KToggleAction(i18n("M&ute"), this);
action->setData("dock_mute");
addAction("dock_mute", action);
#else
KToggleAction *action = actionCollection()->add<KToggleAction>( "dock_mute" );
action->setText( i18n("M&ute") );
#endif
updateDockMuteAction(action);
connect(action, SIGNAL(triggered(bool)), SLOT(dockMute()));
menu->addAction( action );
}
// Put "Select Master Channel" dialog in context menu
#ifdef X_KMIX_KF5_BUILD
QAction *action = new QAction(i18n("Select Master Channel..."), this);
action->setData("select_master");
addAction("select_master", action);
#else
QAction *action = actionCollection()->addAction( "select_master" );
action->setText( i18n("Select Master Channel...") );
#endif
action->setEnabled(Mixer::getGlobalMasterMixer() != 0);
connect(action, SIGNAL(triggered(bool)), _kmixMainWindow, SLOT(slotSelectMaster()));
menu->addAction( action );
//Context menu entry to access phonon settings
menu->addAction(_kmixMainWindow->actionCollection()->action("launch_kdesoundsetup"));
}
示例14: getView
void CMapWidget::showPathContextMenu(void)
{
CMapPath *path = (CMapPath *) getView()->getSelectedElement();
bool twoWay = path->getOpsitePath();
KActionCollection *acol = getView()->actionCollection();
KToggleAction *pathTwoWay = (KToggleAction *)acol->action("pathTwoWay");
KToggleAction *pathOneWay = (KToggleAction *)acol->action("pathOneWay");
QAction *pathEditBends = acol->action("pathEditBends");
QAction *pathDelBend = acol->action("pathDelBend");
QAction *pathAddBend = acol->action("pathAddBend");
pathTwoWay->setChecked(twoWay);
pathOneWay->setChecked(!twoWay);
CMapView *view = (CMapView *) viewWidget;
pathDelBend->setEnabled(path->mouseInPathSeg(selectedPos,view->getCurrentlyViewedZone())!=-1);
pathEditBends->setEnabled(path->getBendCount() > 0);
pathAddBend->setEnabled(path->getSrcRoom()->getZone()==path->getDestRoom()->getZone());
showContextMenu (path_menu);
}
示例15: playerConfig
void JuK::saveConfig()
{
// player settings
KConfigGroup playerConfig(KGlobal::config(), "Player");
if (m_sliderAction->volumeSlider())
{
playerConfig.writeEntry("Volume", m_sliderAction->volumeSlider()->volume());
}
playerConfig.writeEntry("RandomPlay", m_randomPlayAction->isChecked());
KToggleAction *a = ActionCollection::action<KToggleAction>("loopPlaylist");
playerConfig.writeEntry("LoopPlaylist", a->isChecked());
a = ActionCollection::action<KToggleAction>("albumRandomPlay");
if(a->isChecked())
playerConfig.writeEntry("RandomPlay", "AlbumRandomPlay");
else if(m_randomPlayAction->isChecked())
playerConfig.writeEntry("RandomPlay", "Normal");
else
playerConfig.writeEntry("RandomPlay", "Disabled");
// general settings
KConfigGroup settingsConfig(KGlobal::config(), "Settings");
settingsConfig.writeEntry("ShowSplashScreen", m_toggleSplashAction->isChecked());
settingsConfig.writeEntry("StartDocked", m_startDocked);
settingsConfig.writeEntry("DockInSystemTray", m_toggleSystemTrayAction->isChecked());
settingsConfig.writeEntry("DockOnClose", m_toggleDockOnCloseAction->isChecked());
settingsConfig.writeEntry("TrackPopup", m_togglePopupsAction->isChecked());
if(m_outputSelectAction)
settingsConfig.writeEntry("MediaSystem", m_outputSelectAction->currentItem());
KGlobal::config()->sync();
}