Commit e1b2ed35 authored by Esteban Martinena Guerrero's avatar Esteban Martinena Guerrero Committed by Nicolas Fella
Browse files

Consider renaming tabs via DBus interactive. This allows it to override a...

Consider renaming tabs via DBus interactive. This allows it to override a previouly interactively set title.

BUG: 428400


(cherry picked from commit ab4019e9)
parent 86adbfe5
......@@ -842,14 +842,14 @@ void MainWindow::applySettings()
if (Settings::dynamicTabTitles())
{
connect(m_sessionStack, SIGNAL(titleChanged(int,QString)),
m_tabBar, SLOT(setTabTitle(int,QString)));
m_tabBar, SLOT(setTabTitleAutomated(int,QString)));
m_sessionStack->emitTitles();
}
else
{
disconnect(m_sessionStack, SIGNAL(titleChanged(int,QString)),
m_tabBar, SLOT(setTabTitle(int,QString)));
m_tabBar, SLOT(setTabTitleAutomated(int,QString)));
}
m_animationTimer.setInterval(Settings::frames() ? 10 : 0);
......
......@@ -807,7 +807,7 @@ void TabBar::interactiveRenameDone()
m_renamingSessionId = -1;
setTabTitleInteractive(sessionId, m_lineEdit->text().trimmed());
setTabTitle(sessionId, m_lineEdit->text().trimmed());
}
void TabBar::selectTab(int sessionId)
......@@ -895,28 +895,17 @@ QString TabBar::tabTitle(int sessionId)
return QString();
}
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;
emit tabTitleEdited(sessionId, newTitle);
update();
}
void TabBar::setTabTitleInteractive(int sessionId, const QString& newTitle)
void TabBar::setTabTitle(int sessionId, const QString& newTitle, InteractiveType interactive)
{
if (sessionId == -1) return;
if (!m_tabTitles.contains(sessionId)) return;
if (!interactive && m_tabTitlesSetInteractive.value(sessionId, false)) return;
if (interactive)
m_tabTitlesSetInteractive[sessionId] = interactive;
if (!newTitle.isEmpty())
{
m_tabTitles[sessionId] = newTitle;
m_tabTitlesSetInteractive[sessionId] = true;
}
else
m_tabTitlesSetInteractive.remove(sessionId);
......@@ -925,6 +914,11 @@ void TabBar::setTabTitleInteractive(int sessionId, const QString& newTitle)
update();
}
void TabBar::setTabTitleAutomated(int sessionId, const QString& newTitle)
{
setTabTitle(sessionId, newTitle, NonInteractive);
}
int TabBar::sessionAtTab(int index)
{
if (index < 0 || index > m_tabs.count() - 1)
......
......@@ -44,6 +44,7 @@ class TabBar : public QWidget
Q_CLASSINFO("D-Bus Interface", "org.kde.yakuake")
public:
enum InteractiveType {NonInteractive=0, Interactive=1};
explicit TabBar(MainWindow* mainWindow);
~TabBar();
......@@ -64,7 +65,8 @@ class TabBar : public QWidget
void moveTabRight(int sessionId = -1);
Q_SCRIPTABLE QString tabTitle(int sessionId);
Q_SCRIPTABLE void setTabTitle(int sessionId, const QString& newTitle);
Q_SCRIPTABLE void setTabTitle(int sessionId, const QString& newTitle, InteractiveType interactive=Interactive);
void setTabTitleAutomated(int sessionId, const QString& newTitle);
Q_SCRIPTABLE int sessionAtTab(int index);
......@@ -97,8 +99,6 @@ class TabBar : public QWidget
void contextMenuEvent(QContextMenuEvent*) override;
void leaveEvent(QEvent*) override;
void setTabTitleInteractive(int sessionId, const QString& newTitle);
private Q_SLOTS:
void readySessionMenu();
......
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