From kde-panel-devel Fri Nov 30 12:31:58 2007 From: Marco Martin Date: Fri, 30 Nov 2007 12:31:58 +0000 To: kde-panel-devel Subject: [Panel-devel] [PATCH] text in launcher applet Message-Id: <200711301331.59264.martkive () gmail ! com> X-MARC-Message: https://marc.info/?l=kde-panel-devel&m=119642603106728 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_/KAUHE/n9wCJVgn" --Boundary-00=_/KAUHE/n9wCJVgn Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --Boundary-00=_/KAUHE/n9wCJVgn Content-Type: text/x-diff; charset="us-ascii"; name="url.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="url.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 #include #include +#include #include #include @@ -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; --Boundary-00=_/KAUHE/n9wCJVgn Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Panel-devel mailing list Panel-devel@kde.org https://mail.kde.org/mailman/listinfo/panel-devel --Boundary-00=_/KAUHE/n9wCJVgn--