From c2ebd35cadd550421c891b6b23982234d3a94891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 17 Mar 2012 10:31:15 +0100 Subject: [PATCH] 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 --- tabbox/clientmodel.cpp | 9 ++------- tabbox/clientmodel.h | 1 - tabbox/declarative.cpp | 3 --- tabbox/tabboxhandler.cpp | 5 ++--- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/tabbox/clientmodel.cpp b/tabbox/clientmodel.cpp index eae1cfa817..b3f8954212 100644 --- a/tabbox/clientmodel.cpp +++ b/tabbox/clientmodel.cpp @@ -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); diff --git a/tabbox/clientmodel.h b/tabbox/clientmodel.h index 450d66515c..6d646ab4d2 100644 --- a/tabbox/clientmodel.h +++ b/tabbox/clientmodel.h @@ -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 diff --git a/tabbox/declarative.cpp b/tabbox/declarative.cpp index 274b85de91..c8abf6036c 100644 --- a/tabbox/declarative.cpp +++ b/tabbox/declarative.cpp @@ -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()); if (!client) { return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize); diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index ff4406c1a5..2950e51464 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -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());