diff options
Diffstat (limited to 'src')
27 files changed, 1317 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..05543f9 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,19 @@ +INCLUDES = $(all_includes) -I$(kde_includes)/ksplash + +kde_module_LTLIBRARIES = ksplashmoodin.la + +ksplashmoodin_la_SOURCES = thememoodin.cpp effectwidget.cpp cache.cpp magiclabel.cpp scaler.cpp +ksplashmoodin_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) +ksplashmoodin_la_LIBADD = $(LIB_KDEUI) -lksplashthemes + +METASOURCES = AUTO + +noinst_HEADERS = thememoodin.h effectwidget.h cache.h magiclabel.h scaler.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashmoodin.desktop + +themeMoodinKDEdir = $(kde_datadir)/ksplash/Themes/MoodinKDE +themeMoodinKDE_DATA = themes/MoodinKDE/* +themeFingerPrintdir = $(kde_datadir)/ksplash/Themes/FingerPrint +themeFingerPrint_DATA = themes/FingerPrint/* diff --git a/src/cache.cpp b/src/cache.cpp new file mode 100644 index 0000000..a4899f8 --- /dev/null +++ b/src/cache.cpp @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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 <kuser.h> +#include <kstandarddirs.h> +#include <kconfig.h> + +#include <qfileinfo.h> +#include <qdatetime.h> +#include <qimage.h> + +#include "cache.h" + +/* Disabled Cache (Michael Ummels) */ + +Cache::Cache(Scaler* scaler, const QString& themeEngine, const QString& theme) +{ +} + + +QImage* Cache::cacheFile(const QString& file) +{ + return new QImage(file); +} + + +void Cache::createCacheDir() +{ +} + + +void Cache::writeInfoFile(QString& file) +{ +} + + +bool Cache::isInSync(QString& file) +{ + return true; +} + + +QString Cache::getFile(QString file) +{ + return file; +} diff --git a/src/cache.h b/src/cache.h new file mode 100644 index 0000000..c05bcaf --- /dev/null +++ b/src/cache.h @@ -0,0 +1,41 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef CACHE_H +#define CACHE_H + +#include <qstring.h> +#include <qsize.h> +#include <qdir.h> + +#include "scaler.h" + +class Cache +{ + private: + QString mTheme; + QString mThemeEngine; + QDir mCacheDir; + + Scaler* mScaler; + + void createCacheDir(); + void writeInfoFile(QString& file); + bool isInSync(QString& file); + + QString getFile(QString file); + + public: + Cache(Scaler* scaler, const QString& mThemeEngine, const QString& theme); + QImage* cacheFile(const QString& file); +}; + +#endif diff --git a/src/doc/THEMEOPTIONS b/src/doc/THEMEOPTIONS new file mode 100644 index 0000000..2ca2309 --- /dev/null +++ b/src/doc/THEMEOPTIONS @@ -0,0 +1,46 @@ + +Theme.rc Options Type Default +=============================================== + +X ^= Number from 1 to 8 (Labels are limited by "Labels" option) + + +- General +Background <filename> Search order: <given>.png, Background-<width>x<height>.png, Background.png +UsersBackground <boolean> false (use the wallpaper of the current desktop) +BaseResolution <width,height> 1280x1024 (the resolution was designed in -> NECCESSARY for auto scaling) +SplashRect <x,y,w,h> screen size (sullscreen) + +- Labels +Labels <num> 0 +LabelX <text> X = No. (Use ML: as prefix for magiclabels, i.e.: ML:loginname (case insensetive)) +LabelColorX <color> ffffff +LabelFontX <font> Trebuchet MS (i.e.: Arial,14,-1,0,5,50,0) +LabelCoordsX <x,y> centered +StatusMessageX <text> passed by ksplash +StatusColor <color> ffffff (White) +StatusFont <font> Trebuchet MS +StatusPosition <x,y> 50,50 +LabelShadow <boolean> true +LabelShadowColor <color> 6d6d6d (dark gray) +LabelShadowOffset <x,y> 2,2 +ShowStatusText <boolean> true +Translate <boolean> true (i18n i.e.: Welcome (en) -> Willkommen (de)) + +- Images +AnimationLength <number> 30 (fading steps) +AnimationDelay <number> 30 (delay between steps in milliseconds) +BeginOpacity <number> 0.2 (value between 0 an 1) +UseIconSet <boolean> true (use current icon set instead of 1.png, 2.png, ... (see below)) +IconSetSize <number> 48 (size of icons) +ImageX <filename> if UseIconSet is true, you can override single icons (or all) by just giving + their name. they need not to be in the theme directory! + if UseIconSet is false, the engine searches for 1.png to 8.png by default + but you can also override the image names + +- Image Arrangement (currently a little hard to explain, just play :)) +AppendX <boolean> true => horizontal (follow direction type) X is not a number here! +ImageSpacer <number> if UseIconSet its IconSetSize otherwise 0 (used for auto arrangement with AppendX and -1 values) +ImageCoordsX <x,y> -1,-1 (center vert. and horiz.) +ImageOffset <x,y> 0,0 (move images i.e. if they have unknown positions (have a look at MoodinKDE) +LineUpImages <boolean> false (if true, icons are aligned center (See MoodinKDE)) diff --git a/src/effectwidget.cpp b/src/effectwidget.cpp new file mode 100644 index 0000000..1a2804a --- /dev/null +++ b/src/effectwidget.cpp @@ -0,0 +1,165 @@ +/*************************************************************************** + * Copyright Sean Meiners 2004 <Sean.Meiners@LinspireInc.com> * + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <qwidget.h> +#include <qstyle.h> +#include <qtimer.h> +#include <qpainter.h> +#include <qimage.h> + +#include "effectwidget.h" + +QImage* EffectWidget::bgImage = 0; + +EffectWidget::EffectWidget(QWidget* parent, const char* name) + :QWidget(parent, name) +{ + timer = 0; + delayMS = 20; + currentStep = 0; + totalSteps = 0; + playing = false; + loop = false; + beginOpacity = 20.0; + endOpacity = 80.0; + setBackgroundMode(NoBackground); + setBackgroundOrigin(QWidget::ParentOrigin); + updateCache(); +} + + +void EffectWidget::setImage(QImage *i) +{ + image = i; +} + + +void EffectWidget::setDelay(int delayInMS) +{ + delayMS = delayInMS; + + if (timer) + timer->changeInterval(delayMS); +} + + +void EffectWidget::setLoop(bool loop) +{ + this->loop = loop; +} + + +void EffectWidget::setSteps(int steps) +{ + totalSteps = steps; +} + + +void EffectWidget::start() +{ + if ((playing) || (!image) || (totalSteps < 1) || (image->isNull())) + return; + + if (!timer) + { + timer = new QTimer(this); + connect(timer,SIGNAL(timeout()),this,SLOT(timerTick())); + } + + playing = true; + update(); + timer->start(delayMS); +} + + +void EffectWidget::stop() +{ + if ((!playing) || (!timer)) + return; + + timer->stop(); + playing = false; +} + + +void EffectWidget::setStart(float begin, float end, bool reverse) +{ + beginOpacity = begin; + endOpacity = end - beginOpacity; + + if (reverse) + { + float h = beginOpacity; + beginOpacity = endOpacity; + endOpacity = h; + } +} + + +void EffectWidget::rewind() +{ + stop(); + currentStep = 0; +} + + +void EffectWidget::timerTick() +{ + if (loop) + { + currentStep ++; + currentStep %= totalSteps; + } + else if (currentStep + 1 < totalSteps) + currentStep ++; + else + timer->stop(); + + update(); +} + + +void EffectWidget::moveEvent(QMoveEvent *) +{ + updateCache(); +} + + +void EffectWidget::resizeEvent(QResizeEvent *) +{ + updateCache(); +} + + +void EffectWidget::updateCache() +{ + if (!bgImage) + return; + + QPoint pos(mapToParent(QPoint(0, 0))); + background = bgImage->copy(pos.x(), pos.y(), width(), height()); + bitBlt(this, 0, 0, &background); +} + +void EffectWidget::paintEvent(QPaintEvent *) +{ + if (background.isNull()) + return; + + QImage upper = image->copy(); + QImage lower = background.copy(); + KImageEffect::blendOnLower(upper, lower, KImageEffect::Centered, (currentStep + 1 == totalSteps) ? 1.0 : endOpacity / float(totalSteps) * float(currentStep) + beginOpacity); + + bitBlt(this, 0, 0, &lower); +} + +#include "effectwidget.moc" diff --git a/src/effectwidget.h b/src/effectwidget.h new file mode 100644 index 0000000..57df6bf --- /dev/null +++ b/src/effectwidget.h @@ -0,0 +1,69 @@ +/*************************************************************************** + * Copyright Sean Meiners 2004 <Sean.Meiners@LinspireInc.com> * + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#ifndef FADEWIDGET_H +#define FADEWIDGET_H + +#include <qwidget.h> +#include <qptrlist.h> +#include <qpixmap.h> +#include <qimage.h> + +#include <kimageeffect.h> + +class QTimer; + +class EffectWidget : public QWidget +{ + Q_OBJECT + + public: + EffectWidget(QWidget *parent = 0,const char *name = 0); + + static void setBackgroundImage(QImage *image) { bgImage = image; } + + void setImage(QImage *i); + void setDelay(int delayInMS); + void setLoop(bool loop); + void setSteps(int steps); + void setStart(float begin, float end = 1.0, bool reverse = false); + + void start(); + void stop(); + void rewind(); + + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *); + void moveEvent(QMoveEvent *); + + void updateCache(); + + public slots: + void timerTick(); + + private: + static QImage *bgImage; + + QTimer *timer; + QImage *image; + QImage background; + unsigned int delayMS; + unsigned int currentStep; + unsigned int totalSteps; + bool playing; + bool loop; + float + beginOpacity, + endOpacity; +}; + +#endif diff --git a/src/ksplashmoodin.desktop b/src/ksplashmoodin.desktop new file mode 100644 index 0000000..f856da4 --- /dev/null +++ b/src/ksplashmoodin.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Comment=KSplash Plugin +Encoding=UTF-8 +Icon= +Name=KSplashMoodin +ServiceTypes=KSplash/Plugin +Type=Service +X-KDE-Library=ksplashmoodin +X-KSplash-Default=true +X-KSplash-ObjectName=ThemeMoodin +X-KSplash-PluginName=Moodin diff --git a/src/magiclabel.cpp b/src/magiclabel.cpp new file mode 100644 index 0000000..ac75e02 --- /dev/null +++ b/src/magiclabel.cpp @@ -0,0 +1,92 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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 <qstringlist.h> +#include <qregexp.h> + +#include <klocale.h> +#include <kuser.h> +#include <kmessagebox.h> + +#include "magiclabel.h" + +// This class is still very simple (as most of the classes) +// They get all improved later when "OpenGL Effect Widget" structure is completed + +MagicLabel::MagicLabel(QString s, bool translate) +{ + prefix = "ML:"; + preUSER = "USER:"; + preCMD = "CMD:"; + mValue = s; + + transform(); + + if (translate) + mValue = i18n(mValue); +} + + +void MagicLabel::transform() +{ + if (mValue.contains(prefix + preUSER)) + getUserInfo(); + else if (mValue.startsWith(prefix + preCMD)) + getCommandOutput(); +} + + +void MagicLabel::getUserInfo() +{ + static KUser user; + + if (mValue.contains(prefix + preUSER + "loginname")) + mValue = mValue.replace(prefix + preUSER + "loginname", user.loginName()); + else if (mValue.contains(prefix + preUSER + "fullname")) + mValue = mValue.replace(prefix + preUSER + "fullname", user.fullName()); + else if (mValue.contains(prefix + preUSER + "homedir")) + mValue = mValue.replace(prefix + preUSER + "homedir", user.homeDir()); +} + + +void MagicLabel::getCommandOutput() +{ + QString cmd = QStringList::split(prefix + preCMD, mValue)[0]; + QStringList parts = QStringList::split(" ", cmd); + + KShellProcess *proc = new KShellProcess; + + for (int i = 0; i < parts.count(); i++) + *proc << parts[i]; + + connect(proc, SIGNAL(processExited(KProcess*)), this, SLOT(processExited(KProcess*))); + connect(proc, SIGNAL(receivedStdout(KProcess*, char*, int)), this, SLOT(receivedStdout(KProcess*, char*, int))); + + mValue = ""; + + if (!proc->start(KProcess::Block, KProcess::Stdout)) + KMessageBox::information(0, QString("Could not start process: %1").arg(cmd)); +} + + +void MagicLabel::receivedStdout(KProcess *proc, char *buffer, int buflen) +{ + QString buf = QString::fromLatin1(buffer, buflen); + mValue += buf.replace("\n", ""); +} + + +void MagicLabel::processExited(KProcess* proc) +{ + delete proc; +} + +#include "magiclabel.moc" diff --git a/src/magiclabel.h b/src/magiclabel.h new file mode 100644 index 0000000..8db9fad --- /dev/null +++ b/src/magiclabel.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef MAGICLABEL_H +#define MAGICLABEL_H + +#include <qstring.h> + +#include <kprocess.h> + +class MagicLabel : QObject +{ + Q_OBJECT + + private: + QString prefix; + QString preUSER; + QString preCMD; + + QString mValue; + + void transform(); + void getUserInfo(); + void getCommandOutput(); + + private slots: + void processExited(KProcess* proc); + void receivedStdout(KProcess *proc, char *buffer, int buflen); + + public: + MagicLabel(QString s, bool translate); + + inline QString& value() { return mValue; }; +}; + +#endif diff --git a/src/scaler.cpp b/src/scaler.cpp new file mode 100644 index 0000000..70be6d7 --- /dev/null +++ b/src/scaler.cpp @@ -0,0 +1,114 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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 <qfontmetrics.h> + +#include "scaler.h" + +Scaler::Scaler(QSize baseResolution, QSize targetResolution) +{ + mBaseResolution = baseResolution; + mTargetResolution = targetResolution; +} + + +void Scaler::autoCoords(QPoint* pt, const QFont& f, const QString& s) +{ + QFontMetrics fm(f); + QSize fmSize(fm.size(0L, s)); + + autoCoords(pt, fmSize); +} + + +void Scaler::autoCoords(QPoint* pt, const QSize s) +{ + scaleCoords(pt); + + if ((pt->x() == -1) && (pt->y() != -1)) + pt->setX(center(mTargetResolution.width(), s.width())); + else if ((pt->y() == -1) && (pt->x() != -1)) + pt->setY(center(mTargetResolution.height(), s.height())); + else if (*pt == QPoint(-1, -1)) + *pt = QPoint(center(mTargetResolution.width(), s.width()), center(mTargetResolution.height(), s.height())); +} + + +void Scaler::scaleCoords(QPoint* pt) +{ + if (mBaseResolution == mTargetResolution) + return; + + int ox = pt->x(); + int oy = pt->y(); + + float tx = float(mBaseResolution.width()) / float(ox); + float ty = float(mBaseResolution.height()) / float(oy); + + int nx = intIt(float(mTargetResolution.width()) / tx); + int ny = intIt(float(mTargetResolution.height()) / ty); + + pt->setX((ox == -1) ? -1 : nx); + pt->setY((oy == -1) ? -1 : ny); +} + + +bool Scaler::scaleSize(QImage* i) +{ + if ((!i) || !resolutionDiff()) + return false; + + float tx = float(mTargetResolution.width()) / float(mBaseResolution.width()); + float ty = float(mTargetResolution.height()) / float(mBaseResolution.height()); + int nx = intIt(float(i->width()) * tx); + int ny = intIt(float(i->height()) * ty); + + *i = i->smoothScale(nx, ny); + + return true; +} + + +bool Scaler::scaleSize(QFont* f) +{ + if ((!f) || !resolutionDiff()) + return false; + + const float d = 96 / 72; + const float tx = float(mTargetResolution.height()) / float(mBaseResolution.height()); + float pt = f->pointSizeFloat(); + int hPx = intIt(pt * d); + + f->setPixelSize(intIt(float(hPx) * tx)); + + return true; +} + + +bool Scaler::resolutionDiff() +{ + return (mBaseResolution != mTargetResolution); +} + + +int Scaler::intIt(const float v) +{ + float t = v - float(int(v)); + float tt = (t < 0.5) ? 0 : 1; + + return int(v + tt); +} + + +int Scaler::center(const int width, const int size, int offset) +{ + return int(width / 2) - int(size / 2) + offset; +} diff --git a/src/scaler.h b/src/scaler.h new file mode 100644 index 0000000..7dbb884 --- /dev/null +++ b/src/scaler.h @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef SCALER_H +#define SCALER_H + +#include <qpoint.h> +#include <qimage.h> +#include <qfont.h> + +class Scaler +{ + private: + QSize mBaseResolution; + QSize mTargetResolution; + + public: + Scaler(QSize baseResolution, QSize targetResolution); + + const QSize& baseResolution() { return mBaseResolution; }; + const QSize& targetResolution() { return mTargetResolution; }; + + void autoCoords(QPoint* pt, const QFont& f, const QString& s); + void autoCoords(QPoint* pt, const QSize s); + void scaleCoords(QPoint* pt); + bool scaleSize(QImage* i); + bool scaleSize(QFont* f); + + bool resolutionDiff(); + + int center(int width, int size, int offset = 0); + int intIt(const float v); +}; + +#endif diff --git a/src/thememoodin.cpp b/src/thememoodin.cpp new file mode 100644 index 0000000..1af5d87 --- /dev/null +++ b/src/thememoodin.cpp @@ -0,0 +1,419 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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 <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <kuser.h> + +#include <qlabel.h> +#include <qimage.h> +#include <qrect.h> +#include <qpainter.h> +#include <qstringlist.h> +#include <qwidget.h> +#include <qlayout.h> + +#include "magiclabel.h" +#include "thememoodin.h" + +K_EXPORT_COMPONENT_FACTORY(ksplashmoodin, KGenericFactory<ThemeMoodin>("ksplash")) + + +ThemeMoodin::ThemeMoodin(QWidget* parent, const char* name, const QStringList& args) + :ThemeEngine(parent, name, args) +{ + readSettings(); + init(); +} + + +void ThemeMoodin::readSettings() +{ + const QRect screen = kapp->desktop()->screenGeometry(mTheme->xineramaScreen()); + + if (!mTheme) + return; + + KConfig* cfg = mTheme->themeConfig(); + + if (!cfg) + return; + + cfg->setGroup(QString("KSplash Theme: %1").arg(mTheme->theme())); + + QFont defaultFont("Trebuchet MS", 10); + QFont defaultStatusFont("Trebuchet MS", 12, QFont::Bold); + QColor defaultColor(0xFF, 0xFF, 0xFF); + QColor defaultShadowColor(0x6D, 0x6D, 0x6D); + QPoint defaultPoint(-1, -1), defaultOffset(0, 0); + QString defaultIcon; + + mCurrentStatusIndex = 0; + mSplashRect = cfg->readRectEntry("SplashRect", &screen); + mBackgroundImage = cfg->readEntry("Background", QString::null); + mStatusColor = cfg->readColorEntry("StatusColor", &defaultColor); + mStatusFont = cfg->readFontEntry("StatusFont", &defaultStatusFont); + mStatusCoords = cfg->readPointEntry("StatusCoords", &defaultPoint); + mLabelShadow = cfg->readBoolEntry("LabelShadow", true); + mLabelShadowColor = cfg->readColorEntry("LabelShadowColor", &defaultShadowColor); + mShowStatusText = cfg->readBoolEntry("ShowStatusText", true); + mAnimationLength = cfg->readNumEntry("AnimationLength", 30); + mAnimationDelay = cfg->readNumEntry("AnimationDelay", 30); + mBeginOpacity = cfg->readDoubleNumEntry("BeginOpacity", 0.20); + mUseIconSet = cfg->readBoolEntry("UseIconSet", true); + mIconSetSize = cfg->readNumEntry("IconSetSize", 48); + mAppendX = cfg->readBoolEntry("AppendX", true); + mImageSpacer = cfg->readNumEntry("ImageSpacer", mUseIconSet ? mIconSetSize : 0); + mUsersBackground = cfg->readBoolEntry("UsersBackground", false); + mLabelCount = cfg->readNumEntry("Labels", 0); + mLabelShadowOffset = cfg->readPointEntry("LabelShadowOffset", new QPoint(2, 2)); + mBaseResolution = cfg->readSizeEntry("BaseResolution", new QSize(1280, 1024)); + mTranslate = cfg->readBoolEntry("Translate", true); + mLineUpImages = cfg->readBoolEntry("LineUpImages", false); + mKubuntuStyle = cfg->readBoolEntry("KubuntuStyle", false); + + // so we can centre icons, JRiddell + int iconX = mBaseResolution.width(); + int iconY = mBaseResolution.height(); + QRect defaultScreen = kapp->desktop()->screenGeometry(0); + float scaleRatioWidth = ((float)mBaseResolution.width()) / ((float)defaultScreen.width()); + // unused. float scaleRatioHeight = ((float)mBaseResolution.height()) / ((float)desktopWidget.height()); + + iconX = iconX / 2; + // first icon position calculated based on size and spacing + // Edgy Dialog.png is off centre so take off random 8 pixels + iconX = iconX - (int)((((mIconSetSize+mImageSpacer)*4) - 8) * scaleRatioWidth); + // Edgy Dialog.png is off centre so add random 20 pixels + iconY = (iconY / 2) + 20; + + for (int i = 0; i < int(statusPixmaps().count()); i++) + { + if (mUseIconSet) + defaultIcon = statusPixmaps()[i]; + else + defaultIcon = QString("%1.png").arg(i + 1); + + mStatusIcons.append(cfg->readEntry(QString("Image%1").arg(i + 1), defaultIcon)); + if (mKubuntuStyle) { + QPoint *mypoint; + mypoint = new QPoint((int)(iconX + (i * (mIconSetSize+mImageSpacer) * scaleRatioWidth)), iconY); + mStatusIconCoords.append( *mypoint ); + } else { + mStatusIconCoords.append(cfg->readPointEntry(QString("ImageCoords%1").arg(i + 1), &defaultPoint)); + } + mStatusImageOffsets.append(cfg->readPointEntry(QString("ImageOffset%1").arg(i + 1), &defaultOffset)); + mStatusMessages.append(cfg->readEntry(QString("StatusMessage%1").arg(i + 1), QString::null)); + } + + for (int i = 0; i < mLabelCount; i++) + { + mLabels.append(cfg->readEntry(QString("Label%1").arg(i + 1), QString::null)); + mLabelCoords.append(cfg->readPointEntry(QString("LabelCoords%1").arg(i + 1), &defaultPoint)); + mLabelFonts.append(cfg->readFontEntry(QString("LabelFont%1").arg(i + 1), &defaultFont)); + mLabelColors.append(cfg->readColorEntry(QString("LabelColor%1").arg(i + 1), &defaultColor)); + } +} + + +void ThemeMoodin::init() +{ + setBackgroundMode(NoBackground); + setFixedSize(mSplashRect.size()); + + mContainer = new QWidget(this); + mContainer->setFixedSize(size()); + mScaler = new Scaler(mBaseResolution, size()); + mCache = new Cache(mScaler, mTheme->themeEngine(), mTheme->theme()); + mBG = new KPixmap(); + mBG->resize(size()); + + QPainter p; + p.begin(mBG); + + initBackground(&p); + initLabels(&p); + initEffectWidgets(); + + p.end(); + + move(mSplashRect.topLeft()); +} + + +void ThemeMoodin::initBackground(QPainter* p) +{ + if (!p) + return; + + QString bgImage; + + if (mUsersBackground) + { + KConfig kdesktoprc("kdesktoprc", true, false); + kdesktoprc.setGroup("Background Common"); + int num = kdesktoprc.readNumEntry("DeskNum", 0); + + kdesktoprc.setGroup(QString("Desktop%1").arg(num)); + bgImage = kdesktoprc.readPathEntry("Wallpaper", QString::null); + } + else + { + if (!mBackgroundImage.isEmpty()) + bgImage = mTheme->locateThemeData(mBackgroundImage); + } + + if (bgImage.isEmpty()) + bgImage = mTheme->locateThemeData(QString("Background-%1x%2.jpg").arg(width()).arg(height())); + + if (bgImage.isEmpty()) + bgImage = mTheme->locateThemeData("Background.jpg"); + + if (bgImage.isEmpty()) + { + KMessageBox::error(this, i18n("No background. Try to put a Background.jpg in theme folder")); + return; + } + + QImage* bg = mCache->cacheFile(bgImage); + p->drawImage(0, 0, *bg); + delete bg; + + if (mKubuntuStyle) { + //central Dialogue, JRiddell + QImage* central = new QImage( mTheme->locateThemeData("Dialog.png") ); + p->drawImage((mBG->width() / 2) - (462 / 2), (mBG->height() / 2) - (324 / 2), *central); + delete central; + } +} + +void ThemeMoodin::initLabels(QPainter* p) +{ + if ((mLabelCount == 0) || (!p)) + return; + + for (int i = 0; i < mLabelCount; i++) + { + QString s = mLabels[i]; + QPoint pt = mLabelCoords[i]; + QColor c = mLabelColors[i]; + QFont f = mLabelFonts[i]; + + if (s.isNull() || s.isEmpty()) + continue; + + MagicLabel ml(s, mTranslate); + s = ml.value(); + + mScaler->scaleSize(&f); + mScaler->autoCoords(&pt, f, s); + + p->setFont(f); + + if (mLabelShadow) + { + p->setPen(mLabelShadowColor); + p->drawText(pt + mLabelShadowOffset, s); + } + + p->setPen(c); + p->drawText(pt, s); + } +} + + +void ThemeMoodin::initEffectWidgets() +{ + EffectWidget::setBackgroundImage(new QImage(mBG->convertToImage())); + EffectWidget *fadeWidget = 0; + QImage *image = 0; + int index = -1; + + for (QStringList::ConstIterator it = mStatusIcons.constBegin(); it != mStatusIcons.constEnd(); ++it) + { + index++; + + if (mUseIconSet) + { + if ((*it).isEmpty()) + continue; + + // TODO: use cache in iconset mode + QPixmap* px = new QPixmap(DesktopIcon(*it, mIconSetSize)); + image = new QImage(px->convertToImage()); + // JRiddell don't scale icons + if (!mKubuntuStyle) { + mScaler->scaleSize(image); + } + } + else + { + QString name = mTheme->locateThemeData(*it); + + if (name.isEmpty()) + continue; + + image = mCache->cacheFile(name); + + if (image->isNull()) + { + delete image; + continue; + } + } + + fadeWidget = createEffectWidget(mContainer, image); + mEffectWidgets.append(fadeWidget); + mImages.append(image); + arrangeWidget(fadeWidget, index); + } + + for (EffectWidget *fw = mEffectWidgets.first(); fw; fw = mEffectWidgets.next()) + fw->updateCache(); +} + + +void ThemeMoodin::arrangeWidget(QWidget* w, const int index) +{ + QPoint current(mStatusIconCoords[index]); + + if (mLineUpImages) + { + static bool first = true; + + if (first) + { + int hw = mAppendX ? width() : height(); + int hwi = mAppendX ? height() : width(); + int icons = mStatusIcons.count() * mIconSetSize; + int spaces = (mStatusIcons.count() - 1) * mIconSetSize;// + int(float(mIconSetSize) * 0.5); + int q = int((hwi - mIconSetSize) / 2); + int r = int((hw - icons - spaces) / 2); + + int x = mAppendX ? r : q; + int y = mAppendX ? q : r; + + current.setX(x); + current.setY(y); + first = false; + } + else + { + int x = mAppendX ? mIconSetSize * 2 : 0; + int y = mAppendX ? 0 : mIconSetSize * 2; + + current = mStatusIconCoords[index - 1] + QPoint(x, y); + } + } + else + { + mScaler->autoCoords(¤t, QSize(mIconSetSize, mIconSetSize)); + current += mStatusImageOffsets[index]; + } + + mStatusIconCoords[index] = current; + w->move(current); +} + + +EffectWidget* ThemeMoodin::createEffectWidget(QWidget* parent, QImage* image) +{ + EffectWidget *fw = new EffectWidget(parent); + + fw->hide(); + fw->setBackgroundOrigin(QWidget::WindowOrigin); + fw->setDelay(mAnimationDelay); + fw->setSteps(mAnimationLength); + fw->setFixedSize(image->size()); + fw->setImage(image); + fw->setStart(mBeginOpacity); + fw->show(); + + return fw; +} + + +void ThemeMoodin::slotSetText(const QString& s) +{ + if (mShowStatusText) + { + if (!mStatusMessages[mCurrentStatusIndex].isNull()) + mCurrentAction = mStatusMessages[mCurrentStatusIndex]; + else + mCurrentAction = s; + } +} + + +void ThemeMoodin::slotSetPixmap(const QString& s) +{ + if (!mEffectWidgets.count() > 0) + return; + + int n = statusPixmaps().findIndex(s); + + if (n == -1) + return; + + mCurrentStatusIndex = n + 1; + + EffectWidget *fw = mEffectWidgets.at(n); + + if (fw) + fw->start(); + + repaint(false); +} + + +void ThemeMoodin::updateStatus() +{ + QPainter p; + p.begin(mContainer); + + // use a copy, otherwise status messages move around + QPoint pt = mStatusCoords; + QFontMetrics fm(mStatusFont); + QSize fmSize(fm.size(0L, mCurrentAction)); + + mScaler->autoCoords(&pt, fmSize); + + p.setFont(mStatusFont); + + if (mLabelShadow) + { + p.setPen(mLabelShadowColor); + p.drawText(pt + mLabelShadowOffset, mCurrentAction); + } + + p.setPen(mStatusColor); + p.drawText(pt, mCurrentAction); + p.end(); +} + + +void ThemeMoodin::paintEvent(QPaintEvent* pe) +{ + QRect r = pe->rect(); + + bitBlt(mContainer, r.x(), r.y(), mBG, r.x(), r.y(), r.width(), r.height()); + + if (mShowStatusText) + updateStatus(); +} + +#include "thememoodin.moc" diff --git a/src/thememoodin.h b/src/thememoodin.h new file mode 100644 index 0000000..39f4798 --- /dev/null +++ b/src/thememoodin.h @@ -0,0 +1,129 @@ +/*************************************************************************** + * Copyright (C) by * + * - 2005: Christian Leh <moodwrod@web.de> * + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef THEMEMOODIN_H +#define THEMEMOODIN_H + +#include <qptrlist.h> + +#include <kdebug.h> +#include <kpixmap.h> + +#include <themeengine.h> +#include <objkstheme.h> + +#include "scaler.h" +#include "cache.h" +#include "effectwidget.h" + +typedef QPtrList<EffectWidget> EffectWidgetList; +typedef QValueList<QPoint> CoordsList; +typedef QValueList<QColor> ColorList; +typedef QValueList<QFont> FontList; +typedef QPtrList<QImage> ImageList; + +class ThemeMoodin: public ThemeEngine +{ + Q_OBJECT + +public: + ThemeMoodin(QWidget *parent, const char *name, const QStringList& flags); + + inline const QString name() { return QString("Moodin"); } + inline const int version() { return 0x042; } + + static QStringList names() + { + QStringList l; + + l << "Moodin"; + + return l; + }; + + static QStringList statusPixmaps() + { + QStringList l; + + l << "filetypes"; // 1 filetypes + l << "exec"; // 2 exec + l << "key_bindings"; // 3 key_bindings + l << "window_list"; // 4 window_list + l << "desktop"; // 5 desktop + l << "style"; // 6 style + l << "kcmsystem"; // 7 kcmsystem + l << "go"; // 8 go + + return l; + }; + +public slots: + void slotSetText(const QString& s); + void slotSetPixmap(const QString&); + +private: + bool mUseIconSet; + bool mLabelShadow; + bool mShowStatusText; + bool mAppendX; + bool mUsersBackground; + bool mTranslate; + bool mLineUpImages; + bool mKubuntuStyle; + int mAnimationLength; + int mAnimationDelay; + int mIconSetSize; + int mCurrentStatusIndex; + int mImageSpacer; + int mLabelCount; + float mBeginOpacity; + + QString mCurrentAction; + QString mBackgroundImage; + QStringList mStatusIcons; + QStringList mStatusMessages; + QStringList mLabels; + QColor mStatusColor; + QColor mLabelShadowColor; + QFont mStatusFont; + QPoint mStatusCoords; + QPoint mLabelShadowOffset; + QWidget* mContainer; + QSize mBaseResolution; + QRect mSplashRect; + + KPixmap* mBG; + + Scaler* mScaler; + Cache* mCache; + + EffectWidgetList mEffectWidgets; + CoordsList mStatusIconCoords; + CoordsList mStatusImageOffsets; + CoordsList mLabelCoords; + ColorList mLabelColors; + FontList mLabelFonts; + ImageList mImages; + + void init(); + void initBackground(QPainter* p); + void initEffectWidgets(); + void initLabels(QPainter* p); + + void paintEvent(QPaintEvent* pe); + void readSettings(); + void arrangeWidget(QWidget* me, const int index); + void updateStatus(); + + EffectWidget* createEffectWidget(QWidget *parent, QImage *image); +}; + +#endif diff --git a/src/themes/FingerPrint/1.png b/src/themes/FingerPrint/1.png Binary files differnew file mode 100644 index 0000000..9fe0639 --- /dev/null +++ b/src/themes/FingerPrint/1.png diff --git a/src/themes/FingerPrint/2.png b/src/themes/FingerPrint/2.png Binary files differnew file mode 100644 index 0000000..16aeba2 --- /dev/null +++ b/src/themes/FingerPrint/2.png diff --git a/src/themes/FingerPrint/3.png b/src/themes/FingerPrint/3.png Binary files differnew file mode 100644 index 0000000..92c0da1 --- /dev/null +++ b/src/themes/FingerPrint/3.png diff --git a/src/themes/FingerPrint/4.png b/src/themes/FingerPrint/4.png Binary files differnew file mode 100644 index 0000000..040a110 --- /dev/null +++ b/src/themes/FingerPrint/4.png diff --git a/src/themes/FingerPrint/5.png b/src/themes/FingerPrint/5.png Binary files differnew file mode 100644 index 0000000..2c5b83a --- /dev/null +++ b/src/themes/FingerPrint/5.png diff --git a/src/themes/FingerPrint/6.png b/src/themes/FingerPrint/6.png Binary files differnew file mode 100644 index 0000000..6287e1c --- /dev/null +++ b/src/themes/FingerPrint/6.png diff --git a/src/themes/FingerPrint/7.png b/src/themes/FingerPrint/7.png Binary files differnew file mode 100644 index 0000000..01db042 --- /dev/null +++ b/src/themes/FingerPrint/7.png diff --git a/src/themes/FingerPrint/8.png b/src/themes/FingerPrint/8.png Binary files differnew file mode 100644 index 0000000..26e91f7 --- /dev/null +++ b/src/themes/FingerPrint/8.png diff --git a/src/themes/FingerPrint/Background.jpg b/src/themes/FingerPrint/Background.jpg Binary files differnew file mode 100644 index 0000000..2e60642 --- /dev/null +++ b/src/themes/FingerPrint/Background.jpg diff --git a/src/themes/FingerPrint/Preview.png b/src/themes/FingerPrint/Preview.png Binary files differnew file mode 100644 index 0000000..5c6a465 --- /dev/null +++ b/src/themes/FingerPrint/Preview.png diff --git a/src/themes/FingerPrint/Theme.rc b/src/themes/FingerPrint/Theme.rc new file mode 100644 index 0000000..5a77386 --- /dev/null +++ b/src/themes/FingerPrint/Theme.rc @@ -0,0 +1,41 @@ +[KSplash Theme: FingerPrint] +Name = FingerPrint +Description = Taste your fingers (wallpaper from Dalmases http://www.deviantart.com/deviation/11180503/) +Version = 1.2 +Author = Christian Leh <moodwrod@web.de> +Homepage = http://moodwrod.com +Engine = Moodin + +BeginOpacity = 0.1 +BaseResolution = 1280,1024 + +UseIconSet = false + +ImageCoords1 = 682,285 +ImageCoords2 = 682,138 +ImageCoords3 = 805,239 +ImageCoords4 = 805,94 +ImageCoords5 = 928,314 +ImageCoords6 = 925,170 +ImageCoords7 = 1122,472 +ImageCoords8 = 249,418 + +StatusMessage1 = # 0.5 +StatusMessage2 = # 1.0 +StatusMessage3 = # 1.5 +StatusMessage4 = # 2.0 +StatusMessage5 = # 2.5 +StatusMessage6 = # 3.0 +StatusMessage7 = # 3.5 +StatusMessage8 = Access Granted + +Labels = 2 +Label1 = Validating... +LabelFont1 = Trebuchet MS,24,-1,5,50,0 +LabelCoords1 = 75,75 + +Label2 = ML:USER:loginname +LabelFont2 = Trebuchet MS,16,-1,5,50,0 +LabelCoords2 = 250,255 + +StatusCoords = 100,100 diff --git a/src/themes/MoodinKDE/Background.jpg b/src/themes/MoodinKDE/Background.jpg Binary files differnew file mode 100644 index 0000000..460e35b --- /dev/null +++ b/src/themes/MoodinKDE/Background.jpg diff --git a/src/themes/MoodinKDE/Preview.png b/src/themes/MoodinKDE/Preview.png Binary files differnew file mode 100644 index 0000000..cdd73b2 --- /dev/null +++ b/src/themes/MoodinKDE/Preview.png diff --git a/src/themes/MoodinKDE/Theme.rc b/src/themes/MoodinKDE/Theme.rc new file mode 100644 index 0000000..de034c1 --- /dev/null +++ b/src/themes/MoodinKDE/Theme.rc @@ -0,0 +1,30 @@ +[KSplash Theme: MoodinKDE] +Name = MoodinKDE +Description = Fading splash screen based on the svg wallpaper (Lineart Logo) +Version = 1.2 +Author = Christian Leh <moodwrod@web.de> +Homepage = http://moodwrod.com +Engine = Moodin + +BeginOpacity = 0.1 +BaseResolution = 1280,1024 + +UseIconSet = true +IconSetSize = 48 + +Image1 = kcmsystem +Image2 = kcontrol +Image3 = kcmpci +Image7 = kmenuedit +Image8 = kmenu + +LineUpImages = true + +Labels = 1 +Label1 = Welcome +LabelFont1 = Trebuchet MS,48,-1,0,0,0 +LabelCoords1 = -1,400 + +StatusCoords = -1,450 + +ImageOffset1 = 0,20 |