void ActionManagerImpl::initTabWidget(TabWidget* tabWidget)
{
    if (d->tabWidget)
        return;
    else
        d->tabWidget = tabWidget;

    KActionCollection *coll = actionCollection();

    KAction *action = coll->addAction("select_next_tab");
    action->setText(i18n("Select Next Tab"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotNextTab()));
    action->setShortcuts(KShortcut( "Ctrl+Period" ));

    action = coll->addAction("select_previous_tab");
    action->setText(i18n("Select Previous Tab"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotPreviousTab()));
    action->setShortcuts(KShortcut( "Ctrl+Comma" ));

    action = coll->addAction("tab_detach");
    action->setIcon(KIcon("tab-detach"));
    action->setText(i18n("Detach Tab"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotDetachTab()));
    action->setShortcut(QKeySequence(Qt::CTRL+Qt::SHIFT+Qt::Key_B));

    action = coll->addAction("tab_copylinkaddress");
    action->setText(i18n("Copy Link Address"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotCopyLinkAddress()));

    action = coll->addAction("tab_remove");
    action->setIcon(KIcon("tab-close"));
    action->setText(i18n("Close Tab"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotCloseTab()));
    action->setShortcuts(KStandardShortcut::close());

    action = coll->addAction("inc_font_sizes");
    action->setIcon(KIcon("format-font-size-more"));
    action->setText(i18n("Enlarge Font"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotFrameZoomIn()));
    action->setShortcut( QKeySequence::ZoomIn );

    action = coll->addAction("dec_font_sizes");
    action->setIcon(KIcon("format-font-size-less"));
    action->setText(i18n("Shrink Font"));
    connect(action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotFrameZoomOut()));
    action->setShortcut( QKeySequence::ZoomOut );

    QString actionname;
    for (int i=1;i<10;i++) {
      actionname.sprintf("activate_tab_%02d", i);
      action = new KAction( i18n("Activate Tab %1", i),this );
      action->setShortcut( QKeySequence( QString::fromLatin1( "Alt+%1" ).arg( i ) ) );
      coll->addAction( actionname, action );
      connect( action, SIGNAL(triggered(bool)), d->tabWidget, SLOT(slotActivateTab()) );
    }


}
Beispiel #2
0
void MainWindow::setupActions()
{
	KStandardAction::quit(KApplication::instance(), SLOT(quit()), actionCollection());

// commit
	KAction *commitAction = actionCollection()->addAction("commit", ui->stageWidget, SLOT(commit()));
	commitAction->setText(i18n("Commit"));
	commitAction->setIcon(KIcon("git-commit"));
	commitAction->setShortcut(Qt::CTRL + Qt::Key_Return);

	KAction *stageFileAction = actionCollection()->addAction("file_stage", ui->stageWidget, SLOT(stageFile()));
	stageFileAction->setText(i18n("Stage File to Commit"));
	stageFileAction->setIcon(KIcon("git-file-stage"));
	stageFileAction->setShortcut(Qt::CTRL + Qt::Key_S);

	KAction *unstageFileAction = actionCollection()->addAction("file_unstage", ui->stageWidget, SLOT(unstageFile()));
	unstageFileAction->setText(i18n("Unstage File from Commit"));
	unstageFileAction->setIcon(KIcon("git-file-unstage"));
	unstageFileAction->setShortcut(Qt::CTRL + Qt::Key_U);

// repository
	KAction *openRepoAction = actionCollection()->addAction("repository_open", this, SLOT(open()));
	openRepoAction->setText(i18n("Open repository"));
	openRepoAction->setIcon(KIcon("git-repo-open"));
	openRepoAction->setShortcut(Qt::CTRL + Qt::Key_O);

	KAction *reloadRepoAction = actionCollection()->addAction("repository_reload", this, SLOT(reload()));
	reloadRepoAction->setText(i18n("Reload repository"));
	reloadRepoAction->setIcon(KIcon("git-repo-reload"));
	reloadRepoAction->setShortcut(Qt::Key_F5);
}
void ActionManagerImpl::initFrameManager(FrameManager* frameManager)
{
    if (d->frameManager)
        return;

    d->frameManager = frameManager;

    bool isRTL = QApplication::isRightToLeft();

    KToolBarPopupAction* forward = new KToolBarPopupAction(KIcon(isRTL ? "go-previous" : "go-next"), i18nc("Go forward in browser history", "Forward"), this);
    d->actionCollection->addAction("browser_forward", forward);
    forward->setShortcuts(KShortcut(isRTL ? "Alt+Left" : "Alt+Right"));
    connect(forward, SIGNAL(triggered()), frameManager, SLOT(slotBrowserForward()));

    connect(forward->menu(), SIGNAL(aboutToShow()), frameManager, SLOT(slotBrowserForwardAboutToShow()));

    KToolBarPopupAction* back = new KToolBarPopupAction(KIcon(isRTL ? "go-next" : "go-previous"), i18nc("Go back in browser history", "Back"), this);
    d->actionCollection->addAction("browser_back", back);
    back->setShortcuts(KShortcut(isRTL ?  "Alt+Right" : "Alt+Left"));
    connect(back, SIGNAL(triggered()), frameManager, SLOT(slotBrowserBack()));

    connect(back->menu(), SIGNAL(aboutToShow()), frameManager, SLOT(slotBrowserBackAboutToShow()));

    KAction *action = d->actionCollection->addAction("browser_reload");
    action->setIcon(KIcon("view-refresh"));
    action->setText(i18nc("Reload current page", "Reload"));
    connect(action, SIGNAL(triggered(bool)), frameManager, SLOT(slotBrowserReload()));

    action = d->actionCollection->addAction("browser_stop");
    action->setIcon(KIcon("process-stop"));
    action->setText(i18n("Stop"));
    connect(action, SIGNAL(triggered(bool)), frameManager, SLOT(slotBrowserStop()));
}
Beispiel #4
0
void SimonView::setupActions()
{
  connectAction = new KAction(this);
  connectAction->setText(i18n("Connect"));
  connectAction->setCheckable(true);
  connectAction->setIcon(KIcon("network-disconnect"));
  connect(connectAction, SIGNAL(triggered(bool)),
    this, SLOT(toggleConnection()));
  actionCollection()->addAction("connect", connectAction);
  this->trayManager->addAction("connect", connectAction);

  activateAction = new KAction(this);
  activateAction->setText(i18n("Activate"));
  activateAction->setIcon(KIcon("media-playback-start"));
  activateAction->setCheckable(true);
  connect(activateAction, SIGNAL(triggered(bool)),
    this, SLOT(toggleActivation()));
  this->trayManager->addAction("activate", activateAction);
  activateAction->setEnabled(false);
  actionCollection()->addAction("activate", activateAction);
  //must be set after addAction() because of the unique name set in addAction(name,...)
  // deactivated because of KDE bug #307225
  //activateAction->setGlobalShortcut(KShortcut(Qt::SHIFT + Qt::Key_Pause));

  disconnectAction = new KAction(this);
  disconnectAction->setText(i18n("Disconnect"));
  disconnectAction->setIcon(KIcon("network-disconnect"));
  connect(disconnectAction, SIGNAL(triggered(bool)),
    control, SLOT(disconnectFromServer()));

  KToolBarPopupAction* connectActivate = new KToolBarPopupAction(KIcon("network-disconnect"), i18n("Connect"), this);
  connectActivate->setCheckable(true);
  connectActivate->setShortcut(Qt::CTRL + Qt::Key_C);

  actionCollection()->addAction("connectActivate", connectActivate);
  connect(connectActivate, SIGNAL(triggered(bool)),
    this, SLOT(toggleConnection()));

  
  KAction* recompile = new KAction(this);
  recompile->setEnabled(control->getStatus() != SimonControl::Disconnected);
  recompile->setText(i18n("Synchronize"));
  recompile->setIcon(KIcon("view-refresh"));
  recompile->setShortcut(Qt::CTRL + Qt::Key_F5);
  actionCollection()->addAction("compileModel", recompile);
  connect(recompile, SIGNAL(triggered(bool)),
    control, SLOT(compileModel()));

  KAction* sendSampleShareAction = new KAction(this);
  sendSampleShareAction->setText(i18n("Contribute samples"));
  sendSampleShareAction->setIcon(KIcon("repository"));
  actionCollection()->addAction("sampleShare", sendSampleShareAction);
  connect(sendSampleShareAction, SIGNAL(triggered(bool)),this, SLOT(showSampleShare()));
  
  actionCollection()->addAction(KStandardAction::Preferences, "configuration",
    this, SLOT(showSystemDialog()));

  KStandardAction::quit(this, SLOT(closeSimon()),
    actionCollection());
}
Beispiel #5
0
void soundKonverter::setupActions()
{
    KStandardAction::quit( this, SLOT(close()), actionCollection() );
    KStandardAction::preferences( this, SLOT(showConfigDialog()), actionCollection() );

    KAction *logviewer = actionCollection()->addAction("logviewer");
    logviewer->setText(i18n("View logs..."));
    logviewer->setIcon(KIcon("view-list-text"));
    connect( logviewer, SIGNAL(triggered()), this, SLOT(showLogViewer()) );

    KAction *replaygainscanner = actionCollection()->addAction("replaygainscanner");
    replaygainscanner->setText(i18n("Replay Gain tool..."));
    replaygainscanner->setIcon(KIcon("soundkonverter-replaygain"));
    connect( replaygainscanner, SIGNAL(triggered()), this, SLOT(showReplayGainScanner()) );

    KAction *aboutplugins = actionCollection()->addAction("aboutplugins");
    aboutplugins->setText(i18n("About plugins..."));
    aboutplugins->setIcon(KIcon("preferences-plugin"));
    connect( aboutplugins, SIGNAL(triggered()), this, SLOT(showAboutPlugins()) );

    KAction *add_files = actionCollection()->addAction("add_files");
    add_files->setText(i18n("Add files..."));
    add_files->setIcon(KIcon("audio-x-generic"));
    connect( add_files, SIGNAL(triggered()), m_view, SLOT(showFileDialog()) );

    KAction *add_folder = actionCollection()->addAction("add_folder");
    add_folder->setText(i18n("Add folder..."));
    add_folder->setIcon(KIcon("folder"));
    connect( add_folder, SIGNAL(triggered()), m_view, SLOT(showDirDialog()) );

    KAction *add_audiocd = actionCollection()->addAction("add_audiocd");
    add_audiocd->setText(i18n("Add CD tracks..."));
    add_audiocd->setIcon(KIcon("media-optical-audio"));
    connect( add_audiocd, SIGNAL(triggered()), m_view, SLOT(showCdDialog()) );

    KAction *add_url = actionCollection()->addAction("add_url");
    add_url->setText(i18n("Add url..."));
    add_url->setIcon(KIcon("network-workgroup"));
    connect( add_url, SIGNAL(triggered()), m_view, SLOT(showUrlDialog()) );

    KAction *add_playlist = actionCollection()->addAction("add_playlist");
    add_playlist->setText(i18n("Add playlist..."));
    add_playlist->setIcon(KIcon("view-media-playlist"));
    connect( add_playlist, SIGNAL(triggered()), m_view, SLOT(showPlaylistDialog()) );

    KAction *load = actionCollection()->addAction("load");
    load->setText(i18n("Load file list"));
    load->setIcon(KIcon("document-open"));
    connect( load, SIGNAL(triggered()), m_view, SLOT(loadFileList()) );

    KAction *save = actionCollection()->addAction("save");
    save->setText(i18n("Save file list"));
    save->setIcon(KIcon("document-save"));
    connect( save, SIGNAL(triggered()), m_view, SLOT(saveFileList()) );

    actionCollection()->addAction("start", m_view->start());
    actionCollection()->addAction("stop_menu", m_view->stopMenu());
}
Beispiel #6
0
void FileBrowserWidget::setupToolbar()
{
	KActionCollection *coll = m_dirOperator->actionCollection();
	m_toolbar->addAction(coll->action("back"));
	m_toolbar->addAction(coll->action("forward"));

	KAction *action = new KAction(this);
	action->setIcon(SmallIcon("document-open"));
	action->setText(i18n("Open selected"));
	connect(action, SIGNAL(triggered()), this, SLOT(emitFileSelectedSignal()));
	m_toolbar->addAction(action);


	// section for settings menu
	KActionMenu *optionsMenu = new KActionMenu(KIcon("configure"), i18n("Options"), this);
	optionsMenu->setDelayed(false);
	optionsMenu->addAction(m_dirOperator->actionCollection()->action("short view"));
	optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed view"));
	optionsMenu->addAction(m_dirOperator->actionCollection()->action("tree view"));
	optionsMenu->addAction(m_dirOperator->actionCollection()->action("detailed tree view"));
	optionsMenu->addSeparator();
	optionsMenu->addAction(m_dirOperator->actionCollection()->action("show hidden"));

	m_toolbar->addSeparator();
	m_toolbar->addAction(optionsMenu);
}
KAction *create(StandardAction id, const QObject *recvr, const char *slot, QObject *parent)
{
    KAction *pAction = 0;
    const Info* pInfo = infoPtr(id);

    if (pInfo) {
        pAction = new KAction(parent);
        pAction->setObjectName(pInfo->psName);
        KShortcut cut(pInfo->shortcut);
        if (!cut.isEmpty())
            pAction->setShortcut(cut);
        pAction->setText(i18n(pInfo->psText));
        pAction->setToolTip(i18n(pInfo->psToolTip));
        pAction->setWhatsThis(i18n(pInfo->psWhatsThis));
        if (pInfo->psIconName)
            pAction->setIcon(KIcon(QLatin1String(pInfo->psIconName)));
    }

    if (recvr && slot)
        QObject::connect(pAction, SIGNAL(triggered(bool)), recvr, slot);

    if (pAction) {
        KActionCollection *collection = qobject_cast<KActionCollection *>(parent);
        if (collection)
            collection->addAction(pAction->objectName(), pAction);
    }
    return pAction;
}
Beispiel #8
0
void MainWindow::setupActions()
{
    actQuit         = KStandardAction::quit(this, SLOT(quit()), actionCollection());
    KAction *a = NULL;
    a = actionCollection()->addAction("minimizeRestore", this,
                                      SLOT(minimizeRestore()));
    a->setText(i18n("Minimize"));
    a->setIcon(KIcon(""));
    a->setShortcut(0);

    /** Settings : ************************************************************/
//  m_actShowToolbar   = KStandardAction::showToolbar(   this, SLOT(toggleToolBar()),   actionCollection());
    m_actShowStatusbar = KStandardAction::showStatusbar(this, SLOT(toggleStatusBar()), actionCollection());

//  m_actShowToolbar->setCheckedState( KGuiItem(i18n("Hide &Toolbar")) );

    (void) KStandardAction::keyBindings(this, SLOT(showShortcutsSettingsDialog()), actionCollection());

    (void) KStandardAction::configureToolbars(this, SLOT(configureToolbars()), actionCollection());

    //KAction *actCfgNotifs = KStandardAction::configureNotifications(this, SLOT(configureNotifications()), actionCollection() );
    //actCfgNotifs->setEnabled(false); // Not yet implemented !

    actAppConfig = KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollection());
}
QAction* PopupMenuGUIClient::addEmbeddingService( int idx, const QString &name, const KService::Ptr &service )
{
    KAction *act = m_actionCollection.addAction( QByteArray::number( idx ) );
    act->setText( name );
    act->setIcon( KIcon(service->icon()) );
    QObject::connect(act, SIGNAL(triggered(bool)), this, SLOT(slotOpenEmbedded()));
    return act;
}
Beispiel #10
0
KAction* Player::setupKAction(const char *icon, QString text, QString help_text, const char *name) {
	KAction* action = new KAction(this);
	action->setIcon(KIcon(icon));
	action->setText(text);
	action->setHelpText(help_text);
	actionCollection()->addAction(name, action);
	return action;
}
Beispiel #11
0
void KateViewManager::setupActions ()
{
  KAction *a;

  /**
   * view splitting
   */
  a = m_mainWindow->actionCollection()->addAction("view_split_vert");
  a->setIcon( KIcon("view-split-left-right") );
  a->setText( i18n("Split Ve&rtical") );
  a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_L );
  connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceVert()));

  a->setWhatsThis(i18n("Split the currently active view vertically into two views."));

  a = m_mainWindow->actionCollection()->addAction("view_split_horiz");
  a->setIcon( KIcon("view-split-top-bottom") );
  a->setText( i18n("Split &Horizontal") );
  a->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_T );
  connect(a, SIGNAL(triggered()), this, SLOT(slotSplitViewSpaceHoriz()));

  a->setWhatsThis(i18n("Split the currently active view horizontally into two views."));

  m_closeView = m_mainWindow->actionCollection()->addAction("view_close_current_space");
  m_closeView->setIcon( KIcon("view-close") );
  m_closeView->setText( i18n("Cl&ose Current View") );
  m_closeView->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_R );
  connect(m_closeView, SIGNAL(triggered()), this, SLOT(slotCloseCurrentViewSpace()));

  m_closeView->setWhatsThis(i18n("Close the currently active splitted view"));

  goNext = m_mainWindow->actionCollection()->addAction( "go_next_split_view" );
  goNext->setText( i18n("Next Split View") );
  goNext->setShortcut( Qt::Key_F8 );
  connect(goNext, SIGNAL(triggered()), this, SLOT(activateNextView()));

  goNext->setWhatsThis(i18n("Make the next split view the active one."));

  goPrev = m_mainWindow->actionCollection()->addAction( "go_prev_split_view" );
  goPrev->setText( i18n("Previous Split View") );
  goPrev->setShortcut( Qt::SHIFT + Qt::Key_F8 );
  connect(goPrev, SIGNAL(triggered()), this, SLOT(activatePrevView()));

  goPrev->setWhatsThis(i18n("Make the previous split view the active one."));
}
Beispiel #12
0
MainWindow::MainWindow(QWidget *parent)
	: KXmlGuiWindow(parent)
{
	setWindowTitle(i18n("Silence"));
	controller = Controller::create();

	// ContentView
	contentview = new ContentView;
	setCentralWidget(contentview);
	controller->setContentView(contentview);


	nodepropertywidget = new NodePropertyWidget(i18n("Properties"), this);
	nodepropertywidget->hide();
	controller->setNodePropertyWidget(nodepropertywidget);

	// the treeview on the left side
	treeview = new TreeView(i18n("Nodes"), actionCollection(), this);
	controller->setTreeView(treeview);

	// search sidebar
	searchnodesidebar = new SearchNodeSidebar(i18n("Search Nodes"), this);
	controller->setSearchNodeSidebar(searchnodesidebar);

	// navigation sidebar
	navigationsidebar = new NavigationSidebar(i18n("Navigation"), this);
	controller->setNavigationSidebar(navigationsidebar);

	// information sidebar to show the meta-infos
	infosidebar = new InfoSidebar(i18n("Info"), this);
	controller->setInfoSidebar(infosidebar);

	// docking the widgets
	addDockWidget(Qt::RightDockWidgetArea, navigationsidebar);
	addDockWidget(Qt::RightDockWidgetArea, infosidebar);
	addDockWidget(Qt::LeftDockWidgetArea, treeview);
	addDockWidget(Qt::LeftDockWidgetArea, treeview);
	tabifyDockWidget(treeview, searchnodesidebar);
	addDockWidget(Qt::LeftDockWidgetArea, nodepropertywidget);

	statusbar = new SiStatusBar;
	setStatusBar(statusbar);
	controller->setStatusBar(statusbar);

	controller->setActionCollection(actionCollection());

	controller->getTextEdit()->setVisible(false);
	controller->getRichTextEdit()->setVisible(false);

	viewmenu = new ViewMenu(actionCollection());
	KAction *action = actionCollection()->addAction("exit");
	action->setText(i18n("&Exit"));
	action->setIcon(KIcon("application-exit"));
	connect(action, SIGNAL(triggered()), qApp, SLOT(quit()));

	setupGUI(QSize(1100, 600), Keys | StatusBar | Save | Create);
}
void KUI_project::setupActions()
{
  
  KAction *action = new KAction(this);
  
  action->setIcon(KIcon("edit-delete"));
  action->setText(i18n("&Aim"));
  collection->addAction("aim", action);
  connect(action, SIGNAL(triggered(bool)), this, SLOT(aimSlot()));
  
  
  action = new KAction(this);
  action->setIcon(KIcon("media-record"));
  action->setText(i18n("&Record"));
  connect(action, SIGNAL(triggered(bool)), this, SLOT(recordSlot()));
  collection->addAction("record", action);
  
  
  action = new KAction(this);
  action->setIcon(KIcon("media-playback-start"));
  action->setText(i18n("&Play"));
  connect(action, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this , SLOT(playSlot()));
  collection->addAction("play",action);

  action = new KAction(this);
  action->setIcon(KIcon("media-playback-pause"));
  action->setText(i18n("&Pause"));
  connect(action, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this , SLOT(pauseSlot()));
  collection->addAction("pause",action);
    
  action = new KAction(this);
  action->setIcon(KIcon("media-playback-stop"));
  action->setText(i18n("&Stop"));
  connect(action, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this , SLOT(stopSlot()));
  collection->addAction("stop",action);
 
  action = new KAction(this);
  action->setIcon(KIcon("media-playback-start"));
  action->setText(i18n("&Play"));
  connect(action, SIGNAL(triggered(Qt::MouseButtons,Qt::KeyboardModifiers)), this , SLOT(playAfterPauseSlot()));
  collection->addAction("playAfterPause",action);
  
  action = new KAction(this);
  action->setIcon(KIcon("list-add"));
  action->setText(i18n("&Add"));
  connect(action, SIGNAL(triggered(bool)), this, SLOT(addSlot()));
  collection->addAction("add", action);
  
  action = new KAction(this);
  action->setIcon(KIcon("list-remove"));
  action->setText(i18n("&Remove"));
  connect(action, SIGNAL(triggered(bool)), this, SLOT(removeSlot()));
  collection->addAction("remove", action);
}
KHTMLSideBar::KHTMLSideBar()
    : KHTMLPart()
{
    setStatusMessagesEnabled(false);
    setMetaRefreshEnabled(true);
    setJavaEnabled(false);
    setPluginsEnabled(false);

    setFormNotification(KHTMLPart::Only);
    connect(this,
            SIGNAL(formSubmitNotification(const char*,QString,QByteArray,QString,QString,QString)),
            this,
            SLOT(formProxy(const char*,QString,QByteArray,QString,QString,QString))
           );


    _linkMenu = new KMenu(widget());

    KAction* openLinkAction = new KAction(i18n("&Open Link"), this);
    _linkMenu->addAction(openLinkAction);
    connect(openLinkAction, SIGNAL(triggered()), this, SLOT(loadPage()));

    KAction* openWindowAction = new KAction(i18n("Open in New &Window"), this);
    _linkMenu->addAction(openWindowAction);
    connect(openWindowAction, SIGNAL(triggered()), this, SLOT(loadNewWindow()));


    _menu = new KMenu(widget());

    KAction* reloadAction = new KAction(i18n("&Reload"), this);
    reloadAction->setIcon(KIcon("view-refresh"));
    _menu->addAction(reloadAction);
    connect(reloadAction, SIGNAL(triggered()), this, SIGNAL(reload()));

    KAction* autoReloadAction = new KAction(i18n("Set &Automatic Reload"), this);
    autoReloadAction->setIcon(KIcon("view-refresh"));
    _menu->addAction(autoReloadAction);
    connect(autoReloadAction, SIGNAL(triggered()), this, SIGNAL(setAutoReload()));

    connect(this, SIGNAL(popupMenu(QString,QPoint)),
            this, SLOT(showMenu(QString,QPoint)));

}
Beispiel #15
0
KAction *KNS3::standardAction(const QString &what,
                             const QObject *receiver,
                             const char *slot, KActionCollection *parent,
                             const char *name)
{
    KAction *action = new KAction(what, parent);
    parent->addAction(QString(name), action);
    action->setIcon(KIcon("get-hot-new-stuff"));
    QObject::connect(action, SIGNAL(triggered(bool)), receiver, slot);

    return action;
}
Beispiel #16
0
QAction* DebuggerMainWnd::createAction(const QString& text, const char* icon,
			int shortcut, const QObject* receiver,
			const char* slot, const char* name)
{
    KAction* a = actionCollection()->addAction(name);
    a->setText(text);
    a->setIcon(KIcon(icon));
    if (shortcut)
	a->setShortcut(KShortcut(shortcut));
    connect(a, SIGNAL(triggered()), receiver, slot);
    return a;
}
KShellCmdPlugin::KShellCmdPlugin( QObject* parent, const QVariantList & )
    : KParts::Plugin( parent )
{
    if (!KAuthorized::authorizeKAction("shell_access"))
       return;

    KAction *action = actionCollection()->addAction("executeshellcommand");
    action->setIcon(KIcon("system-run"));
    action->setText(i18n( "&Execute Shell Command..." ));
    connect(action, SIGNAL(triggered(bool)), SLOT( slotExecuteShellCommand() ));
    action->setShortcut(Qt::CTRL+Qt::Key_E);
}
Beispiel #18
0
void KMarkNote::setupAction()
{
    KStandardAction::openNew(this, SLOT(newNote()), actionCollection());
    KStandardAction::close(this, SLOT(close()), actionCollection());

    KAction* oneColAction = actionCollection()->addAction("win_onecol", m_view, SLOT(oneColView()));
    KAction* twoColAction = actionCollection()->addAction("win_twocol", m_view, SLOT(twoColView()));
    KAction* threeColAction = actionCollection()->addAction("win_threecol", m_view, SLOT(threeColView()));

    oneColAction->setText(i18n("One Column View"));
    twoColAction->setText(i18n("Two Column View"));
    threeColAction->setText(i18n("Three Column View"));

    oneColAction->setIcon(KIcon("view-split-top-bottom"));
    twoColAction->setIcon(KIcon("view-split-left-right"));
    threeColAction->setIcon(KIcon("view-file-columns"));

    KAction* terminalAction = actionCollection()->addAction("toggle_terminal", m_view, SLOT(toggleTerminal()));
    KShortcut terminalShortcut = terminalAction->shortcut();
    terminalShortcut.setPrimary(QKeySequence("F4"));
    terminalAction->setShortcut(terminalShortcut);
}
Beispiel #19
0
void MainWindow::createActions()
{
    KStandardAction::open( this, SLOT(slotFileOpen()), actionCollection() );
    KStandardAction::openRecent( this, SLOT(slotFileOpenRecent()), actionCollection() );
    KStandardAction::save( this, SLOT(slotFileSave()), actionCollection() );
    KStandardAction::saveAs( this, SLOT(slotFileSaveAs()), actionCollection() );
    KStandardAction::close( this, SLOT(slotViewClose()), actionCollection() );
    KStandardAction::print( this, SLOT(slotFilePrint()), actionCollection() );
    KStandardAction::quit( this, SLOT(slotFileQuit()), actionCollection() );
    KStandardAction::undo( this, SLOT(slotUndo()), actionCollection() );
    KStandardAction::redo( this, SLOT(slotRedo()), actionCollection() );
    KStandardAction::cut( this, SLOT(slotCut()), actionCollection() );
    KStandardAction::copy( this, SLOT(slotCopy()), actionCollection() );
    KStandardAction::paste( this, SLOT(slotPaste()), actionCollection() );

    KActionMenu *newActionMenu = new KActionMenu( KIcon("document-new"), i18n("&New"), this );
    actionCollection()->addAction( KStandardAction::name(KStandardAction::New), newActionMenu );
    connect( newActionMenu, SIGNAL(activated()), this, SLOT(slotFileNew()) );

    KAction *action;
    action = actionCollection()->addAction( QString("newfile_asm") );
    action->setText( i18n("Assembly") );
    action->setIcon( KIcon("") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewAssembly()) );
    newActionMenu->addAction( action );

    action = actionCollection()->addAction( QString("newfile_c") );
    action->setText( i18n("C source") );
    action->setIcon( KIcon("text-x-csrc") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewC()) );
    newActionMenu->addAction( action );

    action = actionCollection()->addAction( QString("ktechlab_circuit") );
    action->setText( i18n("Circuit") );
    action->setIcon( KIcon("ktechlab_circuit") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewCircuit()) );
    newActionMenu->addAction( action );

    action = actionCollection()->addAction( QString("ktechlab_flowcode") );
    action->setText( i18n("FlowCode") );
    action->setIcon( KIcon("ktechlab_flowcode") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewFlowCode()) );
    newActionMenu->addAction( action );

    action = actionCollection()->addAction( QString("ktechlab_mechanics") );
    action->setText( i18n("Mechanics") );
    action->setIcon( KIcon("") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewMechanics()) );
    newActionMenu->addAction( action );

    action = actionCollection()->addAction( QString("ktechlab_microbe") );
    action->setText( i18n("Microbe") );
    action->setIcon( KIcon("ktechlab_microbe") );
    connect( action, SIGNAL(triggered()), this, SLOT(slotFileNewMicrobe()) );
    newActionMenu->addAction( action );
}
Beispiel #20
0
KMarkNote::KMarkNote(QWidget* parent)
    : KXmlGuiWindow(parent)
    , isPreview(false)
{
    KAction* previewAction = actionCollection()->addAction("file_preview", this, SLOT(togglePreview()));
    previewAction->setIcon(KIcon("document-preview"));
    previewAction->setText(i18n("Preview"));
    previewAction->setCheckable(true);

    m_view = new MainView(parent, previewAction);
    m_note = m_view->note;
    setupAction();
    setupUI();
    setupConnect();
}
RubySupportPart::RubySupportPart(QObject *parent, const char *name, const QStringList& )
  : KDevLanguageSupport (&data, parent, name ? name : "RubySupportPart" )
{
  setInstance(RubySupportFactory::instance());
  setXMLFile("kdevrubysupport.rc");

  KAction *action;
  action = new KAction( i18n("&Run"), "exec", SHIFT + Key_F9,
                        this, SLOT(slotRun()),
                        actionCollection(), "build_execute" );
  action->setToolTip(i18n("Run"));
  action->setWhatsThis(i18n("<b>Run</b><p>Starts an application."));
  action->setIcon("ruby_run.png");

  action = new KAction( i18n("Run Test Under Cursor"), "exec", ALT + Key_F9,
                        this, SLOT(slotRunTestUnderCursor()),
                        actionCollection(), "build_execute_test_function" );
  action->setToolTip(i18n("Run Test Under Cursor"));
  action->setWhatsThis(i18n("<b>Run Test Under Cursor</b><p>Runs the function under the cursor as test."));

  action = new KAction( i18n("Launch Browser"), "network", 0, this, SLOT(slotBrowse()), actionCollection(), "build_launch_browser" );
  action->setToolTip(i18n("Launch Browser"));
  action->setWhatsThis(i18n("<b>Launch Browser</b><p>Opens a web browser pointing to the Ruby Rails server") );

  action = new KAction( i18n("Switch To Controller"), 0, CTRL+ALT+Key_1, this, SLOT(slotSwitchToController()), actionCollection(), "switch_to_controller" );
  action = new KAction( i18n("Switch To Model"), 0, CTRL+ALT+Key_2, this, SLOT(slotSwitchToModel()), actionCollection(), "switch_to_model" );
  action = new KAction( i18n("Switch To View"), 0, CTRL+ALT+Key_3, this, SLOT(slotSwitchToView()), actionCollection(), "switch_to_view" );
  action = new KAction( i18n("Switch To Test"), 0, CTRL+ALT+Key_4, this, SLOT(slotSwitchToTest()), actionCollection(), "switch_to_test" );

  kdDebug() << "Creating RubySupportPart" << endl;

  m_shellWidget = new KDevShellWidget( 0, "irb console");
  m_shellWidget->setIcon( SmallIcon("ruby_config.png", KIcon::SizeMedium, KIcon::DefaultState, RubySupportPart::instance()));
  m_shellWidget->setCaption(i18n("Ruby Shell"));
  mainWindow()->embedOutputView( m_shellWidget, i18n("Ruby Shell"), i18n("Ruby Shell"));
  mainWindow()->raiseView( m_shellWidget );

  connect( core(), SIGNAL(projectOpened()), this, SLOT(projectOpened()) );
  connect( core(), SIGNAL(projectClosed()), this, SLOT(projectClosed()) );
  connect( core(), SIGNAL(contextMenu(QPopupMenu *, const Context *)),
        this, SLOT(contextMenu(QPopupMenu *, const Context *)) );
  connect( partController(), SIGNAL(savedFile(const KURL&)),
  	this, SLOT(savedFile(const KURL&)) );
  connect( core(), SIGNAL(projectConfigWidget(KDialogBase*)),
        this, SLOT(projectConfigWidget(KDialogBase*)) );
}
Beispiel #22
0
void KMilion::setupActions()
{
  //akcja uruchomienia gry
  KAction* runAction = new KAction(this);
  runAction->setText(i18n("&Run Quiz"));
  runAction->setIcon(KIcon("system-run"));
  runAction->setShortcut(Qt::CTRL + Qt::Key_R);
  actionCollection()->addAction("run", runAction);
  connect(runAction, SIGNAL(triggered(bool)), this, SLOT(runGame()));
  
//     KStandardAction::preferences(this, SLOT(optionsPreferences()), actionCollection()); 
    KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection());
    
    KStandardAction::open(editorWidget,SLOT(loadTestFile()),actionCollection());
    KStandardAction::save(editorWidget,SLOT(saveTestFileOld()),actionCollection());
    KStandardAction::saveAs(editorWidget,SLOT(saveTestFileNew()),actionCollection());      
    KStandardAction::openNew(editorWidget, SLOT(createTestFileNew()), actionCollection());
}
void ThemeManager::populateThemeMenu()
{
    if (!d->themeMenuAction) return;

    QString theme(currentThemeName());

    d->themeMenuAction->menu()->clear();
    delete d->themeMenuActionGroup;

    d->themeMenuActionGroup = new QActionGroup(d->themeMenuAction);
    connect(d->themeMenuActionGroup, SIGNAL(triggered(QAction*)),
            this, SLOT(slotChangePalette()));

    KAction* action = new KAction(defaultThemeName(), d->themeMenuActionGroup);
    action->setCheckable(true);
    d->themeMenuAction->addAction(action);

    const QStringList schemeFiles = KGlobal::dirs()->findAllResources("data", "color-schemes/*.colors", KStandardDirs::NoDuplicates);

    QMap<QString, QAction*> actionMap;
    for (int i = 0; i < schemeFiles.size(); ++i)
    {
        const QString filename  = schemeFiles.at(i);
        const QFileInfo info(filename);
        KSharedConfigPtr config = KSharedConfig::openConfig(filename);
        QIcon icon              = createSchemePreviewIcon(config);
        KConfigGroup group(config, "General");
        const QString name      = group.readEntry("Name", info.baseName());
        action                  = new KAction(name, d->themeMenuActionGroup);
        d->themeMap.insert(name, filename);
        action->setIcon(icon);
        action->setCheckable(true);
        actionMap.insert(name, action);
    }

    // sort the list
    QStringList actionMapKeys = actionMap.keys();
    actionMapKeys.sort();

    foreach(const QString& name, actionMapKeys)
    {
        d->themeMenuAction->addAction(actionMap.value(name));
    }
void FileManager::setupActions()
{
    KAction* action = new KAction(this);
    action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    action->setText(i18n("Current Document Directory"));
    action->setIcon(KIcon("dirsync"));
    connect(action, SIGNAL(triggered(bool)), this, SLOT(syncCurrentDocumentDirectory()));
    tbActions << (dirop->actionCollection()->action("back"));
    tbActions << (dirop->actionCollection()->action("up"));
    tbActions << (dirop->actionCollection()->action("home"));
    tbActions << (dirop->actionCollection()->action("forward"));
    tbActions << (dirop->actionCollection()->action("reload"));
    tbActions << action;
    tbActions << (dirop->actionCollection()->action("sorting menu"));
    tbActions << (dirop->actionCollection()->action("show hidden"));

    newFileAction = new KAction(this);
    newFileAction->setText(i18n("New File..."));
    newFileAction->setIcon(KIcon("document-new"));
    connect(newFileAction, SIGNAL(triggered()), this, SLOT(createNewFile()));
}
Beispiel #25
0
KonsolePreviewer::KonsolePreviewer(const QString & title, QWidget *parent, const QString& projectType,
                                   const QString& packagePath)
        : QDockWidget(title, parent),
        m_textEdit(0),
        m_projectType(projectType),
        m_packagePath(packagePath)
{
    QVBoxLayout *layout = new QVBoxLayout();
    KToolBar *toolBar = new KToolBar(this, true, true);

    KAction *clear = KStandardAction::clear(this, SLOT(clearOutput()), this);
    KAction *save = KStandardAction::save(this, SLOT(saveOutput()), this);

    //we want those only for the kwin scripts
    if (m_projectType == "KWin/Script") {
        KAction *execute = new KAction(this);
        execute->setText("Execute");
        execute->setIcon(KIcon("system-run"));
        connect(execute, SIGNAL(triggered(bool)), this, SLOT(executeKWinScript()));

        //add it to toolbar
        toolBar->addAction(execute);
    }
void KTNEFMain::setupActions()
{
  KStandardAction::quit( this, SLOT(close()), actionCollection() );

  KAction *action =
    KStandardAction::keyBindings( this, SLOT(slotConfigureKeys()), actionCollection() );
  action->setWhatsThis(
    i18nc( "@info:whatsthis",
           "You will be presented with a dialog where you can configure "
           "the application-wide shortcuts." ) );

  KStandardAction::configureToolbars( this, SLOT(slotEditToolbars()), actionCollection() );

  // File menu
  KStandardAction::open( this, SLOT(openFile()), actionCollection() );

  // Action menu
  KAction *openAction = actionCollection()->addAction( "view_file" );
  openAction->setText( i18nc( "@action:inmenu", "View" ) );
  openAction->setIcon( KIcon( "document-open" ) );
  connect( openAction, SIGNAL(triggered()), this, SLOT(viewFile()) );

  KAction *openAsAction = actionCollection()->addAction( "view_file_as" );
  openAsAction->setText( i18nc( "@action:inmenu", "View With..." ) );
  connect( openAsAction, SIGNAL(triggered()), this, SLOT(viewFileAs()) );

  KAction *extractAction = actionCollection()->addAction( "extract_file" );
  extractAction->setText( i18nc( "@action:inmenu", "Extract" ) );
  connect( extractAction, SIGNAL(triggered()), this, SLOT(extractFile()) );

  KAction *extractToAction = actionCollection()->addAction( "extract_file_to" );
  extractToAction->setText( i18nc( "@action:inmenu", "Extract To..." ) );
  extractToAction->setIcon( KIcon( "archive-extract" ) );
  connect( extractToAction, SIGNAL(triggered()), this, SLOT(extractFileTo()) );

  KAction *extractAllToAction = actionCollection()->addAction( "extract_all_files" );
  extractAllToAction->setText( i18nc( "@action:inmenu", "Extract All To..." ) );
  extractAllToAction->setIcon( KIcon( "archive-extract" ) );
  connect( extractAllToAction, SIGNAL(triggered()), this, SLOT(extractAllFiles()) );

  KAction *filePropsAction = actionCollection()->addAction( "properties_file" );
  filePropsAction->setText( i18nc( "@action:inmenu", "Properties" ) );
  filePropsAction->setIcon( KIcon( "document-properties" ) );
  connect( filePropsAction, SIGNAL(triggered()), this, SLOT(propertiesFile()));

  KAction *messPropsAction = actionCollection()->addAction( "msg_properties" );
  messPropsAction->setText( i18nc( "@action:inmenu", "Message Properties" ) );
  connect( messPropsAction, SIGNAL(triggered()), this, SLOT(slotShowMessageProperties()) );

  KAction *messShowAction = actionCollection()->addAction( "msg_text" );
  messShowAction->setText( i18nc( "@action:inmenu", "Show Message Text" ) );
  messShowAction->setIcon( KIcon( "document-preview-archive" ) );
  connect( messShowAction, SIGNAL(triggered()), this, SLOT(slotShowMessageText()) );

  KAction *messSaveAction = actionCollection()->addAction( "msg_save" );
  messSaveAction->setText( i18nc( "@action:inmenu", "Save Message Text As..." ) );
  messSaveAction->setIcon( KIcon( "document-save" ) );
  connect( messSaveAction, SIGNAL(triggered()), this, SLOT(slotSaveMessageText()) );

  actionCollection()->action( "view_file" )->setEnabled( false );
  actionCollection()->action( "view_file_as" )->setEnabled( false );
  actionCollection()->action( "extract_file" )->setEnabled( false );
  actionCollection()->action( "extract_file_to" )->setEnabled( false );
  actionCollection()->action( "extract_all_files" )->setEnabled( false );
  actionCollection()->action( "properties_file" )->setEnabled( false );

  // Options menu
  KAction *defFolderAction = actionCollection()->addAction( "options_default_dir" );
  defFolderAction->setText( i18nc( "@action:inmenu", "Default Folder..." ) );
  defFolderAction->setIcon( KIcon( "folder-open" ) );
  connect( defFolderAction, SIGNAL(triggered()), this, SLOT(optionDefaultDir()) );

}
Beispiel #27
0
KDirSelectDialog::KDirSelectDialog(const KUrl &startDir, bool localOnly,
                                   QWidget *parent)
    : KDialog( parent ),
      d( new Private( localOnly, this ) )
{
    setCaption( i18nc("@title:window","Select Folder") );
    setButtons( Ok | Cancel | User1 );
    setButtonGuiItem( User1, KGuiItem( i18nc("@action:button","New Folder..."), "folder-new" ) );
    setDefaultButton(Ok);
    button(Ok)->setFocus();

    QFrame *page = new QFrame(this);
    setMainWidget(page);
    QHBoxLayout *hlay = new QHBoxLayout( page);
    hlay->setMargin(0);
    QVBoxLayout *mainLayout = new QVBoxLayout();
    d->m_actions=new KActionCollection(this);
    d->m_actions->addAssociatedWidget(this);
    d->m_placesView = new KFilePlacesView( page );
    d->m_placesView->setModel(new KFilePlacesModel(d->m_placesView));
    d->m_placesView->setObjectName( QLatin1String( "speedbar" ) );
    d->m_placesView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
    d->m_placesView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    connect( d->m_placesView, SIGNAL(urlChanged(KUrl)),
             SLOT(setCurrentUrl(KUrl)) );
    hlay->addWidget( d->m_placesView );
    hlay->addLayout( mainLayout );

    d->m_treeView = new KFileTreeView(page);
    d->m_treeView->setDirOnlyMode(true);
    d->m_treeView->setContextMenuPolicy(Qt::CustomContextMenu);

    for (int i = 1; i < d->m_treeView->model()->columnCount(); ++i)
        d->m_treeView->hideColumn(i);

    d->m_urlCombo = new KHistoryComboBox( page);
    d->m_urlCombo->setLayoutDirection( Qt::LeftToRight );
    d->m_urlCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength);
    d->m_urlCombo->setTrapReturnKey( true );
    KUrlCompletion *comp = new KUrlCompletion();
    comp->setMode( KUrlCompletion::DirCompletion );
    d->m_urlCombo->setCompletionObject( comp, true );
    d->m_urlCombo->setAutoDeleteCompletionObject( true );
    d->m_urlCombo->setDuplicatesEnabled( false );

    d->m_contextMenu = new KMenu( this );

    KAction* newFolder = new KAction( i18nc("@action:inmenu","New Folder..."), this);
    d->m_actions->addAction( newFolder->objectName(), newFolder );
    newFolder->setIcon( KIcon( "folder-new" ) );
    newFolder->setShortcut( Qt::Key_F10);
    connect( newFolder, SIGNAL(triggered(bool)), this, SLOT(slotNewFolder()) );
    d->m_contextMenu->addAction( newFolder );

    d->moveToTrash = new KAction( i18nc( "@action:inmenu","Move to Trash" ), this );
    d->m_actions->addAction( d->moveToTrash->objectName(), d->moveToTrash );
    d->moveToTrash->setIcon( KIcon( "user-trash" ) );
    d->moveToTrash->setShortcut(KShortcut(Qt::Key_Delete));
    connect( d->moveToTrash, SIGNAL(triggered(bool)), this, SLOT(slotMoveToTrash()) );
    d->m_contextMenu->addAction( d->moveToTrash );

    d->deleteAction = new KAction( i18nc("@action:inmenu","Delete"), this );
    d->m_actions->addAction( d->deleteAction->objectName(), d->deleteAction );
    d->deleteAction->setIcon( KIcon( "edit-delete" ) );
    d->deleteAction->setShortcut( KShortcut( Qt::SHIFT + Qt::Key_Delete ) );
    connect( d->deleteAction, SIGNAL(triggered(bool)), this, SLOT(slotDelete()) );
    d->m_contextMenu->addAction( d->deleteAction );

    d->m_contextMenu->addSeparator();

    d->showHiddenFoldersAction = new KToggleAction( i18nc("@option:check", "Show Hidden Folders"), this );
    d->m_actions->addAction( d->showHiddenFoldersAction->objectName(), d->showHiddenFoldersAction );
    d->showHiddenFoldersAction->setShortcut( Qt::Key_F8 );
    connect( d->showHiddenFoldersAction, SIGNAL(triggered(bool)), d->m_treeView, SLOT(setShowHiddenFiles(bool)) );
    d->m_contextMenu->addAction( d->showHiddenFoldersAction );
    d->m_contextMenu->addSeparator();

    KAction* propertiesAction = new KAction( i18nc("@action:inmenu","Properties"), this);
    d->m_actions->addAction(propertiesAction->objectName(), propertiesAction);
    propertiesAction->setIcon(KIcon("document-properties"));
    propertiesAction->setShortcut(KShortcut(Qt::ALT + Qt::Key_Return));
    connect( propertiesAction, SIGNAL(triggered(bool)), this, SLOT(slotProperties()) );
    d->m_contextMenu->addAction( propertiesAction );

    d->m_startURL = KFileDialog::getStartUrl( startDir, d->m_recentDirClass );
    if ( localOnly && !d->m_startURL.isLocalFile() )
    {
        d->m_startURL = KUrl();
        QString docPath = KGlobalSettings::documentPath();
        if (QDir(docPath).exists())
            d->m_startURL.setPath( docPath );
        else
            d->m_startURL.setPath( QDir::homePath() );
    }

    d->m_startDir = d->m_startURL;
    d->m_rootUrl = d->m_treeView->rootUrl();

    d->readConfig( KGlobal::config(), "DirSelect Dialog" );

    mainLayout->addWidget( d->m_treeView, 1 );
    mainLayout->addWidget( d->m_urlCombo, 0 );

    connect( d->m_treeView, SIGNAL(currentChanged(KUrl)),
             SLOT(slotCurrentChanged()));
    connect( d->m_treeView, SIGNAL(activated(QModelIndex)),
             SLOT(slotExpand(QModelIndex)));
    connect( d->m_treeView, SIGNAL(customContextMenuRequested(QPoint)),
             SLOT(slotContextMenuRequested(QPoint)));

    connect( d->m_urlCombo, SIGNAL(editTextChanged(QString)),
             SLOT(slotComboTextChanged(QString)));
    connect( d->m_urlCombo, SIGNAL(activated(QString)),
             SLOT(slotUrlActivated(QString)));
    connect( d->m_urlCombo, SIGNAL(returnPressed(QString)),
             SLOT(slotUrlActivated(QString)));

    connect(this, SIGNAL(user1Clicked()), this, SLOT(slotNewFolder()));

    setCurrentUrl(d->m_startURL);
}
Beispiel #28
0
void WebView::contextMenuEvent(QContextMenuEvent *event)
{
    m_contextMenuHitResult = page()->mainFrame()->hitTestContent(event->pos());

    if (m_contextMenuHitResult.isContentEditable())
    {
        // Check to see if handled by speller
        if (popupSpellMenu(event))
            return;
    }

    WebWindow *webwin = m_parentTab->webWindow();
    
    KMenu menu(this);

    KAction *sendByMailAction = new KAction(&menu);
    sendByMailAction->setIcon(KIcon("mail-send"));
    connect(sendByMailAction, SIGNAL(triggered(bool)), this, SLOT(sendByMail()));

    // Choose right context
    int resultHit = 0;
    if (m_contextMenuHitResult.linkUrl().isEmpty())
        resultHit = WebView::EmptySelection;
    else
        resultHit = WebView::LinkSelection;

    if (!m_contextMenuHitResult.pixmap().isNull())
        resultHit |= WebView::ImageSelection;

    if (m_contextMenuHitResult.isContentSelected())
        resultHit = WebView::TextSelection;

    // --------------------------------------------------------------------------------
    // Ok, let's start filling up the menu...

    // is content editable? Add PASTE
    if (m_contextMenuHitResult.isContentEditable())
    {
        menu.addAction(pageAction(KWebPage::Paste));
        menu.addSeparator();
    }

    QAction *a;

    // EMPTY PAGE ACTIONS -------------------------------------------------------------
    if (resultHit == WebView::EmptySelection)
    {
        // send by mail: page url
        sendByMailAction->setData(page()->currentFrame()->url());
        sendByMailAction->setText(i18n("Share page URL"));

        // navigation
        QWebHistory *history = page()->history();
        if (history->canGoBack())
        {
            menu.addAction(pageAction(KWebPage::Back));
        }

        if (history->canGoForward())
        {
            menu.addAction(pageAction(KWebPage::Forward));
        }

        menu.addAction(pageAction(KWebPage::Reload));

        menu.addSeparator();

        // Frame
        KActionMenu *frameMenu = new KActionMenu(i18n("Current Frame"), &menu);
        frameMenu->addAction(pageAction(KWebPage::OpenFrameInNewWindow));

        a = new KAction(KIcon("document-print-frame"), i18n("Print Frame"), &menu);
        connect(a, SIGNAL(triggered()), m_parentTab, SLOT(printFrame()));
        frameMenu->addAction(a);

        menu.addAction(frameMenu);

        menu.addSeparator();

        // Page Actions
        menu.addAction(pageAction(KWebPage::SelectAll));

        if (webwin)
            menu.addAction(webwin->actionByName(KStandardAction::name(KStandardAction::Save)));

        if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
        {
            a = new KAction(KIcon("kget"), i18n("List All Links"), &menu);
            connect(a, SIGNAL(triggered(bool)), page(), SLOT(downloadAllContentsWithKGet()));
            menu.addAction(a);
        }

        if (webwin)
        {
            menu.addAction(webwin->actionByName("page_source"));
            menu.addAction(webwin->actionByName("web_inspector"));
        }
    }

    // LINK ACTIONS -------------------------------------------------------------------
    if (resultHit & WebView::LinkSelection)
    {
        // send by mail: link url
        sendByMailAction->setData(m_contextMenuHitResult.linkUrl());
        sendByMailAction->setText(i18n("Share link"));

        a = new KAction(KIcon("tab-new"), i18n("Open in New &Tab"), &menu);
        a->setData(m_contextMenuHitResult.linkUrl());
        connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewTab()));
        menu.addAction(a);

        a = new KAction(KIcon("window-new"), i18n("Open in New &Window"), &menu);
        a->setData(m_contextMenuHitResult.linkUrl());
        connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInNewWindow()));
        menu.addAction(a);

        if (!m_parentTab->isWebApp())
        {
            a = new KAction(KIcon("view-media-artist"), i18n("Open in Private &Window"), &menu);
            a->setData(m_contextMenuHitResult.linkUrl());
            connect(a, SIGNAL(triggered(bool)), this, SLOT(openLinkInPrivateWindow()));
            menu.addAction(a);
        }
