AppletInfoDrag::AppletInfoDrag(const AppletInfo& info, QWidget *dragSource) : QDragObject(dragSource, 0) { QBuffer buff(a); buff.open(IO_WriteOnly); QDataStream s(&buff); s << info.desktopFile() << info.configFile() << info.type(); }
AppletWidget::AppletWidget(const AppletInfo& info, bool odd, QWidget *parent) : AppletItem(parent), m_appletInfo(info), m_odd(odd), m_selected(false) { setFocusPolicy(QWidget::StrongFocus); setSelected(m_selected); itemTitle->setText("<h3>" + info.name() + "</h3>"); itemTitle->installEventFilter(this); if (info.comment() != info.name()) { itemDescription->setText(info.comment()); } itemDescription->installEventFilter(this); KIconLoader * ldr = KGlobal::iconLoader(); QPixmap icon = ldr->loadIcon(info.icon(), KIcon::Panel, KIcon::SizeLarge); itemPixmap->setPixmap(icon); itemPixmap->installEventFilter(this); }
bool AppletInfo::operator>(const AppletInfo &rhs) const { return (QString::localeAwareCompare(name(), rhs.name()) > 0); }
bool AppletInfo::operator!=(const AppletInfo &rhs) const { return configFile() != rhs.configFile(); }
void AppletManager::init() { // register built-in applets AppletInfo* info; info = new AppMenuAppletInfo(); knownApplets_.insert(info->id(), info); info = new ClockAppletInfo(); knownApplets_.insert(info->id(), info); info = new ShowDesktopAppletInfo(); knownApplets_.insert(info->id(), info); info = new LauncherAppletInfo(); knownApplets_.insert(info->id(), info); info = new NetStatusAppletInfo(); knownApplets_.insert(info->id(), info); info = new BlankAppletInfo(); knownApplets_.insert(info->id(), info); info = new PagerAppletInfo(); knownApplets_.insert(info->id(), info); info = new TaskAppletInfo(); knownApplets_.insert(info->id(), info); info = new SysTrayAppletInfo(); knownApplets_.insert(info->id(), info); info = new VolumeAppletInfo(); knownApplets_.insert(info->id(), info); // Find dynamically loaded applets // By default, load the deaktop entry files from /usr/share/lxpanel-qt/applets QDir dir; dir.cd(LXPANEL_DATA_DIR "/applets"); qDebug("loading: %s", LXPANEL_DATA_DIR "/applets"); QStringList files = dir.entryList(); Q_FOREACH(QString file, files) { if(file[0] != '.' && file.endsWith(".desktop")) { qDebug("find applet: %s", qPrintable(file)); QString id = file.left(file.length() - 8); QString soPath = LXPANEL_LIB_DIR "/applets/" + id + ".so"; AppletPluginInfo* info = new AppletPluginInfo(id, soPath, dir.absoluteFilePath(file)); knownApplets_.insert(info->id(), info); } } }
Applet* AppletManager::createApplet(QString typeName) { AppletInfo* appletInfo = knownApplets_.value(typeName, NULL); if(appletInfo) return appletInfo->create(NULL); return NULL; }