[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer
From: Petri Damstén <petri.damsten () kdemail ! net>
Date: 2009-11-23 10:09:45
Message-ID: 1258970985.031716.554.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1053110 by pdamsten:
* Add about info to the tooltip
* Add code for uninstall
Review: http://reviewboard.kde.org/r/2213/
M +17 -3 appletslist.cpp
M +1 -0 appletslist.h
M +52 -24 applettooltip.cpp
M +6 -1 applettooltip.h
M +5 -0 plasmaappletitemmodel.cpp
M +1 -0 plasmaappletitemmodel_p.h
M +0 -30 widgetexplorer.cpp
M +0 -5 widgetexplorer.h
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/appletslist.cpp \
#1053109:1053110 @@ -197,6 +197,8 @@
connect(m_modelFilterItems, SIGNAL(searchTermChanged(QString)), this, \
SLOT(updateList()));
connect(m_modelFilterItems, SIGNAL(filterChanged()), this, SLOT(updateList()));
+ connect(m_modelItems, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, \
int)), + this, SLOT(rowsAboutToBeRemoved(const QModelIndex&, int, int)));
updateList();
}
@@ -295,7 +297,8 @@
m_toolTip->setAppletIconWidget(applet);
m_toolTipAppearTimer.start(TOOLTIP_APPEAR_DELAY, this);
} else {
- if(!(m_toolTip->appletIconWidget()->appletItem()->pluginName() ==
+ if(m_toolTip->appletIconWidget()->appletItem() &&
+ !(m_toolTip->appletIconWidget()->appletItem()->pluginName() ==
applet->appletItem()->pluginName())) {
m_toolTip->setAppletIconWidget(applet);
@@ -353,7 +356,7 @@
animateToolTipMove();
} else {
m_toolTip->move(toolTipMoveTo);
- }
+ }
}
void AppletsListWidget::insertAppletIcon(AppletIconWidget *appletIconWidget)
@@ -445,7 +448,7 @@
for (int i = 0; i < m_modelFilterItems->rowCount(); i++) {
PlasmaAppletItem *appletItem = \
static_cast<PlasmaAppletItem*>(getItemByProxyIndex(m_modelFilterItems->index(i, 0))); \
- if (appletItem) {
+ if (appletItem && m_allAppletsHash.contains(appletItem->id())) {
AppletIconWidget *appletIconWidget = \
m_allAppletsHash.value(appletItem->id()); insertAppletIcon(appletIconWidget);
m_currentAppearingAppletsOnList.append(appletIconWidget);
@@ -822,3 +825,14 @@
return m_iconSize;
}
+void AppletsListWidget::rowsAboutToBeRemoved(const QModelIndex& parent, int row, int \
column) +{
+ Q_UNUSED(parent)
+ Q_UNUSED(column)
+ PlasmaAppletItem *item = \
dynamic_cast<PlasmaAppletItem*>(m_modelItems->item(row)); + if (item) {
+ m_allAppletsHash.remove(item->id());
+ updateList();
+ m_toolTip->hide();
+ }
+}
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/appletslist.h \
#1053109:1053110 @@ -131,6 +131,7 @@
void animateToolTipMove();
void toolTipMoveTimeLineFrameChanged(int frame);
+ void rowsAboutToBeRemoved(const QModelIndex& parent, int row, int column);
protected:
bool eventFilter(QObject *obj, QEvent *event);
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/applettooltip.cpp \
#1053109:1053110 @@ -23,6 +23,7 @@
#include <kiconloader.h>
#include <kpushbutton.h>
#include <ktextbrowser.h>
+#include <KStandardDirs>
#include <Plasma/Corona>
#include <Plasma/Theme>
@@ -90,7 +91,7 @@
}
void AppletToolTipWidget::dragEnterEvent(QDragEnterEvent *event)
-{kWarning()<<"AAAAAAAAAAAAAAA";
+{
Q_UNUSED(event);
emit(leave());
}
@@ -111,7 +112,8 @@
void AppletInfoWidget::init()
{
m_iconWidget = new Plasma::IconWidget(this);
- m_nameLabel = new Plasma::TextBrowser(this);
+ m_nameLabel = new Plasma::Label(this);
+ m_versionLabel = new Plasma::Label(this);
m_aboutLabel = new Plasma::TextBrowser(this);
m_uninstallButton = new Plasma::PushButton(this);
@@ -119,11 +121,14 @@
m_uninstallButton->setIcon(KIcon("application-exit"));
m_uninstallButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum, \
QSizePolicy::ButtonBox); m_uninstallButton->setVisible(false);
+ connect(m_uninstallButton, SIGNAL(clicked()), this, SLOT(uninstall()));
// layout init
QGraphicsLinearLayout *textLayout = new QGraphicsLinearLayout(Qt::Vertical);
+ textLayout->addStretch();
textLayout->addItem(m_nameLabel);
- textLayout->addItem(m_aboutLabel);
+ textLayout->addItem(m_versionLabel);
+ textLayout->addStretch();
m_mainLayout = new QGraphicsLinearLayout();
m_mainLayout->addItem(m_iconWidget);
@@ -133,8 +138,9 @@
m_mainVerticalLayout = new QGraphicsLinearLayout(Qt::Vertical);
m_mainVerticalLayout->addItem(m_mainLayout);
+ m_mainVerticalLayout->addItem(m_aboutLabel);
+ m_mainVerticalLayout->addStretch();
m_mainVerticalLayout->addItem(m_uninstallButton);
- m_mainVerticalLayout->setAlignment(m_uninstallButton, Qt::AlignBottom);
// header init
m_iconWidget->setAcceptHoverEvents(false);
@@ -142,30 +148,18 @@
m_iconWidget->setMinimumSize(IconSize(KIconLoader::Desktop), \
IconSize(KIconLoader::Desktop));
m_iconWidget->setMaximumSize(IconSize(KIconLoader::Desktop), \
IconSize(KIconLoader::Desktop));
- QFont font = m_nameLabel->nativeWidget()->font();
+ QFont font = m_versionLabel->nativeWidget()->font();
font.setBold(true);
- font.setPointSize(1.2 * font.pointSize());
+ font.setPointSizeF(0.9 * font.pointSizeF());
+ m_versionLabel->setFont(font);
+ font = m_nameLabel->nativeWidget()->font();
+ font.setBold(true);
+ font.setPointSizeF(1.2 * font.pointSizeF());
m_nameLabel->setFont(font);
- m_nameLabel->nativeWidget()->setFixedHeight(m_iconWidget->maximumHeight());
- m_nameLabel->nativeWidget()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_nameLabel->nativeWidget()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_nameLabel->nativeWidget()->setSizePolicy(QSizePolicy::Preferred, \
QSizePolicy::Fixed);
- // about label
- font.setBold(false);
- m_aboutLabel->setFont(font);
m_aboutLabel->nativeWidget()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_aboutLabel->nativeWidget()->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- m_aboutLabel->nativeWidget()->setAlignment(Qt::AlignLeft | Qt::AlignTop);
- m_aboutLabel->nativeWidget()->setSizePolicy(QSizePolicy::Preferred, \
QSizePolicy::Fixed);
- //set palette
- QPalette plasmaPalette = QPalette();
- QColor textColor = \
Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor);
- plasmaPalette.setColor(QPalette::Text, textColor);
- m_nameLabel->nativeWidget()->setPalette(plasmaPalette);
- m_aboutLabel->nativeWidget()->setPalette(plasmaPalette);
-
setLayout(m_mainVerticalLayout);
}
@@ -179,11 +173,45 @@
if (m_appletItem) {
m_iconWidget->setIcon(m_appletItem->icon());
m_nameLabel->setText(m_appletItem->name());
- m_aboutLabel->setText(m_appletItem->description());
+ m_versionLabel->setText(i18n("Version %1", m_appletItem->version()));
+ QString description = "<html><body>";
+ if (!m_appletItem->description().isEmpty()) {
+ description += m_appletItem->description() + "<br/><br/>";
+ }
+ if (!m_appletItem->author().isEmpty()) {
+ description += i18n("Author:") + "<div style=\"margin-left: 15px\">" +
+ m_appletItem->author();
+ if (!m_appletItem->email().isEmpty()) {
+ description += " <a href=\"mailto:" + m_appletItem->email() + "\">" \
+ + m_appletItem->email() + "</a>";
+ }
+ description += "</div>";
+ }
+ if (!m_appletItem->website().isEmpty()) {
+ description += i18n("Website:") + "<div style=\"margin-left: 15px\">" + \
"<a href=\"" + + m_appletItem->website() + "\">" + \
m_appletItem->website() + + "</a></div>";
+ }
+ description += i18n("License:") + "<div style=\"margin-left: 15px\">" +
+ m_appletItem->license() + "</div>";
+ description += "</body></html>";
+ m_aboutLabel->setText(description);
m_uninstallButton->setVisible(m_appletItem->isLocal());
} else {
m_iconWidget->setIcon("plasma");
- m_nameLabel->setText("Unknown Applet");
+ m_nameLabel->setText(i18n("Unknown Applet"));
m_uninstallButton->setVisible(false);
}
}
+
+void AppletInfoWidget::uninstall()
+{
+ Plasma::PackageStructure installer;
+ installer.uninstallPackage(m_appletItem->pluginName(),
+ KStandardDirs::locateLocal("data", \
"plasma/plasmoids/")); + PlasmaAppletItemModel *model = \
m_appletItem->appletItemModel(); + \
model->takeRow(model->indexFromItem(m_appletItem).row()); + delete m_appletItem;
+ m_appletItem = 0;
+}
+
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/applettooltip.h \
#1053109:1053110 @@ -31,6 +31,7 @@
#include <plasma/widgets/iconwidget.h>
#include <plasma/widgets/pushbutton.h>
#include <plasma/widgets/textbrowser.h>
+#include <plasma/widgets/label.h>
class AppletInfoWidget : public QGraphicsWidget {
@@ -46,13 +47,17 @@
public Q_SLOTS:
void updateInfo();
+ protected Q_SLOTS:
+ void uninstall();
+
private:
PlasmaAppletItem *m_appletItem;
QGraphicsLinearLayout *m_mainLayout;
QGraphicsLinearLayout *m_mainVerticalLayout;
Plasma::IconWidget *m_iconWidget;
- Plasma::TextBrowser *m_nameLabel;
+ Plasma::Label *m_nameLabel;
+ Plasma::Label *m_versionLabel;
Plasma::TextBrowser *m_aboutLabel;
Plasma::PushButton *m_uninstallButton;
};
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/plasmaappletitemmodel.cpp \
#1053109:1053110 @@ -156,6 +156,11 @@
return types;
}
+PlasmaAppletItemModel* PlasmaAppletItem::appletItemModel()
+{
+ return m_model;
+}
+
//PlasmaAppletItemModel
PlasmaAppletItemModel::PlasmaAppletItemModel(KConfigGroup configGroup, QObject * \
parent) :
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/plasmaappletitemmodel_p.h \
#1053109:1053110 @@ -56,6 +56,7 @@
int running() const;
bool isLocal() const;
void setFavorite(bool favorite);
+ PlasmaAppletItemModel* appletItemModel();
//set how many instances of this applet are running
void setRunning(int count);
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/widgetexplorer.cpp \
#1053109:1053110 @@ -365,36 +365,6 @@
d->containment->addApplet(appletItem->pluginName(), appletItem->arguments());
}
-void WidgetExplorer::destroyApplets(const QString &name)
-{
- if (!d->containment) {
- return;
- }
-
- 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();
- foreach (Applet *applet, applets) {
- if (applet->pluginName() == name) {
- d->appletNames.remove(applet);
- applet->disconnect(this);
- applet->destroy();
- }
- }
- }
-
- d->runningApplets.remove(name);
- d->itemModel.setRunningApplets(name, 0);
-}
-
void WidgetExplorer::downloadWidgets(const QString &type)
{
PackageStructure *installer = 0;
--- trunk/KDE/kdebase/workspace/libs/plasmagenericshell/widgetsExplorer/widgetexplorer.h \
#1053109:1053110 @@ -114,11 +114,6 @@
void addApplet(PlasmaAppletItem *appletItem);
/**
- * Destroy all applets with this name
- */
- void destroyApplets(const QString &name);
-
- /**
* Launches a download dialog to retrieve new applets from the Internet
*
* @arg type the type of widget to download; an empty string means the default
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic