Commit 223a1817 authored by Victor Dodon's avatar Victor Dodon
Browse files

Manual set of tab title when automatic titles enabled

When "Show title bar contents in tab labels" is checked in settings, one cannot
set intectively the tab title. This patch allows to interactively set the tab
title, which is kept between change of settings. To clear to title set this
way, one just needs to edit and delete the title.

REVIEW: 124243
parent d077af71
......@@ -796,7 +796,7 @@ void TabBar::interactiveRenameDone()
m_renamingSessionId = -1;
setTabTitle(sessionId, m_lineEdit->text().trimmed());
setTabTitleInteractive(sessionId, m_lineEdit->text().trimmed());
}
void TabBar::selectTab(int sessionId)
......@@ -888,6 +888,7 @@ void TabBar::setTabTitle(int sessionId, const QString& newTitle)
{
if (sessionId == -1) return;
if (!m_tabTitles.contains(sessionId)) return;
if (m_tabTitlesSetInteractive.value(sessionId, false)) return;
if (!newTitle.isEmpty())
m_tabTitles[sessionId] = newTitle;
......@@ -895,6 +896,22 @@ void TabBar::setTabTitle(int sessionId, const QString& newTitle)
update();
}
void TabBar::setTabTitleInteractive(int sessionId, const QString& newTitle)
{
if (sessionId == -1) return;
if (!m_tabTitles.contains(sessionId)) return;
if (!newTitle.isEmpty())
{
m_tabTitles[sessionId] = newTitle;
m_tabTitlesSetInteractive[sessionId] = true;
}
else
m_tabTitlesSetInteractive.remove(sessionId);
update();
}
int TabBar::sessionAtTab(int index)
{
if (index > m_tabs.count() - 1)
......
......@@ -96,6 +96,8 @@ class TabBar : public QWidget
virtual void contextMenuEvent(QContextMenuEvent*);
virtual void leaveEvent(QEvent*);
void setTabTitleInteractive(int sessionId, const QString& newTitle);
private Q_SLOTS:
void readySessionMenu();
......@@ -144,6 +146,7 @@ class TabBar : public QWidget
QList<int> m_tabs;
QHash<int, QString> m_tabTitles;
QHash<int, bool> m_tabTitlesSetInteractive;
QList<int> m_tabWidths;
int m_selectedSessionId;
......
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