Commit 4643c9f9 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

provide menu with all sessions

have two menus for sessions:
  * one as is, last 10 recently used ones
  * second one with just all sessions

BUG: 451458
parent 18b96d13
......@@ -40,7 +40,7 @@ void KateSessionsActionTest::init()
QVERIFY(m_tempdir->isValid());
m_manager = new KateSessionManager(this, m_tempdir->path());
m_ac = new KateSessionsAction(QStringLiteral("menu"), this, m_manager);
m_ac = new KateSessionsAction(QStringLiteral("menu"), this, m_manager, false);
}
void KateSessionsActionTest::cleanup()
......
......@@ -106,7 +106,8 @@
<Menu name="sessions">
<text>Sess&amp;ions</text>
<Action name="sessions_new"/>
<Action name="sessions_list"/>
<Action name="session_open_recent"/>
<Action name="session_open_session"/>
<Action name="sessions_manage"/>
<Separator/>
<Action name="sessions_save"/>
......
......@@ -474,9 +474,13 @@ void KateMainWindow::setupActions()
// Qt::QueuedConnection to avoid deletion of code that is executed when reducing the amount of mainwindows. (bug #227008)
connect(a, &QAction::triggered, KateApp::self()->sessionManager(), &KateSessionManager::sessionManage, Qt::QueuedConnection);
// quick open menu ;)
a = new KateSessionsAction(i18n("&Quick Open Session"), this);
actionCollection()->addAction(QStringLiteral("sessions_list"), a);
// recent sessions menu
a = new KateSessionsAction(i18n("&Recent Sessions"), this, nullptr, false);
actionCollection()->addAction(QStringLiteral("session_open_recent"), a);
// session menu
a = new KateSessionsAction(i18n("&All Session"), this, nullptr, true);
actionCollection()->addAction(QStringLiteral("session_open_session"), a);
// location history actions
a = actionCollection()->addAction(QStringLiteral("view_history_back"));
......
......@@ -14,8 +14,9 @@
#include <QMenu>
#include <algorithm>
KateSessionsAction::KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager)
KateSessionsAction::KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager, bool allSessions)
: KActionMenu(text, parent)
, m_allSessions(allSessions)
{
m_manager = manager ? manager : KateApp::self()->sessionManager();
......@@ -39,9 +40,12 @@ void KateSessionsAction::slotAboutToShow()
qDeleteAll(sessionsGroup->actions());
KateSessionList slist = m_manager->sessionList();
std::sort(slist.begin(), slist.end(), KateSession::compareByTimeDesc);
slist = slist.mid(0, 10); // take first 10
// only show first 10 sessions for recent session menu?
if (!m_allSessions) {
std::sort(slist.begin(), slist.end(), KateSession::compareByTimeDesc);
slist = slist.mid(0, 10); // take first 10
}
// sort the reduced list alphabetically (#364089)
std::sort(slist.begin(), slist.end(), KateSession::compareByName);
......
......@@ -18,7 +18,7 @@ class KATE_TESTS_EXPORT KateSessionsAction : public KActionMenu
Q_OBJECT
public:
KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager = nullptr);
KateSessionsAction(const QString &text, QObject *parent, KateSessionManager *manager, bool allSessions);
public Q_SLOTS:
void slotAboutToShow();
......@@ -29,6 +29,7 @@ private:
friend class KateSessionsActionTest; // tfuj
QActionGroup *sessionsGroup;
KateSessionManager *m_manager;
const bool m_allSessions;
};
#endif
Supports Markdown
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