summaryrefslogtreecommitdiffstats
path: root/src/item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/item.cpp')
-rw-r--r--src/item.cpp274
1 files changed, 274 insertions, 0 deletions
diff --git a/src/item.cpp b/src/item.cpp
new file mode 100644
index 0000000..1de9cf7
--- /dev/null
+++ b/src/item.cpp
@@ -0,0 +1,274 @@
+/***************************************************************************
+ item.cpp - description
+ -------------------
+ begin : Fri May 23 2003
+ copyright : (C) 2003 by KoolDock team
+ email :
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <kglobal.h>
+#include <kicontheme.h>
+
+#include <qfile.h>
+#include <qimage.h>
+#include <qtextstream.h>
+
+#include "item.h"
+
+Item::Item(QString iconName, QString cmd, QString name, int minSize, int maxSize) {
+ iLoader = KGlobal::iconLoader();
+ command = cmd;
+ this->name = name;
+ mCount=0;
+ mIndex=0;
+ mMIndex=0;
+ mClass="";
+ this->minSize = minSize;
+ this->maxSize = maxSize;
+ this->iconName = iconName;
+
+ QImage icon(iLoader->loadIcon(iconName, KIcon::NoGroup, 64).convertToImage());
+ if (minSize <= maxSize)
+ {
+ int count = maxSize - minSize + 1;
+
+ icons.setAutoDelete(TRUE);
+
+ for(int i=0; i<count; i++)
+ {
+ if (i % SIZE_INC == 0)
+ {
+ icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i)));
+ }
+ }
+ }
+
+ id = 0;
+ animed = FALSE;
+}
+
+
+Item::Item(QString fileName, int minSize, int maxSize)
+{
+ QString line;
+ QFile in(fileName);
+ in.open(IO_ReadOnly);
+ mCount=0;
+ mIndex=0;
+ mMIndex=0;
+ mClass="";
+ if(in.readLine(line, MAX_LEN) != -1)
+ {
+ if(line.contains("[Desktop Entry]", FALSE) > 0)
+ {
+ while (in.readLine(line, MAX_LEN) != -1)
+ {
+ if(line.startsWith("Exec="))
+ {
+ command = line.mid(5).stripWhiteSpace();
+ }
+ else if(line.startsWith("Icon="))
+ {
+ iconName = line.mid(5).stripWhiteSpace();
+ }
+ else if(line.startsWith("Name="))
+ {
+ name = line.mid(5).stripWhiteSpace();
+ }
+ }
+ }
+ }
+
+ in.close();
+
+ iLoader = KGlobal::iconLoader();
+ this->minSize = minSize;
+ this->maxSize = maxSize;
+ this->filename = fileName;
+ mCount=0;
+ mIndex=0;
+ mMIndex=0;
+ mClass="";
+ QImage icon(iLoader->loadIcon(iconName, KIcon::NoGroup, 64).convertToImage());
+ if (minSize <= maxSize)
+ {
+ int count = maxSize - minSize + 1;
+
+ icons.setAutoDelete(TRUE);
+
+ for(int i=0; i<count; i++)
+ {
+ if (i % SIZE_INC == 0)
+ {
+ icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i)));
+ }
+ }
+ }
+
+ id = 0;
+ animed = FALSE;
+}
+
+Item::Item(QPixmap iconBig, WId id, QString name, int minSize, int maxSize, bool wi)
+{
+ setId(id);
+ this->name = name;
+ mCount=0;
+ mIndex=0;
+ mMIndex=0;
+ mClass="";
+ this->minSize = minSize;
+ this->maxSize = maxSize;
+ command = "";
+ wIcon=wi;
+ QImage icon(iconBig.convertToImage());
+ if(minSize <= maxSize)
+ {
+ int count = maxSize - minSize + 1;
+
+ icons.setAutoDelete(TRUE);
+
+ for(int i=0; i<count; i++)
+ {
+ if (i % SIZE_INC == 0)
+ {
+ if (wi)
+ {icons.append(new QPixmap(icon));}
+ else
+ {
+ icons.append(new QPixmap(icon.scale(minSize + i, minSize + i)));
+ }
+//moothS
+ }
+ }
+ }
+ animed = FALSE;
+}
+
+Item::~Item()
+{
+}
+
+QPixmap* Item::getIcon(int size)
+{
+ if ((size >= minSize) && (size <= maxSize))
+ {
+ int d = size - minSize;
+ return(icons.at(d / SIZE_INC));
+
+ //return(new QPixmap (icons.at(maxSize-minSize)->convertToImage().scale(size,size)));
+ }
+ else
+ {
+ return(0);
+ }
+}
+
+QString Item::getCommand()
+{
+ return(command);
+}
+
+QString Item::getName()
+{
+ return(name);
+}
+
+QCString Item::getClass()
+{
+ return(mClass);
+}
+
+int Item::getCount()
+{
+ return(mCount);
+}
+
+int Item::getIndex()
+{
+ return(mIndex);
+}
+
+int Item::getMIndex()
+{
+ return(mMIndex);
+}
+
+QString Item::getFilename()
+{
+ return(filename);
+}
+
+WId Item::getId()
+{
+ return(id);
+}
+
+void Item::setId(WId newId)
+{
+
+ info = KWin::windowInfo(newId, 0, NET::WM2AllowedActions);
+ id=newId;
+}
+
+void Item::setIcon(QPixmap iconBig)
+{
+ icons.clear();
+ QImage icon(iconBig.convertToImage());
+
+ int count = maxSize - minSize + 1;
+
+ icons.setAutoDelete(TRUE);
+
+ for (int i = 0; i < count; i++)
+ {
+ if (i % SIZE_INC == 0)
+ {
+ icons.append(new QPixmap(icon.smoothScale(minSize + i, minSize + i)));
+ }
+ }
+}
+
+void Item::setName(QString newName)
+{
+ name = newName;
+}
+
+void Item::setClass(QCString newClass)
+{
+ mClass = newClass;
+}
+
+void Item::setCount(int newCount)
+{
+ mCount = newCount;
+}
+
+void Item::setIndex(int newIndex)
+{
+ mIndex = newIndex;
+}
+
+void Item::setMIndex(int newIndex)
+{
+ mMIndex = newIndex;
+}
+
+bool Item::isAnimed()
+{
+ return(this->animed);
+}
+
+void Item::anim(bool param)
+{
+ this->animed=param;
+}