本文整理汇总了C++中KToggleAction::setChecked方法的典型用法代码示例。如果您正苦于以下问题:C++ KToggleAction::setChecked方法的具体用法?C++ KToggleAction::setChecked怎么用?C++ KToggleAction::setChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KToggleAction
的用法示例。
在下文中一共展示了KToggleAction::setChecked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: 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;
}
示例3: 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() );
}
}
}
示例4: slotContextMenuRequest
/**
* 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));
}
示例5: showPathContextMenu
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);
}
示例6: guiItem
KToggleAction *showStatusbar(const QObject *recvr, const char *slot, KActionCollection *parent, const char *_name)
{
KToggleAction *ret;
ret = new KToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent, _name ? _name : name(ShowStatusbar));
ret->setWhatsThis(
i18n("Show Statusbar<p>"
"Shows the statusbar, which is the bar at the bottom of the window used for status information."));
KGuiItem guiItem(i18n("Hide St&atusbar"), QString::null, QString::null,
i18n("Hide Statusbar<p>"
"Hides the statusbar, which is the bar at the bottom of the window used for status information."));
ret->setCheckedState(guiItem);
ret->setChecked(true);
return ret;
}
示例7: repopulateFOV
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) ) );
}
示例8: setupGUILayout
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();
}
示例9: KMdiMainFrm
KMDITest::KMDITest()
: KMdiMainFrm( 0, "KMDITest", KMdi::IDEAlMode ), m_childs( 0 )
{
setXMLFile("kmditestui.rc");
// Create some actions
KStdAction::openNew( this, SLOT( openNewWindow() ), actionCollection() );
KStdAction::close( this, SLOT( closeCurrent() ), actionCollection() );
KStdAction::quit( kapp, SLOT( quit() ), actionCollection() );
// Allow the user to change the MDI mode
KToggleAction *tl = new KRadioAction( i18n( "Top level mode" ), KShortcut(),
this, SLOT( switchToToplevelMode() ), actionCollection(), "toplevel" );
tl->setExclusiveGroup( "MDIMode" );
KToggleAction *cf = new KRadioAction( i18n( "Child frame mode" ), KShortcut(),
this, SLOT( switchToChildframeMode() ), actionCollection(), "childframe" );
cf->setExclusiveGroup( "MDIMode" );
KToggleAction *tp = new KRadioAction( i18n( "Tab page mode" ), KShortcut(),
this, SLOT( switchToTabPageMode() ), actionCollection(), "tabpage" );
tp->setExclusiveGroup( "MDIMode" );
KToggleAction *id = new KRadioAction( i18n( "IDEAl mode" ), KShortcut(),
this, SLOT( switchToIDEAlMode() ), actionCollection(), "ideal" );
id->setExclusiveGroup( "MDIMode" );
id->setChecked( true );
createGUI( 0 );
// When we change view, change the status bar text
connect( this, SIGNAL( viewActivated( KMdiChildView * ) ),
this, SLOT( currentChanged( KMdiChildView * ) ) );
// Create the status bar
statusBar()->message( i18n( "No view!" ) );
// Create the list of the opened windows
m_listBox = new KListBox( this );
m_listBox->setCaption( i18n( "Opened windows" ) );
addToolWindow( m_listBox, KDockWidget::DockLeft, getMainDockWidget() );
connect( m_listBox, SIGNAL( executed( QListBoxItem * ) ), this,
SLOT( listBoxExecuted( QListBoxItem * ) ) );
}
示例10: initMainWidget
//.........这里部分代码省略.........
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"));
connect(sqf, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotToggleShowQuickFilter()));
sqf->setChecked( Settings::showQuickFilter() );
action = coll->addAction("article_open" );
action->setIcon(KIcon("tab-new"));
action->setText(i18n("Open in Tab"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenSelectedArticles()));
action->setShortcuts(KShortcut( "Shift+Return" ));
action = coll->addAction("article_open_in_background" );
action->setIcon(KIcon("tab-new"));
action->setText(i18n("Open in Background Tab"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenSelectedArticlesInBackground()));
action->setShortcuts(KShortcut( "Return" ));
action = coll->addAction("article_open_external" );
action->setIcon(KIcon("window-new"));
action->setText(i18n("Open in External Browser"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotOpenSelectedArticlesInBrowser()));
action->setShortcuts(KShortcut( "Ctrl+Shift+Return" ));
action = coll->addAction("article_copy_link_address" );
action->setText(i18n("Copy Link Address"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotCopyLinkAddress()));
action = coll->addAction("go_prev_unread_article");
action->setIcon(KIcon("go-previous"));
action->setText(i18n("Pre&vious Unread Article"));
connect(action, SIGNAL(triggered(bool)), d->mainWidget, SLOT(slotPrevUnreadArticle()));
action->setShortcut(QKeySequence(Qt::Key_Minus));
action = coll->addAction("go_next_unread_article");
action->setIcon(KIcon("go-next"));
action->setText(i18n("Ne&xt Unread Article"));
示例11: infoPtr
KAction *create(StdAction id, const char *name, const QObject *recvr, const char *slot, KActionCollection *parent)
{
KAction *pAction = 0;
const KStdActionInfo *pInfo = infoPtr(id);
kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char *)0) << ", " << parent << ", " << name << " )"
<< endl; // ellis
if(pInfo)
{
QString sLabel, iconName = pInfo->psIconName;
switch(id)
{
case Back:
sLabel = i18n("go back", "&Back");
if(QApplication::reverseLayout())
iconName = "forward";
break;
case Forward:
sLabel = i18n("go forward", "&Forward");
if(QApplication::reverseLayout())
iconName = "back";
break;
case Home:
sLabel = i18n("beginning (of line)", "&Home");
break;
case Help:
sLabel = i18n("show help", "&Help");
break;
case AboutApp:
iconName = kapp->miniIconName();
case Preferences:
case HelpContents:
{
const KAboutData *aboutData = KGlobal::instance()->aboutData();
/* TODO KDE4
const KAboutData *aboutData;
if ( parent )
aboutData = parent->instance()->aboutData();
else
aboutData = KGlobal::instance()->aboutData();
*/
QString appName = (aboutData) ? aboutData->programName() : QString::fromLatin1(qApp->name());
sLabel = i18n(pInfo->psLabel).arg(appName);
}
break;
default:
sLabel = i18n(pInfo->psLabel);
}
if(QApplication::reverseLayout())
{
if(id == Prior)
iconName = "forward";
if(id == Next)
iconName = "back";
if(id == FirstPage)
iconName = "finish";
if(id == LastPage)
iconName = "start";
}
KShortcut cut = KStdAccel::shortcut(pInfo->idAccel);
switch(id)
{
case OpenRecent:
pAction = new KRecentFilesAction(sLabel, pInfo->psIconName, cut, recvr, slot, parent, (name) ? name : pInfo->psName);
break;
case ShowMenubar:
case ShowToolbar:
case ShowStatusbar:
{
KToggleAction *ret;
ret = new KToggleAction(sLabel, pInfo->psIconName, cut, recvr, slot, parent, (name) ? name : pInfo->psName);
ret->setChecked(true);
pAction = ret;
break;
}
case FullScreen:
{
KToggleFullScreenAction *ret;
ret = new KToggleFullScreenAction(cut, recvr, slot, parent, NULL, (name) ? name : pInfo->psName);
ret->setChecked(false);
pAction = ret;
break;
}
case PasteText:
{
KPasteTextAction *ret;
ret = new KPasteTextAction(sLabel, iconName, cut, recvr, slot, parent, (name) ? name : pInfo->psName);
pAction = ret;
break;
}
default:
pAction = new KAction(sLabel, iconName, cut, recvr, slot, parent, (name) ? name : pInfo->psName);
break;
}
}
return pAction;
}
示例12: initActions
void KMMainView::initActions()
{
KIconSelectAction *vact = new KIconSelectAction(i18n("&View"), 0, m_actions, "view_change");
QStringList iconlst;
iconlst << "view_icon"
<< "view_detailed"
<< "view_tree";
vact->setItems(QStringList::split(',', i18n("&Icons,&List,&Tree"), false), iconlst);
vact->setCurrentItem(0);
connect(vact, SIGNAL(activated(int)), SLOT(slotChangeView(int)));
KActionMenu *stateAct = new KActionMenu(i18n("Start/Stop Printer"), "kdeprint_printstate", m_actions, "printer_state_change");
stateAct->setDelayed(false);
stateAct->insert(
new KAction(i18n("&Start Printer"), "kdeprint_enableprinter", 0, this, SLOT(slotChangePrinterState()), m_actions, "printer_start"));
stateAct->insert(new KAction(i18n("Sto&p Printer"), "kdeprint_stopprinter", 0, this, SLOT(slotChangePrinterState()), m_actions, "printer_stop"));
stateAct = new KActionMenu(i18n("Enable/Disable Job Spooling"), "kdeprint_queuestate", m_actions, "printer_spool_change");
stateAct->setDelayed(false);
stateAct->insert(
new KAction(i18n("&Enable Job Spooling"), "kdeprint_enableprinter", 0, this, SLOT(slotChangePrinterState()), m_actions, "printer_enable"));
stateAct->insert(
new KAction(i18n("&Disable Job Spooling"), "kdeprint_stopprinter", 0, this, SLOT(slotChangePrinterState()), m_actions, "printer_disable"));
new KAction(i18n("&Remove"), "edittrash", 0, this, SLOT(slotRemove()), m_actions, "printer_remove");
new KAction(i18n("&Configure..."), "configure", 0, this, SLOT(slotConfigure()), m_actions, "printer_configure");
new KAction(i18n("Add &Printer/Class..."), "kdeprint_addprinter", 0, this, SLOT(slotAdd()), m_actions, "printer_add");
new KAction(i18n("Add &Special (pseudo) Printer..."), "kdeprint_addpseudo", 0, this, SLOT(slotAddSpecial()), m_actions, "printer_add_special");
new KAction(i18n("Set as &Local Default"), "kdeprint_defaulthard", 0, this, SLOT(slotHardDefault()), m_actions, "printer_hard_default");
new KAction(i18n("Set as &User Default"), "kdeprint_defaultsoft", 0, this, SLOT(slotSoftDefault()), m_actions, "printer_soft_default");
new KAction(i18n("&Test Printer..."), "kdeprint_testprinter", 0, this, SLOT(slotTest()), m_actions, "printer_test");
new KAction(i18n("Configure &Manager..."), "kdeprint_configmgr", 0, this, SLOT(slotManagerConfigure()), m_actions, "manager_configure");
new KAction(i18n("Initialize Manager/&View"), "reload", 0, this, SLOT(slotInit()), m_actions, "view_refresh");
KIconSelectAction *dact = new KIconSelectAction(i18n("&Orientation"), 0, m_actions, "orientation_change");
iconlst.clear();
iconlst << "view_top_bottom"
<< "view_left_right";
dact->setItems(QStringList::split(',', i18n("&Vertical,&Horizontal"), false), iconlst);
dact->setCurrentItem(0);
connect(dact, SIGNAL(activated(int)), SLOT(slotChangeDirection(int)));
new KAction(i18n("R&estart Server"), "kdeprint_restartsrv", 0, this, SLOT(slotServerRestart()), m_actions, "server_restart");
new KAction(i18n("Configure &Server..."), "kdeprint_configsrv", 0, this, SLOT(slotServerConfigure()), m_actions, "server_configure");
KToggleAction *tact = new KToggleAction(i18n("Show &Toolbar"), 0, m_actions, "view_toolbar");
tact->setCheckedState(i18n("Hide &Toolbar"));
connect(tact, SIGNAL(toggled(bool)), SLOT(slotToggleToolBar(bool)));
tact = new KToggleAction(i18n("Show Me&nu Toolbar"), 0, m_actions, "view_menubar");
tact->setCheckedState(i18n("Hide Me&nu Toolbar"));
connect(tact, SIGNAL(toggled(bool)), SLOT(slotToggleMenuBar(bool)));
tact = new KToggleAction(i18n("Show Pr&inter Details"), "kdeprint_printer_infos", 0, m_actions, "view_printerinfos");
tact->setCheckedState(KGuiItem(i18n("Hide Pr&inter Details"), "kdeprint_printer_infos"));
tact->setChecked(true);
connect(tact, SIGNAL(toggled(bool)), SLOT(slotShowPrinterInfos(bool)));
tact = new KToggleAction(i18n("Toggle Printer &Filtering"), "filter", 0, m_actions, "view_pfilter");
tact->setChecked(KMManager::self()->isFilterEnabled());
connect(tact, SIGNAL(toggled(bool)), SLOT(slotToggleFilter(bool)));
new KAction(i18n("%1 &Handbook").arg("KDEPrint"), "contents", 0, this, SLOT(slotHelp()), m_actions, "invoke_help");
new KAction(i18n("%1 &Web Site").arg("KDEPrint"), "network", 0, this, SLOT(slotHelp()), m_actions, "invoke_web");
KActionMenu *mact = new KActionMenu(i18n("Pri&nter Tools"), "package_utilities", m_actions, "printer_tool");
mact->setDelayed(false);
connect(mact->popupMenu(), SIGNAL(activated(int)), SLOT(slotToolSelected(int)));
QStringList files = KGlobal::dirs()->findAllResources("data", "kdeprint/tools/*.desktop");
for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
{
KSimpleConfig conf(*it);
conf.setGroup("Desktop Entry");
mact->popupMenu()->insertItem(conf.readEntry("Name", "Unnamed"), mact->popupMenu()->count());
m_toollist << conf.readEntry("X-KDE-Library");
}
// add actions to the toolbar
m_actions->action("printer_add")->plug(m_toolbar);
m_actions->action("printer_add_special")->plug(m_toolbar);
m_toolbar->insertLineSeparator();
m_actions->action("printer_state_change")->plug(m_toolbar);
m_actions->action("printer_spool_change")->plug(m_toolbar);
m_toolbar->insertSeparator();
m_actions->action("printer_hard_default")->plug(m_toolbar);
m_actions->action("printer_soft_default")->plug(m_toolbar);
m_actions->action("printer_remove")->plug(m_toolbar);
m_toolbar->insertSeparator();
m_actions->action("printer_configure")->plug(m_toolbar);
m_actions->action("printer_test")->plug(m_toolbar);
m_actions->action("printer_tool")->plug(m_toolbar);
m_pactionsindex = m_toolbar->insertSeparator();
m_toolbar->insertLineSeparator();
m_actions->action("server_restart")->plug(m_toolbar);
m_actions->action("server_configure")->plug(m_toolbar);
m_toolbar->insertLineSeparator();
m_actions->action("manager_configure")->plug(m_toolbar);
m_actions->action("view_refresh")->plug(m_toolbar);
m_toolbar->insertLineSeparator();
m_actions->action("view_printerinfos")->plug(m_toolbar);
m_actions->action("view_change")->plug(m_toolbar);
m_actions->action("orientation_change")->plug(m_toolbar);
//.........这里部分代码省略.........
示例13: main
int main(int argc, char *argv[])
{
KCmdLineOptions options;
options.add("+file", ki18n("URL to open"));
KCmdLineArgs::init(argc, argv, "testkhtml", 0, ki18n("Testkhtml"),
"1.0", ki18n("a basic web browser using the KHTML library"));
KCmdLineArgs::addCmdLineOptions(options);
KApplication a;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs( );
if ( args->count() == 0 ) {
KCmdLineArgs::usage();
::exit( 1 );
}
new KHTMLGlobal;
KXmlGuiWindow *toplevel = new KXmlGuiWindow();
KHTMLPart *doc = new KHTMLPart( toplevel, toplevel, KHTMLPart::BrowserViewGUI );
Dummy *dummy = new Dummy( doc );
QObject::connect( doc->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)),
dummy, SLOT(slotOpenURL(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) );
QObject::connect( doc, SIGNAL(completed()), dummy, SLOT(handleDone()) );
if (args->url(0).url().right(4).toLower() == ".xml") {
KParts::OpenUrlArguments args(doc->arguments());
args.setMimeType("text/xml");
doc->setArguments(args);
}
doc->openUrl( args->url(0) );
toplevel->setCentralWidget( doc->widget() );
toplevel->resize( 800, 600);
QDomDocument d = doc->domDocument();
QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement e = d.createElement( "action" );
e.setAttribute( "name", "debugRenderTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDOMTree" );
viewMenu.appendChild( e );
e = d.createElement( "action" );
e.setAttribute( "name", "debugDoBenchmark" );
viewMenu.appendChild( e );
QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement();
e = d.createElement( "action" );
e.setAttribute( "name", "editable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "navigable" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "reload" );
toolBar.insertBefore( e, toolBar.firstChild() );
e = d.createElement( "action" );
e.setAttribute( "name", "print" );
toolBar.insertBefore( e, toolBar.firstChild() );
KAction *action = new KAction(KIcon("view-refresh"), "Reload", doc );
doc->actionCollection()->addAction( "reload", action );
QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload()));
action->setShortcut(Qt::Key_F5);
KAction *bench = new KAction( KIcon(), "Benchmark...", doc );
doc->actionCollection()->addAction( "debugDoBenchmark", bench );
QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark()));
KAction *kprint = new KAction(KIcon("document-print"), "Print", doc );
doc->actionCollection()->addAction( "print", kprint );
QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", doc );
doc->actionCollection()->addAction( "navigable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isCaretMode());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool)));
ta = new KToggleAction( KIcon("document-properties"), "Editable", doc );
doc->actionCollection()->addAction( "editable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(doc->isEditable());
QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool)));
toplevel->guiFactory()->addClient( doc );
doc->setJScriptEnabled(true);
doc->setJavaEnabled(true);
doc->setPluginsEnabled( true );
doc->setURLCursor(QCursor(Qt::PointingHandCursor));
a.setTopWidget(doc->widget());
QWidget::connect(doc, SIGNAL(setWindowCaption(QString)),
doc->widget()->topLevelWidget(), SLOT(setCaption(QString)));
doc->widget()->show();
toplevel->show();
doc->view()->viewport()->show();
doc->view()->widget()->show();
//.........这里部分代码省略.........
示例14: setupActions
void TestKHTML::setupActions()
{
QDomDocument document = m_part->domDocument();
QDomElement fileMenu = document.documentElement().firstChild().childNodes().item( 0 ).toElement();
QDomElement quitElement = document.createElement("action");
quitElement.setAttribute("name",
KStandardAction::name(KStandardAction::Quit));
fileMenu.appendChild(quitElement);
QDomElement viewMenu = document.documentElement().firstChild().childNodes().item( 2 ).toElement();
QDomElement element = document.createElement("action");
element.setAttribute("name", "debugRenderTree");
viewMenu.appendChild(element);
element = document.createElement("action");
element.setAttribute("name", "debugDOMTree");
viewMenu.appendChild(element);
QDomElement toolBar = document.documentElement().firstChild().nextSibling().toElement();
element = document.createElement("action");
element.setAttribute("name", "editable");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "navigable");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "reload");
toolBar.insertBefore(element, toolBar.firstChild());
element = document.createElement("action");
element.setAttribute("name", "print");
toolBar.insertBefore(element, toolBar.firstChild());
KAction *action = new KAction(KIcon("view-refresh"), "Reload", this );
m_part->actionCollection()->addAction( "reload", action );
connect(action, SIGNAL(triggered(bool)), this, SLOT(reload()));
action->setShortcut(Qt::Key_F5);
KAction *kprint = new KAction(KIcon("document-print"), "Print", this );
m_part->actionCollection()->addAction( "print", kprint );
connect(kprint, SIGNAL(triggered(bool)), m_part->browserExtension(), SLOT(print()));
kprint->setEnabled(true);
KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", this );
actionCollection()->addAction( "navigable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(m_part->isCaretMode());
connect(ta, SIGNAL(toggled(bool)), this, SLOT(toggleNavigable(bool)));
ta = new KToggleAction( KIcon("document-properties"), "Editable", this );
actionCollection()->addAction( "editable", ta );
ta->setShortcuts( KShortcut() );
ta->setChecked(m_part->isEditable());
connect(ta, SIGNAL(toggled(bool)), this, SLOT(toggleEditable(bool)));
KStandardAction::quit( kapp, SLOT(quit()), m_part->actionCollection() );
guiFactory()->addClient(m_part);
}
示例15: initActions
void KPrView::initActions()
{
//setComponentData(KPrFactory::componentData());
if (!koDocument()->isReadWrite() )
setXMLFile( "stage_readonly.rc" );
else
setXMLFile( "stage.rc" );
#ifdef CAN_USE_QTWEBKIT
// do special stage stuff here
m_actionExportHtml = new QAction(i18n("Export as HTML..."), this);
actionCollection()->addAction("file_export_html", m_actionExportHtml);
connect(m_actionExportHtml, SIGNAL(triggered()), this, SLOT(exportToHtml()));
#endif
m_actionViewModeNormal = new QAction(m_normalMode->name(), this);
m_actionViewModeNormal->setCheckable(true);
m_actionViewModeNormal->setChecked(true);
m_actionViewModeNormal->setShortcut(QKeySequence("CTRL+F5"));
actionCollection()->addAction("view_normal", m_actionViewModeNormal);
connect(m_actionViewModeNormal, SIGNAL(triggered()), this, SLOT(showNormal()));
m_actionViewModeNotes = new QAction(m_notesMode->name(), this);
m_actionViewModeNotes->setCheckable(true);
m_actionViewModeNotes->setShortcut(QKeySequence("CTRL+F6"));
actionCollection()->addAction("view_notes", m_actionViewModeNotes);
connect(m_actionViewModeNotes, SIGNAL(triggered()), this, SLOT(showNotes()));
m_actionViewModeSlidesSorter = new QAction(m_slidesSorterMode->name(), this);
m_actionViewModeSlidesSorter->setCheckable(true);
m_actionViewModeSlidesSorter->setShortcut(QKeySequence("CTRL+F7"));
actionCollection()->addAction("view_slides_sorter", m_actionViewModeSlidesSorter);
connect(m_actionViewModeSlidesSorter, SIGNAL(triggered()), this, SLOT(showSlidesSorter()));
if ( QAction *action = actionCollection()->action("view_masterpages") )
action->setShortcut(QKeySequence("CTRL+F8"));
m_actionInsertPictures = new QAction(i18n("Insert Pictures as Slides..."), this);
actionCollection()->addAction("insert_pictures", m_actionInsertPictures);
connect(m_actionInsertPictures, SIGNAL(activated()), this, SLOT(insertPictures()));
QActionGroup *viewModesGroup = new QActionGroup(this);
viewModesGroup->addAction(m_actionViewModeNormal);
viewModesGroup->addAction(m_actionViewModeNotes);
viewModesGroup->addAction(m_actionViewModeSlidesSorter);
m_actionCreateAnimation = new QAction( i18n( "Create Appear Animation" ), this );
actionCollection()->addAction( "edit_createanimation", m_actionCreateAnimation );
connect( m_actionCreateAnimation, SIGNAL(activated()), this, SLOT(createAnimation()) );
m_actionEditCustomSlideShows = new QAction( i18n( "Edit Custom Slide Shows..." ), this );
actionCollection()->addAction( "edit_customslideshows", m_actionEditCustomSlideShows );
connect( m_actionEditCustomSlideShows, SIGNAL(activated()), this, SLOT(editCustomSlideShows()) );
m_actionStartPresentation = new KActionMenu(koIcon("view-presentation"), i18n("Start Presentation"), this);
actionCollection()->addAction( "slideshow_start", m_actionStartPresentation );
connect( m_actionStartPresentation, SIGNAL(activated()), this, SLOT(startPresentation()) );
QAction* action = new QAction( i18n( "From Current Slide" ), this );
action->setShortcut(QKeySequence("Shift+F5"));
m_actionStartPresentation->addAction( action );
connect( action, SIGNAL(activated()), this, SLOT(startPresentation()) );
action = new QAction( i18n( "From First Slide" ), this );
action->setShortcut(QKeySequence("F5"));
m_actionStartPresentation->addAction( action );
connect( action, SIGNAL(activated()), this, SLOT(startPresentationFromBeginning()) );
KToggleAction *showStatusbarAction = new KToggleAction(i18n("Show Status Bar"), this);
showStatusbarAction->setCheckedState(KGuiItem(i18n("Hide Status Bar")));
showStatusbarAction->setToolTip(i18n("Shows or hides the status bar"));
actionCollection()->addAction("showStatusBar", showStatusbarAction);
connect(showStatusbarAction, SIGNAL(toggled(bool)), this, SLOT(showStatusBar(bool)));
//Update state of status bar action
if (showStatusbarAction && statusBar()){
showStatusbarAction->setChecked(! statusBar()->isHidden());
}
action = new QAction( i18n( "Configure Slide Show..." ), this );
actionCollection()->addAction( "slideshow_configure", action );
connect( action, SIGNAL(activated()), this, SLOT(configureSlideShow()) );
action = new QAction( i18n( "Configure Presenter View..." ), this );
actionCollection()->addAction( "slideshow_presenterview", action );
connect( action, SIGNAL(activated()), this, SLOT(configurePresenterView()) );
m_actionDrawOnPresentation = new QAction( i18n( "Draw on the presentation..." ), this );
m_actionDrawOnPresentation->setShortcut(Qt::Key_P);
m_actionDrawOnPresentation->setShortcutContext(Qt::ApplicationShortcut);
actionCollection()->addAction( "draw_on_presentation", m_actionDrawOnPresentation );
connect( m_actionDrawOnPresentation, SIGNAL(activated()), this, SLOT(drawOnPresentation()) );
m_actionDrawOnPresentation->setEnabled(false);
m_actionHighlightPresentation = new QAction( i18n( "Highlight the presentation..." ), this );
m_actionHighlightPresentation->setShortcut(Qt::Key_H);
m_actionHighlightPresentation->setShortcutContext(Qt::ApplicationShortcut);
actionCollection()->addAction( "highlight_presentation", m_actionHighlightPresentation );
connect( m_actionHighlightPresentation, SIGNAL(activated()), this, SLOT(highlightPresentation()) );
m_actionHighlightPresentation->setEnabled(false);
m_actionBlackPresentation = new QAction( i18n( "Blackscreen on the presentation..." ), this );
//.........这里部分代码省略.........