Commit 6ae99927 authored by Robert Knight's avatar Robert Knight

Add beginnings of a XMLGUI-based menu to Konsole.

svn path=/branches/work/konsole-split-view/; revision=616882
parent 13ba2637
......@@ -7,4 +7,4 @@ install( FILES terminalemulator.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR
install( FILES konsolepart.desktop kwrited.desktop konsole-script.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
install( FILES konsolehere.desktop DESTINATION ${DATA_INSTALL_DIR}/konqueror/servicemenus )
install( FILES kwrited.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded )
install( FILES konsole.notifyrc tips DESTINATION ${DATA_INSTALL_DIR}/konsole )
install( FILES konsole.notifyrc tips konsoleui.rc DESTINATION ${DATA_INSTALL_DIR}/konsole )
<!DOCTYPE kpartgui>
<kpartgui name="konsole">
<MenuBar>
<Menu name="file"><text>File</text>
<Action name="new-tab" />
<Action name="new-window" />
<Separator/>
<DefineGroup name="new-session-operations"/>
<Separator/>
<Action name="close-session"/>
<Action name="exit" />
</Menu>
<Menu name="edit"><text>Edit</text>
<DefineGroup name="edit-operations"/>
</Menu>
<Menu name="view"><text>View</text>
<DefineGroup name="view-operations"/>
</Menu>
<Action name="bookmark">
</Menu>
<Menu name="settings"><text>Settings</text>
<DefineGroup name="session-settings"/>
<Separator/>
<Action name="configure-notifications"/>
<Action name="configure-shortcuts"/>
<Action name="configure-application"/>
</Menu>
<Menu name="help"><text>Help</text>
</Menu>
</MenuBar>
</kpartgui>
......@@ -61,6 +61,10 @@ set(konsole_KDEINIT_SRCS
TEHistory.cpp
TEScreen.cpp
TEWidget.cpp
ViewContainer.cpp
ViewManager.cpp
ViewSplitter.cpp
konsolebookmarkhandler.cpp
zmodem_dialog.cpp
keytrans.cpp
BlockArray.cpp
......
......@@ -53,3 +53,5 @@ SessionManager* KonsoleApp::sessionManager()
{
return _sessionManager;
}
#include "KonsoleApp.moc"
......@@ -17,6 +17,9 @@
02110-1301 USA.
*/
#ifndef KONSOLEAPP_H
#define KONSOLEAPP_H
// KDE
#include <KUniqueApplication>
......@@ -28,6 +31,8 @@ class SessionManager;
*/
class KonsoleApp : public KUniqueApplication
{
Q_OBJECT
public:
/** Constructs a new Konsole application. */
KonsoleApp();
......@@ -46,3 +51,5 @@ private:
SessionManager* _sessionManager;
};
#endif //KONSOLEAPP_H
......@@ -17,10 +17,64 @@
02110-1301 USA.
*/
// KDE
#include <KAction>
#include <KActionCollection>
#include <KActionMenu>
#include <KLocale>
#include <KMenu>
#include <kstandardaction.h>
// Konsole
#include "konsolebookmarkhandler.h"
#include "KonsoleApp.h"
#include "KonsoleMainWindow.h"
#include "ViewManager.h"
#include "ViewSplitter.h"
KonsoleMainWindow::KonsoleMainWindow()
: KMainWindow()
{
// create main window widgets
setupWidgets();
// create actions for menus
setupActions();
// create view manager
_viewManager = new ViewManager(this);
// create menus
setXMLFile("konsoleui.rc");
createGUI();
}
void KonsoleMainWindow::setupActions()
{
// File Menu
new KAction( i18n("New &Tab") , actionCollection() , "new-tab" );
new KAction( i18n("New &Window") , actionCollection() , "new-window" );
KStandardAction::quit( KonsoleApp::self() , SLOT(quit()) , actionCollection() ,"exit");
// Bookmark Menu
KActionMenu* bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), actionCollection(),"bookmark");
new KonsoleBookmarkHandler( this , bookmarkMenu->menu() , true );
// Settings Menu
KStandardAction::configureNotifications( 0 , 0 , actionCollection() , "configure-notifications" );
KStandardAction::keyBindings( 0 , 0 , actionCollection() , "configure-shortcuts" );
KStandardAction::preferences( 0 , 0 , actionCollection() , "configure-application" );
}
void KonsoleMainWindow::setupWidgets()
{
// create main view area
_viewSplitter = new ViewSplitter(this);
setCentralWidget(_viewSplitter);
}
#include "KonsoleMainWindow.moc"
#ifndef KONSOLEMAINWINDOW_H
#define KONSOLEMAINWINDOW_H
#include <KMainWindow>
class ViewSplitter;
class ViewManager;
class KonsoleMainWindow : public KMainWindow
{
Q_OBJECT
public:
KonsoleMainWindow();
protected:
void setupActions();
void setupWidgets();
private:
ViewSplitter* m_viewSplitter;
ViewSplitter* _viewSplitter;
ViewManager* _viewManager;
};
#endif // KONSOLEMAINWINDOW_H
......@@ -35,7 +35,6 @@
#include <ktabwidget.h>
// Konsole
#include "NavigationItem.h"
#include "ViewContainer.h"
void ViewContainer::addView(QWidget* view , NavigationItem* item)
......@@ -149,10 +148,10 @@ void TabbedViewContainer::showContextMenu(QWidget* widget , const QPoint& positi
{
//TODO - Use the tab under the mouse, not just the active tab
_contextMenuTab = _tabWidget->indexOf(widget);
NavigationItem* item = navigationItem( widget );
//NavigationItem* item = navigationItem( widget );
_tabContextMenu->clear();
_tabContextMenu->addActions( item->contextMenuActions(_viewActions) );
// _tabContextMenu->addActions( item->contextMenuActions(_viewActions) );
_tabContextMenu->popup( position );
}
......@@ -172,10 +171,10 @@ void TabbedViewContainer::prepareColorCells()
void TabbedViewContainer::viewAdded( QWidget* view )
{
NavigationItem* item = navigationItem(view);
connect( item , SIGNAL(titleChanged(NavigationItem*)) , this , SLOT(updateTitle(NavigationItem*)));
connect( item , SIGNAL(iconChanged(NavigationItem*) ) , this ,SLOT(updateIcon(NavigationItem*)));
_tabWidget->addTab( view , item->icon() , item->title() );
// NavigationItem* item = navigationItem(view);
// connect( item , SIGNAL(titleChanged(NavigationItem*)) , this , SLOT(updateTitle(NavigationItem*)));
// connect( item , SIGNAL(iconChanged(NavigationItem*) ) , this ,SLOT(updateIcon(NavigationItem*)));
_tabWidget->addTab( view , "Tab" ); //, item->icon() , item->title() );
}
void TabbedViewContainer::viewRemoved( QWidget* view )
{
......@@ -193,8 +192,8 @@ void TabbedViewContainer::updateIcon(NavigationItem* item)
while ( itemIter.hasNext() )
{
int index = _tabWidget->indexOf( itemIter.next() );
_tabWidget->setTabIcon( index , item->icon() );
//int index = _tabWidget->indexOf( itemIter.next() );
// _tabWidget->setTabIcon( index , item->icon() );
}
}
void TabbedViewContainer::updateTitle(NavigationItem* item)
......@@ -206,8 +205,8 @@ void TabbedViewContainer::updateTitle(NavigationItem* item)
while ( itemIter.hasNext() )
{
int index = _tabWidget->indexOf( itemIter.next() );
_tabWidget->setTabText( index , item->title() );
//int index = _tabWidget->indexOf( itemIter.next() );
//_tabWidget->setTabText( index , item->title() );
}
}
......@@ -278,7 +277,7 @@ void StackedViewContainer::viewAdded( QWidget* view )
{
_stackWidget->addWidget(view);
}
void StackedViewContainer::viewRemoved( QWidget* view )
void StackedViewContainer::viewRemoved( QWidget* /*view*/ )
{}
#include "ViewContainer.moc"
......@@ -111,7 +111,7 @@ void ViewSplitter::addContainer( ViewContainer* container ,
}
else
{
ViewSplitter* newSplitter = new ViewSplitter();
ViewSplitter* newSplitter = new ViewSplitter(this);
connect( newSplitter , SIGNAL(empty(ViewSplitter*)) , splitter , SLOT(childEmpty(ViewSplitter*)) );
ViewContainer* oldContainer = splitter->activeContainer();
......
......@@ -44,6 +44,8 @@ class ViewSplitter : public QSplitter
Q_OBJECT
public:
ViewSplitter(QWidget* parent) : QSplitter(parent) {}
/**
* Locates the child ViewSplitter widget which currently has the focus
* and inserts the container into it.
......
......@@ -18,19 +18,24 @@
// Born as kdelibs/kio/kfile/kfilebookmarkhandler.cpp
#include <kmenu.h>
#include <kstandarddirs.h>
// Qt
#include <QFile>
// KDE
#include <kshell.h>
#include <kio/job.h>
#include <kio/netaccess.h>
#include <kdebug.h>
#include <kbookmarkmenu.h>
#include <QFile>
#include "konsole.h"
#include <KMainWindow>
#include <KMenu>
#include <KStandardDirs>
#include <KIO/Job>
#include <KIO/NetAccess>
#include <KBookmarkMenu>
// Konsole
#include "konsolebookmarkhandler.h"
KonsoleBookmarkHandler::KonsoleBookmarkHandler( Konsole *konsole, bool toplevel )
KonsoleBookmarkHandler::KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* menu, bool toplevel )
: QObject( konsole ),
KBookmarkOwner(),
m_konsole( konsole ),
......@@ -38,7 +43,7 @@ KonsoleBookmarkHandler::KonsoleBookmarkHandler( Konsole *konsole, bool toplevel
{
setObjectName( "KonsoleBookmarkHandler" );
m_menu = new KMenu( konsole );
m_menu = menu;
// KDE3.5 - Konsole's bookmarks are now in konsole/bookmarks.xml
// TODO: Consider removing for KDE4
......@@ -58,7 +63,9 @@ KonsoleBookmarkHandler::KonsoleBookmarkHandler( Konsole *konsole, bool toplevel
m_file = KStandardDirs::locateLocal( "data", "konsole/bookmarks.xml" );
KBookmarkManager *manager = KBookmarkManager::managerForFile( m_file, "konsole", false);
manager->setEditorOptions(kapp->caption(), false);
//TODO: Replace KApp with KonsoleApp::self()
//manager->setEditorOptions(KApp->caption(), false);
manager->setUpdate( true );
if (toplevel) {
......@@ -92,12 +99,14 @@ bool KonsoleBookmarkHandler::editBookmarkEntry() const
QString KonsoleBookmarkHandler::currentUrl() const
{
return m_konsole->baseURL().prettyUrl();
qWarning() << __FILE__ << ":" << __FUNCTION__ << ": Needs to be implemented";
return QString(); //m_konsole->baseURL().prettyUrl();
}
QString KonsoleBookmarkHandler::currentTitle() const
{
const KUrl &u = m_konsole->baseURL();
qWarning() << __FILE__ << ":" << __FUNCTION__ << ": Needs to be implemented";
const KUrl &u = QString(); //m_konsole->baseURL();
if (u.isLocalFile())
{
QString path = u.path();
......
......@@ -29,13 +29,14 @@
class KMenu;
class KBookmarkMenu;
class KBookmarkManager;
class KMainWindow;
class KonsoleBookmarkHandler : public QObject, public KBookmarkOwner
{
Q_OBJECT
public:
KonsoleBookmarkHandler( Konsole *konsole, bool toplevel );
KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* menu, bool toplevel );
~KonsoleBookmarkHandler();
QMenu * popupMenu();
......@@ -54,7 +55,7 @@ private Q_SLOTS:
void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
private:
Konsole *m_konsole;
KMainWindow *m_konsole;
KMenu *m_menu;
KBookmarkMenu *m_bookmarkMenu;
QString m_file;
......
......@@ -28,7 +28,12 @@
extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
{
KAboutData about("konsole",i18n("Konsole").toLocal8Bit().data(),KONSOLE_VERSION);
KAboutData about( "konsole",
I18N_NOOP("Konsole"),
KONSOLE_VERSION,
I18N_NOOP("Terminal emulator for KDE"),
KAboutData::License_GPL_V2
);
KCmdLineArgs::init(argc,argv,&about);
KUniqueApplication::addCmdLineOptions();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment