2005-09-07 00:51:35 +02:00
|
|
|
/*****************************************************************
|
|
|
|
Copyright (c) 2000-2001 Matthias Elter <elter@kde.org>
|
|
|
|
Copyright (c) 2001 John Firebaugh <jfirebaugh@kde.org>
|
|
|
|
Copyright (c) 2001-2005 Aaron Seigo <aseigo@kde.org>
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <kdesktopfile.h>
|
|
|
|
#include <kapplication.h>
|
|
|
|
|
|
|
|
#include "appletinfo.h"
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class AppletInfo::Private
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
public:
|
|
|
|
Private()
|
|
|
|
: unique(false),
|
|
|
|
hidden(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
QString name;
|
|
|
|
QString comment;
|
|
|
|
QString icon;
|
|
|
|
QString lib;
|
|
|
|
QString languageBindings;
|
|
|
|
QString desktopFile;
|
|
|
|
QString desktopFilePath;
|
|
|
|
bool unique;
|
|
|
|
bool hidden;
|
2005-09-07 00:51:35 +02:00
|
|
|
};
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
AppletInfo::AppletInfo(const QString& desktopFile)
|
2005-09-07 00:51:35 +02:00
|
|
|
{
|
|
|
|
d = new Private;
|
2005-09-07 22:23:08 +02:00
|
|
|
QFileInfo fi(desktopFile);
|
2005-09-07 00:51:35 +02:00
|
|
|
d->desktopFilePath = fi.absFilePath();
|
|
|
|
d->desktopFile = fi.fileName();
|
2005-09-07 22:23:08 +02:00
|
|
|
KDesktopFile df(desktopFile, true);
|
2005-09-07 00:51:35 +02:00
|
|
|
|
|
|
|
// set the appletssimple attributes
|
|
|
|
setName(df.readName());
|
|
|
|
setComment(df.readComment());
|
|
|
|
setIcon(df.readIcon());
|
|
|
|
|
|
|
|
// library
|
|
|
|
setLibrary(df.readEntry("X-KDE-Library"));
|
|
|
|
|
|
|
|
// language the applet is written in
|
2005-09-07 22:23:08 +02:00
|
|
|
setLanguageBindings(df.readEntry("X-KDE-LanguageBindings", "native").toLower());
|
2005-09-07 00:51:35 +02:00
|
|
|
|
|
|
|
// is it a unique applet?
|
|
|
|
setUnique(df.readBoolEntry("X-KDE-UniqueApplet", false));
|
|
|
|
|
|
|
|
// should it be shown in the gui?
|
|
|
|
d->hidden = df.readBoolEntry("Hidden", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletInfo::AppletInfo(const AppletInfo ©)
|
|
|
|
{
|
|
|
|
d = new Private;
|
|
|
|
*d = *copy.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletInfo::~AppletInfo()
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
AppletInfo& AppletInfo::operator=(const AppletInfo &rhs)
|
|
|
|
{
|
|
|
|
*d = *rhs.d;
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::name() const
|
|
|
|
{
|
|
|
|
return d->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::comment() const
|
|
|
|
{
|
|
|
|
return d->comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::icon() const
|
|
|
|
{
|
|
|
|
return d->icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::library() const
|
|
|
|
{
|
|
|
|
return d->lib;
|
|
|
|
}
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
QString AppletInfo::languageBindings() const
|
|
|
|
{
|
|
|
|
return d->languageBindings;
|
|
|
|
}
|
|
|
|
|
2005-09-07 00:51:35 +02:00
|
|
|
QString AppletInfo::desktopFilePath() const
|
|
|
|
{
|
|
|
|
return d->desktopFilePath;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::desktopFile() const
|
|
|
|
{
|
|
|
|
return d->desktopFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AppletInfo::generateConfigFileName() const
|
|
|
|
{
|
|
|
|
// generate a config file base name from the library name
|
|
|
|
QString configFile = "plasmaApplet_" + d->lib.lower();
|
|
|
|
|
|
|
|
if (d->unique)
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
configFile.append("rc");
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
configFile.append("_")
|
|
|
|
.append(kapp->randomString(20).lower())
|
|
|
|
.append("_rc");
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return configFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::unique() const
|
|
|
|
{
|
|
|
|
return d->unique;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::hidden() const
|
|
|
|
{
|
|
|
|
return d->hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletInfo::setName(const QString &name)
|
|
|
|
{
|
|
|
|
d->name = name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletInfo::setComment(const QString &comment)
|
|
|
|
{
|
|
|
|
d->comment = comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletInfo::setIcon(const QString &icon)
|
|
|
|
{
|
|
|
|
d->icon = icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppletInfo::setLibrary(const QString &lib)
|
|
|
|
{
|
|
|
|
d->lib = lib;
|
|
|
|
}
|
|
|
|
|
2005-09-07 22:23:08 +02:00
|
|
|
void AppletInfo::setLanguageBindings(const QString &language)
|
|
|
|
{
|
|
|
|
d->languageBindings = language;
|
|
|
|
}
|
|
|
|
|
2005-09-07 00:51:35 +02:00
|
|
|
void AppletInfo::setUnique(bool u)
|
|
|
|
{
|
|
|
|
d->unique = u;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::operator!=(const AppletInfo& rhs) const
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
return library() != rhs.library();
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::operator==(const AppletInfo& rhs) const
|
|
|
|
{
|
2005-09-07 22:23:08 +02:00
|
|
|
return library() == rhs.library();
|
2005-09-07 00:51:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::operator<(const AppletInfo& rhs) const
|
|
|
|
{
|
|
|
|
return name().lower() < rhs.name().lower();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::operator>(const AppletInfo& rhs) const
|
|
|
|
{
|
|
|
|
return name().lower() > rhs.name().lower();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppletInfo::operator<=(const AppletInfo& rhs) const
|
|
|
|
{
|
|
|
|
return name().lower() <= rhs.name().lower();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Plasma namespace
|