Plasma Package support for desktop switcher layouts
The existing desktop switcher becomes the first available layout called "informative". For both variants of desktop switchers a new config key is introduced to define the desktop switcher layout. Desktop layouts are installed into a different directory than window switcher layout and use a different service type. For the moment it's basically a hidden config option as there are no further layouts yet. BUG: 296068 FIXED-IN: 4.11 REVIEW: 110021
This commit is contained in:
parent
badc7a2bc4
commit
7c489e43d9
8 changed files with 94 additions and 18 deletions
|
@ -3,3 +3,4 @@ add_subdirectory( tests )
|
||||||
|
|
||||||
# Install the KWin/WindowSwitcher service type
|
# Install the KWin/WindowSwitcher service type
|
||||||
install( FILES kwinwindowswitcher.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
|
install( FILES kwinwindowswitcher.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
|
||||||
|
install( FILES kwindesktopswitcher.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} )
|
||||||
|
|
|
@ -351,12 +351,26 @@ void DeclarativeView::updateQmlSource(bool force)
|
||||||
if (!force && tabBox->config().layoutName() == m_currentLayout) {
|
if (!force && tabBox->config().layoutName() == m_currentLayout) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (m_mode == TabBoxConfig::DesktopTabBox) {
|
const bool desktopMode = (m_mode == TabBoxConfig::DesktopTabBox);
|
||||||
m_currentLayout = tabBox->config().layoutName();
|
m_currentLayout = tabBox->config().layoutName();
|
||||||
const QString file = KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + QLatin1String("/tabbox/desktop.qml"));
|
KService::Ptr service = desktopMode ? findDesktopSwitcher() : findWindowSwitcher();
|
||||||
rootObject()->setProperty("source", QUrl(file));
|
if (service.isNull()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (service->property("X-Plasma-API").toString() != "declarativeappletscript") {
|
||||||
|
kDebug(1212) << "Window Switcher Layout is no declarativeappletscript";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const QString file = desktopMode ? findDesktopSwitcherScriptFile(service) : findWindowSwitcherScriptFile(service);
|
||||||
|
if (file.isNull()) {
|
||||||
|
kDebug(1212) << "Could not find QML file for window switcher";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rootObject()->setProperty("source", QUrl(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
KService::Ptr DeclarativeView::findWindowSwitcher()
|
||||||
|
{
|
||||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(tabBox->config().layoutName());
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(tabBox->config().layoutName());
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("KWin/WindowSwitcher", constraint);
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/WindowSwitcher", constraint);
|
||||||
if (offers.isEmpty()) {
|
if (offers.isEmpty()) {
|
||||||
|
@ -365,23 +379,40 @@ void DeclarativeView::updateQmlSource(bool force)
|
||||||
offers = KServiceTypeTrader::self()->query("KWin/WindowSwitcher", constraint);
|
offers = KServiceTypeTrader::self()->query("KWin/WindowSwitcher", constraint);
|
||||||
if (offers.isEmpty()) {
|
if (offers.isEmpty()) {
|
||||||
kDebug(1212) << "could not find default window switcher layout";
|
kDebug(1212) << "could not find default window switcher layout";
|
||||||
return;
|
return KService::Ptr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_currentLayout = tabBox->config().layoutName();
|
return offers.first();
|
||||||
KService::Ptr service = offers.first();
|
}
|
||||||
|
|
||||||
|
KService::Ptr DeclarativeView::findDesktopSwitcher()
|
||||||
|
{
|
||||||
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(tabBox->config().layoutName());
|
||||||
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/DesktopSwitcher", constraint);
|
||||||
|
if (offers.isEmpty()) {
|
||||||
|
// load default
|
||||||
|
constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg("informative");
|
||||||
|
offers = KServiceTypeTrader::self()->query("KWin/DesktopSwitcher", constraint);
|
||||||
|
if (offers.isEmpty()) {
|
||||||
|
kDebug(1212) << "could not find default desktop switcher layout";
|
||||||
|
return KService::Ptr();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return offers.first();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DeclarativeView::findWindowSwitcherScriptFile(KService::Ptr service)
|
||||||
|
{
|
||||||
const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
|
const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
|
||||||
if (service->property("X-Plasma-API").toString() != "declarativeappletscript") {
|
|
||||||
kDebug(1212) << "Window Switcher Layout is no declarativeappletscript";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const QString scriptName = service->property("X-Plasma-MainScript").toString();
|
const QString scriptName = service->property("X-Plasma-MainScript").toString();
|
||||||
const QString file = KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/tabbox/" + pluginName + "/contents/" + scriptName);
|
return KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/tabbox/" + pluginName + "/contents/" + scriptName);
|
||||||
if (file.isNull()) {
|
}
|
||||||
kDebug(1212) << "Could not find QML file for window switcher";
|
|
||||||
return;
|
QString DeclarativeView::findDesktopSwitcherScriptFile(KService::Ptr service)
|
||||||
}
|
{
|
||||||
rootObject()->setProperty("source", QUrl(file));
|
const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
|
||||||
|
const QString scriptName = service->property("X-Plasma-MainScript").toString();
|
||||||
|
return KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/desktoptabbox/" + pluginName + "/contents/" + scriptName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarativeView::slotEmbeddedChanged(bool enabled)
|
void DeclarativeView::slotEmbeddedChanged(bool enabled)
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
// includes
|
// includes
|
||||||
#include <QtDeclarative/QDeclarativeImageProvider>
|
#include <QtDeclarative/QDeclarativeImageProvider>
|
||||||
#include <QtDeclarative/QDeclarativeView>
|
#include <QtDeclarative/QDeclarativeView>
|
||||||
|
#include <KDE/KService>
|
||||||
#include "tabboxconfig.h"
|
#include "tabboxconfig.h"
|
||||||
|
|
||||||
// forward declaration
|
// forward declaration
|
||||||
|
@ -71,6 +72,10 @@ private Q_SLOTS:
|
||||||
void currentIndexChanged(int row);
|
void currentIndexChanged(int row);
|
||||||
void slotWindowChanged(WId wId, unsigned int properties);
|
void slotWindowChanged(WId wId, unsigned int properties);
|
||||||
private:
|
private:
|
||||||
|
KService::Ptr findWindowSwitcher();
|
||||||
|
KService::Ptr findDesktopSwitcher();
|
||||||
|
QString findWindowSwitcherScriptFile(KService::Ptr service);
|
||||||
|
QString findDesktopSwitcherScriptFile(KService::Ptr service);
|
||||||
QAbstractItemModel *m_model;
|
QAbstractItemModel *m_model;
|
||||||
TabBoxConfig::TabBoxMode m_mode;
|
TabBoxConfig::TabBoxMode m_mode;
|
||||||
QRect m_currentScreenGeometry;
|
QRect m_currentScreenGeometry;
|
||||||
|
|
14
tabbox/kwindesktopswitcher.desktop
Normal file
14
tabbox/kwindesktopswitcher.desktop
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=ServiceType
|
||||||
|
X-KDE-ServiceType=KWin/DesktopSwitcher
|
||||||
|
|
||||||
|
Comment=KWin Desktop Switcher Layout
|
||||||
|
|
||||||
|
[PropertyDef::X-Plasma-API]
|
||||||
|
Type=QString
|
||||||
|
|
||||||
|
[PropertyDef::X-Plasma-MainScript]
|
||||||
|
Type=QString
|
||||||
|
|
||||||
|
[PropertyDef::X-KWin-Exclude-Listing]
|
||||||
|
Type=bool
|
|
@ -1,5 +1,4 @@
|
||||||
install( FILES tabbox.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
install( FILES tabbox.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
||||||
install( FILES desktop.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
|
||||||
|
|
||||||
# packages
|
# packages
|
||||||
install( DIRECTORY clients/big_icons DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
install( DIRECTORY clients/big_icons DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
||||||
|
@ -11,6 +10,8 @@ install( DIRECTORY clients/text DESTINATION ${DATA_INSTALL_DIR}/${KWIN_N
|
||||||
install( DIRECTORY clients/thumbnails DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
install( DIRECTORY clients/thumbnails DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
||||||
install( DIRECTORY clients/window_strip DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
install( DIRECTORY clients/window_strip DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox )
|
||||||
|
|
||||||
|
install( DIRECTORY desktops/informative DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/desktoptabbox )
|
||||||
|
|
||||||
# service files
|
# service files
|
||||||
install( FILES clients/big_icons/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_big_icons.desktop )
|
install( FILES clients/big_icons/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_big_icons.desktop )
|
||||||
install( FILES clients/compact/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_compact.desktop )
|
install( FILES clients/compact/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_compact.desktop )
|
||||||
|
@ -21,6 +22,8 @@ install( FILES clients/text/metadata.desktop DESTINATION ${SERVICES_INST
|
||||||
install( FILES clients/thumbnails/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_thumbnails.desktop )
|
install( FILES clients/thumbnails/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_thumbnails.desktop )
|
||||||
install( FILES clients/window_strip/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_window_strip.desktop )
|
install( FILES clients/window_strip/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_window_switcher_window_strip.desktop )
|
||||||
|
|
||||||
|
install( FILES desktops/informative/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_desktop_switcher_informative.desktop )
|
||||||
|
|
||||||
install (FILES IconTabBox.qml ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/big_icons/contents/ui)
|
install (FILES IconTabBox.qml ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/big_icons/contents/ui)
|
||||||
install (FILES IconTabBox.qml ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/small_icons/contents/ui)
|
install (FILES IconTabBox.qml ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/small_icons/contents/ui)
|
||||||
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/)
|
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/)
|
||||||
|
@ -29,3 +32,5 @@ install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/
|
||||||
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/present_windows/contents/ui)
|
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/present_windows/contents/ui)
|
||||||
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/thumbnails/contents/ui)
|
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/thumbnails/contents/ui)
|
||||||
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/text/contents/ui)
|
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/tabbox/text/contents/ui)
|
||||||
|
|
||||||
|
install (FILES ShadowedSvgItem.qml DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/desktoptabbox/informative/contents/ui)
|
||||||
|
|
17
tabbox/qml/desktops/informative/metadata.desktop
Normal file
17
tabbox/qml/desktops/informative/metadata.desktop
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=Informative
|
||||||
|
Comment=An informative desktop switcher layout
|
||||||
|
Icon=preferences-system-desktop-switcher-informative
|
||||||
|
|
||||||
|
X-Plasma-API=declarativeappletscript
|
||||||
|
X-Plasma-MainScript=ui/main.qml
|
||||||
|
|
||||||
|
X-KDE-PluginInfo-Author=Martin Gräßlin
|
||||||
|
X-KDE-PluginInfo-Email=mgraesslin@kde.org
|
||||||
|
X-KDE-PluginInfo-Name=informative
|
||||||
|
X-KDE-PluginInfo-Version=1.0
|
||||||
|
|
||||||
|
X-KDE-PluginInfo-Depends=
|
||||||
|
X-KDE-PluginInfo-License=GPL
|
||||||
|
X-KDE-ServiceTypes=KWin/DesktopSwitcher
|
||||||
|
Type=Service
|
|
@ -729,6 +729,9 @@ void TabBox::reconfigure()
|
||||||
m_delayShow = config.readEntry<bool>("ShowDelay", true);
|
m_delayShow = config.readEntry<bool>("ShowDelay", true);
|
||||||
m_delayShowTime = config.readEntry<int>("DelayTime", 90);
|
m_delayShowTime = config.readEntry<int>("DelayTime", 90);
|
||||||
|
|
||||||
|
m_desktopConfig.setLayoutName(config.readEntry("DesktopLayout", "informative"));
|
||||||
|
m_desktopListConfig.setLayoutName(config.readEntry("DesktopListLayout", "informative"));
|
||||||
|
|
||||||
QList<ElectricBorder> *borders = &m_borderActivate;
|
QList<ElectricBorder> *borders = &m_borderActivate;
|
||||||
QString borderConfig = "BorderActivate";
|
QString borderConfig = "BorderActivate";
|
||||||
for (int i = 0; i < 2; ++i) {
|
for (int i = 0; i < 2; ++i) {
|
||||||
|
|
Loading…
Reference in a new issue