extragear/multimedia/amarok/src/context

Nikolaj Hald Nielsen nhnfreespirit at gmail.com
Sun Feb 8 11:23:08 CET 2009


I don't know the technicalities of allowing scripted applets, so maybe
this is prescribed by technical necessity, but wont allowing applets
to be written in python ( and friends I presume ) undo much of the
point of switching to qtscript exclusively for scripts, as people will
now potentially run into all kinds of dependency issues, not just for
the language itself but any add on modules needed for xml parsing or
whatever?

- Nikolaj

On Sat, Feb 7, 2009 at 6:51 PM, Leo Franchi <lfranchi at kde.org> wrote:
> SVN commit 922869 by lfranchi:
>
> initial work on supporting scripted applets. added an "install amarok script" button for TESTING PURPOSES ONLY until we get a GHNS dialog up.
>
>  M  +23 -0     ToolbarView.cpp
>  M  +1 -0      ToolbarView.h
>  M  +2 -1      applets/CMakeLists.txt
>  A             applets/scriptedsample (directory)
>  A             applets/scriptedsample/contents (directory)
>  A             applets/scriptedsample/contents/code (directory)
>  A             applets/scriptedsample/contents/code/main.py
>  A             applets/scriptedsample/metadata.desktop
>  M  +1 -0      toolbar/AppletToolbar.cpp
>  M  +2 -0      toolbar/AppletToolbar.h
>  M  +1 -0      toolbar/AppletToolbarAddItem.cpp
>  M  +1 -0      toolbar/AppletToolbarAddItem.h
>  M  +20 -0     widgets/ToolBoxMenu.cpp
>  M  +4 -2      widgets/ToolBoxMenu.h
>
>
> --- trunk/extragear/multimedia/amarok/src/context/ToolbarView.cpp #922868:922869
> @@ -19,10 +19,14 @@
>  #include "toolbar/AppletToolbar.h"
>  #include "toolbar/AppletToolbarAppletItem.h"
>
> +#include <kfiledialog.h>
> +#include <kstandarddirs.h>
>  #include <plasma/applet.h>
>  #include <plasma/containment.h>
> +#include <plasma/packagestructure.h>
>  #include <plasma/theme.h>
>
> +#include <QDBusInterface>
>  #include <QGraphicsLinearLayout>
>  #include <QGraphicsScene>
>  #include <QPalette>
> @@ -59,6 +63,7 @@
>     m_toolbar->setPos( TOOLBAR_X_OFFSET, 0 );
>
>    connect( m_toolbar, SIGNAL( configModeToggled() ), this, SLOT( toggleConfigMode() ) );
> +   connect( m_toolbar, SIGNAL( installApplets() ), this, SLOT( installApplets() ) );
>
>    Context::Containment* cont = dynamic_cast< Context::Containment* >( containment );
>    if( cont )
> @@ -233,4 +238,22 @@
>     }
>  }
>
> +void
> +Context::ToolbarView::installApplets()
> +{
> +    DEBUG_BLOCK
> +    // TODO this hsould open the GHNS dialog, for now just allow user to specify package
> +    QString appletFile = KFileDialog::getOpenFileName( KUrl(), "*.amarokapplet.zip", this, "Please select Amarok Applet to install" );
> +
> +    debug() << "installing amarok applet file:" << appletFile;
> +    QString packageRoot = "plasma/plasmoids/";
> +    packageRoot = KStandardDirs::locateLocal("data", packageRoot);
> +
> +    Plasma::PackageStructure* installer = new Plasma::PackageStructure();
> +    installer->setServicePrefix( "amarok-context-applet-" );
> +    installer->installPackage( appletFile, packageRoot );
> +
> +    QDBusInterface dbus("org.kde.kded", "/kbuildsycoca", "org.kde.kbuildsycoca");
> +    dbus.call(QDBus::Block, "recreate");
> +}
>  #include "ToolbarView.moc"
> --- trunk/extragear/multimedia/amarok/src/context/ToolbarView.h #922868:922869
> @@ -53,6 +53,7 @@
>         void appletAdded( Plasma::Applet*, int);
>         void refreshOverlays();
>         void recreateOverlays();
> +        void installApplets();
>
>     private:
>         int m_height;
> --- trunk/extragear/multimedia/amarok/src/context/applets/CMakeLists.txt #922868:922869
> @@ -1,7 +1,8 @@
>  add_subdirectory( albums )
> - add_subdirectory( bookmark )
> +add_subdirectory( bookmark )
>  add_subdirectory( currenttrack )
>  add_subdirectory( lyrics )
> +add_subdirectory( scriptedsample )
>  add_subdirectory( serviceinfo )
>  add_subdirectory( wikipedia )
>  add_subdirectory( mediadevices )
> --- trunk/extragear/multimedia/amarok/src/context/toolbar/AppletToolbar.cpp #922868:922869
> @@ -406,6 +406,7 @@
>     DEBUG_BLOCK
>     Context::AppletToolbarAddItem* additem = new Context::AppletToolbarAddItem( this, m_cont, false );
>     connect( additem, SIGNAL( addApplet( const QString&, AppletToolbarAddItem* ) ), this, SLOT( addApplet( const QString&, AppletToolbarAddItem* ) ) );
> +    connect( additem, SIGNAL( installApplets() ), this, SIGNAL( installApplets() ) );
>     m_appletLayout->insertItem( loc, additem );
>     m_configAddIcons << additem;
>  }
> --- trunk/extragear/multimedia/amarok/src/context/toolbar/AppletToolbar.h #922868:922869
> @@ -61,7 +61,9 @@
>         void appletAddedToToolbar( Plasma::Applet* applet, int loc );
>         void moveApplet( Plasma::Applet*, int, int );
>         void configModeToggled();
> +        void installApplets();
>
> +
>     protected:
>         // reimplemented dfrom QGraphicsWidget
>         virtual void resizeEvent( QGraphicsSceneResizeEvent * event );
> --- trunk/extragear/multimedia/amarok/src/context/toolbar/AppletToolbarAddItem.cpp #922868:922869
> @@ -68,6 +68,7 @@
>     m_addMenu->setContainment( cont );
>     m_addMenu->setZValue( zValue() - 10000 );
>     connect( m_addMenu, SIGNAL( addAppletToContainment( const QString& ) ), this, SLOT( addApplet( const QString& ) ) );
> +    connect( m_addMenu, SIGNAL( installApplets() ), this, SIGNAL( installApplets() ) );
>
>   //  resize( QSizeF( 18, 24 ) );
>  }
> --- trunk/extragear/multimedia/amarok/src/context/toolbar/AppletToolbarAddItem.h #922868:922869
> @@ -51,6 +51,7 @@
>
>     signals:
>         void addApplet( const QString&, AppletToolbarAddItem*  );
> +        void installApplets();
>
>     public slots:
>         void updatedContainment( Containment* cont );
> --- trunk/extragear/multimedia/amarok/src/context/widgets/ToolBoxMenu.cpp #922868:922869
> @@ -18,6 +18,7 @@
>
>  #include <plasma/applet.h>
>  #include <plasma/corona.h>
> +
>  #include <kicon.h>
>
>  #define ENTRY_HEIGHT  32
> @@ -33,6 +34,7 @@
>     , m_containment( 0 )
>     , m_removeApplets( false )
>     , m_menuSize( 4 )
> +    , m_installScriptedApplet( 0 )
>     , m_showing( 0 )
>     , m_delay( 250 )
>  {
> @@ -114,6 +116,20 @@
>     m_downArrow = new ToolBoxIcon( this );
>     createArrow( m_upArrow, "up" );
>     createArrow( m_downArrow, "down" );
> +
> +    m_installScriptedApplet = new ToolBoxIcon( this );
> +    m_installScriptedApplet->setDrawBackground( true );
> +    m_installScriptedApplet->setOrientation( Qt::Horizontal );
> +    m_installScriptedApplet->setText( i18n( "Install Applets" ) );
> +    const QSizeF size( ENTRY_WIDTH - 60, ENTRY_HEIGHT - 9 );
> +    m_installScriptedApplet->setMinimumSize( size );
> +    m_installScriptedApplet->setMaximumSize( size );
> +    m_installScriptedApplet->resize( size );
> +    m_installScriptedApplet->setZValue( zValue() + 1 );
> +    m_installScriptedApplet->hide();
> +
> +    connect( m_installScriptedApplet, SIGNAL( clicked() ), this, SIGNAL( installApplets() ) );
> +
>  }
>
>  void
> @@ -295,6 +311,10 @@
>     m_hideIcon->setPos( 5, boundingRect().height() - ( ENTRY_HEIGHT + ENTRY_MARGIN ) * m_menuSize - OFFSET_Y + ENTRY_MARGIN * 2 );
>     m_hideIcon->show();
>     setZValue( zValue() + 10000 );
> +
> +    m_installScriptedApplet->setPos( 30, boundingRect().height() - ( ENTRY_HEIGHT + ENTRY_MARGIN ) * m_menuSize - OFFSET_Y + ENTRY_MARGIN * 2 );
> +    m_installScriptedApplet->show();
> +
>     for( int i = m_currentMenu.count() - 1; i >= 0; i-- )
>     {
>         ToolBoxIcon *entry = m_currentMenu[m_currentMenu.count() - i - 1];
> --- trunk/extragear/multimedia/amarok/src/context/widgets/ToolBoxMenu.h #922868:922869
> @@ -54,6 +54,7 @@
>  Q_SIGNALS:
>     void menuHidden();
>     void addAppletToContainment( const QString& );
> +    void installApplets();
>
>  protected:
>     virtual void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
> @@ -70,7 +71,7 @@
>     void scrollUp();
>     void timeToHide();
>     void addApplet( const QString &pluginName );
> -
> +
>  private:
>     void init( QMap< QString, QString > allAppletsList, QStringList appletsToShow );
>     void createArrow( ToolBoxIcon *arrow, const QString &direction );
> @@ -95,7 +96,8 @@
>     ToolBoxIcon *m_hideIcon;
>     ToolBoxIcon *m_upArrow;
>     ToolBoxIcon *m_downArrow;
> -
> +    ToolBoxIcon* m_installScriptedApplet;
> +
>     QMap<Plasma::Containment *, QStringList> m_runningApplets;
>
>     QTimer *m_timer;
>


More information about the Amarok-devel mailing list