2007-09-26 09:44:06 +02:00
/*
* Copyright ( C ) 2007 Ivan Cukic < ivan . cukic + kde @ gmail . com >
*
* This program is free software ; you can redistribute it and / or modify
2007-10-12 10:44:02 +02:00
* it under the terms of the GNU Library / Lesser General Public License
* version 2 , or ( at your option ) any later version , as published by the
* Free Software Foundation
2007-09-26 09:44:06 +02:00
*
* 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
*
2007-10-12 10:44:02 +02:00
* You should have received a copy of the GNU Library / Lesser General Public
2007-09-26 09:44:06 +02:00
* License along with this program ; if not , write to the
* Free Software Foundation , Inc . ,
* 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA .
*/
2007-09-27 21:55:18 +02:00
# include "plasma/appletbrowser.h"
2007-09-27 20:51:31 +02:00
2008-02-29 09:10:14 +01:00
# include <QVBoxLayout>
# include <QLabel>
2007-09-26 09:44:06 +02:00
# include <KAction>
2007-10-08 23:50:38 +02:00
# include <KConfig>
# include <KConfigGroup>
2008-02-26 22:22:13 +01:00
# include <KMenu>
2008-02-29 09:10:14 +01:00
# include <KPageWidgetItem>
2008-02-26 22:22:13 +01:00
# include <KPushButton>
# include <KServiceTypeTrader>
# include <KStandardAction>
2007-09-27 21:39:28 +02:00
2008-02-29 09:10:14 +01:00
# include "plasma/applet.h"
2007-09-27 21:39:28 +02:00
# include "plasma/corona.h"
# include "plasma/containment.h"
2007-09-27 21:55:18 +02:00
# include "plasma/appletbrowser/kcategorizeditemsview_p.h"
2008-02-29 09:10:14 +01:00
# include "plasma/appletbrowser/plasmaappletitemmodel_p.h"
# include "plasma/appletbrowser/openwidgetassistant_p.h"
2008-10-14 00:40:00 +02:00
# include "plasma/private/packages_p.h"
2007-09-27 21:39:28 +02:00
namespace Plasma
{
2008-07-01 20:56:43 +02:00
class AppletBrowserWidgetPrivate
2007-09-27 21:39:28 +02:00
{
public :
2008-10-11 18:19:04 +02:00
AppletBrowserWidgetPrivate ( AppletBrowserWidget * w )
2008-04-29 22:01:23 +02:00
: q ( w ) ,
containment ( 0 ) ,
2007-09-27 21:39:28 +02:00
appletList ( 0 ) ,
2007-10-08 23:50:38 +02:00
config ( " plasmarc " ) ,
configGroup ( & config , " Applet Browser " ) ,
2007-11-16 13:23:42 +01:00
itemModel ( configGroup , w ) ,
filterModel ( w )
2007-09-27 21:39:28 +02:00
{
}
2007-11-06 22:10:11 +01:00
void initFilters ( ) ;
2008-04-29 22:01:23 +02:00
void init ( ) ;
void initRunningApplets ( ) ;
2008-07-17 20:36:55 +02:00
void containmentDestroyed ( ) ;
2007-11-06 22:10:11 +01:00
2008-04-29 22:01:23 +02:00
/**
* Tracks a new running applet
*/
2008-10-11 18:19:04 +02:00
void appletAdded ( Plasma : : Applet * applet ) ;
2008-04-29 22:01:23 +02:00
/**
* A running applet is no more
*/
2008-10-11 18:19:04 +02:00
void appletRemoved ( Plasma : : Applet * applet ) ;
2008-04-29 22:01:23 +02:00
AppletBrowserWidget * q ;
2007-11-06 03:45:24 +01:00
QString application ;
2007-09-27 21:39:28 +02:00
Plasma : : Containment * containment ;
KCategorizedItemsView * appletList ;
2008-02-13 05:03:17 +01:00
QHash < QString , int > runningApplets ; // applet name => count
2007-12-10 02:18:57 +01:00
//extra hash so we can look up the names of deleted applets
2008-10-12 00:48:38 +02:00
QHash < Plasma : : Applet * , QString > appletNames ;
2007-10-23 22:14:29 +02:00
2007-10-08 23:50:38 +02:00
KConfig config ;
KConfigGroup configGroup ;
2007-09-27 21:39:28 +02:00
PlasmaAppletItemModel itemModel ;
KCategorizedItemsViewModels : : DefaultFilterModel filterModel ;
} ;
2008-07-01 20:56:43 +02:00
void AppletBrowserWidgetPrivate : : initFilters ( )
2007-11-06 22:10:11 +01:00
{
filterModel . clear ( ) ;
filterModel . addFilter ( i18n ( " All Widgets " ) ,
2008-08-23 19:22:26 +02:00
KCategorizedItemsViewModels : : Filter ( ) , KIcon ( " plasma " ) ) ;
2007-11-06 22:10:11 +01:00
// Recommended emblems and filters
QRegExp rx ( " recommended[.]([0-9A-Za-z]+) [ . ] caption " ) ;
QMapIterator < QString , QString > i ( configGroup . entryMap ( ) ) ;
while ( i . hasNext ( ) ) {
i . next ( ) ;
if ( ! rx . exactMatch ( i . key ( ) ) ) {
continue ;
}
2008-01-08 02:25:09 +01:00
//kDebug() << "These are the key/vals in rc file " << rx.cap(1) << "\n";
2007-11-06 22:10:11 +01:00
QString id = rx . cap ( 1 ) ;
QString caption = configGroup . readEntry ( " recommended. " + id + " .caption " ) ;
QString icon = configGroup . readEntry ( " recommended. " + id + " .icon " ) ;
QString plugins = configGroup . readEntry ( " recommended. " + id + " .plugins " ) ;
2008-08-23 19:22:26 +02:00
appletList - > addEmblem ( i18n ( " Recommended by %1 " , caption ) , KIcon ( icon ) ,
2007-11-06 22:10:11 +01:00
KCategorizedItemsViewModels : : Filter ( " recommended. " + id , true ) ) ;
filterModel . addFilter ( i18n ( " Recommended by %1 " , caption ) ,
2008-10-12 00:48:38 +02:00
KCategorizedItemsViewModels : : Filter ( " recommended. " + id , true ) ,
KIcon ( icon ) ) ;
2007-11-06 22:10:11 +01:00
}
// Filters: Special
filterModel . addFilter ( i18n ( " My Favorite Widgets " ) ,
KCategorizedItemsViewModels : : Filter ( " favorite " , true ) ,
2008-08-23 19:22:26 +02:00
KIcon ( " bookmarks " ) ) ;
2007-11-06 22:10:11 +01:00
filterModel . addFilter ( i18n ( " Widgets I Have Used Before " ) ,
KCategorizedItemsViewModels : : Filter ( " used " , true ) ,
2008-08-23 19:22:26 +02:00
KIcon ( " view-history " ) ) ;
2007-12-10 02:18:57 +01:00
filterModel . addFilter ( i18n ( " Currently Running Widgets " ) ,
KCategorizedItemsViewModels : : Filter ( " running " , true ) ,
2008-08-23 19:22:26 +02:00
KIcon ( " view-history " ) ) ;
2007-11-06 22:10:11 +01:00
filterModel . addSeparator ( i18n ( " Categories: " ) ) ;
2008-10-11 18:19:04 +02:00
foreach ( const QString & category , Plasma : : Applet : : listCategories ( application ) ) {
2007-11-06 22:10:11 +01:00
filterModel . addFilter ( category ,
KCategorizedItemsViewModels : : Filter ( " category " , category ) ) ;
}
}
2008-04-29 22:01:23 +02:00
AppletBrowserWidget : : AppletBrowserWidget ( QWidget * parent , Qt : : WindowFlags f )
2007-11-16 13:23:42 +01:00
: QWidget ( parent , f ) ,
2008-07-01 20:56:43 +02:00
d ( new AppletBrowserWidgetPrivate ( this ) )
2007-09-26 09:44:06 +02:00
{
2008-04-29 22:01:23 +02:00
d - > init ( ) ;
2007-09-26 09:44:06 +02:00
}
2007-11-16 13:23:42 +01:00
AppletBrowserWidget : : ~ AppletBrowserWidget ( )
2007-09-27 21:39:28 +02:00
{
2007-11-16 13:23:42 +01:00
delete d ;
}
2008-07-01 20:56:43 +02:00
void AppletBrowserWidgetPrivate : : init ( )
2007-11-16 13:23:42 +01:00
{
2008-04-29 22:01:23 +02:00
QVBoxLayout * layout = new QVBoxLayout ( q ) ;
2007-11-16 13:23:42 +01:00
2008-04-29 22:01:23 +02:00
appletList = new KCategorizedItemsView ( q ) ;
2008-07-01 20:56:43 +02:00
QObject : : connect ( appletList , SIGNAL ( doubleClicked ( const QModelIndex & ) ) , q , SLOT ( addApplet ( ) ) ) ;
2008-04-29 22:01:23 +02:00
layout - > addWidget ( appletList ) ;
2007-09-27 21:39:28 +02:00
2007-10-08 23:50:38 +02:00
// Other Emblems
2008-08-23 19:22:26 +02:00
appletList - > addEmblem ( i18n ( " Widgets I Have Used Before " ) , KIcon ( " view-history " ) ,
2008-04-29 22:01:23 +02:00
KCategorizedItemsViewModels : : Filter ( " used " , true ) ) ;
2007-09-27 19:50:31 +02:00
2008-04-29 22:01:23 +02:00
initFilters ( ) ;
appletList - > setFilterModel ( & filterModel ) ;
2007-09-26 09:44:06 +02:00
// Other models
2008-04-29 22:01:23 +02:00
appletList - > setItemModel ( & itemModel ) ;
2007-12-10 02:18:57 +01:00
initRunningApplets ( ) ;
2008-02-18 21:55:50 +01:00
2008-04-29 22:01:23 +02:00
q - > setLayout ( layout ) ;
2007-12-10 02:18:57 +01:00
}
2008-07-01 20:56:43 +02:00
void AppletBrowserWidgetPrivate : : initRunningApplets ( )
2007-12-10 02:18:57 +01:00
{
//get applets from corona, count them, send results to model
2008-04-29 22:01:23 +02:00
if ( ! containment ) {
2008-02-26 22:22:13 +01:00
return ;
}
2008-04-29 22:01:23 +02:00
//kDebug() << runningApplets.count();
Plasma : : Corona * c = containment - > corona ( ) ;
2007-12-20 00:58:13 +01:00
2007-12-10 02:18:57 +01:00
//we've tried our best to get a corona
//we don't want just one containment, we want them all
if ( ! c ) {
2008-01-08 02:25:09 +01:00
kDebug ( ) < < " can't happen " ;
2007-12-10 02:18:57 +01:00
return ;
}
2007-12-20 00:58:13 +01:00
2008-04-29 22:01:23 +02:00
appletNames . clear ( ) ;
runningApplets . clear ( ) ;
2007-12-20 00:58:13 +01:00
QList < Containment * > containments = c - > containments ( ) ;
2008-06-23 00:06:43 +02:00
foreach ( Containment * containment , containments ) {
2008-07-01 20:56:43 +02:00
QObject : : connect ( containment , SIGNAL ( appletAdded ( Plasma : : Applet * , QPointF ) ) , q , SLOT ( appletAdded ( Plasma : : Applet * ) ) ) ;
QObject : : connect ( containment , SIGNAL ( appletRemoved ( Plasma : : Applet * ) ) , q , SLOT ( appletRemoved ( Plasma : : Applet * ) ) ) ;
2008-06-23 00:06:43 +02:00
foreach ( Applet * applet , containment - > applets ( ) ) {
runningApplets [ applet - > name ( ) ] + + ;
}
2007-12-10 02:18:57 +01:00
}
2008-02-13 05:03:17 +01:00
2008-04-29 22:01:23 +02:00
//kDebug() << runningApplets;
itemModel . setRunningApplets ( runningApplets ) ;
2007-09-26 09:44:06 +02:00
}
2008-10-11 18:19:04 +02:00
void AppletBrowserWidget : : setApplication ( const QString & app )
2007-09-26 09:44:06 +02:00
{
2007-11-06 03:45:24 +01:00
d - > application = app ;
2007-11-06 22:10:11 +01:00
d - > initFilters ( ) ;
d - > itemModel . setApplication ( app ) ;
//FIXME: AFAIK this shouldn't be necessary ... but here it is. need to find out what in that
// maze of models and views is screwing up
d - > appletList - > setItemModel ( & d - > itemModel ) ;
2007-12-10 02:18:57 +01:00
2008-06-29 02:06:04 +02:00
//kDebug() << d->runningApplets;
2008-02-13 05:03:17 +01:00
d - > itemModel . setRunningApplets ( d - > runningApplets ) ;
2007-11-06 03:45:24 +01:00
}
2007-11-16 13:23:42 +01:00
QString AppletBrowserWidget : : application ( )
2007-11-06 03:45:24 +01:00
{
return d - > application ;
}
2007-12-20 00:58:13 +01:00
2008-02-13 03:30:07 +01:00
void AppletBrowserWidget : : setContainment ( Plasma : : Containment * containment )
{
2008-05-25 22:03:28 +02:00
if ( d - > containment ! = containment ) {
2008-07-17 20:36:55 +02:00
if ( d - > containment ) {
d - > containment - > disconnect ( this ) ;
}
2008-05-25 22:03:28 +02:00
d - > containment = containment ;
2008-07-17 20:36:55 +02:00
if ( d - > containment ) {
connect ( d - > containment , SIGNAL ( destroyed ( QObject * ) ) , this , SLOT ( containmentDestroyed ( ) ) ) ;
}
2008-05-25 22:03:28 +02:00
d - > initRunningApplets ( ) ;
}
2008-02-13 03:30:07 +01:00
}
Containment * AppletBrowserWidget : : containment ( ) const
{
return d - > containment ;
}
2008-07-17 20:36:55 +02:00
void AppletBrowserWidgetPrivate : : containmentDestroyed ( )
{
containment = 0 ;
}
2007-11-16 13:23:42 +01:00
void AppletBrowserWidget : : addApplet ( )
2007-09-27 21:39:28 +02:00
{
2007-12-20 00:58:13 +01:00
if ( ! d - > containment ) {
return ;
}
2007-09-27 19:50:31 +02:00
2007-09-27 21:39:28 +02:00
foreach ( AbstractItem * item , d - > appletList - > selectedItems ( ) ) {
PlasmaAppletItem * selectedItem = ( PlasmaAppletItem * ) item ;
2008-06-29 02:06:04 +02:00
//kDebug() << "Adding applet " << selectedItem->name() << "to containment";
2007-12-20 00:58:13 +01:00
d - > containment - > addApplet ( selectedItem - > pluginName ( ) , selectedItem - > arguments ( ) ) ;
2007-09-27 19:50:31 +02:00
}
}
2007-09-27 20:51:31 +02:00
2008-10-11 18:19:04 +02:00
void AppletBrowserWidgetPrivate : : appletAdded ( Plasma : : Applet * applet )
2007-12-10 02:18:57 +01:00
{
QString name = applet - > name ( ) ;
2008-04-29 22:01:23 +02:00
//kDebug() << name;
2008-02-13 05:03:17 +01:00
2008-04-29 22:01:23 +02:00
runningApplets [ name ] + + ;
appletNames . insert ( applet , name ) ;
itemModel . setRunningApplets ( name , runningApplets [ name ] ) ;
2007-12-10 02:18:57 +01:00
}
2008-10-11 18:19:04 +02:00
void AppletBrowserWidgetPrivate : : appletRemoved ( Plasma : : Applet * applet )
2007-12-10 02:18:57 +01:00
{
2008-06-17 23:55:35 +02:00
//kDebug() << (QObject*)applet;
2008-10-11 18:19:04 +02:00
Plasma : : Applet * a = ( Plasma : : Applet * ) applet ; //don't care if it's valid, just need the address
2008-02-13 05:03:17 +01:00
2008-04-29 22:01:23 +02:00
QString name = appletNames . take ( a ) ;
2008-02-13 05:03:17 +01:00
int count = 0 ;
2008-04-29 22:01:23 +02:00
if ( runningApplets . contains ( name ) ) {
count = runningApplets [ name ] - 1 ;
2008-02-13 05:03:17 +01:00
if ( count < 1 ) {
2008-04-29 22:01:23 +02:00
runningApplets . remove ( name ) ;
2008-02-13 05:03:17 +01:00
} else {
2008-04-29 22:01:23 +02:00
runningApplets [ name ] = count ;
2008-02-13 05:03:17 +01:00
}
}
2008-04-29 22:01:23 +02:00
itemModel . setRunningApplets ( name , count ) ;
2007-12-10 02:18:57 +01:00
}
2008-02-19 10:19:02 +01:00
void AppletBrowserWidget : : destroyApplets ( const QString & name )
2007-12-10 02:18:57 +01:00
{
2008-02-26 22:22:13 +01:00
if ( ! d - > containment ) {
return ;
}
2008-02-13 05:03:17 +01:00
Plasma : : Corona * c = d - > containment - > corona ( ) ;
//we've tried our best to get a corona
//we don't want just one containment, we want them all
if ( ! c ) {
kDebug ( ) < < " can't happen " ;
return ;
}
foreach ( Containment * containment , c - > containments ( ) ) {
QList < Applet * > applets = containment - > applets ( ) ;
2008-04-29 22:01:23 +02:00
foreach ( Applet * applet , applets ) {
2008-02-13 05:03:17 +01:00
if ( applet - > name ( ) = = name ) {
2008-04-29 22:01:23 +02:00
d - > appletNames . remove ( applet ) ;
2008-02-13 05:03:17 +01:00
applet - > disconnect ( this ) ;
2008-04-29 22:01:23 +02:00
applet - > destroy ( ) ;
2008-02-13 05:03:17 +01:00
}
}
2007-12-10 02:18:57 +01:00
}
2008-02-13 05:03:17 +01:00
2007-12-10 02:18:57 +01:00
d - > runningApplets . remove ( name ) ;
2008-02-13 05:03:17 +01:00
d - > itemModel . setRunningApplets ( name , 0 ) ;
2007-12-10 02:18:57 +01:00
}
2008-10-14 00:40:00 +02:00
void AppletBrowserWidget : : downloadWidgets ( const QString & type )
2007-09-27 21:39:28 +02:00
{
2008-10-14 00:40:00 +02:00
kDebug ( ) < < type ;
PackageStructure * installer = 0 ;
if ( ! type . isEmpty ( ) ) {
QString constraint = QString ( " '%1' == [X-KDE-PluginInfo-Name] " ) . arg ( type ) ;
KService : : List offers = KServiceTypeTrader : : self ( ) - > query ( " Plasma/PackageStructure " ,
constraint ) ;
if ( offers . isEmpty ( ) ) {
kDebug ( ) < < " could not find requested PackageStructure plugin " < < type ;
} else {
KService : : Ptr service = offers . first ( ) ;
QString error ;
installer = service - > createInstance < Plasma : : PackageStructure > ( topLevelWidget ( ) ,
QVariantList ( ) , & error ) ;
if ( installer ) {
connect ( installer , SIGNAL ( newWidgetBrowserFinished ( ) ) ,
installer , SLOT ( deleteLater ( ) ) ) ;
} else {
kDebug ( ) < < " found, but could not load requested PackageStructure plugin " < < type
< < " ; reported error was " < < error ;
}
}
}
if ( ! installer ) {
// we don't need to delete the default Applet::packageStructure as that
// belongs to the applet
installer = new PlasmoidPackage ( ) ;
2008-06-16 11:04:14 +02:00
}
2008-10-14 00:40:00 +02:00
installer - > createNewWidgetBrowser ( this ) ;
2007-09-27 21:39:28 +02:00
}
2008-02-26 22:22:13 +01:00
void AppletBrowserWidget : : openWidgetFile ( )
{
2008-10-12 00:48:38 +02:00
// TODO: if we already have one of these showing and the user clicks to
// add it again, show the same window?
2008-02-29 09:10:14 +01:00
OpenWidgetAssistant * assistant = new OpenWidgetAssistant ( topLevelWidget ( ) ) ;
assistant - > setAttribute ( Qt : : WA_DeleteOnClose , true ) ;
2008-03-04 13:03:34 +01:00
assistant - > show ( ) ;
2008-02-26 22:22:13 +01:00
}
2007-11-16 13:23:42 +01:00
2008-07-01 20:56:43 +02:00
class AppletBrowserPrivate
2007-11-16 13:23:42 +01:00
{
2008-02-26 22:22:13 +01:00
public :
2008-10-14 00:40:00 +02:00
void init ( AppletBrowser * browser ) ;
void populateWidgetsMenu ( ) ;
AppletBrowser * q ;
2008-02-26 22:22:13 +01:00
AppletBrowserWidget * widget ;
2008-10-14 00:40:00 +02:00
QMenu * widgetsMenu ;
2008-02-26 22:22:13 +01:00
} ;
2007-11-16 13:23:42 +01:00
2008-10-14 00:40:00 +02:00
void AppletBrowserPrivate : : populateWidgetsMenu ( )
2007-11-16 13:23:42 +01:00
{
2008-10-14 00:40:00 +02:00
if ( ! widgetsMenu - > actions ( ) . isEmpty ( ) ) {
// already populated.
return ;
}
QSignalMapper * mapper = new QSignalMapper ( q ) ;
QObject : : connect ( mapper , SIGNAL ( mapped ( QString ) ) , widget , SLOT ( downloadWidgets ( QString ) ) ) ;
QAction * action = new QAction ( KIcon ( " applications-internet " ) ,
i18n ( " Download New Plasma Widgets " ) , q ) ;
QObject : : connect ( action , SIGNAL ( triggered ( bool ) ) , mapper , SLOT ( map ( ) ) ) ;
mapper - > setMapping ( action , QString ( ) ) ;
widgetsMenu - > addAction ( action ) ;
KService : : List offers = KServiceTypeTrader : : self ( ) - > query ( " Plasma/PackageStructure " ) ;
foreach ( const KService : : Ptr service , offers ) {
if ( service - > property ( " X-Plasma-ProvidesWidgetBrowser " ) . toBool ( ) ) {
QAction * action = new QAction ( KIcon ( " applications-internet " ) ,
i18n ( " Download New %1 Widgets " , service - > name ( ) ) , q ) ;
QObject : : connect ( action , SIGNAL ( triggered ( bool ) ) , mapper , SLOT ( map ( ) ) ) ;
mapper - > setMapping ( action , service - > property ( " X-KDE-PluginInfo-Name " ) . toString ( ) ) ;
}
}
widgetsMenu - > addSeparator ( ) ;
action = new QAction ( KIcon ( " package-x-generic " ) ,
i18n ( " Install A Widget From A Local File... " ) , q ) ;
QObject : : connect ( action , SIGNAL ( triggered ( bool ) ) , widget , SLOT ( openWidgetFile ( ) ) ) ;
widgetsMenu - > addAction ( action ) ;
2007-11-16 13:23:42 +01:00
}
2008-10-14 00:40:00 +02:00
void AppletBrowserPrivate : : init ( AppletBrowser * browser )
2007-11-16 13:23:42 +01:00
{
2008-10-14 00:40:00 +02:00
q = browser ;
2008-04-29 22:01:23 +02:00
widget = new AppletBrowserWidget ( q ) ;
2008-02-26 22:22:13 +01:00
q - > setMainWidget ( widget ) ;
q - > setWindowTitle ( i18n ( " Widgets " ) ) ;
q - > setButtons ( KDialog : : Apply | KDialog : : Close | KDialog : : User1 ) ;
q - > setButtonText ( KDialog : : Apply , i18n ( " Add Widget " ) ) ;
2008-02-28 04:53:26 +01:00
q - > setButtonText ( KDialog : : User1 , i18n ( " Install New Widgets " ) ) ;
2008-02-26 22:22:13 +01:00
2008-10-14 00:40:00 +02:00
widgetsMenu = new KMenu ( i18n ( " Get New Widgets " ) , q ) ;
QObject : : connect ( widgetsMenu , SIGNAL ( aboutToShow ( ) ) , q , SLOT ( populateWidgetsMenu ( ) ) ) ;
2008-02-26 22:22:13 +01:00
q - > button ( KDialog : : User1 ) - > setMenu ( widgetsMenu ) ;
q - > setButtonToolTip ( KDialog : : Close , i18n ( " Close the dialog " ) ) ;
q - > setButtonWhatsThis ( KDialog : : Close , i18n ( " <qt>When clicking <b>Close</b>, this dialog will be closed with no further action taken.</qt> " ) ) ;
q - > setButtonToolTip ( KDialog : : Apply , i18n ( " Add selected widgets " ) ) ;
q - > setButtonWhatsThis ( KDialog : : Apply , i18n ( " <qt>When clicking <b>Add Widget</b>, the selected widgets will be added to your desktop.</qt> " ) ) ;
2008-03-30 01:56:34 +01:00
q - > setButtonToolTip ( KDialog : : User1 , i18n ( " Install new widgets " ) ) ;
q - > setButtonWhatsThis ( KDialog : : User1 , i18n ( " <qt>Selecting <b>Get New Widgets</b> will show a window that allows you to download new widgets directly from the Internet, while Install From File allows you to add new widgets from files you have on disk.</qt> " ) ) ;
2008-02-26 22:22:13 +01:00
2008-07-01 20:56:43 +02:00
QObject : : connect ( q , SIGNAL ( applyClicked ( ) ) , widget , SLOT ( addApplet ( ) ) ) ;
2008-02-28 04:53:26 +01:00
q - > setInitialSize ( QSize ( 400 , 600 ) ) ;
KConfigGroup cg ( KGlobal : : config ( ) , " PlasmaAppletBrowserDialog " ) ;
q - > restoreDialogSize ( cg ) ;
2007-11-16 13:23:42 +01:00
}
2008-10-14 00:40:00 +02:00
AppletBrowser : : AppletBrowser ( QWidget * parent , Qt : : WindowFlags f )
: KDialog ( parent , f ) ,
d ( new AppletBrowserPrivate )
{
d - > init ( this ) ;
}
2007-11-16 13:23:42 +01:00
AppletBrowser : : ~ AppletBrowser ( )
{
2008-02-28 04:53:26 +01:00
KConfigGroup cg ( KGlobal : : config ( ) , " PlasmaAppletBrowserDialog " ) ;
saveDialogSize ( cg ) ;
2007-11-16 13:23:42 +01:00
}
2008-10-11 18:19:04 +02:00
void AppletBrowser : : setApplication ( const QString & app )
2007-11-16 13:23:42 +01:00
{
2008-10-11 18:19:04 +02:00
d - > widget - > setApplication ( app ) ;
2007-11-16 13:23:42 +01:00
}
QString AppletBrowser : : application ( )
{
2008-02-26 22:22:13 +01:00
return d - > widget - > application ( ) ;
2007-11-16 13:23:42 +01:00
}
2008-02-13 03:30:07 +01:00
void AppletBrowser : : setContainment ( Plasma : : Containment * containment )
{
2008-02-26 22:22:13 +01:00
d - > widget - > setContainment ( containment ) ;
2008-02-13 03:30:07 +01:00
}
2008-10-11 18:19:04 +02:00
Containment * AppletBrowser : : containment ( ) const
2008-02-13 03:30:07 +01:00
{
2008-02-26 22:22:13 +01:00
return d - > widget - > containment ( ) ;
2008-02-13 03:30:07 +01:00
}
2007-09-27 21:39:28 +02:00
} // namespace Plasma
2007-09-27 21:48:51 +02:00
# include "appletbrowser.moc"