things builds, but the test is fubar'd until i figure out how to get the
.desktop files over to the builddir svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=458312
This commit is contained in:
parent
7b202ba764
commit
3ce6b30e51
21
Makefile.am
Normal file
21
Makefile.am
Normal file
@ -0,0 +1,21 @@
|
||||
INCLUDES = $(all_includes)
|
||||
|
||||
lib_LTLIBRARIES = libplasma.la
|
||||
|
||||
libplasma_la_SOURCES = appletinfo.cpp
|
||||
|
||||
libplasma_la_METASOURCES = AUTO
|
||||
|
||||
libplasma_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -no-undefined
|
||||
libplasma_la_LIBADD = $(LIB_KIO)
|
||||
|
||||
libplasma_la_includedir = $(includedir)/plasma
|
||||
|
||||
noinst_HEADERS =
|
||||
|
||||
libplasma_la_include_HEADERS = appletinfo.h
|
||||
|
||||
#kde_kcfg_DATA = plasmaSettings.kcfg extensionSettings.kcfg
|
||||
|
||||
messages: rc.cpp
|
||||
$(XGETTEXT) *.cpp *.h -o $(podir)/libplasma.pot
|
11
README
Normal file
11
README
Normal file
@ -0,0 +1,11 @@
|
||||
libplasma
|
||||
|
||||
This directory contains the classes making up libplasma, which provides the
|
||||
core framework used by Plasma and its components. This includes applet and
|
||||
extension definitions and loading, common GUI elements, etc.
|
||||
|
||||
Domain specific sets of functionality, e.g. for network awareness or sensors,
|
||||
are not found here but in one of the Plasma Engines.
|
||||
|
||||
Please refer to the Plasma website (http://plasma.kde.org) for API
|
||||
documentation and design documents regrading this lbirary.
|
@ -30,31 +30,30 @@ namespace Plasma
|
||||
|
||||
class AppletInfo::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
unique(false),
|
||||
hidden(false)
|
||||
{}
|
||||
public:
|
||||
Private()
|
||||
: unique(false),
|
||||
hidden(false)
|
||||
{}
|
||||
|
||||
QString name;
|
||||
QString comment;
|
||||
QString icon;
|
||||
QString lib;
|
||||
QString languageBindings;
|
||||
QString desktopFile;
|
||||
QString desktopFilePath;
|
||||
bool unique;
|
||||
bool hidden;
|
||||
QString name;
|
||||
QString comment;
|
||||
QString icon;
|
||||
QString lib;
|
||||
QString languageBindings;
|
||||
QString desktopFile;
|
||||
QString desktopFilePath;
|
||||
bool unique;
|
||||
bool hidden;
|
||||
};
|
||||
|
||||
AppletInfo::AppletInfo(const QString& deskFile)
|
||||
AppletInfo::AppletInfo(const QString& desktopFile)
|
||||
{
|
||||
d = new Private;
|
||||
QFileInfo fi(deskFile);
|
||||
QFileInfo fi(desktopFile);
|
||||
d->desktopFilePath = fi.absFilePath();
|
||||
d->desktopFile = fi.fileName();
|
||||
|
||||
KDesktopFile df(deskFile);
|
||||
KDesktopFile df(desktopFile, true);
|
||||
|
||||
// set the appletssimple attributes
|
||||
setName(df.readName());
|
||||
@ -65,7 +64,7 @@ AppletInfo::AppletInfo(const QString& deskFile)
|
||||
setLibrary(df.readEntry("X-KDE-Library"));
|
||||
|
||||
// language the applet is written in
|
||||
setLanguage(df.readEntry("X-KDE-LanguageBindings", "native").toLower());
|
||||
setLanguageBindings(df.readEntry("X-KDE-LanguageBindings", "native").toLower());
|
||||
|
||||
// is it a unique applet?
|
||||
setUnique(df.readBoolEntry("X-KDE-UniqueApplet", false));
|
||||
@ -112,6 +111,11 @@ QString AppletInfo::library() const
|
||||
return d->lib;
|
||||
}
|
||||
|
||||
QString AppletInfo::languageBindings() const
|
||||
{
|
||||
return d->languageBindings;
|
||||
}
|
||||
|
||||
QString AppletInfo::desktopFilePath() const
|
||||
{
|
||||
return d->desktopFilePath;
|
||||
@ -129,13 +133,13 @@ QString AppletInfo::generateConfigFileName() const
|
||||
|
||||
if (d->unique)
|
||||
{
|
||||
d->configFile.append("rc");
|
||||
configFile.append("rc");
|
||||
}
|
||||
else
|
||||
{
|
||||
d->configFile.append("_")
|
||||
.append(kapp->randomString(20).lower())
|
||||
.append("_rc");
|
||||
configFile.append("_")
|
||||
.append(kapp->randomString(20).lower())
|
||||
.append("_rc");
|
||||
}
|
||||
|
||||
return configFile;
|
||||
@ -171,6 +175,11 @@ void AppletInfo::setLibrary(const QString &lib)
|
||||
d->lib = lib;
|
||||
}
|
||||
|
||||
void AppletInfo::setLanguageBindings(const QString &language)
|
||||
{
|
||||
d->languageBindings = language;
|
||||
}
|
||||
|
||||
void AppletInfo::setUnique(bool u)
|
||||
{
|
||||
d->unique = u;
|
||||
@ -178,12 +187,12 @@ void AppletInfo::setUnique(bool u)
|
||||
|
||||
bool AppletInfo::operator!=(const AppletInfo& rhs) const
|
||||
{
|
||||
return configFile() != rhs.configFile();
|
||||
return library() != rhs.library();
|
||||
}
|
||||
|
||||
bool AppletInfo::operator==(const AppletInfo& rhs) const
|
||||
{
|
||||
return configFile() == rhs.configFile();
|
||||
return library() == rhs.library();
|
||||
}
|
||||
|
||||
bool AppletInfo::operator<(const AppletInfo& rhs) const
|
||||
|
13
appletinfo.h
13
appletinfo.h
@ -136,20 +136,21 @@ class KDE_EXPORT AppletInfo
|
||||
bool operator<=(const AppletInfo& rhs) const;
|
||||
|
||||
/**
|
||||
* Inequality operator, for sorting by name in lists
|
||||
* Inequality operator. Compares the library used by each.
|
||||
*/
|
||||
bool operator!=(const AppletInfo& rhs) const;
|
||||
|
||||
/**
|
||||
* Less than operator, for sorting by name in lists
|
||||
* Less than operator. Compares the library used by each.
|
||||
*/
|
||||
bool operator==(const AppletInfo& rhs) const;
|
||||
|
||||
private:
|
||||
void setName(const QString &name);
|
||||
void setComment(const QString &comment);
|
||||
void setIcon(const QString &icon);
|
||||
void setLibrary(const QString &lib);
|
||||
void setName(const QString& name);
|
||||
void setComment(const QString& comment);
|
||||
void setIcon(const QString& icon);
|
||||
void setLibrary(const QString& lib);
|
||||
void setLanguageBindings(const QString& language);
|
||||
void setUnique(bool u);
|
||||
|
||||
class Private;
|
||||
|
11
tests/Makefile.am
Normal file
11
tests/Makefile.am
Normal file
@ -0,0 +1,11 @@
|
||||
INCLUDES = -I$(top_srcdir)/workspace/plasma/lib $(all_includes)
|
||||
|
||||
AM_LDFLAGS = $(QT_LDFLAGS) $(X_LDFLAGS) $(KDE_RPATH)
|
||||
|
||||
noinst_PROGRAMS = testAppletInfo
|
||||
noinst_HEADERS = testAppletInfo.h
|
||||
|
||||
METASOURCES = AUTO
|
||||
|
||||
LDADD = ../libplasma.la -lQtTest_debug
|
||||
testAppletInfo_SOURCES = testAppletInfo.cpp
|
@ -20,12 +20,17 @@ Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include <QDir>
|
||||
|
||||
#include <kaboutdata.h>
|
||||
#include <kinstance.h>
|
||||
|
||||
#include "appletinfo.h"
|
||||
#include "testAppletInfo.h"
|
||||
#include "appletInfo.h"
|
||||
|
||||
TestAppletInfo::TestAppletInfo(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_aboutData = new KAboutData("Test Applet Info", "testappletinfo", "1");
|
||||
m_instance = new KInstance("testappletinfo");
|
||||
QString pwd = QDir::currentPath();
|
||||
notUniqueNative = new Plasma::AppletInfo(pwd + "/nativeApplet.desktop");
|
||||
uniqueJavascript = new Plasma::AppletInfo(pwd + "/uniqueJavaScriptApplet.desktop");
|
||||
@ -36,9 +41,9 @@ void TestAppletInfo::name_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.name()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->name()
|
||||
<< "Non-Unique Native Applet";
|
||||
*t.newData("Unique Javascript Applet") << t.name()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->name()
|
||||
<< "Unique Javascript Applet";
|
||||
}
|
||||
|
||||
@ -55,9 +60,9 @@ void TestAppletInfo::comment_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.comment()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->comment()
|
||||
<< "A natively compiled applet";
|
||||
*t.newData("Unique Javascript Applet") << t.comment()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->comment()
|
||||
<< "An applet written in JavaScript";
|
||||
}
|
||||
|
||||
@ -74,9 +79,9 @@ void TestAppletInfo::icon_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.icon()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->icon()
|
||||
<< "native";
|
||||
*t.newData("Unique Javascript Applet") << t.icon()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->icon()
|
||||
<< "javascript";
|
||||
}
|
||||
|
||||
@ -93,9 +98,9 @@ void TestAppletInfo::library_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.library()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->library()
|
||||
<< "plasma_applet_native";
|
||||
*t.newData("Unique Javascript Applet") << t.library()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->library()
|
||||
<< "plasma_applet_javascript";
|
||||
}
|
||||
|
||||
@ -112,9 +117,9 @@ void TestAppletInfo::languageBindings_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.languageBindings()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->languageBindings()
|
||||
<< "native";
|
||||
*t.newData("Unique Javascript Applet") << t.languageBindings()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->languageBindings()
|
||||
<< "javascript";
|
||||
}
|
||||
|
||||
@ -133,9 +138,9 @@ void TestAppletInfo::desktopFilePath_data(QtTestTable &t)
|
||||
|
||||
QString pwd = QDir::currentPath();
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.desktopFilePath()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFilePath()
|
||||
<< pwd + "/nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << t.desktopFilePath()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFilePath()
|
||||
<< pwd + "/uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
@ -152,9 +157,9 @@ void TestAppletInfo::desktopFile_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.desktopFile()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->desktopFile()
|
||||
<< "nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << t.desktopFile()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->desktopFile()
|
||||
<< "uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
@ -166,14 +171,14 @@ void TestAppletInfo::desktopFile()
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
void TestAppletInfo::desktopFile_data(QtTestTable &t)
|
||||
void TestAppletInfo::unique_data(QtTestTable &t)
|
||||
{
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
t.defineElement("bool", "expected");
|
||||
t.defineElement("bool", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.unique()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
|
||||
<< "nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << t.unique()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
|
||||
<< "uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
@ -190,9 +195,9 @@ void TestAppletInfo::hidden_data(QtTestTable &t)
|
||||
t.defineElement("QString", "expected");
|
||||
t.defineElement("QString", "actual");
|
||||
|
||||
*t.newData("Non-Unique Native Applet") << t.unique()
|
||||
*t.newData("Non-Unique Native Applet") << notUniqueNative->unique()
|
||||
<< "nativeApplet.desktop";
|
||||
*t.newData("Unique Javascript Applet") << t.unique()
|
||||
*t.newData("Unique Javascript Applet") << uniqueJavascript->unique()
|
||||
<< "uniqueJavaScriptApplet.desktop";
|
||||
}
|
||||
|
||||
@ -204,5 +209,5 @@ void TestAppletInfo::hidden()
|
||||
COMPARE(expected, actual);
|
||||
}
|
||||
|
||||
QTTEST_MAIN(TestQString)
|
||||
QTTEST_MAIN(TestAppletInfo)
|
||||
#include "testAppletInfo.moc"
|
||||
|
@ -18,9 +18,17 @@ Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include <QtTest>
|
||||
#ifndef testappletinfo_h_
|
||||
#define testappletinfo_h_
|
||||
|
||||
class Plasma::AppletInfo;
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
class AppletInfo;
|
||||
}
|
||||
class KAboutData;
|
||||
class KInstance;
|
||||
|
||||
class TestAppletInfo: public QObject
|
||||
{
|
||||
@ -29,26 +37,30 @@ class TestAppletInfo: public QObject
|
||||
TestAppletInfo(QObject* parent = 0);
|
||||
|
||||
private slots:
|
||||
void name_data(QTestTable& t);
|
||||
void name_data(QtTestTable& t);
|
||||
void name();
|
||||
void comment_data(QTestTable& t);
|
||||
void comment_data(QtTestTable& t);
|
||||
void comment();
|
||||
void icon_data(QTestTable& t);
|
||||
void icon_data(QtTestTable& t);
|
||||
void icon();
|
||||
void library_data(QTestTable& t);
|
||||
void library_data(QtTestTable& t);
|
||||
void library();
|
||||
void languageBindings_data(QTestTable& t);
|
||||
void languageBindings_data(QtTestTable& t);
|
||||
void languageBindings();
|
||||
void desktopFilePath_data(QTestTable& t);
|
||||
void desktopFilePath_data(QtTestTable& t);
|
||||
void desktopFilePath();
|
||||
void desktopFile_data(QTestTable& t);
|
||||
void desktopFile_data(QtTestTable& t);
|
||||
void desktopFile();
|
||||
void unique_data(QTestTable& t);
|
||||
void unique_data(QtTestTable& t);
|
||||
void unique();
|
||||
void hidden_data(QTestTable& t);
|
||||
void hidden_data(QtTestTable& t);
|
||||
void hidden();
|
||||
|
||||
private:
|
||||
Plasma::AppletInfo* notUniqueNative;
|
||||
Plasma::AppletInfo* uniqueJavascript;
|
||||
KAboutData* m_aboutData;
|
||||
KInstance* m_instance;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user