/*************************************************************************** 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 #include #include #include #include #include "item.h" Item::Item(const QString& iconName, const QString& cmd, const 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 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; iname = 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= 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(const 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(const QString& newName) { name = newName; } void Item::setClass(const 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; }