2001-06-24 06:10:59 +00:00
|
|
|
#include <qfile.h>
|
|
|
|
#include <qdir.h>
|
2001-12-29 17:33:05 +00:00
|
|
|
#include <kapplication.h>
|
2001-06-24 06:10:59 +00:00
|
|
|
#include <ksimpleconfig.h>
|
|
|
|
#include <kglobal.h>
|
2002-02-24 18:16:45 +00:00
|
|
|
#include <kdebug.h>
|
2001-12-29 17:33:05 +00:00
|
|
|
#include <kstandarddirs.h>
|
2001-06-24 06:10:59 +00:00
|
|
|
#include <kcmdlineargs.h>
|
|
|
|
#include <klocale.h>
|
|
|
|
|
2004-02-06 23:46:21 +00:00
|
|
|
static const char description[] =
|
2001-06-24 06:10:59 +00:00
|
|
|
I18N_NOOP("Installs a KWM theme");
|
2003-01-23 07:11:25 +00:00
|
|
|
|
2001-06-24 06:10:59 +00:00
|
|
|
static KCmdLineOptions options[] =
|
|
|
|
{
|
|
|
|
{ "+[file]", I18N_NOOP("Path to a theme config file"), 0 },
|
2003-01-23 07:11:25 +00:00
|
|
|
KCmdLineLastOption
|
2001-06-24 06:10:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void copy(const QString &src, const QString &dest)
|
|
|
|
{
|
|
|
|
QFile copyInput(src);
|
|
|
|
QFile copyOutput(dest);
|
2005-11-08 15:54:49 +00:00
|
|
|
if(!copyInput.open(QIODevice::ReadOnly)){
|
2002-02-24 18:16:45 +00:00
|
|
|
kdWarning() << "Couldn't open " << src << endl;
|
2001-06-24 06:10:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-11-10 11:50:13 +00:00
|
|
|
if(!copyOutput.open(QIODevice::WriteOnly)){
|
2002-02-24 18:16:45 +00:00
|
|
|
kdWarning() << "Couldn't open " << dest << endl;
|
2001-06-24 06:10:59 +00:00
|
|
|
copyInput.close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
while(!copyInput.atEnd()){
|
|
|
|
copyOutput.putch(copyInput.getch());
|
|
|
|
}
|
|
|
|
copyInput.close();
|
|
|
|
copyOutput.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
KCmdLineArgs::init(argc, argv, "kwmtheme", description, "0.1");
|
|
|
|
KCmdLineArgs::addCmdLineOptions( options );
|
|
|
|
KApplication app(argc, argv);
|
|
|
|
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
|
|
|
|
if(!args->count()){
|
2002-02-24 18:16:45 +00:00
|
|
|
kdWarning() << "You need to specify the path to a theme config file!" << endl;
|
2001-06-24 06:10:59 +00:00
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString srcStr = QString(QFile::decodeName(args->arg(0)));
|
|
|
|
QFile f(srcStr);
|
|
|
|
QString tmpStr;
|
|
|
|
|
|
|
|
if(!f.exists()){
|
2002-02-24 18:16:45 +00:00
|
|
|
kdWarning() << "Specified theme config file doesn't exist!" << endl;
|
2001-06-24 06:10:59 +00:00
|
|
|
return(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList appDirs = KGlobal::dirs()->findDirs("data", "kwin");
|
|
|
|
QString localDirStr = *(appDirs.end());
|
|
|
|
if(localDirStr.isEmpty()){
|
|
|
|
localDirStr = KGlobal::dirs()->saveLocation("data", "kwin");
|
|
|
|
}
|
|
|
|
localDirStr += "/pics/";
|
|
|
|
if(!QFile::exists(localDirStr))
|
|
|
|
QDir().mkdir(localDirStr);
|
|
|
|
|
|
|
|
QFileInfo fi(f);
|
2005-11-08 10:20:07 +00:00
|
|
|
KSimpleConfig input(fi.absoluteFilePath());
|
2001-06-24 06:10:59 +00:00
|
|
|
srcStr = fi.dirPath(true) + "/";
|
|
|
|
KConfig *output = KGlobal::config();
|
|
|
|
input.setGroup("Window Border");
|
|
|
|
output->setGroup("General");
|
|
|
|
|
|
|
|
tmpStr = input.readEntry("shapePixmapTop");
|
|
|
|
if(!tmpStr.isEmpty()){
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
}
|
|
|
|
output->writeEntry("wm_top", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapBottom");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_bottom", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapLeft");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_left", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapRight");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_right", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapTopLeft");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_topleft", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapTopRight");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_topright", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapBottomLeft");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_bottomleft", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("shapePixmapBottomRight");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("wm_bottomright", tmpStr, true, true);
|
|
|
|
|
|
|
|
|
|
|
|
input.setGroup("Window Titlebar");
|
|
|
|
output->writeEntry("TitleAlignment", input.readEntry("TitleAlignment"), true, true);
|
|
|
|
output->writeEntry("PixmapUnderTitleText", input.readEntry("PixmapUnderTitleText"), true, true);
|
|
|
|
output->writeEntry("TitleFrameShaded", input.readEntry("TitleFrameShaded"), true, true);
|
|
|
|
|
|
|
|
tmpStr = input.readEntry("MenuButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("menu", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("PinUpButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("pinup", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("PinDownButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("pindown", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("CloseButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("close", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("MaximizeButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("maximize", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("MaximizeDownButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("maximizedown", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("MinimizeButton");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("iconify", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("TitlebarPixmapActive");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("TitlebarPixmapActive", tmpStr, true, true);
|
|
|
|
tmpStr = input.readEntry("TitlebarPixmapInactive");
|
|
|
|
if(!tmpStr.isEmpty())
|
|
|
|
copy(srcStr+tmpStr, localDirStr+tmpStr);
|
|
|
|
output->writeEntry("TitlebarPixmapInactive", tmpStr, true, true);
|
|
|
|
|
|
|
|
input.setGroup("Window Button Layout");
|
|
|
|
output->setGroup("Buttons");
|
|
|
|
output->writeEntry("ButtonA", input.readEntry("ButtonA"), true, true);
|
|
|
|
output->writeEntry("ButtonB", input.readEntry("ButtonB"), true, true);
|
|
|
|
output->writeEntry("ButtonC", input.readEntry("ButtonC"), true, true);
|
|
|
|
output->writeEntry("ButtonD", input.readEntry("ButtonD"), true, true);
|
|
|
|
output->writeEntry("ButtonE", input.readEntry("ButtonE"), true, true);
|
|
|
|
output->writeEntry("ButtonF", input.readEntry("ButtonF"), true, true);
|
|
|
|
|
|
|
|
output->sync();
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|