Commit c7056336 authored by Eike Hein's avatar Eike Hein
Browse files

* Fixed a bug that could cause actions also available from the tab context

  menu to operate on the wrong session when triggered by keyboard shortcut
  and the context menu had been used previously.
* Fixed the "Close Active Terminal", "Split Left/Right" and "Split Top/Bot-
  tom" actions not operating on the correct session when activated from the
  context menu of a tab other than the active tab.

svn path=/trunk/extragear/utils/yakuake/; revision=787263
parent d6e4e8aa
Changes since 2.9:
* Fixed Open/Retract action not working with versions of KDE 4 trunk (4.1)
after March 10th, 2008.
* Starting Yakuake a second time now toggles the window state, making it
* Starting Yakuake a second time now toggles the window state, making it
possible to open and retract Yakuake from a panel button or simply run-
ning the executable.
* Disabled standard startup notifications ("Launch Feedback") for Yakuake.
* Fixed Open/Retract action not working with versions of KDE 4 trunk (4.1)
after March 10th, 2008.
* Fixed a bug that could cause actions also available from the tab context
menu to operate on the wrong session when triggered by keyboard shortcut
and the context menu had been used previously.
* Fixed the "Close Active Terminal", "Split Left/Right" and "Split Top/Bot-
tom" actions not operating on the correct session when activated from the
context menu of a tab other than the active tab.
* Some additions to the KDE4FAQ file.
......
......@@ -64,7 +64,7 @@ int main (int argc, char *argv[])
if (!KUniqueApplication::start())
{
fprintf(stderr, "Yakuake is already running!\n");
fprintf(stderr, "Yakuake is already running! Opening window ...\n");
exit(0);
}
......
......@@ -163,7 +163,8 @@ void MainWindow::setupActions()
action = actionCollection()->addAction("edit-profile");
action->setText(i18nc("@action", "Edit Current Profile..."));
action->setIcon(KIcon("document-properties"));
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("increase-window-width");
action->setText(i18nc("@action", "Increase Window Width"));
......@@ -210,7 +211,8 @@ void MainWindow::setupActions()
action->setText(i18nc("@action", "Close Session"));
action->setIcon(KIcon("tab-close"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_S));
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("previous-session");
action->setText(i18nc("@action", "Previous Session"));
......@@ -228,18 +230,21 @@ void MainWindow::setupActions()
action->setText(i18nc("@action", "Move Session Left"));
action->setIcon(KIcon("arrow-left"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Left));
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("move-session-right");
action->setText(i18nc("@action", "Move Session Right"));
action->setIcon(KIcon("arrow-right"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_Right));
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("rename-session");
action->setText(i18nc("@action", "Rename Session..."));
action->setIcon(KIcon("edit-rename"));
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("previous-terminal");
action->setText(i18nc("@action", "Previous Terminal"));
......@@ -258,51 +263,80 @@ void MainWindow::setupActions()
action->setIcon(KIcon("view-close"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R));
connect(action, SIGNAL(triggered()), m_sessionStack, SIGNAL(closeTerminal()));
m_contextDependendActions << action;
action = actionCollection()->addAction("split-left-right");
action->setText(i18nc("@action", "Split Left/Right"));
action->setIcon(KIcon("view-split-left-right"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_L));
connect(action, SIGNAL(triggered()), m_sessionStack, SIGNAL(splitLeftRight()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
action = actionCollection()->addAction("split-top-bottom");
action->setText(i18nc("@action", "Split Top/Bottom"));
action->setIcon(KIcon("view-split-top-bottom"));
action->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
connect(action, SIGNAL(triggered()), m_sessionStack, SIGNAL(splitTopBottom()));
connect(action, SIGNAL(triggered()), this, SLOT(handleContextDependendAction()));
m_contextDependendActions << action;
for (uint i = 1; i <= 10; ++i)
{
action = actionCollection()->addAction(QString("switch-to-session-%1").arg(i));
action->setText(i18nc("@action", "Switch to Session <numid>%1</numid>", i));
action->setData(i);
connect(action, SIGNAL(triggered()), this, SLOT(handleSpecialAction()));
connect(action, SIGNAL(triggered()), this, SLOT(handleSwitchToAction()));
}
m_actionCollection->associateWidget(this);
m_actionCollection->readSettings();
}
void MainWindow::handleSpecialAction()
void MainWindow::handleContextDependendAction(QAction* action, int sessionId)
{
QAction* action = static_cast<QAction*>(QObject::sender());
if (sessionId == -1) sessionId = m_sessionStack->activeSessionId();
if (sessionId == -1) return;
if (!action) action = static_cast<QAction*>(QObject::sender());
if (action == actionCollection()->action("edit-profile"))
m_sessionStack->editProfile(sessionId);
if (action == actionCollection()->action("close-session"))
m_sessionStack->removeSession(sessionId);
if (action == actionCollection()->action("move-session-left"))
m_tabBar->moveTabLeft(m_tabBar->retrieveContextMenuSessionId());
m_tabBar->moveTabLeft(sessionId);
if (action == actionCollection()->action("move-session-right"))
m_tabBar->moveTabRight(m_tabBar->retrieveContextMenuSessionId());
m_tabBar->moveTabRight(sessionId);
if (action == actionCollection()->action("rename-session"))
m_tabBar->interactiveRename(m_tabBar->retrieveContextMenuSessionId());
m_tabBar->interactiveRename(sessionId);
if (action == actionCollection()->action("close-session"))
m_sessionStack->removeSession(m_tabBar->retrieveContextMenuSessionId());
if (action == actionCollection()->action("close-active-terminal"))
m_sessionStack->closeActiveTerminal(sessionId);
if (action == actionCollection()->action("edit-profile"))
m_sessionStack->editProfile(m_tabBar->retrieveContextMenuSessionId());
if (action == actionCollection()->action("split-left-right"))
m_sessionStack->splitLeftRight(sessionId);
if (action == actionCollection()->action("split-top-bottom"))
m_sessionStack->splitTopBottom(sessionId);
}
void MainWindow::setContextDependendActionsQuiet(bool quiet)
{
for (int i = 0; i < m_contextDependendActions.size(); ++i)
{
m_contextDependendActions.at(i)->blockSignals(quiet);
}
}
void MainWindow::handleSwitchToAction()
{
QAction* action = static_cast<QAction*>(QObject::sender());
if (!action->data().isNull())
if (action && !action->data().isNull())
m_sessionStack->raiseSession(m_tabBar->sessionAtTab(action->data().toInt()-1));
}
......
......@@ -62,10 +62,14 @@ class MainWindow : public KMainWindow
bool useTranslucency() { return m_useTranslucency; }
void setContextDependendActionsQuiet(bool quiet);
public slots:
Q_SCRIPTABLE void toggleWindowState();
void handleContextDependendAction(QAction* action = 0, int sessionId = -1);
protected:
virtual void paintEvent(QPaintEvent*);
......@@ -106,8 +110,8 @@ class MainWindow : public KMainWindow
void setFullScreen(bool state);
void updateFullScreen();
void handleSpecialAction();
void handleSwitchToAction();
void whatsThis();
void configureKeys();
......@@ -138,6 +142,7 @@ class MainWindow : public KMainWindow
bool m_useTranslucency;
KActionCollection* m_actionCollection;
QList<KAction*> m_contextDependendActions;
Skin* m_skin;
TitleBar* m_titleBar;
......
......@@ -168,7 +168,7 @@ void Session::focusPreviousTerminal()
if (!m_terminals.contains(m_activeTerminalId)) return;
QMapIterator<int, Terminal*> it(m_terminals);
it.toBack();
while (it.hasPrevious())
......@@ -201,7 +201,7 @@ void Session::focusNextTerminal()
if (!m_terminals.contains(m_activeTerminalId)) return;
QMapIterator<int, Terminal*> it(m_terminals);
while (it.hasNext())
{
it.next();
......
......@@ -90,7 +90,7 @@ class Session : public QObject
int m_sessionId;
Splitter* m_baseSplitter;
int m_activeTerminalId;
QMap<int, Terminal*> m_terminals;
......
......@@ -73,10 +73,8 @@ void SessionStack::raiseSession(int sessionId)
disconnect(m_sessions[m_activeSessionId], SLOT(closeTerminal()));
disconnect(m_sessions[m_activeSessionId], SLOT(focusPreviousTerminal()));
disconnect(m_sessions[m_activeSessionId], SLOT(focusNextTerminal()));
disconnect(m_sessions[m_activeSessionId], SLOT(splitLeftRight()));
disconnect(m_sessions[m_activeSessionId], SLOT(splitTopBottom()));
disconnect(m_sessions[m_activeSessionId], SLOT(manageProfiles()));
disconnect(m_sessions[m_activeSessionId], SIGNAL(titleChanged(const QString&)),
disconnect(m_sessions[m_activeSessionId], SIGNAL(titleChanged(const QString&)),
this, SIGNAL(activeTitleChanged(const QString&)));
}
......@@ -90,10 +88,8 @@ void SessionStack::raiseSession(int sessionId)
connect(this, SIGNAL(closeTerminal()), m_sessions[sessionId], SLOT(closeTerminal()));
connect(this, SIGNAL(previousTerminal()), m_sessions[sessionId], SLOT(focusPreviousTerminal()));
connect(this, SIGNAL(nextTerminal()), m_sessions[sessionId], SLOT(focusNextTerminal()));
connect(this, SIGNAL(splitLeftRight()), m_sessions[sessionId], SLOT(splitLeftRight()));
connect(this, SIGNAL(splitTopBottom()), m_sessions[sessionId], SLOT(splitTopBottom()));
connect(this, SIGNAL(manageProfiles()), m_sessions[sessionId], SLOT(manageProfiles()));
connect(m_sessions[sessionId], SIGNAL(titleChanged(const QString&)),
connect(m_sessions[sessionId], SIGNAL(titleChanged(const QString&)),
this, SIGNAL(activeTitleChanged(const QString&)));
emit sessionRaised(sessionId);
......@@ -115,14 +111,14 @@ void SessionStack::removeTerminal(int terminalId)
{
if (m_activeSessionId == -1) return;
if (!m_sessions.contains(m_activeSessionId)) return;
m_sessions[m_activeSessionId]->closeTerminal();
}
else
{
QHashIterator<int, Session*> it(m_sessions);
while (it.hasNext())
while (it.hasNext())
{
it.next();
......@@ -131,6 +127,16 @@ void SessionStack::removeTerminal(int terminalId)
}
}
void SessionStack::closeActiveTerminal(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions[sessionId]->closeTerminal();
}
void SessionStack::cleanup(int sessionId)
{
if (sessionId == m_activeSessionId) m_activeSessionId = -1;
......@@ -154,7 +160,7 @@ const QString SessionStack::sessionIdList()
for (int i = 0; i < keyList.size(); ++i)
idList << QString::number(keyList.at(i));
return idList.join(",");
}
......@@ -202,6 +208,23 @@ void SessionStack::editProfile(int sessionId)
m_sessions[sessionId]->editProfile();
}
void SessionStack::splitLeftRight(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions[sessionId]->splitLeftRight();
}
void SessionStack::splitTopBottom(int sessionId)
{
if (sessionId == -1) sessionId = m_activeSessionId;
if (sessionId == -1) return;
if (!m_sessions.contains(sessionId)) return;
m_sessions[sessionId]->splitTopBottom();
}
void SessionStack::emitTitles()
{
......
......@@ -41,6 +41,13 @@ class SessionStack : public QStackedWidget
explicit SessionStack(QWidget* parent = 0);
~SessionStack();
void closeActiveTerminal(int sessionId = -1);
void editProfile(int sessionId = -1);
void splitLeftRight(int sessionId = -1);
void splitTopBottom(int sessionId = -1);
void emitTitles();
......@@ -63,8 +70,6 @@ class SessionStack : public QStackedWidget
Q_SCRIPTABLE void runCommand(const QString& command);
Q_SCRIPTABLE void runCommandInTerminal(int terminalId, const QString& command);
void editProfile(int sessionId = -1);
signals:
void sessionAdded(int sessionId);
......@@ -79,9 +84,6 @@ class SessionStack : public QStackedWidget
void previousTerminal();
void nextTerminal();
void splitLeftRight();
void splitTopBottom();
void manageProfiles();
......
......@@ -42,6 +42,8 @@ TabBar::TabBar(MainWindow* mainWindow) : QWidget(mainWindow)
"<title>Tab Bar</title>"
"<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_mousePressed = false;
m_mousePressedIndex = -1;
......@@ -110,8 +112,6 @@ void TabBar::readyTabContextMenu()
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("rename-session"));
m_tabContextMenu->addAction(m_mainWindow->actionCollection()->action("close-session"));
}
updateTabContextMenuActions(m_mousePressedIndex);
}
void TabBar::readySessionMenu()
......@@ -124,11 +124,9 @@ void TabBar::readySessionMenu()
m_sessionMenu->addAction(m_mainWindow->actionCollection()->action("new-session-two-vertical"));
m_sessionMenu->addAction(m_mainWindow->actionCollection()->action("new-session-quad"));
}
updateTabContextMenuActions(m_mousePressedIndex);
}
void TabBar::updateTabContextMenuActions(int index)
void TabBar::updateMoveActions(int index)
{
m_mainWindow->actionCollection()->action("move-session-left")->setEnabled(false);
m_mainWindow->actionCollection()->action("move-session-right")->setEnabled(false);
......@@ -150,28 +148,18 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
m_sessionMenu->exec(QCursor::pos());
else
{
m_mousePressedIndex = index;
updateMoveActions(index);
m_tabContextMenu->exec(QCursor::pos());
}
m_mainWindow->setContextDependendActionsQuiet(true);
QWidget::contextMenuEvent(event);
}
QAction* action = m_tabContextMenu->exec(QCursor::pos());
int TabBar::retrieveContextMenuSessionId()
{
if (m_mousePressedIndex < 0 || m_mousePressedIndex > m_tabs.size())
{
m_mousePressedIndex = -1;
if (action) m_mainWindow->handleContextDependendAction(action, sessionAtTab(index));
return m_mousePressedIndex;
m_mainWindow->setContextDependendActionsQuiet(false);
}
int tmpSessionId = m_tabs.at(m_mousePressedIndex);
m_mousePressedIndex = -1;
return tmpSessionId;
QWidget::contextMenuEvent(event);
}
void TabBar::resizeEvent(QResizeEvent* event)
......@@ -291,7 +279,7 @@ int TabBar::tabAt(int x)
{
for (int index = 0; index < m_tabWidths.size(); ++index)
{
if (x > m_skin->tabBarPosition().x() && x < m_tabWidths.at(index))
if (x > m_skin->tabBarPosition().x() && x < m_tabWidths.at(index))
return index;
}
......@@ -343,7 +331,7 @@ void TabBar::mouseReleaseEvent(QMouseEvent* event)
if (event->button() == Qt::LeftButton && index != m_tabs.indexOf(m_selectedSessionId))
{
if (m_mousePressed && m_mousePressedIndex == index)
if (m_mousePressed && m_mousePressedIndex == index)
emit tabSelected(m_tabs.at(index));
}
......@@ -391,11 +379,11 @@ void TabBar::addTab(int sessionId)
void TabBar::removeTab(int sessionId)
{
if (sessionId == -1) sessionId = m_selectedSessionId;
if (sessionId == -1) return;
if (!m_tabs.contains(sessionId)) return;
int index = m_tabs.indexOf(sessionId);
if (index == -1) return;
if (m_lineEdit->isVisible() && index == m_editingSessionId)
m_lineEdit->hide();
......@@ -447,7 +435,7 @@ void TabBar::selectTab(int sessionId)
m_selectedSessionId = sessionId;
updateTabContextMenuActions(m_tabs.indexOf(m_selectedSessionId));
updateMoveActions(m_tabs.indexOf(sessionId));
repaint();
}
......@@ -533,7 +521,7 @@ int TabBar::sessionAtTab(int index)
for (int i = 0; i < m_tabs.size(); ++i)
{
if (i == index) return m_tabs.at(i);
}
}
return -1;
}
......
......@@ -50,8 +50,6 @@ class TabBar : public QWidget
void applySkin();
int retrieveContextMenuSessionId();
public slots:
void addTab(int sessionId);
......@@ -103,7 +101,7 @@ class TabBar : public QWidget
QString makeTabTitle(int number);
int tabAt(int x);
void updateTabContextMenuActions(int index);
void updateMoveActions(int index);
MainWindow* m_mainWindow;
Skin* m_skin;
......
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