add containmentactions

pull/2/head
Michail Vourlakos 7 years ago
parent 35643ac5f3
commit d3756e0ce1

@ -57,6 +57,7 @@ include(WriteBasicConfigVersionFile)
include(Definitions.cmake)
add_subdirectory(liblattedock)
add_subdirectory(containmentactions)
add_subdirectory(app)
add_subdirectory(applets)
add_subdirectory(containment)

@ -68,6 +68,7 @@ void DockMenuManager::menuAboutToHide()
bool DockMenuManager::mousePressEvent(QMouseEvent *event)
{
//qDebug() << "Step -1 ...";
if (!event || !m_dockView->containment()) {
return false;
}
@ -86,7 +87,7 @@ bool DockMenuManager::mousePressEvent(QMouseEvent *event)
}
//qDebug() << "1 ...";
const QString trigger = Plasma::ContainmentActions::eventToString(event);
QString trigger = Plasma::ContainmentActions::eventToString(event);
if (trigger == "RightButton;NoModifier") {
Plasma::ContainmentActions *plugin = m_dockView->containment()->containmentActions().value(trigger);

@ -111,6 +111,10 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
m_visibility = new VisibilityManager(this);
}
//! Only way to be sure that actions are set correctly because of the old way to expose the menu actions
//! an alternative would be for Layout to remove on startup ActionPlugins that are old style...
this->containment()->setContainmentActions(QString("RightButton;NoModifier"), QString("org.kde.latte.contextmenu"));
QAction *lockWidgetsAction = this->containment()->actions()->action("lock widgets");
this->containment()->actions()->removeAction(lockWidgetsAction);
QAction *removeAction = containment()->actions()->action("remove");

@ -41,6 +41,7 @@ void DockPackage::initPackage(KPackage::Package *package)
auto fallback = KPackage::PackageLoader::self()->loadPackage("Plasma/Shell", "org.kde.plasma.desktop");
package->setDefaultPackageRoot(QStringLiteral("plasma/shells/"));
package->setPath("org.kde.latte.shell");
package->addFileDefinition("defaults", QStringLiteral("defaults"), i18n("Latte Dock defaults"));
package->addFileDefinition("lattedockui", QStringLiteral("views/Panel.qml"), i18n("Latte Dock panel"));
//Configuration
package->addFileDefinition("lattedockconfigurationui", QStringLiteral("configuration/LatteDockConfiguration.qml"), i18n("Dock configuration UI"));

@ -0,0 +1 @@
add_subdirectory(contextmenu)

@ -0,0 +1,16 @@
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_containmentactions_lattecontextmenu\")
set(contextmenu_SRCS
menu.cpp
)
add_library(plasma_containmentactions_lattecontextmenu MODULE ${contextmenu_SRCS})
kcoreaddons_desktop_to_json(plasma_containmentactions_lattecontextmenu plasma-containmentactions-lattecontextmenu.desktop)
target_link_libraries(plasma_containmentactions_lattecontextmenu
Qt5::Widgets
KF5::Plasma)
install(TARGETS plasma_containmentactions_lattecontextmenu DESTINATION ${KDE_INSTALL_PLUGINDIR})
install(FILES plasma-containmentactions-lattecontextmenu.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR})

@ -0,0 +1,2 @@
#! /usr/bin/env bash
$XGETTEXT *.cpp -o $podir/plasma_containmentactions_lattecontextmenu.pot

@ -0,0 +1,80 @@
/*
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "menu.h"
#include <QAction>
#include <QDebug>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/ServiceJob>
Menu::Menu(QObject *parent, const QVariantList &args)
: Plasma::ContainmentActions(parent, args)
{
}
Menu::~Menu()
{
qDeleteAll(m_actions);
}
void Menu::makeMenu()
{
qDeleteAll(m_actions);
m_actions.clear();
QAction *action = new QAction(QIcon::fromTheme("edit"), "Print Message...", this);
connect(action, &QAction::triggered, [ = ]() {
qDebug() << "Action Trigerred !!!";
});
m_actions << action;
/*foreach (const QString &id, m_consumer.activities(KActivities::Info::Running)) {
KActivities::Info info(id);
QAction *action = new QAction(QIcon::fromTheme(info.icon()), info.name(), this);
action->setData(id);
if (id == m_consumer.currentActivity()) {
QFont font = action->font();
font.setBold(true);
action->setFont(font);
}
connect(action, &QAction::triggered, [ = ]() {
switchTo(action);
});
m_actions << action;
}*/
}
QList<QAction *> Menu::contextualActions()
{
makeMenu();
return m_actions;
}
K_EXPORT_PLASMA_CONTAINMENTACTIONS_WITH_JSON(lattecontextmenu, Menu, "plasma-containmentactions-lattecontextmenu.json")
#include "menu.moc"

@ -0,0 +1,45 @@
/*
* Copyright 2018 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MENU_H
#define MENU_H
#include <QObject>
#include <Plasma/ContainmentActions>
class QAction;
class Menu : public Plasma::ContainmentActions {
Q_OBJECT
public:
Menu(QObject *parent, const QVariantList &args);
~Menu() override;
QList<QAction *> contextualActions() override;
private Q_SLOTS:
void makeMenu();
private:
QList<QAction *>m_actions;
};
#endif

@ -0,0 +1,16 @@
[Desktop Entry]
Name=Standard Latte Menu
Comment=The latte menu that normally shows on right-click
Type=Service
Icon=help-contextual
ServiceTypes=Plasma/ContainmentActions
X-KDE-Library=plasma_containmentactions_lattecontextmenu
X-KDE-PluginInfo-Author=Michail Vourlakos
X-KDE-PluginInfo-Email=mvourlakos@gmail.com
X-KDE-PluginInfo-Name=org.kde.latte.contextmenu
X-KDE-PluginInfo-Version=0.1
X-KDE-PluginInfo-Website=https://github.com/psifidotos/Latte-Dock/
X-KDE-PluginInfo-Depends=
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true

@ -0,0 +1,5 @@
[Panel]
Containment=org.kde.latte.containment
[Panel][ContainmentActions]
RightButton;NoModifier=org.kde.latte.contextmenu

@ -1,12 +0,0 @@
[Panel]
Containment=org.kde.latte.containment
# TODO
#ToolBox=audoban.toolbox.candildock
[Panel][ContainmentActions]
# TODO
RightButton;NoModifier=
#MidButton;NoModifier=
[Theme]
Theme=default
Loading…
Cancel
Save