Commit ee644b4b authored by Robert Knight's avatar Robert Knight

Re-enable bookmark menu in the front end and make menu pick up the working...

Re-enable bookmark menu in the front end and make menu pick up the working directory of the current session when 'Add Bookmark' is clicked.  Not yet emitting the 'cd /bookmark/path' command when the bookmark is selected

svn path=/branches/work/konsole-split-view/; revision=637883
parent f03e7358
......@@ -23,23 +23,25 @@
// KDE
#include <kshell.h>
#include <kdebug.h>
#include <KBookmarkMenu>
#include <KDebug>
#include <KIO/Job>
#include <KIO/NetAccess>
#include <KMainWindow>
#include <KMenu>
#include <KStandardDirs>
#include <KIO/Job>
#include <KIO/NetAccess>
#include <KBookmarkMenu>
// Konsole
#include "KonsoleBookmarkHandler.h"
#include "SessionController.h"
KonsoleBookmarkHandler::KonsoleBookmarkHandler( KMainWindow* konsole, KMenu* menu, bool toplevel )
: QObject( konsole ),
KBookmarkOwner(),
m_konsole( konsole ),
m_toplevel(toplevel)
m_toplevel(toplevel),
m_controller( 0 )
{
setObjectName( "KonsoleBookmarkHandler" );
......@@ -97,14 +99,19 @@ bool KonsoleBookmarkHandler::editBookmarkEntry() const
QString KonsoleBookmarkHandler::currentUrl() const
{
qWarning() << __FILE__ << ":" << __FUNCTION__ << ": Needs to be implemented";
return QString(); //m_konsole->baseURL().prettyUrl();
if ( m_controller )
{
return m_controller->url().prettyUrl();
}
else
{
return QString(); //m_konsole->baseURL().prettyUrl();
}
}
QString KonsoleBookmarkHandler::currentTitle() const
{
qWarning() << __FILE__ << ":" << __FUNCTION__ << ": Needs to be implemented";
const KUrl &u = QString(); //m_konsole->baseURL();
const KUrl &u = m_controller ? m_controller->url() : KUrl();
if (u.isLocalFile())
{
QString path = u.path();
......@@ -114,4 +121,13 @@ QString KonsoleBookmarkHandler::currentTitle() const
return u.prettyUrl();
}
void KonsoleBookmarkHandler::setController( SessionController* controller )
{
m_controller = controller;
}
SessionController* KonsoleBookmarkHandler::controller() const
{
return m_controller;
}
#include "KonsoleBookmarkHandler.moc"
......@@ -31,6 +31,8 @@ class KBookmarkMenu;
class KBookmarkManager;
class KMainWindow;
class SessionController;
class KonsoleBookmarkHandler : public QObject, public KBookmarkOwner
{
Q_OBJECT
......@@ -48,18 +50,30 @@ public:
KMenu *menu() const { return m_menu; }
/**
* Sets the controller used to retrieve the current session URL when
* the "Add Bookmark" menu item is selected.
*/
void setController( SessionController* controller );
/**
* Returns the controller used to retrieve the current session URL when
* the "Add Bookmark" menu item is selected.
*/
SessionController* controller() const;
Q_SIGNALS:
void openUrl( const QString&, const QString& );
void openUrl( const QString& url , const QString& text );
private Q_SLOTS:
void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
private:
KMainWindow *m_konsole;
KMenu *m_menu;
KBookmarkMenu *m_bookmarkMenu;
KMainWindow* m_konsole;
KMenu* m_menu;
KBookmarkMenu* m_bookmarkMenu;
QString m_file;
bool m_toplevel;
SessionController* m_controller;
};
#endif // KONSOLEBOOKMARKHANDLER_H
......@@ -38,7 +38,8 @@
#include "ViewSplitter.h"
KonsoleMainWindow::KonsoleMainWindow()
: KMainWindow()
: KMainWindow() ,
_bookmarkHandler(0)
{
// add a small amount of space between the top of the window and the main widget
// to prevent the menu bar and main widget borders touching (which looks very ugly) in styles
......@@ -84,8 +85,9 @@ void KonsoleMainWindow::setupActions()
KStandardAction::quit( KonsoleApp::self() , SLOT(quit()) , collection );
// Bookmark Menu
//KActionMenu* bookmarkMenu = new KActionMenu(i18n("&Bookmarks"), collection,"bookmark");
//new KonsoleBookmarkHandler( this , bookmarkMenu->menu() , true );
KActionMenu* bookmarkMenu = new KActionMenu(i18n("&Bookmarks") , collection );
_bookmarkHandler = new KonsoleBookmarkHandler( this , bookmarkMenu->menu() , true );
collection->addAction("bookmark" , bookmarkMenu);
// Settings Menu
KStandardAction::configureNotifications( 0 , 0 , collection );
......@@ -93,6 +95,11 @@ void KonsoleMainWindow::setupActions()
KStandardAction::preferences( this , SLOT(showPreferencesDialog()) , collection );
}
KonsoleBookmarkHandler* KonsoleMainWindow::bookmarkHandler() const
{
return _bookmarkHandler;
}
void KonsoleMainWindow::setSessionList(SessionList* list)
{
unplugActionList("new-session-types");
......
......@@ -25,6 +25,7 @@
class ViewSplitter;
class ViewManager;
class SessionList;
class KonsoleBookmarkHandler;
/**
* The main window. This contains the menus and an area which contains the terminal displays.
......@@ -56,6 +57,11 @@ class KonsoleMainWindow : public KMainWindow
/** Sets the list of sessions to be displayed in the File menu */
void setSessionList(SessionList* list);
/**
* Returns the bookmark handler associated with this window.
*/
KonsoleBookmarkHandler* bookmarkHandler() const;
public slots:
/**
* Merges all of the KonsoleMainWindow widgets in the application into this window.
......@@ -86,6 +92,7 @@ class KonsoleMainWindow : public KMainWindow
private:
ViewManager* _viewManager;
KonsoleBookmarkHandler* _bookmarkHandler;
};
#endif // KONSOLEMAINWINDOW_H
......@@ -64,6 +64,11 @@ SessionController::~SessionController()
{
}
KUrl SessionController::url() const
{
return KUrl( _session->currentWorkingDirectory() + '/' );
}
bool SessionController::eventFilter(QObject* watched , QEvent* event)
{
if ( watched == _view )
......
......@@ -60,6 +60,8 @@ public:
/** Returns the view associated with this controller */
TEWidget* view() { return _view; }
// reimplemented
virtual KUrl url() const;
signals:
/**
* Emitted when the view associated with the controller is focused.
......
......@@ -27,6 +27,7 @@
#include <KXMLGUIFactory>
// Konsole
#include "KonsoleBookmarkHandler.h"
#include "KonsoleMainWindow.h"
#include "TESession.h"
#include "TEWidget.h"
......@@ -183,16 +184,20 @@ void ViewManager::viewFocused( SessionController* controller )
disconnect( controller , SIGNAL(titleChanged(ViewProperties*)),
this , SLOT(activeViewTitleChanged(ViewProperties*)) );
}
_pluggedController = controller;
// update the menus in the main window to use the actions from the active
// controller
_mainWindow->guiFactory()->addClient(controller);
// make the bookmark menu operate on the currently focused session
_mainWindow->bookmarkHandler()->setController(controller);
// update the caption of the main window to match that of the focused session
connect( controller , SIGNAL(titleChanged(ViewProperties*)),
this , SLOT(activeViewTitleChanged(ViewProperties*)) );
_pluggedController = controller;
//kDebug() << "Plugged actions for " << controller->session()->displayTitle() << endl;
}
......
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