Merge branch 'optional_alternatives'

REVIEW:119944
wilder-5.14
Aaron Seigo 12 years ago
commit f14f961c59
  1. 4
      shell/CMakeLists.txt
  2. 49
      shell/alternativeshelper.cpp
  3. 19
      shell/alternativeshelper.h
  4. 2
      shell/containmentconfigview.cpp
  5. 2
      shell/containmentconfigview.h
  6. 2
      shell/desktopview.h
  7. 2
      shell/interactiveconsole.cpp
  8. 2
      shell/main.cpp
  9. 2
      shell/osd.cpp
  10. 2
      shell/panelconfigview.h
  11. 5
      shell/panelview.h
  12. 207
      shell/plasmaquick/dialog.h
  13. 43
      shell/shellcorona.cpp
  14. 1
      shell/shellcorona.h

@ -9,8 +9,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include_directories(plasmaquick)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5DBus REQUIRED)
@ -48,7 +46,7 @@ qt5_add_dbus_adaptor(scripting_SRC ${plasmashell_dbusXML} shellcorona.h ShellCor
set (plasma_shell_SRCS
activity.cpp
alternativesdialog.cpp
alternativeshelper.cpp
main.cpp
containmentconfigview.cpp
currentcontainmentactionsmodel.cpp

@ -18,56 +18,40 @@
*/
#include "alternativesdialog.h"
#include "alternativeshelper.h"
#include <QQmlEngine>
#include <QQmlContext>
#include <kdeclarative/qmlobject.h>
#include <Plasma/Package>
#include <Plasma/Containment>
#include <Plasma/Corona>
#include <Plasma/PluginLoader>
AlternativesDialog::AlternativesDialog(Plasma::Applet *applet, QQuickItem *parent)
: PlasmaQuick::Dialog(parent),
AlternativesHelper::AlternativesHelper(Plasma::Applet *applet, QObject *parent)
: QObject(parent),
m_applet(applet)
{
setVisualParent(applet->property("_plasma_graphicObject").value<QQuickItem *>());
connect(applet, &QObject::destroyed, this, &AlternativesDialog::close);
setLocation(applet->location());
setFlags(flags()|Qt::WindowStaysOnTopHint);
//We already have the proper shellpluginloader
Plasma::Package pkg;
if (applet && applet->containment() && applet->containment()->corona()) {
pkg = applet->containment()->corona()->package();
}
//TODO: use the proper package: we must be in the corona
pkg.setPath("org.kde.plasma.desktop");
m_qmlObj = new KDeclarative::QmlObject(this);
m_qmlObj->setInitializationDelayed(true);
m_qmlObj->setSource(QUrl::fromLocalFile(pkg.filePath("explorer", "AppletAlternatives.qml")));
m_qmlObj->engine()->rootContext()->setContextProperty("alternativesDialog", this);
m_qmlObj->completeInitialization();
setMainItem(qobject_cast<QQuickItem *>(m_qmlObj->rootObject()));
}
AlternativesDialog::~AlternativesDialog()
AlternativesHelper::~AlternativesHelper()
{
}
QStringList AlternativesDialog::appletProvides() const
QStringList AlternativesHelper::appletProvides() const
{
return m_applet->pluginInfo().property("X-Plasma-Provides").value<QStringList>();
}
QString AlternativesDialog::currentPlugin() const
QString AlternativesHelper::currentPlugin() const
{
return m_applet->pluginInfo().pluginName();
}
void AlternativesDialog::loadAlternative(const QString &plugin)
QQuickItem *AlternativesHelper::applet() const
{
return m_applet->property("_plasma_graphicObject").value<QQuickItem *>();
}
void AlternativesHelper::loadAlternative(const QString &plugin)
{
if (plugin == m_applet->pluginInfo().pluginName() || m_applet->isContainment()) {
return;
@ -90,12 +74,5 @@ void AlternativesDialog::loadAlternative(const QString &plugin)
m_applet->destroy();
}
//To emulate Qt::WA_DeleteOnClose that QWindow doesn't have
void AlternativesDialog::hideEvent(QHideEvent *ev)
{
QQuickWindow::hideEvent(ev);
deleteLater();
}
#include "moc_alternativesdialog.cpp"
#include "moc_alternativeshelper.cpp"

@ -22,34 +22,27 @@
#include <Plasma/Applet>
#include <plasmaquick/dialog.h>
#include <QQuickItem>
namespace KDeclarative {
class QmlObject;
}
//FIXME: this thing really ought to be in the shell
class AlternativesDialog : public PlasmaQuick::Dialog
class AlternativesHelper : public QObject
{
Q_OBJECT
Q_PROPERTY(QStringList appletProvides READ appletProvides CONSTANT)
Q_PROPERTY(QString currentPlugin READ currentPlugin CONSTANT)
Q_PROPERTY(QQuickItem *applet READ applet CONSTANT)
public:
AlternativesDialog(Plasma::Applet *applet, QQuickItem *parent = 0);
~AlternativesDialog();
AlternativesHelper(Plasma::Applet *applet, QObject *parent = 0);
~AlternativesHelper();
QQuickItem *applet() const;
QStringList appletProvides() const;
QString currentPlugin() const;
Q_INVOKABLE void loadAlternative(const QString &plugin);
protected:
void hideEvent(QHideEvent *ev);
private:
Plasma::Applet *m_applet;
KDeclarative::QmlObject *m_qmlObj;
};
#endif

@ -19,7 +19,7 @@
#include "currentcontainmentactionsmodel.h"
#include "containmentconfigview.h"
#include "configmodel.h"
#include "plasmaquick/configmodel.h"
#include "shellcorona.h"
#include "config-workspace.h"

@ -21,7 +21,7 @@
#define CONTAINMENTCONFIGVIEW_H
#include "configview.h"
#include "plasmaquick/configview.h"
namespace Plasma {

@ -20,7 +20,7 @@
#define DESKTOVIEW_H
#include <view.h>
#include "plasmaquick/view.h"
#include "panelconfigview.h"
#include <QtCore/qpointer.h>

@ -50,7 +50,7 @@
#include <Plasma/Package>
#include "scripting/desktopscriptengine.h"
#include "shellpluginloader.h"
#include "plasmaquick/shellpluginloader.h"
#include "shellcorona.h"
//TODO:

@ -26,7 +26,7 @@
#include <kdbusservice.h>
#include <klocalizedstring.h>
#include "shellpluginloader.h"
#include "plasmaquick/shellpluginloader.h"
#include "shellmanager.h"
static const char description[] = "Plasma Shell";

@ -17,7 +17,7 @@
*/
#include "osd.h"
#include "shellpluginloader.h"
#include "plasmaquick/shellpluginloader.h"
#include "shellcorona.h"
#include <QDBusConnection>

@ -20,7 +20,7 @@
#ifndef PANELCONFIGVIEW_H
#define PANELCONFIGVIEW_H
#include "configview.h"
#include "plasmaquick/configview.h"
#include "panelview.h"
#include <QQuickItem>

@ -19,13 +19,12 @@
#ifndef PANELVIEW_H
#define PANELVIEW_H
#include <view.h>
#include <QtCore/qpointer.h>
#include <Plasma/Theme>
#include <QTimer>
#include <configview.h>
#include "plasmaquick/view.h"
#include "plasmaquick/configview.h"
class ShellCorona;

@ -1,207 +0,0 @@
/***************************************************************************
* Copyright 2011 Marco Martin <mart@kde.org> *
* Copyright 2013 Sebastian Kügler <sebas@kde.org> *
* *
* This program 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. *
* *
* This program 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, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
#ifndef DIALOG_PROXY_P
#define DIALOG_PROXY_P
#include <QQuickItem>
#include <QQuickWindow>
#include <QWeakPointer>
#include <QPoint>
#include <QQmlParserStatus>
#include <Plasma/Plasma>
#include <Plasma/Theme>
#include <netwm_def.h>
//
// W A R N I N G
// -------------
//
// This file is not part of the public Plasma API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
class QQuickItem;
class QScreen;
namespace PlasmaQuick {
class DialogPrivate;
/**
* QML wrapper for dialogs
*
* Exposed as `PlasmaCore.Dialog` in QML.
*/
class Dialog : public QQuickWindow, public QQmlParserStatus
{
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
/**
* The main QML item that will be displayed in the Dialog
*/
Q_PROPERTY(QQuickItem *mainItem READ mainItem WRITE setMainItem NOTIFY mainItemChanged)
/**
* The main QML item that will be displayed in the Dialog
*/
Q_PROPERTY(QQuickItem *visualParent READ visualParent WRITE setVisualParent NOTIFY visualParentChanged)
/**
* Margins of the dialog around the mainItem.
* @see DialogMargins
*/
Q_PROPERTY(QObject *margins READ margins CONSTANT)
/**
* Plasma Location of the dialog window. Useful if this dialog is a popup for a panel
*/
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
/**
* Type of the window
*/
Q_PROPERTY(WindowType type READ type WRITE setType NOTIFY typeChanged)
/**
* Whether the dialog should be hidden when the dialog loses focus.
*
* The default value is @c false.
**/
Q_PROPERTY(bool hideOnWindowDeactivate READ hideOnWindowDeactivate WRITE setHideOnWindowDeactivate NOTIFY hideOnWindowDeactivateChanged)
/**
* Whether the dialog is output only. Default value is @c false. If it is @c true
* the dialog does not accept input and all pointer events are not accepted, thus the dialog
* is click through.
*
* This property is currently only supported on the X11 platform. On any other platform the
* property has no effect.
**/
Q_PROPERTY(bool outputOnly READ isOutputOnly WRITE setOutputOnly NOTIFY outputOnlyChanged)
/**
* This property holds the window flags of the window.
* The window flags control the window's appearance in the windowing system,
* whether it's a dialog, popup, or a regular window, and whether it should
* have a title bar, etc.
* Regardless to what the user sets, the flags will always have the
* FramelessWindowHint flag set
*/
Q_PROPERTY(Qt::WindowFlags flags READ flags WRITE setFramelessFlags NOTIFY flagsChanged)
Q_CLASSINFO("DefaultProperty", "mainItem")
public:
enum WindowType {
Normal = NET::Normal,
Dock = NET::Dock,
DialogWindow = NET::Dialog,
PopupMenu = NET::PopupMenu,
Tooltip = NET::Tooltip,
Notification = NET::Notification
};
Q_ENUMS(WindowType)
Dialog(QQuickItem *parent = 0);
~Dialog();
//PROPERTIES ACCESSORS
QQuickItem *mainItem() const;
void setMainItem(QQuickItem *mainItem);
QQuickItem *visualParent() const;
void setVisualParent(QQuickItem *visualParent);
Plasma::Types::Location location() const;
void setLocation(Plasma::Types::Location location);
QObject *margins() const;
void setFramelessFlags(Qt::WindowFlags flags);
void setType(WindowType type);
WindowType type() const;
bool hideOnWindowDeactivate() const;
void setHideOnWindowDeactivate(bool hide);
void setOutputOnly(bool outputOnly);
bool isOutputOnly() const;
/**
* @returns The suggested screen position for the popup
* @arg item the item the popup has to be positioned relatively to. if null, the popup will be positioned in the center of the window
* @arg alignment alignment of the popup compared to the item
*/
virtual QPoint popupPosition(QQuickItem *item, const QSize &size);
Q_SIGNALS:
void mainItemChanged();
void locationChanged();
void visualParentChanged();
void typeChanged();
void hideOnWindowDeactivateChanged();
void outputOnlyChanged();
void flagsChanged();
protected:
/*
* set the dialog position. subclasses may change it. ToolTipDialog adjusts the position in an animated way
*/
virtual void adjustGeometry(const QRect &geom);
//Reimplementations
virtual void classBegin();
virtual void componentComplete();
virtual void resizeEvent(QResizeEvent *re);
virtual void focusInEvent(QFocusEvent *ev);
virtual void focusOutEvent(QFocusEvent *ev);
virtual void showEvent(QShowEvent *event);
virtual void hideEvent(QHideEvent *event);
virtual bool event(QEvent *event);
private:
friend class DialogPrivate;
DialogPrivate *const d;
Q_PRIVATE_SLOT(d, void syncBorders())
Q_PRIVATE_SLOT(d, void updateContrast())
Q_PRIVATE_SLOT(d, void updateVisibility(bool visible))
Q_PRIVATE_SLOT(d, void updateMinimumWidth())
Q_PRIVATE_SLOT(d, void updateMinimumHeight())
Q_PRIVATE_SLOT(d, void updateMaximumWidth())
Q_PRIVATE_SLOT(d, void updateMaximumHeight())
Q_PRIVATE_SLOT(d, void syncMainItemToSize())
Q_PRIVATE_SLOT(d, void syncToMainItemSize())
Q_PRIVATE_SLOT(d, void requestSyncToMainItemSize(bool delayed))
};
}
#endif

@ -41,6 +41,7 @@
#include <KAuthorized>
#include <KWindowSystem>
#include <kdeclarative/kdeclarative.h>
#include <kdeclarative/qmlobject.h>
#include <KMessageBox>
#include <KScreen/Config>
@ -48,14 +49,14 @@
#include "config-ktexteditor.h" // HAVE_KTEXTEDITOR
#include "alternativesdialog.h"
#include "alternativeshelper.h"
#include "activity.h"
#include "desktopview.h"
#include "panelview.h"
#include "scripting/desktopscriptengine.h"
#include "widgetexplorer/widgetexplorer.h"
#include "configview.h"
#include "shellpluginloader.h"
#include "plasmaquick/configview.h"
#include "plasmaquick/shellpluginloader.h"
#include "shellmanager.h"
#include "osd.h"
#if HAVE_KTEXTEDITOR
@ -112,11 +113,11 @@ public:
QMenu *addPanelsMenu;
Plasma::Package lookNFeelPackage;
QSet<KScreen::Output *> redundantOutputs;
QList<KDeclarative::QmlObject *> alternativesObjects;
#if HAVE_KTEXTEDITOR
QWeakPointer<InteractiveConsole> console;
#endif
QPointer <AlternativesDialog> alternativesDialog;
KScreen::Config *screenConfiguration;
QTimer waitingPanelsTimer;
QTimer appConfigSyncTimer;
@ -449,13 +450,41 @@ void ShellCorona::screenInvariants() const
void ShellCorona::showAlternativesForApplet(Plasma::Applet *applet)
{
if (!d->alternativesDialog) {
d->alternativesDialog = new AlternativesDialog(applet);
const QString alternativesQML = package().filePath("appletalternativesui");
if (alternativesQML.isEmpty()) {
return;
}
d->alternativesDialog->show();
KDeclarative::QmlObject *qmlObj = new KDeclarative::QmlObject(this);
qmlObj->setInitializationDelayed(true);
qmlObj->setSource(QUrl::fromLocalFile(alternativesQML));
AlternativesHelper *helper = new AlternativesHelper(applet, qmlObj);
qmlObj->engine()->rootContext()->setContextProperty("alternativesHelper", helper);
d->alternativesObjects << qmlObj;
qmlObj->completeInitialization();
connect(qmlObj->rootObject(), SIGNAL(visibleChanged(bool)),
this, SLOT(alternativesVisibilityChanged(bool)));
}
void ShellCorona::alternativesVisibilityChanged(bool visible)
{
if (visible) {
return;
}
QObject *root = sender();
QMutableListIterator<KDeclarative::QmlObject *> it(d->alternativesObjects);
while (it.hasNext()) {
KDeclarative::QmlObject *obj = it.next();
if (obj->rootObject() == root) {
it.remove();
obj->deleteLater();
}
}
}
void ShellCorona::unload()
{

@ -156,6 +156,7 @@ private Q_SLOTS:
void activityRemoved();
void desktopContainmentDestroyed(QObject*);
void showOpenGLNotCompatibleWarning();
void alternativesVisibilityChanged(bool visible);
private:
KScreen::Output *findPrimaryOutput() const;

Loading…
Cancel
Save