aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
diff options
context:
space:
mode:
authorKris Moore <kris@pcbsd.org>2014-09-04 11:42:13 -0400
committerKris Moore <kris@pcbsd.org>2014-09-04 11:42:13 -0400
commit71737f70949bd25f9aa8bc4e7d03039ba83c6cb1 (patch)
treeab29e864d1ae59d10cc6875af9541e3ad306b2fb /lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
parentInitial commit (diff)
downloadlumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.gz
lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.tar.bz2
lumina-71737f70949bd25f9aa8bc4e7d03039ba83c6cb1.zip
Initial import of the lumina code from pcbsd git repo
Diffstat (limited to 'lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp')
-rw-r--r--lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp b/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
new file mode 100644
index 00000000..21b1d1f6
--- /dev/null
+++ b/lumina-desktop/desktop-plugins/desktopview/DeskItem.cpp
@@ -0,0 +1,50 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "DeskItem.h"
+
+DeskItem::DeskItem(QWidget *parent, QString itempath, int ssize) : QToolButton(parent){
+ this->setFixedSize(ssize, ssize);
+ this->setWhatsThis(itempath);
+ this->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
+ this->setAutoRaise(true);
+ int txtheight = this->fontMetrics().height() *2;
+ this->setIconSize( QSize(ssize-txtheight, ssize-txtheight));
+ connect(this, SIGNAL(clicked()), this, SLOT(RunItem()) );
+ updateItem();
+}
+
+DeskItem::~DeskItem(){
+
+}
+
+void DeskItem::updateItem(){
+ QFileInfo info(this->whatsThis());
+ QIcon ico;
+ QString txt;
+ if(info.isDir()){
+ ico = LXDG::findIcon("folder","");
+ txt = info.fileName();
+ }else if(info.suffix()=="desktop"){
+ bool ok = false;
+ XDGDesktop dsk = LXDG::loadDesktopFile(this->whatsThis(), ok);
+ if(ok){
+ ico = LXDG::findIcon( dsk.icon );
+ txt = dsk.name;
+ }else{
+ ico = LXDG::findIcon("","");
+ txt = info.fileName();
+ }
+ }else{
+ ico = LXDG::findIcon("application-x-zerosize","");
+ txt = info.fileName();
+ }
+ this->setIcon(ico);
+ //Trim the text size to fit
+ txt = this->fontMetrics().elidedText(txt, Qt::ElideRight ,this->width() - 4);
+ this->setText(txt);
+
+} \ No newline at end of file
bgstack15