Beispiel #29
0
void ViewManager::setupActions()
{
    KActionCollection* collection = _actionCollection;

    KAction* nextViewAction = new KAction(i18nc("@action Shortcut entry", "Next Tab") , this);
    KAction* previousViewAction = new KAction(i18nc("@action Shortcut entry", "Previous Tab") , this);
    KAction* lastViewAction = new KAction(i18nc("@action Shortcut entry", "Switch to Last Tab") , this);
    KAction* nextContainerAction = new KAction(i18nc("@action Shortcut entry", "Next View Container") , this);

    KAction* moveViewLeftAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Left") , this);
    KAction* moveViewRightAction = new KAction(i18nc("@action Shortcut entry", "Move Tab Right") , this);

    // list of actions that should only be enabled when there are multiple view
    // containers open
    QList<QAction*> multiViewOnlyActions;
    multiViewOnlyActions << nextContainerAction;

    if (collection) {
        KAction* splitLeftRightAction = new KAction(KIcon("view-split-left-right"),
                i18nc("@action:inmenu", "Split View Left/Right"),
                this);
        splitLeftRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenLeft));
        collection->addAction("split-view-left-right", splitLeftRightAction);
        connect(splitLeftRightAction , SIGNAL(triggered()) , this , SLOT(splitLeftRight()));

        KAction* splitTopBottomAction = new KAction(KIcon("view-split-top-bottom") ,
                i18nc("@action:inmenu", "Split View Top/Bottom"), this);
        splitTopBottomAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_ParenRight));
        collection->addAction("split-view-top-bottom", splitTopBottomAction);
        connect(splitTopBottomAction , SIGNAL(triggered()) , this , SLOT(splitTopBottom()));

        KAction* closeActiveAction = new KAction(i18nc("@action:inmenu Close Active View", "Close Active") , this);
        closeActiveAction->setIcon(KIcon("view-close"));
        closeActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
        closeActiveAction->setEnabled(false);
        collection->addAction("close-active-view", closeActiveAction);
        connect(closeActiveAction , SIGNAL(triggered()) , this , SLOT(closeActiveView()));

        multiViewOnlyActions << closeActiveAction;

        KAction* closeOtherAction = new KAction(i18nc("@action:inmenu Close Other Views", "Close Others") , this);
        closeOtherAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_O));
        closeOtherAction->setEnabled(false);
        collection->addAction("close-other-views", closeOtherAction);
        connect(closeOtherAction , SIGNAL(triggered()) , this , SLOT(closeOtherViews()));

        multiViewOnlyActions << closeOtherAction;

        KAction* detachViewAction = collection->addAction("detach-view");
        detachViewAction->setIcon(KIcon("tab-detach"));
        detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab"));
        // Ctrl+Shift+D is not used as a shortcut by default because it is too close
        // to Ctrl+D - which will terminate the session in many cases
        detachViewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_H));

        connect(this , SIGNAL(splitViewToggle(bool)) , this , SLOT(updateDetachViewState()));
        connect(detachViewAction , SIGNAL(triggered()) , this , SLOT(detachActiveView()));

        // Expand & Shrink Active View
        KAction* expandActiveAction = new KAction(i18nc("@action:inmenu", "Expand View") , this);
        expandActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketRight));
        expandActiveAction->setEnabled(false);
        collection->addAction("expand-active-view", expandActiveAction);
        connect(expandActiveAction , SIGNAL(triggered()) , this , SLOT(expandActiveView()));

        multiViewOnlyActions << expandActiveAction;

        KAction* shrinkActiveAction = new KAction(i18nc("@action:inmenu", "Shrink View") , this);
        shrinkActiveAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_BracketLeft));
        shrinkActiveAction->setEnabled(false);
        collection->addAction("shrink-active-view", shrinkActiveAction);
        connect(shrinkActiveAction , SIGNAL(triggered()) , this , SLOT(shrinkActiveView()));

        multiViewOnlyActions << shrinkActiveAction;

        // Next / Previous View , Next Container
        collection->addAction("next-view", nextViewAction);
        collection->addAction("previous-view", previousViewAction);
        collection->addAction("last-tab", lastViewAction);
        collection->addAction("next-container", nextContainerAction);
        collection->addAction("move-view-left", moveViewLeftAction);
        collection->addAction("move-view-right", moveViewRightAction);

        // Switch to tab N shortcuts
        const int SWITCH_TO_TAB_COUNT = 10;
        QSignalMapper* switchToTabMapper = new QSignalMapper(this);
        connect(switchToTabMapper, SIGNAL(mapped(int)), this, SLOT(switchToView(int)));
        for (int i = 0; i < SWITCH_TO_TAB_COUNT; i++) {
            KAction* switchToTabAction = new KAction(i18nc("@action Shortcut entry", "Switch to Tab %1", i + 1), this);
            switchToTabMapper->setMapping(switchToTabAction, i);
            connect(switchToTabAction, SIGNAL(triggered()), switchToTabMapper,
                    SLOT(map()));
            collection->addAction(QString("switch-to-tab-%1").arg(i), switchToTabAction);
        }
    }

    QListIterator<QAction*> iter(multiViewOnlyActions);
    while (iter.hasNext()) {
        connect(this , SIGNAL(splitViewToggle(bool)) , iter.next() , SLOT(setEnabled(bool)));
    }

    // keyboard shortcut only actions
    nextViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Right));
    connect(nextViewAction, SIGNAL(triggered()) , this , SLOT(nextView()));
    _viewSplitter->addAction(nextViewAction);

    previousViewAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left));
    connect(previousViewAction, SIGNAL(triggered()) , this , SLOT(previousView()));
    _viewSplitter->addAction(previousViewAction);

    nextContainerAction->setShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Tab));
    connect(nextContainerAction , SIGNAL(triggered()) , this , SLOT(nextContainer()));
    _viewSplitter->addAction(nextContainerAction);

    moveViewLeftAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Left));
    connect(moveViewLeftAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewLeft()));
    _viewSplitter->addAction(moveViewLeftAction);

    moveViewRightAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Right));
    connect(moveViewRightAction , SIGNAL(triggered()) , this , SLOT(moveActiveViewRight()));
    _viewSplitter->addAction(moveViewRightAction);

    connect(lastViewAction, SIGNAL(triggered()) , this , SLOT(lastView()));
    _viewSplitter->addAction(lastViewAction);
}
void KateMainWindow::setupActions()
{
  KAction *a;

  actionCollection()->addAction( KStandardAction::New, "file_new", m_viewManager, SLOT(slotDocumentNew()) )
  ->setWhatsThis(i18n("Create a new document"));
  actionCollection()->addAction( KStandardAction::Open, "file_open", m_viewManager, SLOT(slotDocumentOpen()) )
  ->setWhatsThis(i18n("Open an existing document for editing"));

  fileOpenRecent = KStandardAction::openRecent (m_viewManager, SLOT(openUrl(KUrl)), this);
  actionCollection()->addAction(fileOpenRecent->objectName(), fileOpenRecent);
  fileOpenRecent->setWhatsThis(i18n("This lists files which you have opened recently, and allows you to easily open them again."));

  a = actionCollection()->addAction( "file_save_all" );
  a->setIcon( KIcon("document-save-all") );
  a->setText( i18n("Save A&ll") );
  a->setShortcut( QKeySequence(Qt::CTRL + Qt::Key_L) );
  connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(saveAll()) );
  a->setWhatsThis(i18n("Save all open, modified documents to disk."));

  a = actionCollection()->addAction( "file_reload_all" );
  a->setText( i18n("&Reload All") );
  connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(reloadAll()) );
  a->setWhatsThis(i18n("Reload all open documents."));

  a = actionCollection()->addAction( "file_close_orphaned" );
  a->setText( i18n("Close Orphaned") );
  connect( a, SIGNAL(triggered()), KateDocManager::self(), SLOT(closeOrphaned()) );
  a->setWhatsThis(i18n("Close all documents in the file list that could not be reopened, because they are not accessible anymore."));

  actionCollection()->addAction( KStandardAction::Close, "file_close", m_viewManager, SLOT(slotDocumentClose()) )
  ->setWhatsThis(i18n("Close the current document."));

  a = actionCollection()->addAction( "file_close_other" );
  a->setText( i18n( "Close Other" ) );
  connect( a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseOther()) );
  a->setWhatsThis(i18n("Close other open documents."));

  a = actionCollection()->addAction( "file_close_all" );
  a->setText( i18n( "Clos&e All" ) );
  connect( a, SIGNAL(triggered()), this, SLOT(slotDocumentCloseAll()) );
  a->setWhatsThis(i18n("Close all open documents."));

  a = actionCollection()->addAction( KStandardAction::Quit, "file_quit" );
  // Qt::QueuedConnection: delay real shutdown, as we are inside menu action handling (bug #185708)
  connect( a, SIGNAL(triggered()), this, SLOT(slotFileQuit()), Qt::QueuedConnection );
  a->setWhatsThis(i18n("Close this window"));

  a = actionCollection()->addAction( "view_new_view" );
  a->setIcon( KIcon("window-new") );
  a->setText( i18n("&New Window") );
  connect( a, SIGNAL(triggered()), this, SLOT(newWindow()) );
  a->setWhatsThis(i18n("Create a new Kate view (a new window with the same document list)."));

  KToggleAction* showFullScreenAction = KStandardAction::fullScreen( 0, 0, this, this);
  actionCollection()->addAction( showFullScreenAction->objectName(), showFullScreenAction );
  connect( showFullScreenAction, SIGNAL(toggled(bool)), this, SLOT(slotFullScreen(bool)));

  documentOpenWith = new KActionMenu(i18n("Open W&ith"), this);
  actionCollection()->addAction("file_open_with", documentOpenWith);
  documentOpenWith->setWhatsThis(i18n("Open the current document using another application registered for its file type, or an application of your choice."));
  connect(documentOpenWith->menu(), SIGNAL(aboutToShow()), this, SLOT(mSlotFixOpenWithMenu()));
  connect(documentOpenWith->menu(), SIGNAL(triggered(QAction*)), this, SLOT(slotOpenWithMenuAction(QAction*)));

  a = KStandardAction::keyBindings(this, SLOT(editKeys()), actionCollection());
  a->setWhatsThis(i18n("Configure the application's keyboard shortcut assignments."));

  a = KStandardAction::configureToolbars(this, SLOT(slotEditToolbars()), actionCollection());
  a->setWhatsThis(i18n("Configure which items should appear in the toolbar(s)."));

  QAction* settingsConfigure = KStandardAction::preferences(this, SLOT(slotConfigure()), actionCollection());
  settingsConfigure->setWhatsThis(i18n("Configure various aspects of this application and the editing component."));

  // tip of the day :-)
  actionCollection()->addAction( KStandardAction::TipofDay, this, SLOT(tipOfTheDay()) )
  ->setWhatsThis(i18n("This shows useful tips on the use of this application."));

  if (KatePluginManager::self()->pluginList().count() > 0)
  {
    a = actionCollection()->addAction( "help_plugins_contents" );
    a->setText( i18n("&Plugins Handbook") );
    connect( a, SIGNAL(triggered()), this, SLOT(pluginHelp()) );
    a->setWhatsThis(i18n("This shows help files for various available plugins."));
  }

  a = actionCollection()->addAction( "help_about_editor" );
  a->setText( i18n("&About Editor Component") );
  connect( a, SIGNAL(triggered()), this, SLOT(aboutEditor()) );

  connect(m_viewManager, SIGNAL(viewChanged()), m_mainWindow, SIGNAL(viewChanged()));
  connect(m_viewManager, SIGNAL(viewCreated(KTextEditor::View*)), m_mainWindow, SIGNAL(viewCreated(KTextEditor::View*)));
  connect(m_viewManager, SIGNAL(viewChanged()), this, SLOT(slotWindowActivated()));
  connect(m_viewManager, SIGNAL(viewChanged()), this, SLOT(slotUpdateOpenWith()));
  connect(m_viewManager, SIGNAL(viewChanged()), this, SLOT(slotUpdateBottomViewBar()));
  connect(m_viewManager, SIGNAL(viewChanged()), this, SLOT(slotUpdateTopViewBar()));
  slotWindowActivated ();

  // session actions
  a = actionCollection()->addAction( "sessions_new" );
  a->setIcon( KIcon("document-new") );
  a->setText( i18nc("Menu entry Session->New", "&New") );
  // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
  connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionNew()), Qt::QueuedConnection );
  a = actionCollection()->addAction( "sessions_open" );
  a->setIcon( KIcon("document-open") );
  a->setText( i18n("&Open Session") );
  // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
  connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionOpen()), Qt::QueuedConnection );
  a = actionCollection()->addAction( "sessions_save" );
  a->setIcon( KIcon("document-save") );
  a->setText( i18n("&Save Session") );
  connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSave()) );
  a = actionCollection()->addAction( "sessions_save_as" );
  a->setIcon( KIcon("document-save-as") );
  a->setText( i18n("Save Session &As...") );
  connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionSaveAs()) );
  a = actionCollection()->addAction( "sessions_manage" );
  a->setIcon( KIcon("view-choose") );
  a->setText( i18n("&Manage Sessions...") );
  // Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
  connect( a, SIGNAL(triggered()), KateSessionManager::self(), SLOT(sessionManage()), Qt::QueuedConnection );

  // quick open menu ;)
  a = new KateSessionsAction (i18n("&Quick Open Session"), this);
  actionCollection()->addAction("sessions_list", a);
}