From 192b7af94830ff981760570254cce1a27a81d341 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 10 Aug 2015 16:45:54 +0900 Subject: Added Kate session panel. This commit contains the GUI elements. The logic will be added in a separate commit. Signed-off-by: Michele Calgaro --- kate/app/CMakeLists.txt | 4 +- kate/app/Makefile.am | 2 +- kate/app/katemain.h | 1 + kate/app/katemainwindow.cpp | 10 ++- kate/app/katemainwindow.h | 1 + kate/app/katesessionpanel.cpp | 185 ++++++++++++++++++++++++++++++++++++++++++ kate/app/katesessionpanel.h | 92 +++++++++++++++++++++ 7 files changed, 289 insertions(+), 6 deletions(-) create mode 100644 kate/app/katesessionpanel.cpp create mode 100644 kate/app/katesessionpanel.h (limited to 'kate/app') diff --git a/kate/app/CMakeLists.txt b/kate/app/CMakeLists.txt index 7adea8ea3..77908ffcf 100644 --- a/kate/app/CMakeLists.txt +++ b/kate/app/CMakeLists.txt @@ -38,8 +38,8 @@ set( ${target}_SRCS kbookmarkhandler.cpp katedocmanageriface.skel kateappIface.cpp kateappIface.skel katedocmanageriface.cpp kateexternaltools.cpp katesavemodifieddialog.cpp kateviewspacecontainer.cpp - katemwmodonhddialog.cpp katesession.cpp katemdi.cpp - katetabwidget.cpp + katemwmodonhddialog.cpp katesession.cpp katesessionpanel.cpp + katemdi.cpp katetabwidget.cpp ) tde_add_library( ${target} SHARED AUTOMOC diff --git a/kate/app/Makefile.am b/kate/app/Makefile.am index de2258630..c50f68562 100644 --- a/kate/app/Makefile.am +++ b/kate/app/Makefile.am @@ -10,7 +10,7 @@ libkateinterfaces_la_SOURCES = kateapp.cpp kateconfigdialog.cpp kateconfigplugin katemailfilesdialog.cpp kbookmarkhandler.cpp \ katedocmanageriface.skel kateappIface.cpp kateappIface.skel katedocmanageriface.cpp \ kateexternaltools.cpp katesavemodifieddialog.cpp kateviewspacecontainer.cpp \ - katemwmodonhddialog.cpp katesession.cpp katemdi.cpp katetabwidget.cpp + katemwmodonhddialog.cpp katesession.cpp katesessionpanel.cpp katemdi.cpp katetabwidget.cpp libkateinterfaces_la_LIBADD = ../interfaces/libkateinterfacesprivate.la $(LIB_TDEUTILS) ../utils/libkateutils.la diff --git a/kate/app/katemain.h b/kate/app/katemain.h index 374b834cc..24663f58f 100644 --- a/kate/app/katemain.h +++ b/kate/app/katemain.h @@ -60,6 +60,7 @@ class KateConsole; class KateDocManager; class KateFileList; class KateFileSelector; +class KateSessionPanel; class KateMainWindow; class KatePluginIface; class KatePluginManager; diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp index 0bcf08883..a867cb418 100644 --- a/kate/app/katemainwindow.cpp +++ b/kate/app/katemainwindow.cpp @@ -31,6 +31,7 @@ #include "kateapp.h" #include "katefileselector.h" #include "katefilelist.h" +#include "katesessionpanel.h" #include "kategrepdialog.h" #include "katemailfilesdialog.h" #include "katemainwindowiface.h" @@ -217,6 +218,9 @@ void KateMainWindow::setupMainWindow () fileselector = new KateFileSelector( this, m_viewManager, t, "operator"); connect(fileselector->dirOperator(),TQT_SIGNAL(fileSelected(const KFileItem*)),this,TQT_SLOT(fileSelected(const KFileItem*))); + KateMDI::ToolView *st = createToolView("kate_sessionpanel", KMultiTabBar::Left, SmallIcon("view_choose"), i18n("Sessions")); + sessionpanel = new KateSessionPanel( this, m_viewManager, st, "sessionpanel"); + // ONLY ALLOW SHELL ACCESS IF ALLOWED ;) if (KateApp::self()->authorize("shell_access")) { @@ -302,7 +306,7 @@ void KateMainWindow::setupActions() slotWindowActivated (); // session actions - new TDEAction(i18n("Menu entry Session->New", "&New"), "document-new", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new"); + new TDEAction(i18n("Menu entry Session->New", "&New"), "list-add", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new"); new TDEAction(i18n("&Open..."), "document-open", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionOpen()), actionCollection(), "sessions_open"); new TDEAction(i18n("&Save"), "document-save", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionSave()), actionCollection(), "sessions_save"); new TDEAction(i18n("Save &As..."), "document-save-as", 0, TQT_TQOBJECT(KateSessionManager::self()), TQT_SLOT(sessionSaveAs()), actionCollection(), "sessions_save_as"); @@ -434,7 +438,7 @@ void KateMainWindow::saveOptions () config->writeEntry("Show Full Path in Title", m_viewManager->getShowFullPath()); config->writeEntry("Sync Konsole", syncKonsole); config->writeEntry("UseInstance", useInstance); - + fileOpenRecent->saveEntries(config, "Recent Files"); fileselector->writeConfig(config, "fileselector"); filelist->writeConfig(config, "Filelist"); @@ -482,7 +486,7 @@ void KateMainWindow::documentMenuAboutToShow() TQListViewItem * item = filelist->firstChild(); while( item ) { // would it be saner to use the screen width as a limit that some random number?? - TQString name = KStringHandler::rsqueeze( ((KateFileListItem *)item)->document()->docName(), 150 ); + TQString name = KStringHandler::rsqueeze( ((KateFileListItem *)item)->document()->docName(), 150 ); Kate::Document* doc = ((KateFileListItem *)item)->document(); documentMenu->insertItem ( doc->isModified() ? i18n("'document name [*]', [*] means modified", "%1 [*]").arg(name) : name, diff --git a/kate/app/katemainwindow.h b/kate/app/katemainwindow.h index 157b4e57d..15b7f35c6 100644 --- a/kate/app/katemainwindow.h +++ b/kate/app/katemainwindow.h @@ -198,6 +198,7 @@ class KateMainWindow : public KateMDI::MainWindow, virtual public KParts::PartBa KateFileList *filelist; KateFileSelector *fileselector; + KateSessionPanel *sessionpanel; TDEActionMenu* documentOpenWith; diff --git a/kate/app/katesessionpanel.cpp b/kate/app/katesessionpanel.cpp new file mode 100644 index 000000000..da595b15e --- /dev/null +++ b/kate/app/katesessionpanel.cpp @@ -0,0 +1,185 @@ +/* This file is part of the TDE project + Copyright (C) 2015 Michele Calgaro + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "katesessionpanel.h" +#include "katesessionpanel.moc" + +#include "katemainwindow.h" +#include "kateviewmanager.h" +#include "katesession.h" + +#include +#include + + +void KateSessionPanelToolBarParent::setToolBar(TDEToolBar *tbar) +{ + m_tbar = tbar; +} + +//------------------------------------------- +void KateSessionPanelToolBarParent::resizeEvent (TQResizeEvent*) +{ + if (m_tbar) + { + setMinimumHeight(m_tbar->sizeHint().height()); + m_tbar->resize(width(),height()); + } +} + +//------------------------------------------- +KateSessionPanel::KateSessionPanel(KateMainWindow *mainWindow, KateViewManager *viewManager, + TQWidget *parent, const char *name) + : TQVBox(parent, name), m_mainWin(mainWindow), m_viewManager(viewManager), + m_sessionManager(KateSessionManager::self()), m_actionCollection(new TDEActionCollection(this)) +{ + // Toolbar + setup_toolbar(); + + // Listview + m_listview = new TDEListView(this); + m_listview->setRootIsDecorated(true); + m_listview->setSorting(-1); + m_listview->setMinimumWidth(m_listview->sizeHint().width()); +} + +//------------------------------------------- +void KateSessionPanel::setup_toolbar() +{ + // Toolbar widget and frame + KateSessionPanelToolBarParent *tbarParent=new KateSessionPanelToolBarParent(this); + m_toolbar = new TDEToolBar(tbarParent, "Kate Session Panel Toolbar", true); + tbarParent->setToolBar(m_toolbar); + m_toolbar->setMovingEnabled(false); + m_toolbar->setFlat(true); + m_toolbar->setIconText(TDEToolBar::IconOnly); + m_toolbar->setIconSize(16); + m_toolbar->setEnableContextMenu(false); + + // Toolbar actions + TDEAction *a; + a = new TDEAction(i18n("New"), SmallIcon("list-add"), 0, + TQT_TQOBJECT(m_sessionManager), TQT_SLOT(sessionNew()), m_actionCollection, "session_new"); + a->setWhatsThis(i18n("Create a new session.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Save"), SmallIcon("document-save"), 0, + TQT_TQOBJECT(this), TQT_SLOT(saveSession()), m_actionCollection, "session_save"); + a->setWhatsThis(i18n("Save the current session.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Save as..."), SmallIcon("document-save-as"), 0, + TQT_TQOBJECT(this), TQT_SLOT(saveSessionAs()), m_actionCollection, "session_save_as"); + a->setWhatsThis(i18n("Save the current session with a different name.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Rename"), SmallIcon("edit_user"), 0, + TQT_TQOBJECT(this), TQT_SLOT(renameSession()), m_actionCollection, "session_rename"); + a->setWhatsThis(i18n("Rename the selected session.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Delete"), SmallIcon("edit-delete"), 0, + TQT_TQOBJECT(this), TQT_SLOT(deleteSession()), m_actionCollection, "session_delete"); + a->setWhatsThis(i18n("Delete the selected session.")); + a->plug(m_toolbar); + + m_toolbar->insertLineSeparator(); + + a = new TDEAction(i18n("Activate"), SmallIcon("forward"), 0, + TQT_TQOBJECT(this), TQT_SLOT(sessionActivate()), m_actionCollection, "session_activate"); + a->setWhatsThis(i18n("Activate the selected session.")); + a->plug(m_toolbar); + + TDEToggleAction *tglA = new TDEToggleAction(i18n("Toggle read only"), SmallIcon("encrypted"), 0, + TQT_TQOBJECT(this), TQT_SLOT(sessionToggleReadOnly()), m_actionCollection, "session_toggle_read_only"); + tglA->setWhatsThis(i18n("Toggle read only status for the selected session.

" + "In a read only session, you can work as usual but the list of documents in the session " + "will not be saved when you exit Kate or switch to another session.

" + "You can use this option to create template sessions that you wish to keep unchanged over time.")); + tglA->plug(m_toolbar); + + a = new TDEAction(i18n("Move Up"), SmallIcon("go-up"), 0, + TQT_TQOBJECT(this), TQT_SLOT(sessionMoveUp()), m_actionCollection, "session_move_up"); + a->setWhatsThis(i18n("Move up the selected session.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Move Down"), SmallIcon("go-down"), 0, + TQT_TQOBJECT(this), TQT_SLOT(sessionMoveDown()), m_actionCollection, "session_move_down"); + a->setWhatsThis(i18n("Move down the selected session.")); + a->plug(m_toolbar); + + m_toolbar->insertLineSeparator(); + + a = new TDEAction(i18n("Open"), SmallIcon("document-open"), 0, + TQT_TQOBJECT(m_sessionManager), TQT_SLOT(sessionOpen()), m_actionCollection, "session_open"); + a->setWhatsThis(i18n("Switch to another session chosen from a list of existing ones.")); + a->plug(m_toolbar); + + a = new TDEAction(i18n("Manage"), SmallIcon("view_choose"), 0, + TQT_TQOBJECT(m_sessionManager), TQT_SLOT(sessionManage()), m_actionCollection, "session_manage"); + a->setWhatsThis(i18n("Manage existing sessions.")); + a->plug(m_toolbar); +} + +//------------------------------------------- +void KateSessionPanel::saveSession() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::saveSessionAs() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::renameSession() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::deleteSession() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::sessionActivate() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::sessionToggleReadOnly() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::sessionMoveUp() +{ +//TODO +} + +//------------------------------------------- +void KateSessionPanel::sessionMoveDown() +{ +//TODO +} diff --git a/kate/app/katesessionpanel.h b/kate/app/katesessionpanel.h new file mode 100644 index 000000000..f110fd32b --- /dev/null +++ b/kate/app/katesessionpanel.h @@ -0,0 +1,92 @@ +/* This file is part of the TDE project + Copyright (C) 2015 Michele Calgaro + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __KATE_SESSIONPANEL_H__ +#define __KATE_SESSIONPANEL_H__ + +/* + The kate session panel displays the available sessions (and their documents) + in a treeview list and allows for quick switching among them. + A toolbar on the top also provides quick access to actions needed + to manage sessions. +*/ + +#include +#include +#include +#include + +class KateMainWindow; +class KateViewManager; +class KateSessionManager; +class TDEActionCollection; + + +class KateSessionPanelToolBarParent: public TQFrame +{ + Q_OBJECT + + public: + KateSessionPanelToolBarParent(TQWidget *parent) : TQFrame(parent), m_tbar(0) {} + ~KateSessionPanelToolBarParent() {} + void setToolBar(TDEToolBar *tbar); + + protected: + virtual void resizeEvent (TQResizeEvent*); + + private: + TDEToolBar *m_tbar; +}; + + + +class KateSessionPanel : public TQVBox +{ + Q_OBJECT + + public: + + KateSessionPanel(KateMainWindow *mainWindow=0, KateViewManager *viewManager=0, + TQWidget *parent=0, const char *name=0); + ~KateSessionPanel() {} + + public slots: + void saveSession(); + void saveSessionAs(); + void renameSession(); + void deleteSession(); + void sessionActivate(); + void sessionToggleReadOnly(); + void sessionMoveUp(); + void sessionMoveDown(); + + private: + void setup_toolbar(); + + KateMainWindow *m_mainWin; + KateViewManager *m_viewManager; + KateSessionManager *m_sessionManager; + TDEActionCollection *m_actionCollection; + + TDEToolBar *m_toolbar; + TDEListView *m_listview; +}; + + +#endif //__KATE_SESSIONPANEL_H__ +// kate: space-indent on; indent-width 2; replace-tabs on; -- cgit v1.2.1