[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-panel-devel
Subject: [Panel-devel] [PATCH] text in launcher applet
From: Marco Martin <martkive () gmail ! com>
Date: 2007-11-30 12:31:58
Message-ID: 200711301331.59264.martkive () gmail ! com
[Download RAW message or body]
Hi,
this patch adds text in the launcher applet (like the trashcan only in the
desktop and not in the panel)
it uses the filename part of the url if it's a normal file
if it's a desktop file it uses the name and the icon stored in it.
Cheers,
Marco Martin
["url.diff" (text/x-diff)]
--- url_1.cpp 2007-11-30 13:25:09.000000000 +0100
+++ url.cpp 2007-11-30 13:24:30.000000000 +0100
@@ -29,6 +29,7 @@
#include <KRun>
#include <KSharedConfig>
#include <KUrl>
+#include <KDesktopFile>
#include <plasma/layouts/boxlayout.h>
#include <plasma/widgets/icon.h>
@@ -39,8 +40,9 @@
m_dialog(0)
{
setAcceptDrops(true);
- new Plasma::HBoxLayout(this);
+ //new Plasma::HBoxLayout(this);
m_icon = new Plasma::Icon(this);
+ setMinimumSize(QSize(48,48));
if (args.count() > 2) {
setUrl(args.at(2).toString());
}
@@ -71,7 +73,15 @@
KMimeType::Ptr mime = KMimeType::findByUrl(url);
m_mimetype = mime->name();
- m_icon->setIcon(KMimeType::iconNameForUrl(url));
+
+ if (m_url.isLocalFile() && KDesktopFile::isDesktopFile(m_url.toLocalFile())) {
+ KDesktopFile *f= new KDesktopFile(m_url.toLocalFile());
+ m_text = f->readName();
+ m_icon->setIcon(f->readIcon());
+ }else{
+ m_text = m_url.fileName();
+ m_icon->setIcon(KMimeType::iconNameForUrl(url));
+ }
if (m_icon->icon().isNull()) {
m_icon->setIcon("unknown");
@@ -91,6 +101,16 @@
void Url::constraintsUpdated(Plasma::Constraints constraints)
{
setDrawStandardBackground(false);
+
+ if (constraints & Plasma::FormFactorConstraint) {
+ if (formFactor() == Plasma::Planar ||
+ formFactor() == Plasma::MediaCenter) {
+ m_icon->setText(m_text);
+ } else {
+ m_icon->setText(0);
+ }
+ }
+
if (constraints & Plasma::SizeConstraint) {
m_icon->resize(size());
}
@@ -111,6 +131,7 @@
KConfigGroup cg = config();
m_url = m_dialog->kurl();
cg.writeEntry("Url", m_url);
+ setUrl(m_url);
update();
delete m_dialog;
m_dialog = 0;
@@ -128,5 +149,6 @@
}
}
+
#include "url.moc"
--- url_1.h 2007-11-29 13:36:53.000000000 +0100
+++ url.h 2007-11-30 13:20:05.000000000 +0100
@@ -58,6 +58,7 @@
private:
Plasma::Icon* m_icon;
+ QString m_text;
KPropertiesDialog *m_dialog;
QString m_mimetype;
KUrl m_url;
_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic