summaryrefslogtreecommitdiffstats
path: root/kate/app/katemainwindow.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2016-10-08 23:57:24 +0900
committerMichele Calgaro <[email protected]>2016-10-08 23:57:24 +0900
commit6131095c14221ddbd16805059a9f3b3fc6c58225 (patch)
treeab3f49608e1141e8e61b2e65da8c6eee5953e2a8 /kate/app/katemainwindow.cpp
parent67642abd943f30babeea0c44397cc40e7c2c1b9e (diff)
downloadtdebase-6131095c14221ddbd16805059a9f3b3fc6c58225.tar.gz
tdebase-6131095c14221ddbd16805059a9f3b3fc6c58225.zip
Kate session panel: added "Sessions" menu support.
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'kate/app/katemainwindow.cpp')
-rw-r--r--kate/app/katemainwindow.cpp99
1 files changed, 85 insertions, 14 deletions
diff --git a/kate/app/katemainwindow.cpp b/kate/app/katemainwindow.cpp
index 4493eae12..1a021beb9 100644
--- a/kate/app/katemainwindow.cpp
+++ b/kate/app/katemainwindow.cpp
@@ -219,7 +219,7 @@ void KateMainWindow::setupMainWindow ()
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");
+ m_sessionpanel = new KateSessionPanel( this, m_viewManager, st, "sessionpanel");
// ONLY ALLOW SHELL ACCESS IF ALLOWED ;)
if (KateApp::self()->authorize("shell_access"))
@@ -305,17 +305,30 @@ void KateMainWindow::setupActions()
slotWindowActivated ();
-// FIXME to fix and enable again
// session actions
-/* new TDEAction(i18n("Menu entry Session->New", "&New"), "list-add", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionNew()), actionCollection(), "sessions_new");
- new TDEAction(i18n("&Open..."), "document-open", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionOpen()), actionCollection(), "sessions_open");
- new TDEAction(i18n("&Save"), "document-save", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionSave()), actionCollection(), "sessions_save");
- new TDEAction(i18n("Save &As..."), "document-save-as", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionSaveAs()), actionCollection(), "sessions_save_as");
- new TDEAction(i18n("&Manage..."), "view_choose", 0, TQT_TQOBJECT(OldKateSessionManager::self()), TQT_SLOT(sessionManage()), actionCollection(), "sessions_manage");
-
- // quick open menu ;)
- new OldKateSessionsAction (i18n("&Quick Open"), actionCollection(), "sessions_list");
-*/
+ new TDEAction(i18n("&New"), "list-add", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotNewSession()), actionCollection(), "session_new");
+ new TDEAction(i18n("&Save"), "document-save", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSaveSession()), actionCollection(), "session_save");
+ new TDEAction(i18n("Save &As..."), "document-save-as", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSaveSessionAs()), actionCollection(), "session_save_as");
+ new TDEAction(i18n("&Rename"), "edit_user", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotRenameSession()), actionCollection(), "session_rename");
+ new TDEAction(i18n("&Delete"), "edit-delete", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotDeleteSession()), actionCollection(), "session_delete");
+ new TDEAction(i18n("Re&load"), "reload", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotReloadSession()), actionCollection(), "session_reload");
+ new TDEAction(i18n("Acti&vate"), "forward", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotActivateSession()), actionCollection(), "session_activate");
+ new TDEToggleAction(i18n("Toggle read &only"), "encrypted", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionToggleReadOnly()), actionCollection(), "session_toggle_read_only");
+ new TDEAction(i18n("Move &Up"), "go-up", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionMoveUp()), actionCollection(), "session_move_up");
+ new TDEAction(i18n("Move Do&wn"), "go-down", 0,
+ TQT_TQOBJECT(m_sessionpanel), TQT_SLOT(slotSessionMoveDown()), actionCollection(), "session_move_down");
+ new KateSessionListActionMenu(this, i18n("Sele&ct session"), actionCollection(), "session_list");
+
+ connect(m_sessionpanel, TQT_SIGNAL(selectionChanged()), TQT_TQOBJECT(this), TQT_SLOT(slotSelectionChanged()));
}
KateTabWidget *KateMainWindow::tabWidget ()
@@ -857,10 +870,68 @@ void KateMainWindow::readProperties(TDEConfig *config)
config->setGroup(grp);
}
-void KateMainWindow::saveGlobalProperties( TDEConfig* sessionConfig )
+//-------------------------------------------
+void KateMainWindow::slotSelectionChanged()
+{
+ TDEActionCollection *mwac = actionCollection(); // Main Window Action Collection
+ TDEActionPtrList actionList = m_sessionpanel->m_actionCollection->actions();
+ TDEActionPtrList::ConstIterator spa_it;
+ for (spa_it = actionList.begin(); spa_it != actionList.end(); ++spa_it)
+ {
+ TDEAction *a = mwac->action((*spa_it)->name());
+ TDEToggleAction *ta = dynamic_cast<TDEToggleAction*>(a);
+ if (ta)
+ {
+ ta->setChecked((dynamic_cast<TDEToggleAction*>(*spa_it))->isChecked());
+ }
+ if (a)
+ {
+ a->setEnabled((*spa_it)->isEnabled());
+ }
+ }
+}
+
+//-------------------------------------------
+void KateMainWindow::activateSession(int sessionId)
+{
+ if (sessionId < 0 || sessionId == KateApp::self()->sessionManager()->getActiveSessionId())
+ {
+ return;
+ }
+
+ // Select the required session in the session panel's listview
+ TQListViewItem *item = m_sessionpanel->m_listview->firstChild();
+ int idx = 0;
+ while (item && idx < sessionId)
+ {
+ item = item->nextSibling();
+ ++idx;
+ }
+ if (idx == sessionId && item)
+ {
+ // Required session item found, switch session with consistent behavior
+ m_sessionpanel->m_listview->setSelected(item, true);
+ m_sessionpanel->slotActivateSession();
+ }
+}
+
+//-------------------------------------------
+KateSessionListActionMenu::KateSessionListActionMenu(KateMainWindow *mw, const TQString &text, TQObject *parent, const char *name)
+ : TDEActionMenu(text, parent, name), m_mainWindow(mw)
{
-// FIXME do we still need this code here?
-// KateDocManager::self()->saveDocumentList (sessionConfig);
+ connect(popupMenu(), TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(slotAboutToShow()));
+}
+
+//-------------------------------------------
+void KateSessionListActionMenu::slotAboutToShow()
+{
+ popupMenu()->clear();
+
+ TQPtrList<KateSession> &sessions = KateApp::self()->sessionManager()->getSessionsList();
+ for (int idx = 0; idx < (int)sessions.count(); ++idx)
+ {
+ popupMenu()->insertItem(sessions[idx]->getSessionName(), m_mainWindow, TQT_SLOT(activateSession(int)), 0, idx);
+ }
}
// kate: space-indent on; indent-width 2; replace-tabs on;