Use Show desktop item instead of empty text in TabBox

If there are no windows for Alt+Tab the Show Desktop entry
is shown. This works better with both layouts and effects.
Before this change effects were not activated at all but
a fallback to the layouts was used. Concerning the layouts
some looked rather bad. E.g. Thumbnails did not show a
thumbnail but a legacy text had been shown.

When a window gets added to the empty list, the show desktop
window is removed and consequently when the last window goes
away the show desktop entry is added again.

There is a not considered corner case: if there is no desktop
window, the show desktop functionality is not available and
the behavior is unfortunately undefined. It is a corner case
as we can expect that there is always a desktop window when
using KWin. E.g. there is either Plasma Desktop or Netbook
and on PA there is always at least one window.

BUG: 260938
FIXED-IN: 4.9.0
REVIEW: 104379
This commit is contained in:
Martin Gräßlin 2012-03-17 10:31:15 +01:00
parent d03c73a223
commit c2ebd35cad
4 changed files with 4 additions and 14 deletions

View file

@ -57,10 +57,7 @@ QVariant ClientModel::data(const QModelIndex& index, int role) const
return QVariant();
if (m_clientList.isEmpty()) {
if (role == EmptyRole)
return true;
else
return i18n("*** No Windows ***");
return QVariant();
}
int clientIndex = index.row() * columnCount() + index.column();
@ -75,8 +72,6 @@ QVariant ClientModel::data(const QModelIndex& index, int role) const
case DesktopNameRole: {
return tabBox->desktopName(m_clientList[ clientIndex ]);
}
case EmptyRole:
return false;
case WIdRole:
return qulonglong(m_clientList[ clientIndex ]->window());
case MinimizedRole:
@ -235,7 +230,7 @@ void ClientModel::createClientList(int desktop, bool partialReset)
m_clientList.removeAll(c);
m_clientList.prepend(c);
}
if (tabBox->config().showDesktopMode() == TabBoxConfig::ShowDesktopClient) {
if (tabBox->config().showDesktopMode() == TabBoxConfig::ShowDesktopClient || m_clientList.isEmpty()) {
TabBoxClient* desktopClient = tabBox->desktopClient();
if (desktopClient)
m_clientList.append(desktopClient);

View file

@ -53,7 +53,6 @@ public:
CaptionRole = Qt::UserRole + 1, ///< The caption of TabBoxClient
DesktopNameRole = Qt::UserRole + 2, ///< The name of the desktop the TabBoxClient is on
IconRole = Qt::UserRole + 3, // TODO: to be removed
EmptyRole = Qt::UserRole + 4, ///< Indicates if the model contains TabBoxClients
WIdRole = Qt::UserRole + 5, ///< The window ID of TabBoxClient
MinimizedRole = Qt::UserRole + 6, ///< TabBoxClient is minimized
CloseableRole = Qt::UserRole + 7 ///< TabBoxClient can be closed

View file

@ -69,9 +69,6 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize
if (!index.isValid()) {
return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize);
}
if (index.model()->data(index, ClientModel::EmptyRole).toBool()) {
return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize);
}
TabBoxClient* client = static_cast< TabBoxClient* >(index.model()->data(index, ClientModel::ClientRole).value<void *>());
if (!client) {
return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize);

View file

@ -119,7 +119,7 @@ void TabBoxHandlerPrivate::updateOutline()
if (config.tabBoxMode() != TabBoxConfig::ClientTabBox)
return;
// if ( c == NULL || !m_isShown || !c->isShown( true ) || !c->isOnCurrentDesktop())
if (!isShown || clientModel()->data(index, ClientModel::EmptyRole).toBool()) {
if (!isShown) {
q->hideOutline();
return;
}
@ -410,8 +410,7 @@ TabBoxClientList TabBoxHandler::clientList() const
TabBoxClient* TabBoxHandler::client(const QModelIndex& index) const
{
if ((!index.isValid()) ||
(d->config.tabBoxMode() != TabBoxConfig::ClientTabBox) ||
(d->clientModel()->data(index, ClientModel::EmptyRole).toBool()))
(d->config.tabBoxMode() != TabBoxConfig::ClientTabBox))
return NULL;
TabBoxClient* c = static_cast< TabBoxClient* >(
d->clientModel()->data(index, ClientModel::ClientRole).value<void *>());