Commit 1f07a21e authored by Eike Hein's avatar Eike Hein
Browse files

* Fixed interactive tab rename always renaming the active tab,

  rather than the tab the line edit was invoked for and shown
  on top of.
* Don't allow tab reordering by drag'n'drop during interactive
  rename.
* Some minor cleanup and optimization around tab renaming.

svn path=/trunk/extragear/utils/yakuake/; revision=952400
parent a2b229f2
......@@ -55,6 +55,8 @@ Changes since 2.9.5:
* Fixed the 'removeTerminal(int terminalId)' D-Bus call always closing the
active terminal of the session containing the target terminal, rather than
the target terminal.
* Fixed interactive tab rename always renaming the active tab, rather than
the tab the line edit was invoked for and shown on top of.
* Slightly improved options layout on the Behavior page of the configura-
tion dialog.
* On KDE 4.2 and higher, the first-run dialog now no longer allows setting
......
......@@ -50,6 +50,7 @@ TabBar::TabBar(MainWindow* mainWindow) : QWidget(mainWindow)
"<para>The tab bar allows you to switch between sessions. You can double-click a tab to edit its label.</para>"));
m_selectedSessionId = -1;
m_renamingSessionId = -1;
m_mousePressed = false;
m_mousePressedIndex = -1;
......@@ -88,7 +89,7 @@ TabBar::TabBar(MainWindow* mainWindow) : QWidget(mainWindow)
m_lineEdit->hide();
connect(m_lineEdit, SIGNAL(editingFinished()), m_lineEdit, SLOT(hide()));
connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(renameTab()));
connect(m_lineEdit, SIGNAL(returnPressed()), this, SLOT(interactiveRenameDone()));
setAcceptDrops(true);
}
......@@ -462,7 +463,7 @@ void TabBar::mouseMoveEvent(QMouseEvent* event)
{
int index = tabAt(m_startPos.x());
if (index >= 0)
if (index >= 0 && !m_lineEdit->isVisible())
startDrag(index);
}
}
......@@ -601,7 +602,7 @@ void TabBar::removeTab(int sessionId)
int index = m_tabs.indexOf(sessionId);
if (m_lineEdit->isVisible() && index == m_editingSessionId)
if (m_lineEdit->isVisible() && sessionId == m_renamingSessionId)
m_lineEdit->hide();
m_tabs.removeAt(index);
......@@ -615,16 +616,13 @@ void TabBar::removeTab(int sessionId)
void TabBar::renameTab(int sessionId, const QString& newTitle)
{
if (sessionId == -1) sessionId = m_selectedSessionId;
if (sessionId == -1) return;
if (!m_tabTitles.contains(sessionId)) return;
if (newTitle.isEmpty() && !m_lineEdit->text().isEmpty())
m_tabTitles[sessionId] = m_lineEdit->text().trimmed();
else
if (!newTitle.isEmpty())
m_tabTitles[sessionId] = newTitle;
repaint();
update();
}
void TabBar::interactiveRename(int sessionId)
......@@ -637,7 +635,7 @@ void TabBar::interactiveRename(int sessionId)
int y = m_skin->tabBarPosition().y();
int width = m_tabWidths.at(index) - x;
m_editingSessionId = index;
m_renamingSessionId = index;
m_lineEdit->setText(m_tabTitles[sessionId]);
m_lineEdit->setGeometry(x-1, y-1, width+3, height()+2);
......@@ -646,6 +644,15 @@ void TabBar::interactiveRename(int sessionId)
m_lineEdit->show();
}
void TabBar::interactiveRenameDone()
{
int sessionId = m_renamingSessionId;
m_renamingSessionId = -1;
renameTab(sessionId, m_lineEdit->text().trimmed());
}
void TabBar::selectTab(int sessionId)
{
if (!m_tabs.contains(sessionId)) return;
......
......@@ -101,19 +101,22 @@ class TabBar : public QWidget
private slots:
void readyTabContextMenu();
void readySessionMenu();
void contextMenuActionHovered(QAction* action);
void closeTabButtonClicked();
void interactiveRenameDone();
private:
QString standardTabTitle();
QString makeTabTitle(int number);
int tabAt(int x);
void readyTabContextMenu();
void updateMoveActions(int index);
void updateToggleActions(int sessionId);
void updateToggleKeyboardInputMenu(int sessionId = -1);
......@@ -136,7 +139,7 @@ class TabBar : public QWidget
KMenu* m_sessionMenu;
KLineEdit* m_lineEdit;
int m_editingSessionId;
int m_renamingSessionId;
QList<int> m_tabs;
QHash<int, QString> m_tabTitles;
......
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