Activate TabBoxClient from mouse click and close TabBox

This is useful in combination of non-modal TabBox through DBus and
window-strip layout. With DBus the non-modal TabBox can be started
and selecting any item on the strip will end TabBox again.
icc-effect-5.14.5
Martin Gräßlin 2011-11-27 17:03:35 +01:00
parent 5a7120fbf5
commit e858b413a3
6 changed files with 37 additions and 4 deletions

View File

@ -244,5 +244,15 @@ void ClientModel::close(int i)
m_clientList.at(i)->close();
}
void ClientModel::activate(int i)
{
QModelIndex ind = index(i, 0);
if (!ind.isValid()) {
return;
}
tabBox->setCurrentIndex(ind);
tabBox->activateAndClose();
}
} // namespace Tabbox
} // namespace KWin

View File

@ -98,6 +98,11 @@ public:
public Q_SLOTS:
void close(int index);
/**
* Activates the client at @p index and closes the TabBox.
* @param index The row index
**/
void activate(int index);
private:
TabBoxClientList m_clientList;

View File

@ -81,10 +81,7 @@ Item {
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: {
thumbnailListView.currentIndex = index
thumbnailListView.currentIndexChanged(thumbnailListView.currentIndex);
}
onClicked: thumbnailListView.model.activate(index)
}
}
PlasmaComponents.Label {

View File

@ -214,6 +214,22 @@ QVector< Window > TabBoxHandlerImpl::outlineWindowIds() const
return Workspace::self()->outline()->windowIds();
}
void TabBoxHandlerImpl::activateAndClose()
{
Client* c = NULL;
if (TabBoxClientImpl* cl = static_cast< TabBoxClientImpl* >(client(currentIndex()))) {
c = cl->client();
}
m_tabBox->close();
if (c) {
Workspace::self()->activateClient(c);
if (c->isShade() && options->shadeHover)
c->setShade(ShadeActivated);
if (c->isDesktop())
Workspace::self()->setShowingDesktop(!Workspace::self()->showingDesktop());
}
}
/*********************************************************
* TabBoxClientImpl

View File

@ -61,6 +61,7 @@ public:
virtual void hideOutline();
virtual void showOutline(const QRect &outline);
virtual QVector< Window > outlineWindowIds() const;
virtual void activateAndClose();
private:
TabBox* m_tabBox;

View File

@ -173,6 +173,10 @@ public:
* @return The first desktop window in the stacking order.
*/
virtual TabBoxClient* desktopClient() const = 0;
/**
* Activates the currently selected client and closes the TabBox.
**/
virtual void activateAndClose() = 0;
/**
* @return The currently used TabBoxConfig