diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /ksplashml | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksplashml')
86 files changed, 4723 insertions, 0 deletions
diff --git a/ksplashml/Makefile.am b/ksplashml/Makefile.am new file mode 100644 index 000000000..8e8496db5 --- /dev/null +++ b/ksplashml/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = themeengine pics kcmksplash + +INCLUDES = -I$(srcdir)/themeengine -I$(srcdir)/themeengine/default $(all_includes) + +METASOURCES=AUTO + +bin_PROGRAMS = ksplash +ksplash_SOURCES = wndmain.cpp ksplashiface.skel main.cpp +ksplash_LDFLAGS = $(all_libraries) $(KDE_RPATH) +ksplash_LDADD = $(LIB_KDEUI) themeengine/default/libthemedefault.la themeengine/libksplashthemes.la $(LIB_KIO) + +noinst_HEADERS = ksplashiface.h wndmain.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplash.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp themeengine/*.cpp -o $(podir)/ksplash.pot diff --git a/ksplashml/kcmksplash/Makefile.am b/ksplashml/kcmksplash/Makefile.am new file mode 100644 index 000000000..d2ebe6cdd --- /dev/null +++ b/ksplashml/kcmksplash/Makefile.am @@ -0,0 +1,18 @@ +# Makefile.am for kdebase/ksplashml/kcmksplash +SUBDIRS=pics + +INCLUDES = $(all_includes) +METASOURCES = AUTO + +kde_module_LTLIBRARIES = kcm_ksplashthemes.la + +kcm_ksplashthemes_la_SOURCES = installer.cpp main.cpp +noinst_HEADERS = installer.h + +kcm_ksplashthemes_la_LIBADD = $(LIB_KIO) +kcm_ksplashthemes_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module + +xdg_apps_DATA = ksplashthememgr.desktop + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/ksplashthemes.pot diff --git a/ksplashml/kcmksplash/installer.cpp b/ksplashml/kcmksplash/installer.cpp new file mode 100644 index 000000000..a2850ecfa --- /dev/null +++ b/ksplashml/kcmksplash/installer.cpp @@ -0,0 +1,484 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * Copyright (c) 1998 Stefan Taferner <taferner@kde.org> * + * * + * 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. * + * * + ***************************************************************************/ + +#include <unistd.h> +#include <stdlib.h> + +#include <qdir.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qtextedit.h> + +#include "installer.h" + +#include <kdebug.h> +#include <kfiledialog.h> +#include <kglobalsettings.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprocess.h> +#include <kpushbutton.h> +#include <kstandarddirs.h> +#include <ktar.h> +#include <ktrader.h> +#include <kurldrag.h> +#include <kio/netaccess.h> + +ThemeListBox::ThemeListBox(QWidget *parent) + : KListBox(parent) +{ + setAcceptDrops(true); + connect(this, SIGNAL(mouseButtonPressed(int, QListBoxItem *, const QPoint &)), + this, SLOT(slotMouseButtonPressed(int, QListBoxItem *, const QPoint &))); +} + +void ThemeListBox::dragEnterEvent(QDragEnterEvent* event) +{ + event->accept((event->source() != this) && KURLDrag::canDecode(event)); +} + +void ThemeListBox::dropEvent(QDropEvent* event) +{ + KURL::List urls; + if (KURLDrag::decode(event, urls)) + { + emit filesDropped(urls); + } +} + +void ThemeListBox::slotMouseButtonPressed(int button, QListBoxItem *item, const QPoint &p) +{ + if ((button & LeftButton) == 0) return; + mOldPos = p; + mDragFile = QString::null; + int cur = index(item); + if (cur >= 0) + mDragFile = text2path[text(cur)]; +} + +void ThemeListBox::mouseMoveEvent(QMouseEvent *e) +{ + if (((e->state() & LeftButton) != 0) && !mDragFile.isEmpty()) + { + int delay = KGlobalSettings::dndEventDelay(); + QPoint newPos = e->globalPos(); + if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || + newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) + { + KURL url; + url.setPath(mDragFile); + KURL::List urls; + urls.append(url); + KURLDrag *d = new KURLDrag(urls, this); + d->dragCopy(); + } + } + KListBox::mouseMoveEvent(e); +} + +//----------------------------------------------------------------------------- +SplashInstaller::SplashInstaller (QWidget *aParent, const char *aName, bool aInit) + : QWidget(aParent, aName), mGui(!aInit) +{ + KGlobal::dirs()->addResourceType("ksplashthemes", KStandardDirs::kde_default("data") + "ksplash/Themes"); + + if (!mGui) + return; + + QHBoxLayout* hbox = new QHBoxLayout( this, 0, KDialog::spacingHint() ); + + QVBoxLayout* leftbox = new QVBoxLayout( hbox, KDialog::spacingHint() ); + hbox->setStretchFactor( leftbox, 1 ); + + mThemesList = new ThemeListBox(this); + mThemesList->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding ); + connect(mThemesList, SIGNAL(highlighted(int)), SLOT(slotSetTheme(int))); + connect(mThemesList, SIGNAL(filesDropped(const KURL::List&)), SLOT(slotFilesDropped(const KURL::List&))); + leftbox->addWidget(mThemesList); + + mBtnAdd = new KPushButton( i18n("Add..."), this ); + leftbox->addWidget( mBtnAdd ); + connect(mBtnAdd, SIGNAL(clicked()), SLOT(slotAdd())); + + mBtnRemove = new KPushButton( i18n("Remove"), this ); + leftbox->addWidget( mBtnRemove ); + connect(mBtnRemove, SIGNAL(clicked()), SLOT(slotRemove())); + + mBtnTest = new KPushButton( i18n("Test"), this ); + leftbox->addWidget( mBtnTest ); + connect(mBtnTest, SIGNAL(clicked()), SLOT(slotTest())); + + QVBoxLayout* rightbox = new QVBoxLayout( hbox, KDialog::spacingHint() ); + hbox->setStretchFactor( rightbox, 3 ); + + mPreview = new QLabel(this); + mPreview->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); + mPreview->setMinimumSize(QSize(320,240)); + mPreview->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter); + rightbox->addWidget(mPreview); + rightbox->setStretchFactor( mPreview, 3 ); + + mText = new QTextEdit(this); + mText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); + mText->setMinimumSize(mText->sizeHint()); + mText->setReadOnly(true); + rightbox->addWidget(mText); + rightbox->setStretchFactor( mText, 1 ); + + readThemesList(); + load(); +} + + +//----------------------------------------------------------------------------- +SplashInstaller::~SplashInstaller() +{ +} + +int SplashInstaller::addTheme(const QString &path, const QString &name) +{ + //kdDebug() << "SplashInstaller::addTheme: " << path << " " << name << endl; + QString tmp(i18n( name.utf8() )); + int i = mThemesList->count(); + while((i > 0) && (mThemesList->text(i-1) > tmp)) + i--; + if ((i > 0) && (mThemesList->text(i-1) == tmp)) + return i-1; + mThemesList->insertItem(tmp, i); + mThemesList->text2path.insert( tmp, path+"/"+name ); + return i; +} + +// Copy theme package into themes directory +void SplashInstaller::addNewTheme(const KURL &srcURL) +{ + QString dir = KGlobal::dirs()->saveLocation("ksplashthemes"); + KURL url; + QString filename = srcURL.fileName(); + int i = filename.findRev('.'); + // Convert extension to lower case. + if (i >= 0) + filename = filename.left(i)+filename.mid(i).lower(); + url.setPath(locateLocal("tmp",filename)); + + // Remove file from temporary directory if it aleady exists - usually the result of a failed install. + if ( KIO::NetAccess::exists( url, true, 0 ) ) + KIO::NetAccess::del( url, 0 ); + + bool rc = KIO::NetAccess::copy(srcURL, url, 0); + if (!rc) + { + kdWarning() << "Failed to copy theme " << srcURL.fileName() + << " into temporary directory " << url.path() << endl; + return; + } + + // Extract into theme directory: we may have multiple themes in one tarball! + KTar tarFile(url.path()); + if (!tarFile.open(IO_ReadOnly)) + { + kdDebug() << "Unable to open archive: " << url.path() << endl; + return; + } + KArchiveDirectory const *ad = tarFile.directory(); + // Find first directory entry. + QStringList entries = ad->entries(); + QString themeName( entries.first() ); +#if 0 + // The isDirectory() call always returns false; why? + for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) + { + if ( ad->entry( *it )->isDirectory() ) + { + themeName = *it; + break; + } + } +#endif + // TODO: Make sure we put the entries into a subdirectory if the tarball does not. + // TODO: Warn the user if we overwrite something. + ad->copyTo(locateLocal("ksplashthemes","/")); + tarFile.close(); + KIO::NetAccess::del( url, 0 ); + + // TODO: Update only the entries from this installation. + readThemesList(); + mThemesList->setCurrentItem(findTheme(themeName)); + mThemesList->setSelected(mThemesList->currentItem(), true); +} + +//----------------------------------------------------------------------------- +void SplashInstaller::readThemesList() +{ + mThemesList->clear(); + + // Read local themes + QStringList entryList = KGlobal::dirs()->resourceDirs("ksplashthemes"); + //kdDebug() << "readThemesList: " << entryList << endl; + QDir dir; + QStringList subdirs; + QStringList::ConstIterator name; + for(name = entryList.begin(); name != entryList.end(); name++) + { + dir = *name; + if (!dir.exists()) + continue; + subdirs = dir.entryList( QDir::Dirs ); + // kdDebug() << "readThemesList: " << subdirs << endl; + // TODO: Make sure it contains a *.rc file. + for (QStringList::Iterator l = subdirs.begin(); l != subdirs.end(); l++ ) + if ( !(*l).startsWith(QString(".")) ) + { + mThemesList->blockSignals( true ); // Don't activate any theme until all themes are loaded. + addTheme(dir.path(),*l); + mThemesList->blockSignals( false ); + } + } +} + +//----------------------------------------------------------------------------- +void SplashInstaller::defaults() +{ + load( true ); +} + +void SplashInstaller::load() +{ + load( false ); +} + +void SplashInstaller::load( bool useDefaults ) +{ + KConfig cnf("ksplashrc"); + cnf.setReadDefaults( useDefaults ); + cnf.setGroup("KSplash"); + QString curTheme = cnf.readEntry("Theme","Default"); + mThemesList->setCurrentItem(findTheme(curTheme)); + emit changed( useDefaults ); +} + +//----------------------------------------------------------------------------- +void SplashInstaller::save() +{ + KConfig cnf("ksplashrc"); + cnf.setGroup("KSplash"); + int cur = mThemesList->currentItem(); + if (cur < 0) + return; + QString path = mThemesList->text(cur); + if ( mThemesList->text2path.contains( path ) ) + path = mThemesList->text2path[path]; + cur = path.findRev('/'); + cnf.writeEntry("Theme", path.mid(cur+1) ); + cnf.sync(); + emit changed( false ); +} + +//----------------------------------------------------------------------------- +void SplashInstaller::slotRemove() +{ + int cur = mThemesList->currentItem(); + if (cur < 0) + return; + + bool rc = false; + QString themeName = mThemesList->text(cur); + QString themeDir = mThemesList->text2path[themeName]; + if (!themeDir.isEmpty()) + { + KURL url; + url.setPath(themeDir); + if (KMessageBox::warningContinueCancel(this,i18n("Delete folder %1 and its contents?").arg(themeDir),"",KGuiItem(i18n("&Delete"),"editdelete"))==KMessageBox::Continue) + rc = KIO::NetAccess::del(url,this); + else + return; + } + if (!rc) + { + KMessageBox::sorry(this, i18n("Failed to remove theme '%1'").arg(themeName)); + return; + } + //mThemesList->removeItem(cur); + readThemesList(); + cur = ((unsigned int)cur >= mThemesList->count())?mThemesList->count()-1:cur; + mThemesList->setCurrentItem(cur); +} + + +//----------------------------------------------------------------------------- +void SplashInstaller::slotSetTheme(int id) +{ + bool enabled; + QString path(QString::null); + QString infoTxt; + + if (id < 0) + { + mPreview->setText(QString::null); + mText->setText(QString::null); + enabled = false; + } + else + { + QString error = i18n("(Could not load theme)"); + path = mThemesList->text(id); + if ( mThemesList->text2path.contains( path ) ) + path = mThemesList->text2path[path]; + enabled = false; + KURL url; + QString themeName; + if (!path.isEmpty()) + { + // Make sure the correct plugin is installed. + int i = path.findRev('/'); + if (i >= 0) + themeName = path.mid(i+1); + url.setPath( path + "/Theme.rc" ); + if (!KIO::NetAccess::exists(url, true, 0)) + { + url.setPath( path + "/Theme.RC" ); + if (!KIO::NetAccess::exists(url, true, 0)) + { + url.setPath( path + "/theme.rc" ); + if (!KIO::NetAccess::exists(url, true, 0)) + url.setPath( path + "/" + themeName + ".rc" ); + } + } + if (KIO::NetAccess::exists(url, true, 0)) + { + KConfig cnf(url.path()); + cnf.setGroup( QString("KSplash Theme: %1").arg(themeName) ); + + // Get theme information. + infoTxt = "<qt>"; + if ( cnf.hasKey( "Name" ) ) + infoTxt += i18n( "<b>Name:</b> %1<br>" ).arg( cnf.readEntry( "Name", i18n( "Unknown" ) ) ); + if ( cnf.hasKey( "Description" ) ) + infoTxt += i18n( "<b>Description:</b> %1<br>" ).arg( cnf.readEntry( "Description", i18n( "Unknown" ) ) ); + if ( cnf.hasKey( "Version" ) ) + infoTxt += i18n( "<b>Version:</b> %1<br>" ).arg( cnf.readEntry( "Version", i18n( "Unknown" ) ) ); + if ( cnf.hasKey( "Author" ) ) + infoTxt += i18n( "<b>Author:</b> %1<br>" ).arg( cnf.readEntry( "Author", i18n( "Unknown" ) ) ); + if ( cnf.hasKey( "Homepage" ) ) + infoTxt += i18n( "<b>Homepage:</b> %1<br>" ).arg( cnf.readEntry( "Homepage", i18n( "Unknown" ) ) ); + infoTxt += "</qt>"; + + QString pluginName( cnf.readEntry( "Engine", "Default" ) ); // Perhaps no default is better? + if ((KTrader::self()->query("KSplash/Plugin", QString("[X-KSplash-PluginName] == '%1'").arg(pluginName))).isEmpty()) + { + enabled = false; + error = i18n("This theme requires the plugin %1 which is not installed.").arg(pluginName); + } + else + enabled = true; // Hooray, there is at least one plugin which can handle this theme. + } + else + { + error = i18n("Could not load theme configuration file."); + } + } + mBtnTest->setEnabled(enabled && themeName != "None" ); + mText->setText(infoTxt); + if (!enabled) + { + url.setPath( path + "/" + "Preview.png" ); + if (KIO::NetAccess::exists(url, true, 0)) + mPreview->setPixmap(QPixmap(url.path())); + else + mPreview->setText(i18n("(Could not load theme)")); + KMessageBox::sorry(this, error); + } + else + { + url.setPath( path + "/" + "Preview.png" ); + if (KIO::NetAccess::exists(url, true, 0)) + mPreview->setPixmap(QPixmap(url.path())); + else + mPreview->setText(i18n("No preview available.")); + emit changed(true); + } + } + mBtnRemove->setEnabled( !path.isEmpty() && QFileInfo(path).isWritable()); +} + + +//----------------------------------------------------------------------------- +void SplashInstaller::slotAdd() +{ + static QString path; + if (path.isEmpty()) path = QDir::homeDirPath(); + + KFileDialog dlg(path, "*.tgz *.tar.gz *.tar.bz2|" + i18n( "KSplash Theme Files" ), 0, 0, true); + dlg.setCaption(i18n("Add Theme")); + if (!dlg.exec()) + return; + + path = dlg.baseURL().url(); + addNewTheme(dlg.selectedURL()); +} + +//----------------------------------------------------------------------------- +void SplashInstaller::slotFilesDropped(const KURL::List &urls) +{ + for(KURL::List::ConstIterator it = urls.begin(); + it != urls.end(); + ++it) + addNewTheme(*it); +} + +//----------------------------------------------------------------------------- +int SplashInstaller::findTheme( const QString &theme ) +{ + // theme is untranslated, but the listbox contains translated items + QString tmp(i18n( theme.utf8() )); + int id = mThemesList->count()-1; + + while (id >= 0) + { + if (mThemesList->text(id) == tmp) + return id; + id--; + } + + return 0; +} + +//----------------------------------------------------------------------------- +void SplashInstaller::slotTest() +{ + int i = mThemesList->currentItem(); + if (i < 0) + return; + QString themeName = mThemesList->text2path[mThemesList->text(i)]; + int r = themeName.findRev('/'); + if (r >= 0) + themeName = themeName.mid(r+1); + + // special handling for none and simple splashscreens + if( themeName == "None" ) + return; + if( themeName == "Simple" ) + { + KProcess proc; + proc << "ksplashsimple" << "--test"; + if (!proc.start(KProcess::Block)) + KMessageBox::error(this,i18n("Unable to start ksplashsimple.")); + return; + } + KProcess proc; + proc << "ksplash" << "--test" << "--theme" << themeName; + if (!proc.start(KProcess::Block)) + KMessageBox::error(this,i18n("Unable to start ksplash.")); +} + +//----------------------------------------------------------------------------- +#include "installer.moc" diff --git a/ksplashml/kcmksplash/installer.h b/ksplashml/kcmksplash/installer.h new file mode 100644 index 000000000..43e37d0fc --- /dev/null +++ b/ksplashml/kcmksplash/installer.h @@ -0,0 +1,87 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * Copyright (c) 1998 Stefan Taferner <taferner@kde.org> * + * * + * 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. * + * * + ***************************************************************************/ +#ifndef SPLASHINSTALLER_H +#define SPLASHINSTALLER_H + +#include <qmap.h> +#include <qpoint.h> + +#include <klistbox.h> +#include <kurl.h> + +class QLabel; +class QTextEdit; +class QPushButton; +class ThemeListBox; + +class SplashInstaller : public QWidget +{ + Q_OBJECT +public: + SplashInstaller(QWidget *parent=0, const char *aName=0, bool aInit=FALSE); + ~SplashInstaller(); + + virtual void load(); + virtual void load( bool useDefaults ); + virtual void save(); + virtual void defaults(); + +signals: + void changed( bool state ); + +protected slots: + virtual void slotAdd(); + virtual void slotRemove(); + virtual void slotTest(); + virtual void slotSetTheme(int); + void slotFilesDropped(const KURL::List &urls); + +protected: + /** Scan Themes directory for available theme packages */ + virtual void readThemesList(); + /** add a theme to the list, returns the list index */ + int addTheme(const QString &path, const QString &name); + void addNewTheme(const KURL &srcURL); + int findTheme( const QString &theme ); + +private: + bool mGui; + ThemeListBox *mThemesList; + QPushButton *mBtnAdd, *mBtnRemove, *mBtnTest; + QTextEdit *mText; + QLabel *mPreview; +}; + +class ThemeListBox: public KListBox +{ + Q_OBJECT +public: + ThemeListBox(QWidget *parent); + QMap<QString, QString> text2path; + +signals: + void filesDropped(const KURL::List &urls); + +protected: + void dragEnterEvent(QDragEnterEvent* event); + void dropEvent(QDropEvent* event); + void mouseMoveEvent(QMouseEvent *e); + +protected slots: + void slotMouseButtonPressed(int button, QListBoxItem *item, const QPoint &p); + +private: + QString mDragFile; + QPoint mOldPos; + +}; + +#endif diff --git a/ksplashml/kcmksplash/ksplashthememgr.desktop b/ksplashml/kcmksplash/ksplashthememgr.desktop new file mode 100644 index 000000000..293e3b1a4 --- /dev/null +++ b/ksplashml/kcmksplash/ksplashthememgr.desktop @@ -0,0 +1,216 @@ +[Desktop Entry] +Icon=ksplash +Exec=kcmshell ksplashthememgr +DocPath=ksplashml/themes.html + +X-KDE-ModuleType=Library +X-KDE-Library=ksplashthemes +X-KDE-FactoryName=ksplashthemes +X-KDE-ParentApp=kcontrol + +Name=Splash Screen +Name[af]=Spat Skerm +Name[ar]=شاشة بادئة +Name[az]=Açılış Rəsmi +Name[be]=Застаўка загрузкі +Name[bg]=Начален екран +Name[bn]=স্প্ল্যাশ স্ক্রীণ +Name[br]=Skramm-degemer +Name[ca]=Pantalla d'inici +Name[cs]=Úvodní obrazovka +Name[csb]=Ekran na przëwitanié +Name[cy]=Sgrîn Croeso +Name[da]=Splashskærm +Name[de]=Startbildschirm +Name[el]=Αρχική οθόνη +Name[eo]=Salutŝildo +Name[es]=Pantalla anunciadora +Name[et]=Käivitusekraan +Name[eu]=Splash pantaila +Name[fa]=رنگپاشی پرده +Name[fi]=Aloitusruutu +Name[fr]=Écran de démarrage +Name[fy]=Begjinskerm +Name[ga]=Splancscáileán +Name[gl]=Pantalla de Benvida +Name[he]=מצג פתיחה +Name[hi]=स्प्लैश स्क्रीन +Name[hr]=Pozdravni zaslon +Name[hu]=Nyitókép-témák +Name[is]=Upphafsskjár +Name[it]=Schermata d'avvio +Name[ja]=スプラッシュスクリーン +Name[kk]=Бастау экраны +Name[km]=អេក្រង់ស្វាគមន៍ +Name[ko]=시작 화면 +Name[lo]=จอเริ่มการทำงาน +Name[lt]=Pasveikinimo ekranas +Name[lv]=Šļaksta Ekrāns +Name[mk]=Поздравен екран +Name[mn]=Эхлэл дэлгэц +Name[ms]=Splash Screen +Name[nb]=Velkomstbilde +Name[nds]=Startschirm +Name[ne]=स्प्लयास पर्दा +Name[nl]=Opstartscherm +Name[nn]=Velkomstbilete +Name[pa]=ਸਵਾਗਤੀ ਸਕਰੀਨ +Name[pl]=Ekran powitalny +Name[pt]=Ecrã Inicial +Name[pt_BR]=Tela de Apresentação +Name[ro]=Imagine de pornire +Name[ru]=Заставка +Name[rw]=Gukwiza Mugaragaza +Name[se]=Álgošearbma +Name[sk]=Úvodná obrazovka +Name[sl]=Uvodni zaslon +Name[sr]=Сплеш екран +Name[sr@Latn]=Spleš ekran +Name[sv]=Startskärm +Name[ta]=தோன்றும் திரை +Name[tg]=Пардаи оғоз +Name[th]=หน้าจอเริ่มการทำงาน +Name[tr]=Açılış ekranı +Name[tt]=Kürsätmä Täräzä +Name[uk]=Екран заставки +Name[uz]=Splesh oynasi +Name[uz@cyrillic]=Сплэш ойнаси +Name[ven]=U kwasha tshikirini +Name[vi]=Màn hình Chào mừng +Name[wa]=Waitroûle d' enondaedje +Name[zh_CN]=飞溅屏幕 +Name[zh_TW]=啟動畫面 +Name[zu]=Isikrini Sokuphahlaza +Type=Application +Comment=Manager for Splash Screen Themes +Comment[af]=Bestuurder vir Spat Skerm Temas +Comment[ar]=مدير سمات الشاشات الافتتاحية +Comment[az]=Açılış Rəsmi Örtükləri İdarəçisi +Comment[be]=Кіраўнік заставак загрузкі +Comment[bg]=Настройване на началния екран +Comment[bn]=স্প্ল্যাশ স্ক্রীণ থীম ম্যানেজার +Comment[br]=Merour evit gwiskadoù ar skramm degemer +Comment[bs]=Upravitelj temama splash screen-a +Comment[ca]=Gestor per als temes de la pantalla d'inici +Comment[cs]=Správce motivů úvodních obrazovek +Comment[csb]=Menedżer témów ekranu na przëwitanié +Comment[cy]=Rheolydd Themau Sgriniau Croeso +Comment[da]=Håndtering for opstartskærme-temaer +Comment[de]=Verwaltung für Startbildschirmdesigns +Comment[el]=Διαχειριστής για θέματα αρχικής οθόνης +Comment[eo]=Administrilo por la salutŝildo +Comment[es]=Gestor de los temas de la pantalla anunciadora +Comment[et]=Käivitusekraani teemade haldur +Comment[eu]=Splash pantailako gaien kudeatzailea +Comment[fa]=مدیر چهرههای رنگپاشی پرده +Comment[fi]=Hallintaohjelma aloitusruuduille +Comment[fr]=Gestionnaire de thèmes d'écran de démarrage +Comment[fy]=Temabehear foar begjinskerm +Comment[gl]=Xestor dos Temas para a Pantalla de Benvida +Comment[he]=מנהל ערכות נושא למצג הפתיחה +Comment[hi]=स्प्लैश स्क्रीन प्रसंगों के लिए प्रबंधक +Comment[hr]=Upravitelj tema pozdravnih zaslona +Comment[hu]=A nyitókép témájának beállítása +Comment[is]=Stjórna þemum upphafsskjáa +Comment[it]=Gestore dei temi della schermata di avvio +Comment[ja]=スプラッシュスクリーンのテーマを管理 +Comment[kk]=Бастау бейнеперде нақыштарының менеджері +Comment[km]=កម្មវិធីគ្រប់គ្រងស្បែកអេក្រង់ស្វាគមន៍ +Comment[ko]=시작 화면 테마 관리자 +Comment[lt]=Pasveikinimo ekrano temų tvarkyklė +Comment[lv]=Šļakstekrānu tēmu menedžeris +Comment[mk]=Менаџер на теми за поздравни екрани +Comment[mn]=Ажлын тавцанын эхлэл дэлгэцийн хэлбэр удирдагч +Comment[ms]=Pengurus untuk Tema Splash Screen +Comment[mt]=Manager għat-temi tal-Isplash Screen +Comment[nb]=Behandler for velkomstbilder +Comment[nds]=Startschirmmuster instellen +Comment[ne]=स्प्लयास पर्दा विषयवस्तुका लागि प्रबन्धक +Comment[nl]=Themabeheer voor opstartschermen +Comment[nn]=Handsamar for velkomstbilete +Comment[pa]=ਸਵਾਗਤੀ ਪਰਦਾ ਸਰੂਪ ਲਈ ਮੈਨੇਜਰ +Comment[pl]=Menedżer motywów ekranu powitalnego +Comment[pt]=Gestor de Temas do Ecrã Inicial +Comment[pt_BR]=Gerenciador de Temas para a Tela de Apresentação +Comment[ro]=Manager pentru tematicile imaginii de pornire a KDE +Comment[ru]=Менеджер тем экрана-заставки +Comment[rw]=Umuyobozi wo Gukwiza Insanganyamatsiko za Mugaragaza +Comment[se]=Álgošearbmafáttáid gieđahalli +Comment[sk]=Správca tém úvodnej obrazovky +Comment[sl]=Upravitelj tem uvodnih zaslonov +Comment[sr]=Менаџер тема сплеш екрана +Comment[sr@Latn]=Menadžer tema spleš ekrana +Comment[sv]=Hanterare för startskärmsteman +Comment[ta]=தோன்றும் திரை தலைப்புகளுக்கு மேலாளர் +Comment[tg]=Мудири услубҳои пардаи оғоз +Comment[th]=เครื่องมือจัดการชุดตกแต่งของหน้าจอเริ่มการทำงาน +Comment[tr]=Açılış Ekran Teması Yöneticisi +Comment[tt]=Alsürät Tärzäse öçen Tışlaw İdäräçe +Comment[uk]=Менеджер тем екранів заставки +Comment[uz]=Splesh oynasi uchun mavzularni moslash +Comment[uz@cyrillic]=Сплэш ойнаси учун мавзуларни мослаш +Comment[vi]=Trình quản lý các Sắc thái của Màn hình Chào mừng +Comment[wa]=Manaedjeu po les tinmes del waitroûle d' enondaedje +Comment[zh_CN]=飞溅屏幕主题管理器 +Comment[zh_TW]=啟動畫面佈景管理程式 +Keywords=splash screen,splash theme,startup +Keywords[ar]=الشاشة الافتتاحية، سمات الشاشة الافتتاحية، بدء التشغيل +Keywords[az]=splash screen,splash theme,startup,açılış,örtük +Keywords[be]=Застаўка,Загрузка,Запуск,Тэма загрузкі,splash screen,splash theme,startup +Keywords[bg]=стартиране, начален, екран, splash screen, splash theme, startup +Keywords[bs]=splash screen,splash theme,startup,pokretanje,splash +Keywords[ca]=pantalla d'inici,tema d'inici,iniciació +Keywords[cs]=úvodní obrazovka,splash +Keywords[csb]=ekran na przëwitanié,téma ekranu,rozpòczãce,sztart +Keywords[cy]=sgrîn croeso,thema croeso,ymgychwyn +Keywords[da]=opstartsskærm,opstartstema,opstart +Keywords[de]=startbildschirm +Keywords[el]=αρχική οθόνη,θέμα αρχικής οθόνης,ξεκίνημα +Keywords[eo]=Kcm_salutŝildo,Salutŝildo,Saluto +Keywords[es]=pantalla de inicio,tema de inicio,inicio +Keywords[et]=käivitusekraan,käivutusteema,käivitamine +Keywords[eu]=splash pantaila,splash gaia,abioa +Keywords[fa]=رنگپاشی پرده، چهرۀ رنگپاشی، راهاندازی +Keywords[fi]=aloitusruutu,aloitusruututeema,käynnistys +Keywords[fr]=écran de démarrage,thème de démarrage,démarrage,splash screen +Keywords[fy]=opstartscherm,begjinskerm,splash screen +Keywords[ga]=splancscáileán,splancthéama,tosú,tosach +Keywords[gl]=pantalla de benvida,tema de benvida,comezo +Keywords[he]=מצג פתיחה,ערכת נושא למצג פתיחה,הפעלה,splash screen,splash theme,startup +Keywords[hi]=स्प्लैश स्क्रीन,स्प्लैश प्रसंग,प्रारंभ में +Keywords[hr]=splash screen,splash theme,startup,zaslon,pozdravna tema,pokretanje,početni zaslon +Keywords[hu]=nyitókép,indítási téma,indulás +Keywords[it]=schermata di avvio,splash screen,tema schermata di avvio,avvio +Keywords[ja]=スプラッシュスクリーン,スプラッシュテーマ,起動 +Keywords[km]=អេក្រង់ស្វាគមន៍,ស្បែកពេលចាប់ផ្ដើម,ចាប់ផ្ដើម +Keywords[lt]=splash screen,splash theme,startup,pasveikinimo ekranas,pasveikinimo tema +Keywords[lv]=šļakstekrāns,šļakstekrāna tēma,palaišanās +Keywords[mk]=splash screen,splash theme,startup,поздравен екран,поздравна тема +Keywords[mn]=эхлэл дэлгэц,эхлэлийн хэлбэр,эхлэл +Keywords[nb]=oppstart,oppstartsbilde,oppstartstema,velkomstbilde,velkomsttema +Keywords[nds]=splash,starten,Startschirm,Muster,theme +Keywords[ne]=स्प्लयास पर्दा, स्प्लयास विषयवस्तु, सुरुआत +Keywords[nl]=opstartscherm,splash screen +Keywords[nn]=oppstart,velkomstbilete,velkomsttema,oppstartstema +Keywords[pa]=ਸ਼ੁਰੂਆਤੀ ਸਕਰੀਨ, ਸ਼ੁਰੂਆਤੀ ਸੂਰਪ,ਸ਼ੁਰੂਆਤ +Keywords[pl]=ekran powitalny,motyw ekranu powitalnego,rozpoczęcie,start +Keywords[pt]=ecrã inicial,tema do ecrã inicial,arranque +Keywords[pt_BR]=tela de apresentação, tema da tela de apresentação,inicialização +Keywords[ro]=imagine,tematică,întîmpinare,pornire +Keywords[rw]=gukwiza mugaragaza,gukwiza insanganyamatsiko,gutangira +Keywords[sk]=úvodná obrazovka,téma,spustenie,splash +Keywords[sl]=uvodni zaslon,uvodna tema,zagon +Keywords[sr]=splash screen,splash theme,startup,сплеш екран, сплеш тема,покретање,стартни екран +Keywords[sr@Latn]=splash screen,splash theme,startup,spleš ekran, spleš tema,pokretanje,startni ekran +Keywords[sv]=startskärm,starttema,start +Keywords[ta]=தோன்றும் திரை,தோன்றும் தலைப்பு,துவக்கம் +Keywords[th]=หน้าจอเริ่มการทำงาน,ชุดตกแต่ง splash,เริ่มทำงาน +Keywords[tr]=açılış ekranı, açılış teması, başlangıç +Keywords[uk]=екран заставки,тема заставки,запуск,старт +Keywords[uz]=splesh oynasi,splesh mavzusi,ishga tushish +Keywords[uz@cyrillic]=сплэш ойнаси,сплэш мавзуси,ишга тушиш +Keywords[vi]=màn hình chào mừng,sắc thái chào mừng,khởi động +Keywords[wa]=waitroûle d' enondaedje,tinme d' enondaedje,enonde tot seu +Keywords[zh_CN]=splash screen,splash theme,startup,飞溅屏幕,飞溅主题,启动 +Keywords[zh_TW]=splash screen,splash theme,startup,啟動 +Categories=Qt;KDE;X-KDE-settings-looknfeel; diff --git a/ksplashml/kcmksplash/main.cpp b/ksplashml/kcmksplash/main.cpp new file mode 100644 index 000000000..d48923a28 --- /dev/null +++ b/ksplashml/kcmksplash/main.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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. * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <qlayout.h> +#include <qtabwidget.h> + +#include <kaboutdata.h> +#include <kcmodule.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kstandarddirs.h> + +#include "installer.h" + +class KSplashThemeMgr : public KCModule +{ +public: + KSplashThemeMgr( QWidget *parent, const char *name, const QStringList &/*unused*/); + ~KSplashThemeMgr(); + + QString quickHelp() const; + + virtual void init(); + virtual void save(); + virtual void load(); + virtual void defaults(); + +private: + SplashInstaller *mInstaller; +}; + +typedef KGenericFactory< KSplashThemeMgr, QWidget > KSplashThemeMgrFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_ksplashthemes, KSplashThemeMgrFactory("ksplashthemes") ) + +// ----------------------------------------------------------------------------------------- + +KSplashThemeMgr::KSplashThemeMgr( QWidget *parent, const char *name, const QStringList &) + : KCModule( KSplashThemeMgrFactory::instance(), parent, name ), mInstaller(new SplashInstaller(this)) +{ + init(); + +#if 0 + QHBoxLayout *box = new QHBoxLayout(this); + QTabWidget *tab = new QTabWidget(this); // There will be more tabs in the future. + box->addWidget(tab); + tab->addTab( mInstaller, i18n("&Theme Installer") ); +#else + QHBoxLayout *box = new QHBoxLayout(this, 0, 0); + box->addWidget(mInstaller); +#endif + connect( mInstaller, SIGNAL(changed(bool)), SIGNAL(changed(bool)) ); + KAboutData *about = new KAboutData( "kcmksplash" + ,I18N_NOOP("KDE splash screen theme manager") + ,"0.1" + ,0 + ,KAboutData::License_GPL + ,I18N_NOOP("(c) 2003 KDE developers") ); + about->addAuthor("Ravikiran Rajagopal", 0, "ravi@ee.eng.ohio-state.edu"); + about->addCredit("Brian Ledbetter", I18N_NOOP("Original KSplash/ML author"), "brian@shadowcom.net"); + about->addCredit(I18N_NOOP("KDE Theme Manager authors" ), I18N_NOOP("Original installer code") ); + // Once string freeze is over, replace second argument with "Icon" + about->addCredit("Hans Karlsson", 0, "karlsson.h@home.se" ); + setAboutData(about); +} + +KSplashThemeMgr::~KSplashThemeMgr() +{ + // Do not delete the installer as it is now owned by the tab widget. +} + +QString KSplashThemeMgr::quickHelp() const +{ + return i18n("<h1>Splash Screen Theme Manager </h1> Install and view splash screen themes."); +} + +void KSplashThemeMgr::init() +{ + KGlobal::dirs()->addResourceType("ksplashthemes", KStandardDirs::kde_default("data") + "ksplash/Themes"); +} + +void KSplashThemeMgr::save() +{ + mInstaller->save(); +} + +void KSplashThemeMgr::load() +{ + mInstaller->load(); +} + +void KSplashThemeMgr::defaults() +{ + mInstaller->defaults(); +} diff --git a/ksplashml/kcmksplash/pics/Makefile.am b/ksplashml/kcmksplash/pics/Makefile.am new file mode 100644 index 000000000..a4b97f06a --- /dev/null +++ b/ksplashml/kcmksplash/pics/Makefile.am @@ -0,0 +1 @@ +KDE_ICON=AUTO diff --git a/ksplashml/kcmksplash/pics/hi128-app-ksplash.png b/ksplashml/kcmksplash/pics/hi128-app-ksplash.png Binary files differnew file mode 100644 index 000000000..fe0be47ae --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi128-app-ksplash.png diff --git a/ksplashml/kcmksplash/pics/hi16-app-ksplash.png b/ksplashml/kcmksplash/pics/hi16-app-ksplash.png Binary files differnew file mode 100644 index 000000000..cf1cbf3d1 --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi16-app-ksplash.png diff --git a/ksplashml/kcmksplash/pics/hi22-app-ksplash.png b/ksplashml/kcmksplash/pics/hi22-app-ksplash.png Binary files differnew file mode 100644 index 000000000..66e74b5a0 --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi22-app-ksplash.png diff --git a/ksplashml/kcmksplash/pics/hi32-app-ksplash.png b/ksplashml/kcmksplash/pics/hi32-app-ksplash.png Binary files differnew file mode 100644 index 000000000..353385a08 --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi32-app-ksplash.png diff --git a/ksplashml/kcmksplash/pics/hi48-app-ksplash.png b/ksplashml/kcmksplash/pics/hi48-app-ksplash.png Binary files differnew file mode 100644 index 000000000..441a75713 --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi48-app-ksplash.png diff --git a/ksplashml/kcmksplash/pics/hi64-app-ksplash.png b/ksplashml/kcmksplash/pics/hi64-app-ksplash.png Binary files differnew file mode 100644 index 000000000..444b6b927 --- /dev/null +++ b/ksplashml/kcmksplash/pics/hi64-app-ksplash.png diff --git a/ksplashml/ksplash.desktop b/ksplashml/ksplash.desktop new file mode 100644 index 000000000..d942ed3d9 --- /dev/null +++ b/ksplashml/ksplash.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Name=KSplash +Name[ar]=الشاشة الافتتاحية +Name[cy]=KCroeso +Name[eo]=Ksalutŝildo +Name[hi]=के-स्प्लैश +Name[ne]=के स्प्लयास +Name[pa]=ਕੇ-ਸਪਲੇਸ +Name[rw]=K-Gukwiza +Name[sv]=Startskärm +Name[ta]=Kஸ்ப்ளாஷ் +Name[vi]=Chào mừng KDE +Exec=ksplash +Icon=ksplash +Type=Service +Terminal=false +Categories=Application;System; diff --git a/ksplashml/ksplashiface.h b/ksplashml/ksplashiface.h new file mode 100644 index 000000000..2e8e7a8fc --- /dev/null +++ b/ksplashml/ksplashiface.h @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 __KSPLASHIFACE_H__ +#define __KSPLASHIFACE_H__ + +#include <dcopobject.h> + +#include <qstring.h> + +/** @short DCOP interface for KSplash. */ +class KSplashIface : virtual public DCOPObject +{ + K_DCOP +public: + KSplashIface( const char *name = "ksplash" ) : DCOPObject(name) {} + +k_dcop: + virtual ASYNC upAndRunning( QString ) = 0; + virtual ASYNC setMaxProgress(int) = 0; + virtual ASYNC setProgress(int) = 0; + virtual ASYNC setStartupItemCount( int count ) = 0; + virtual ASYNC programStarted( QString programIcon, QString programName, QString description ) = 0; + virtual ASYNC startupComplete() = 0; + virtual ASYNC close() = 0; + virtual ASYNC hide() = 0; + virtual ASYNC show() = 0; +}; + +#endif diff --git a/ksplashml/main.cpp b/ksplashml/main.cpp new file mode 100644 index 000000000..c1208cc3b --- /dev/null +++ b/ksplashml/main.cpp @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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.) * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <iostream> +#include <stdlib.h> +#include <unistd.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <kdebug.h> +#include <klocale.h> +#include <dcopclient.h> + +#include "wndmain.h" + +static KCmdLineOptions options[] = { + { "managed", I18N_NOOP("Execute KSplash in MANAGED mode"),0 }, + { "test", I18N_NOOP("Run in test mode"), 0 }, + { "nofork", I18N_NOOP("Do not fork into the background"), 0 }, + { "theme <argument>", I18N_NOOP("Override theme"), "" }, + { "nodcop", I18N_NOOP("Do not attempt to start DCOP server"),0 }, + { "steps <number>", I18N_NOOP("Number of steps"), "7" }, + KCmdLineLastOption +}; + +int main( int argc, char **argv ) +{ + KAboutData about( + "ksplash", + I18N_NOOP("KSplash"), + VERSION, + I18N_NOOP("KDE splash screen"), + KAboutData::License_GPL, + I18N_NOOP("(c) 2001 - 2003, Flaming Sword Productions\n (c) 2003 KDE developers"), + "http://www.kde.org"); + about.addAuthor( "Ravikiran Rajagopal", I18N_NOOP("Author and maintainer"), "ravi@ee.eng.ohio-state.edu" ); + about.addAuthor( "Brian Ledbetter", I18N_NOOP("Original author"), "brian@shadowcom.net" ); + + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions(options); + KCmdLineArgs *arg = KCmdLineArgs::parsedArgs(); + + if( arg->isSet( "fork" ) ) + { + if (fork()) + exit(0); + } + + if ( !( arg->isSet( "dcop" ) ) ) + KApplication::disableAutoDcopRegistration(); + else if ( KApplication::dcopClient()->attach() ) + KApplication::dcopClient()->registerAs( "ksplash", false ); + + KApplication app; + + KSplash wndMain("ksplash"); + if ( arg->isSet( "steps" ) ) + { + int steps = QMAX( arg->getOption( "steps" ).toInt(), 0 ); + if ( steps ) + wndMain.setStartupItemCount( steps ); + } + + app.setMainWidget(&wndMain); + app.setTopWidget(&wndMain); + return(app.exec()); +} diff --git a/ksplashml/pics/Makefile.am b/ksplashml/pics/Makefile.am new file mode 100644 index 000000000..5afb4a43f --- /dev/null +++ b/ksplashml/pics/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS=themes +EXTRA_DIST=splash.png + +ksplashml_pics_datadir = $(kde_datadir)/ksplash/pics +ksplashml_pics_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/splash.png b/ksplashml/pics/splash.png Binary files differnew file mode 100644 index 000000000..6608881c9 --- /dev/null +++ b/ksplashml/pics/splash.png diff --git a/ksplashml/pics/themes/Makefile.am b/ksplashml/pics/themes/Makefile.am new file mode 100644 index 000000000..84e5124fc --- /dev/null +++ b/ksplashml/pics/themes/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS=$(AUTODIRS) + diff --git a/ksplashml/pics/themes/blue-bend/Makefile.am b/ksplashml/pics/themes/blue-bend/Makefile.am new file mode 100644 index 000000000..4f2063eab --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Theme.rc Preview.png splash_active_bar.png splash_bottom.png splash_inactive_bar.png splash_top.png + +ksplashml_pics_default_datadir = $(kde_datadir)/ksplash/Themes/blue-bend +ksplashml_pics_default_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/themes/blue-bend/Preview.png b/ksplashml/pics/themes/blue-bend/Preview.png Binary files differnew file mode 100644 index 000000000..5f4b4e884 --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/Preview.png diff --git a/ksplashml/pics/themes/blue-bend/Theme.rc b/ksplashml/pics/themes/blue-bend/Theme.rc new file mode 100644 index 000000000..c329290ce --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/Theme.rc @@ -0,0 +1,23 @@ +# +# Blue-Bend KSplash/ML Theme +# + +[KSplash Theme: blue-bend] +Name = Blue-Bend KDE Splash Theme +Description = Load Blue-Bend KDE KSplash theme. +Version = 1.0 +Author = Everaldo Coelho <everaldo@everaldo.com> +Homepage = http://www.everaldo.com + +# Theme behavior settings. +Engine = Default + +# Should icons blink ala KDE, or not? +Icons Flashing = true + +# Configurable Messages. You may specify messages in as many +# languages as you prefer. Messages may be copied verbatim from +# this file, if you wish to maintain the default settings. +#Message1 = Please wait, starting KDE... +#Message1[es] = Por favor escuchar, estarto KDE... +#Message2 = Loading ... diff --git a/ksplashml/pics/themes/blue-bend/splash_active_bar.png b/ksplashml/pics/themes/blue-bend/splash_active_bar.png Binary files differnew file mode 100644 index 000000000..ce549be5d --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/splash_active_bar.png diff --git a/ksplashml/pics/themes/blue-bend/splash_bottom.png b/ksplashml/pics/themes/blue-bend/splash_bottom.png Binary files differnew file mode 100644 index 000000000..070097af1 --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/splash_bottom.png diff --git a/ksplashml/pics/themes/blue-bend/splash_inactive_bar.png b/ksplashml/pics/themes/blue-bend/splash_inactive_bar.png Binary files differnew file mode 100644 index 000000000..6eea21b22 --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/splash_inactive_bar.png diff --git a/ksplashml/pics/themes/blue-bend/splash_top.png b/ksplashml/pics/themes/blue-bend/splash_top.png Binary files differnew file mode 100644 index 000000000..8cde6855f --- /dev/null +++ b/ksplashml/pics/themes/blue-bend/splash_top.png diff --git a/ksplashml/pics/themes/default/Makefile.am b/ksplashml/pics/themes/default/Makefile.am new file mode 100644 index 000000000..263854f11 --- /dev/null +++ b/ksplashml/pics/themes/default/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS=locolor +EXTRA_DIST=Theme.rc Preview.png splash_active_bar.png splash_bottom.png splash_inactive_bar.png splash_top.png + +ksplashml_pics_default_datadir = $(kde_datadir)/ksplash/Themes/Default +ksplashml_pics_default_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/themes/default/Preview.png b/ksplashml/pics/themes/default/Preview.png Binary files differnew file mode 100644 index 000000000..4b589d71d --- /dev/null +++ b/ksplashml/pics/themes/default/Preview.png diff --git a/ksplashml/pics/themes/default/Theme.rc b/ksplashml/pics/themes/default/Theme.rc new file mode 100644 index 000000000..75cfed06f --- /dev/null +++ b/ksplashml/pics/themes/default/Theme.rc @@ -0,0 +1,19 @@ +# Default KSplash/ML Theme + +[KSplash Theme: default] +Name = KDE 3.5 Splash Screen +Description = Waves of change +Version = 1.0 +Author = Lee Olson <clearbeast@gmail.com> + +# Theme behaviour settings. +Engine = Default + +# Should icons blink ala KDE, or not? +Icons Flashing = true + +# Show progress bar? +Always Show Progress = false + +# Status text colour +Label Foreground = #FFFFFF diff --git a/ksplashml/pics/themes/default/locolor/Makefile.am b/ksplashml/pics/themes/default/locolor/Makefile.am new file mode 100644 index 000000000..9617b1ea5 --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Theme.rc splash_active_bar.png splash_bottom.png splash_inactive_bar.png splash_top.png + +ksplashml_pics_classic_locolor_datadir = $(kde_datadir)/ksplash/Themes/Default/locolor +ksplashml_pics_classic_locolor_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/themes/default/locolor/Preview.png b/ksplashml/pics/themes/default/locolor/Preview.png Binary files differnew file mode 100644 index 000000000..fa45b2319 --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/Preview.png diff --git a/ksplashml/pics/themes/default/locolor/Theme.rc b/ksplashml/pics/themes/default/locolor/Theme.rc new file mode 100644 index 000000000..75cfed06f --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/Theme.rc @@ -0,0 +1,19 @@ +# Default KSplash/ML Theme + +[KSplash Theme: default] +Name = KDE 3.5 Splash Screen +Description = Waves of change +Version = 1.0 +Author = Lee Olson <clearbeast@gmail.com> + +# Theme behaviour settings. +Engine = Default + +# Should icons blink ala KDE, or not? +Icons Flashing = true + +# Show progress bar? +Always Show Progress = false + +# Status text colour +Label Foreground = #FFFFFF diff --git a/ksplashml/pics/themes/default/locolor/splash_active_bar.png b/ksplashml/pics/themes/default/locolor/splash_active_bar.png Binary files differnew file mode 100644 index 000000000..bb4346b60 --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/splash_active_bar.png diff --git a/ksplashml/pics/themes/default/locolor/splash_bottom.png b/ksplashml/pics/themes/default/locolor/splash_bottom.png Binary files differnew file mode 100644 index 000000000..26c99f3af --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/splash_bottom.png diff --git a/ksplashml/pics/themes/default/locolor/splash_inactive_bar.png b/ksplashml/pics/themes/default/locolor/splash_inactive_bar.png Binary files differnew file mode 100644 index 000000000..4787900ce --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/splash_inactive_bar.png diff --git a/ksplashml/pics/themes/default/locolor/splash_top.png b/ksplashml/pics/themes/default/locolor/splash_top.png Binary files differnew file mode 100644 index 000000000..6e09167a3 --- /dev/null +++ b/ksplashml/pics/themes/default/locolor/splash_top.png diff --git a/ksplashml/pics/themes/default/splash.xcf.bz2 b/ksplashml/pics/themes/default/splash.xcf.bz2 Binary files differnew file mode 100644 index 000000000..329ec1416 --- /dev/null +++ b/ksplashml/pics/themes/default/splash.xcf.bz2 diff --git a/ksplashml/pics/themes/default/splash_active_bar.png b/ksplashml/pics/themes/default/splash_active_bar.png Binary files differnew file mode 100644 index 000000000..be3fa94e2 --- /dev/null +++ b/ksplashml/pics/themes/default/splash_active_bar.png diff --git a/ksplashml/pics/themes/default/splash_bottom.png b/ksplashml/pics/themes/default/splash_bottom.png Binary files differnew file mode 100644 index 000000000..ef5e14a58 --- /dev/null +++ b/ksplashml/pics/themes/default/splash_bottom.png diff --git a/ksplashml/pics/themes/default/splash_inactive_bar.png b/ksplashml/pics/themes/default/splash_inactive_bar.png Binary files differnew file mode 100644 index 000000000..0cfa31e4a --- /dev/null +++ b/ksplashml/pics/themes/default/splash_inactive_bar.png diff --git a/ksplashml/pics/themes/default/splash_top.png b/ksplashml/pics/themes/default/splash_top.png Binary files differnew file mode 100644 index 000000000..0db66470b --- /dev/null +++ b/ksplashml/pics/themes/default/splash_top.png diff --git a/ksplashml/pics/themes/none/Makefile.am b/ksplashml/pics/themes/none/Makefile.am new file mode 100644 index 000000000..2f439900f --- /dev/null +++ b/ksplashml/pics/themes/none/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Theme.rc + +ksplashml_pics_default_datadir = $(kde_datadir)/ksplash/Themes/None +ksplashml_pics_default_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/themes/none/Theme.rc b/ksplashml/pics/themes/none/Theme.rc new file mode 100644 index 000000000..75ef28336 --- /dev/null +++ b/ksplashml/pics/themes/none/Theme.rc @@ -0,0 +1,6 @@ +# Default KSplash/ML Theme + +[KSplash Theme: None] +Name = No Splash Screen +Description = Splash Screen Turned Off +Version = 1.0 diff --git a/ksplashml/pics/themes/simple/Makefile.am b/ksplashml/pics/themes/simple/Makefile.am new file mode 100644 index 000000000..cafb7cc83 --- /dev/null +++ b/ksplashml/pics/themes/simple/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Theme.rc Preview.png + +ksplashml_pics_default_datadir = $(kde_datadir)/ksplash/Themes/Simple +ksplashml_pics_default_data_DATA = $(EXTRA_DIST) diff --git a/ksplashml/pics/themes/simple/Preview.png b/ksplashml/pics/themes/simple/Preview.png Binary files differnew file mode 100644 index 000000000..2e9b39236 --- /dev/null +++ b/ksplashml/pics/themes/simple/Preview.png diff --git a/ksplashml/pics/themes/simple/Theme.rc b/ksplashml/pics/themes/simple/Theme.rc new file mode 100644 index 000000000..45b685986 --- /dev/null +++ b/ksplashml/pics/themes/simple/Theme.rc @@ -0,0 +1,7 @@ +# Default KSplash/ML Theme + +[KSplash Theme: Simple] +Name = Simple Splash Screen +Description = Very Simple Optimized Splash Screen +Version = 1.0 +Author = Lubos Lunak <l.lunak@kde.org> diff --git a/ksplashml/themeengine/Makefile.am b/ksplashml/themeengine/Makefile.am new file mode 100644 index 000000000..411825cc9 --- /dev/null +++ b/ksplashml/themeengine/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = . default standard redmond simple + +INCLUDES = -I$(srcdir)/.. $(all_includes) + +lib_LTLIBRARIES = libksplashthemes.la + +libksplashthemes_la_SOURCES = themeengine.cpp objkstheme.cpp +libksplashthemes_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined +libksplashthemes_la_LIBADD = $(LIB_KDEUI) $(LIB_XCURSOR) +METASOURCES = AUTO + +# install this header for theme developers. +pkgincludedir = $(includedir)/ksplash +pkginclude_HEADERS=themeengine.h objkstheme.h + +servicetypesdir = $(kde_servicetypesdir) +servicetypes_DATA = ksplashplugins.desktop + diff --git a/ksplashml/themeengine/default/Makefile.am b/ksplashml/themeengine/default/Makefile.am new file mode 100644 index 000000000..e3f522751 --- /dev/null +++ b/ksplashml/themeengine/default/Makefile.am @@ -0,0 +1,17 @@ + +INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../.. $(all_includes) + +noinst_LTLIBRARIES = libthemedefault.la +libthemedefault_la_SOURCES = themelegacy.cpp +libthemedefault_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) +libthemedefault_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la + +kde_module_LTLIBRARIES = ksplashdefault.la + +ksplashdefault_la_SOURCES = main.cpp +ksplashdefault_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(KDE_PLUGIN) -module +ksplashdefault_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la libthemedefault.la +METASOURCES = AUTO + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashdefault.desktop diff --git a/ksplashml/themeengine/default/ksplashdefault.desktop b/ksplashml/themeengine/default/ksplashdefault.desktop new file mode 100644 index 000000000..66244d5d4 --- /dev/null +++ b/ksplashml/themeengine/default/ksplashdefault.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +Comment=KSplash Plugin +Comment[af]=KSplash Inprop module +Comment[ar]=ملحق للشاشة الافتتاحية +Comment[az]=KSplash Əlavəsi +Comment[be]=Утулка KSplash +Comment[bg]=Приставка KSplash +Comment[bn]=কে-স্প্ল্যাশ প্লাগ-ইন +Comment[br]=Lugent KSplash +Comment[bs]=KSplash dodatak +Comment[ca]=Connector per a KSplash +Comment[cs]=Modul aplikaci KSplash +Comment[csb]=Plugins KSplash +Comment[cy]=Ategyn KCroeso +Comment[da]=KSplash-plugin +Comment[de]=KSplash-Plugin +Comment[el]=Πρόσθετο KSplash +Comment[eo]=Ksalutŝilda kromaĵo +Comment[es]=Complemento KSplash +Comment[et]=KSplashi plugin +Comment[eu]=KSplash plugina +Comment[fa]=وصلۀ KSplash +Comment[fi]=KSplash-liitännäinen +Comment[fr]=Modules de KSplash +Comment[fy]=KSplash-plugin +Comment[ga]=Breiseán KSplash +Comment[gl]=Plugin de KSplash +Comment[he]=תוסף KSplash +Comment[hi]=के-स्प्लैश प्लगइन +Comment[hr]=KSplash dodatak +Comment[hu]=KSplash bővítőmodul +Comment[is]=KSplash íforrit +Comment[it]=Plugin KSplash +Comment[ja]=KSplash プラグイン +Comment[ka]=KSplash პლაგინი +Comment[kk]=KSplash модулі +Comment[km]=កម្មវិធីជំនួយខាងក្នុងរបស់ KSplash +Comment[lt]=KSplash įskiepis +Comment[lv]=KSplash spraudnis +Comment[mk]=Приклучок за KSplash +Comment[ms]=Plugin KSplash +Comment[mt]=Plugin ta' KSplash +Comment[nb]=Programtillegg Ksplash +Comment[ne]=के स्प्लयास प्लगइन +Comment[nl]=KSplash-plugin +Comment[nn]=KSplash-programtillegg +Comment[pa]=ਕੇ-ਸਪਲੇਸ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka KSplash +Comment[pt]='Plugin' do KSplash +Comment[pt_BR]=Plug-in do KSplash +Comment[ro]=Modul KSplash +Comment[ru]=Модуль KSplash +Comment[rw]=Icomeka rya K-Gukwiza +Comment[se]=KSplash-lassemoduvla +Comment[sk]=Modul KSplash +Comment[sl]=Vstavek KSplash +Comment[sr]=KSplash прикључак +Comment[sr@Latn]=KSplash priključak +Comment[sv]=Insticksprogram för startskärm +Comment[ta]=Kஸ்ப்ளாஷ் செருகு பொருள் +Comment[tg]=Мутассалкунандаи KSplash +Comment[th]=ปลั๊กอิน KSplash +Comment[tr]=KSplash Eklentisi +Comment[tt]=KSplash atlı Östämä +Comment[uk]=Втулок KSplash +Comment[uz]=KSplash plagini +Comment[uz@cyrillic]=KSplash плагини +Comment[vi]=Trình bổ sung Chào mừng KDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashLegacy +Name[af]=KSplash Verouders +Name[be]=Старая тэма +Name[ca]=KSplash heretat +Name[cs]=Staré +Name[cy]=KCroesoEtifeddiaeth +Name[de]=KSplash mit älterem Programm +Name[eo]=Ksalutŝildotestamento +Name[et]=KSplahs Legacy +Name[hi]=के-स्प्लैश-लीजेसी +Name[it]=KSplashVecchio +Name[ne]=के स्प्लयास अवस्था +Name[pa]=ਕੇਸਪਲੇਸਲੀਜੈਂਸੀ +Name[pt_BR]=Herança do KSplash +Name[rw]=K-GukwizaUmurage +Name[sv]=Klassisk startskärm +Name[ta]=Kஸ்ப்ளாஷ் Legacy +Name[tg]=МеросиKSplash +Name[vi]=Chào mừng KDE Gia tài +Name[wa]=KSplashTayons +ServiceTypes=KSplash/Plugin +X-KDE-Library=ksplashdefault +X-KSplash-Default=true +X-KSplash-PluginName=Default +X-KSplash-ObjectName=ThemeLegacy diff --git a/ksplashml/themeengine/default/main.cpp b/ksplashml/themeengine/default/main.cpp new file mode 100644 index 000000000..e1382dd37 --- /dev/null +++ b/ksplashml/themeengine/default/main.cpp @@ -0,0 +1,17 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 <kgenericfactory.h> + +#include "themelegacy.h" + +K_EXPORT_COMPONENT_FACTORY( ksplashdefault, KGenericFactory<ThemeDefault>( "ksplash" ) ) diff --git a/ksplashml/themeengine/default/themelegacy.cpp b/ksplashml/themeengine/default/themelegacy.cpp new file mode 100644 index 000000000..35d47241b --- /dev/null +++ b/ksplashml/themeengine/default/themelegacy.cpp @@ -0,0 +1,310 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <kglobalsettings.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kprogress.h> + +#include <qcheckbox.h> +#include <qdesktopwidget.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qpixmap.h> +#include <qwidget.h> +#include <qtimer.h> + +#include "objkstheme.h" +#include "themeengine.h" +#include "themelegacy.h" +#include "themelegacy.moc" + +DefaultConfig::DefaultConfig( QWidget *parent, KConfig *config ) + :ThemeEngineConfig( parent, config ) +{ + mConfig->setGroup( QString("KSplash Theme: Default") ); + QVBox *hbox = new QVBox( this ); + mFlash = new QCheckBox( i18n("Icons flash while they are starting"), hbox ); + mFlash->setChecked( mConfig->readBoolEntry("Icons Flashing",true) ); + mAlwaysShow = new QCheckBox( i18n("Always show progress bar"), hbox ); + mAlwaysShow->setChecked( mConfig->readBoolEntry("Always Show Progress",true) ); +} + +void DefaultConfig::save() +{ + kdDebug() << "DefaultConfig::save()" << endl; + mConfig->setGroup( QString("KSplash Theme: Default") ); + mConfig->writeEntry( "Icons Flashing", mFlash->isChecked() ); + mConfig->writeEntry( "Always Show Progress", mAlwaysShow->isChecked() ); + mConfig->sync(); +} + +#define BIDI 0 + +ThemeDefault::ThemeDefault( QWidget *parent, const char *name, const QStringList &args ) + :ThemeEngine( parent, name, args ) +{ + + mActivePixmap = mInactivePixmap = 0L; + mState = 0; + + _readSettings(); + _initUi(); + + if( mIconsFlashing ) + { + mFlashTimer = new QTimer( this ); + connect( mFlashTimer, SIGNAL(timeout()), this, SLOT(flash()) ); + mFlashPixmap1 = new QPixmap(); + mFlashPixmap2 = new QPixmap(); + + } + else + { + mFlashTimer = 0L; + mFlashPixmap1 = 0L; + mFlashPixmap2 = 0L; + } +} + +ThemeDefault::~ThemeDefault() +{ + delete mFlashPixmap1; + delete mFlashPixmap2; +} + +void ThemeDefault::_initUi() +{ + QString resource_prefix; + + QVBox *vbox = new QVBox( this ); + vbox->setBackgroundMode(NoBackground); + + + QString activePix, inactivePix; +#if BIDI + if ( QApplication::reverseLayout() ) + { + activePix = _findPicture(QString("splash_active_bar_bidi.png")); + inactivePix = _findPicture(QString("splash_inactive_bar_bidi.png")); + } + else +#endif + { + activePix = _findPicture(QString("splash_active_bar.png")); + inactivePix = _findPicture(QString("splash_inactive_bar.png")); + } + kdDebug() << "Inactive pixmap: " << inactivePix << endl; + kdDebug() << "Active pixmap: " << activePix << endl; + + mActivePixmap = new QPixmap( activePix ); + mInactivePixmap = new QPixmap( inactivePix ); + + if (mActivePixmap->isNull()) + { + mActivePixmap->resize(200,100); + mActivePixmap->fill(Qt::blue); + } + if (mInactivePixmap->isNull()) + { + mInactivePixmap->resize(200,100); + mInactivePixmap->fill(Qt::black); + } + + QPixmap tlimage( _findPicture(QString("splash_top.png")) ); + if (tlimage.isNull()) + { + tlimage.resize(200,100); + tlimage.fill(Qt::blue); + } + QLabel *top_label = new QLabel( vbox ); + top_label->setPixmap( tlimage ); + top_label->setFixedSize( tlimage.width(), tlimage.height() ); + top_label->setBackgroundMode(NoBackground); + + mBarLabel = new QLabel( vbox ); + mBarLabel->setPixmap(*mInactivePixmap); + mBarLabel->setBackgroundMode(NoBackground); + + QPixmap blimage( _findPicture(QString("splash_bottom.png")) ); + if (blimage.isNull()) + { + blimage.resize(200,100); + blimage.fill(Qt::black); + } + QLabel *bottom_label = new QLabel( vbox ); + bottom_label->setPaletteBackgroundPixmap( blimage ); + + + mLabel = new QLabel( bottom_label ); + mLabel->setBackgroundOrigin( QWidget::ParentOrigin ); + mLabel->setPaletteForegroundColor( mLabelForeground ); + mLabel->setPaletteBackgroundPixmap( blimage ); + QFont f(mLabel->font()); + f.setBold(TRUE); + mLabel->setFont(f); + + mProgressBar = new KProgress( mLabel ); + int h, s, v; + mLabelForeground.getHsv( &h, &s, &v ); + mProgressBar->setPalette( QPalette( v > 128 ? black : white )); + mProgressBar->setBackgroundOrigin( QWidget::ParentOrigin ); + mProgressBar->setPaletteBackgroundPixmap( blimage ); + + bottom_label->setFixedWidth( QMAX(blimage.width(),tlimage.width()) ); + bottom_label->setFixedHeight( mLabel->sizeHint().height()+4 ); + + // 3 pixels of whitespace between the label and the progressbar. + mLabel->resize( bottom_label->width(), bottom_label->height() ); + + mProgressBar->setFixedSize( 120, mLabel->height() ); + + if (QApplication::reverseLayout()){ + mProgressBar->move( 2, 0 ); +// mLabel->move( mProgressBar->width() + 4, 0); + } + else{ + mProgressBar->move( bottom_label->width() - mProgressBar->width() - 4, 0); + mLabel->move( 2, 0 ); + } + + mProgressBar->hide(); + + setFixedWidth( mInactivePixmap->width() ); + setFixedHeight( mInactivePixmap->height() + + top_label->height() + bottom_label->height() ); + + const QRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + // kdDebug() << "ThemeDefault::_initUi" << rect << endl; + + move( rect.x() + (rect.width() - size().width())/2, + rect.y() + (rect.height() - size().height())/2 ); +} + +// Attempt to find overrides elsewhere? +void ThemeDefault::_readSettings() +{ + if( !mTheme ) + return; + + KConfig *cfg = mTheme->themeConfig(); + if( !cfg ) + return; + + cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ); + + mIconsFlashing = cfg->readBoolEntry( "Icons Flashing", true ); + QColor df(Qt::white); + mLabelForeground = cfg->readColorEntry( "Label Foreground", &df ); +} + +/* + * ThemeDefault::slotUpdateState(): IF in Default mode, THEN adjust the bar + * pixmap label. Whee, phun! + * + * A similar method exists in the old KSplash. + */ +void ThemeDefault::slotUpdateState() +{ + if( mState > 8 ) + mState = 8; + + if( mIconsFlashing ) + { + + *mFlashPixmap1 = updateBarPixmap( mState ); + *mFlashPixmap2 = updateBarPixmap( mState+1 ); + mBarLabel->setPixmap(*mFlashPixmap2); + mFlashTimer->stop(); + + if( mState < 8 ) + mFlashTimer->start(400); + } + else + mBarLabel->setPixmap( updateBarPixmap( mState ) ); + + mState++; +} + +/* + * ThemeDefault::updateBarPixmap(): IF in Default mode, THEN adjust the + * bar pixmap to reflect the current state. WARNING! KSplash Default + * does NOT support our "Restoring Session..." state. We will need + * to reflect that somehow. + */ +QPixmap ThemeDefault::updateBarPixmap( int state ) +{ + int offs; + + QPixmap x; + if( !mActivePixmap ) return( x ); +#if BIDI + + + if( QApplication::reverseLayout() ) + { + if ( state > 7 ) + return ( x ); + } +#endif + + offs = state * 58; + if (state == 3) + offs += 8; + else if (state == 6) + offs -= 8; + + QPixmap tmp(*mActivePixmap); + QPainter p(&tmp); +#if BIDI + if ( QApplication::reverseLayout() ) + p.drawPixmap(0, 0, *mInactivePixmap, 0, 0, tmp.width()-offs ); + else +#endif + p.drawPixmap(offs, 0, *mInactivePixmap, offs, 0); + return tmp ; +} + +void ThemeDefault::flash() +{ + if( !mIconsFlashing ) + return; + QPixmap *swap = mFlashPixmap1; + mFlashPixmap1 = mFlashPixmap2; + mFlashPixmap2 = swap; + mBarLabel->setPixmap(*mFlashPixmap2); +} + +QString ThemeDefault::_findPicture( const QString &pic ) +{ + // Don't use ObjKsTheme::locateThemeData here for compatibility reasons. + QString f = pic; + if (mTheme->loColor()) + f = QString("locolor/")+f; + //kdDebug() << "Searching for " << f << endl; + //kdDebug() << "Theme directory: " << mTheme->themeDir() << endl; + //kdDebug() << "Theme name: " << mTheme->theme() << endl; + QString p = QString::null; + if ((p = locate("appdata",mTheme->themeDir()+f)).isEmpty()) + if ((p = locate("appdata",mTheme->themeDir()+"pics/"+f)).isEmpty()) + if ((p = locate("appdata", QString("pics/")+mTheme->theme()+"/"+f)).isEmpty()) + if ((p = locate("appdata",f)).isEmpty()) + if ((p = locate("appdata",QString("pics/")+f)).isEmpty()) + if ((p = locate("data",QString("pics/")+f)).isEmpty()) { + ; // No more places to search + } + return p; +} diff --git a/ksplashml/themeengine/default/themelegacy.h b/ksplashml/themeengine/default/themelegacy.h new file mode 100644 index 000000000..b0a6138a9 --- /dev/null +++ b/ksplashml/themeengine/default/themelegacy.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 __THEMELEGACY_H__ +#define __THEMELEGACY_H__ + +#include <kprogress.h> + +#include <qlabel.h> +#include <qwidget.h> + +#include "themeengine.h" +class QPixmap; +class QTimer; + +class QCheckBox; + +class DefaultConfig: public ThemeEngineConfig +{ + Q_OBJECT +public: + DefaultConfig( QWidget *, KConfig * ); + void save(); +protected: + QCheckBox *mFlash, *mAlwaysShow; +}; + +/** + * @short Traditional KDE splash screen. + */ +class ObjKsTheme; +class KDE_EXPORT ThemeDefault : public ThemeEngine +{ + Q_OBJECT +public: + ThemeDefault( QWidget *, const char *, const QStringList& ); + virtual ~ThemeDefault(); + + inline const DefaultConfig *config( QWidget *p, KConfig *c ) + { + return new DefaultConfig( p, c ); + }; + + static QStringList names() + { + QStringList Names; + Names << "Default"; + Names << "Classic"; + Names << "Klassic"; + return( Names ); + } + +public slots: + inline void slotSetText( const QString& s ) + { + if( mLabel ) + mLabel->setText( s ); + slotUpdateState(); + }; + inline void slotUpdateSteps( int s ) + { + mProgressBar->show(); + mProgressBar->setTotalSteps( s ); + } + inline void slotUpdateProgress( int i ) + { + mProgressBar->setProgress( i ); + } + + +private slots: + void slotUpdateState(); + QPixmap updateBarPixmap( int ); + void flash(); + +private: + void _initUi(); + void _readSettings(); + QString _findPicture( const QString &pic ); + + // Configurable Options + bool mIconsFlashing; + QColor mLabelForeground; + + // Internals. + KProgress *mProgressBar; + QLabel *mLabel, *mBarLabel; + QPixmap *mActivePixmap, *mInactivePixmap; + int mState; + QTimer *mFlashTimer; + QPixmap *mFlashPixmap1, *mFlashPixmap2; +}; + +#endif diff --git a/ksplashml/themeengine/ksplashplugins.desktop b/ksplashml/themeengine/ksplashplugins.desktop new file mode 100644 index 000000000..3ebbfcdcd --- /dev/null +++ b/ksplashml/themeengine/ksplashplugins.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=ServiceType +X-KDE-ServiceType=KSplash/Plugin + +[PropertyDef::X-KSplash-PluginName] +Type=QString + +[PropertyDef::X-KSplash-ObjectName] +Type=QString + +[PropertyDef::X-KSplash-Default] +Type=bool diff --git a/ksplashml/themeengine/objkstheme.cpp b/ksplashml/themeengine/objkstheme.cpp new file mode 100644 index 000000000..955b5f903 --- /dev/null +++ b/ksplashml/themeengine/objkstheme.cpp @@ -0,0 +1,168 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 <kapplication.h> +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kglobal.h> +#include <klocale.h> +#include <kstandarddirs.h> + +#include <qcolor.h> +#include <qcursor.h> +#include <qdesktopwidget.h> +#include <qfont.h> +#include <qpixmap.h> +#include <qrect.h> +#include <qstring.h> + +#include "objkstheme.h" +#include "objkstheme.moc" + +ObjKsTheme::ObjKsTheme( const QString& theme ) + :mActiveTheme (theme), mThemeDir("/"), mThemeConfig (0L), mThemePrefix( "Themes/" ), d(0) +{ + // Get Xinerama config. + KConfig *config = kapp->config(); + config->setGroup( "Xinerama" ); + QDesktopWidget *desktop = kapp->desktop(); + mXineramaScreen = config->readNumEntry("KSplashScreen", desktop->primaryScreen()); + + // For Xinerama, let's put the mouse on the first head. Otherwise it could appear anywhere! + if (desktop->isVirtualDesktop() && mXineramaScreen != -2) + { + QRect rect = desktop->screenGeometry( mXineramaScreen ); + if (!rect.contains(QCursor::pos())) + QCursor::setPos(rect.center()); + } + + // Does the active theme exist? + if( !loadThemeRc( mActiveTheme, false ) ) + if( !loadLocalConfig( mActiveTheme, false ) ) + if( !loadThemeRc( "Default", false ) ) + loadLocalConfig( "Default", true ); //force: we need some defaults + loadCmdLineArgs(KCmdLineArgs::parsedArgs()); + mThemePrefix += ( mActiveTheme + "/" ); +} + +ObjKsTheme::~ObjKsTheme() +{ +} + +bool ObjKsTheme::loadThemeRc( const QString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadThemeRc: " << activeTheme << endl; + QString prefix("Themes/"); + QString themeFile; + KConfig *cf = 0L; + + // Try our best to find a theme file. + themeFile = locate( "appdata", prefix + activeTheme + "/" + QString("Theme.rc") ); + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+QString("Theme.RC")):themeFile; + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+QString("theme.rc")):themeFile; + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+activeTheme+QString(".rc")):themeFile; + + if( !themeFile.isEmpty() ) + cf = new KConfig( themeFile ); + + if( cf ) + { + mActiveTheme = activeTheme; + mThemeDir = prefix + activeTheme+"/"; + if( loadKConfig( cf, activeTheme, force ) ) + { + mThemeConfig = cf; + return true; + } + else + delete cf; + } + return false; +} + +bool ObjKsTheme::loadLocalConfig( const QString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadLocalConfig" << endl; + KConfig *cfg = kapp->config(); + return( loadKConfig( cfg, activeTheme, force ) ); +} + +// ObjKsConfig::loadKConfig(): Load our settings from a KConfig object. +bool ObjKsTheme::loadKConfig( KConfig *cfg, const QString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadKConfig" << endl; + if( !cfg ) + return false; + + // Themes are always stored in the group [KSplash Theme: ThemeName], + // and ThemeName should always be the same name as the themedir, if any. + // If we can't find this theme group, then we can't load. + if( !cfg->hasGroup( QString("KSplash Theme: %1").arg(activeTheme) ) && !force ) + return false; + + cfg->setGroup( QString("KSplash Theme: %1").arg(activeTheme) ); + mThemeConfig = cfg; + + mThemeEngine = cfg->readEntry( "Engine", "Default" ); + + m_icons.clear(); + m_icons.append( cfg->readEntry( "Icon1", "filetypes" ) ); + m_icons.append( cfg->readEntry( "Icon2", "exec" ) ); + m_icons.append( cfg->readEntry( "Icon3", "key_bindings" ) ); + m_icons.append( cfg->readEntry( "Icon4", "window_list" ) ); + m_icons.append( cfg->readEntry( "Icon5", "desktop" ) ); + m_icons.append( cfg->readEntry( "Icon6", "style" ) ); + m_icons.append( cfg->readEntry( "Icon7", "kcmsystem" ) ); + m_icons.append( cfg->readEntry( "Icon8", "go" ) ); + + m_text.clear(); + m_text.append( cfg->readEntry( "Message1", i18n("Setting up interprocess communication") ) ); + m_text.append( cfg->readEntry( "Message2", i18n("Initializing system services") ) ); + m_text.append( cfg->readEntry( "Message3", i18n("Initializing peripherals") ) ); + m_text.append( cfg->readEntry( "Message4", i18n("Loading the window manager") ) ); + m_text.append( cfg->readEntry( "Message5", i18n("Loading the desktop") ) ); + m_text.append( cfg->readEntry( "Message6", i18n("Loading the panel") ) ); + m_text.append( cfg->readEntry( "Message7", i18n("Restoring session") ) ); + m_text.append( cfg->readEntry( "Message8", i18n("KDE is up and running") ) ); + + return true; +} + +/* + * ObjKsTheme::loadCmdLineArgs(): Handle any overrides which the user might have + * specified. + */ +void ObjKsTheme::loadCmdLineArgs( KCmdLineArgs *args ) +{ + + mManagedMode = args->isSet( "managed" ); + mTesting = args->isSet("test"); + mLoColor = ( QPixmap::defaultDepth() <= 8 ); + QString theme = args->getOption( "theme" ); + if( theme != mActiveTheme && !theme.isNull() ) + if( loadThemeRc( theme, false ) ) + mActiveTheme = theme; + //args->clear(); +} + +QString ObjKsTheme::locateThemeData( const QString &resource ) +{ + if ( !mLoColor ) + return locate( "appdata", mThemePrefix+resource ); + else + { + QString res = locate( "appdata", mThemePrefix+"locolor/"+resource ); + if ( res.isEmpty() ) + res = locate( "appdata", mThemePrefix+resource ); + return res; + } +} diff --git a/ksplashml/themeengine/objkstheme.h b/ksplashml/themeengine/objkstheme.h new file mode 100644 index 000000000..9685d4529 --- /dev/null +++ b/ksplashml/themeengine/objkstheme.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 __OBJKSTHEME_H__ +#define __OBJKSTHEME_H__ + +#include <kcmdlineargs.h> + +#include <qstring.h> +#include <qstringlist.h> + +class KConfig; +/** + * @short Theme reader. + * A Theme is read in from the file + * <KDEDIR>/share/apps/ksplash/Themes/<theme>/Theme.rc + * This controls the behavior, graphics, and appearance + * of KSplash completely, and offers a friendlier way + * of installing custom splash screens. + */ +class KDE_EXPORT ObjKsTheme : public QObject +{ + Q_OBJECT +public: + explicit ObjKsTheme( const QString& ); + virtual ~ObjKsTheme(); + + void loadCmdLineArgs( KCmdLineArgs * ); + + QString theme() const { return( mActiveTheme ); } + QString themeEngine() const { return( mThemeEngine ); } + KConfig *themeConfig() const { return( mThemeConfig ); } + QString themeDir() const { return( mThemeDir ); } + bool loColor() const { return( mLoColor ); } + bool testing() const { return( mTesting ); } + bool managedMode() const { return( mManagedMode ); } + QString icon( int i ) { return (m_icons[i-1].isNull()?(QString::null):m_icons[i-1]); } + QString text( int i ) { return (m_text[i-1].isNull()?(QString::null):m_text[i-1]); } + QString locateThemeData( const QString &resource ); + int xineramaScreen() const { return mXineramaScreen; } + +protected: + bool loadThemeRc( const QString&, bool ); + bool loadLocalConfig( const QString&, bool ); + bool loadKConfig( KConfig *, const QString&, bool ); + +private: + QString mActiveTheme, mThemeDir; + KConfig *mThemeConfig; + + int mXineramaScreen; + bool mLoColor, mTesting, mManagedMode; + QString mThemeEngine; + QString mThemePrefix; + + QStringList m_icons, m_text; + + class ObjKsThemePrivate; + ObjKsThemePrivate *d; +}; + +#endif diff --git a/ksplashml/themeengine/redmond/Makefile.am b/ksplashml/themeengine/redmond/Makefile.am new file mode 100644 index 000000000..70f8cfb1c --- /dev/null +++ b/ksplashml/themeengine/redmond/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = pics + +INCLUDES = -I$(top_srcdir)/ksplashml/themeengine $(all_includes) + +ksplashredmond_la_SOURCES = previewredmond.cpp themeredmond.cpp +ksplashredmond_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) +ksplashredmond_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) ../libksplashthemes.la +METASOURCES = AUTO + +kde_module_LTLIBRARIES = ksplashredmond.la + +noinst_HEADERS = themeredmond.h previewredmond.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashredmond.desktop + +themedir = $(kde_datadir)/ksplash/Themes/Redmond +theme_DATA = Theme.rc diff --git a/ksplashml/themeengine/redmond/Theme.rc b/ksplashml/themeengine/redmond/Theme.rc new file mode 100644 index 000000000..3c5b0687e --- /dev/null +++ b/ksplashml/themeengine/redmond/Theme.rc @@ -0,0 +1,2 @@ +[KSplash Theme: Redmond] +Engine=Redmond diff --git a/ksplashml/themeengine/redmond/ksplashredmond.desktop b/ksplashml/themeengine/redmond/ksplashredmond.desktop new file mode 100644 index 000000000..fd70c5f3a --- /dev/null +++ b/ksplashml/themeengine/redmond/ksplashredmond.desktop @@ -0,0 +1,96 @@ +[Desktop Entry] +Type=Service +Comment=KSplash Plugin +Comment[af]=KSplash Inprop module +Comment[ar]=ملحق للشاشة الافتتاحية +Comment[az]=KSplash Əlavəsi +Comment[be]=Утулка KSplash +Comment[bg]=Приставка KSplash +Comment[bn]=কে-স্প্ল্যাশ প্লাগ-ইন +Comment[br]=Lugent KSplash +Comment[bs]=KSplash dodatak +Comment[ca]=Connector per a KSplash +Comment[cs]=Modul aplikaci KSplash +Comment[csb]=Plugins KSplash +Comment[cy]=Ategyn KCroeso +Comment[da]=KSplash-plugin +Comment[de]=KSplash-Plugin +Comment[el]=Πρόσθετο KSplash +Comment[eo]=Ksalutŝilda kromaĵo +Comment[es]=Complemento KSplash +Comment[et]=KSplashi plugin +Comment[eu]=KSplash plugina +Comment[fa]=وصلۀ KSplash +Comment[fi]=KSplash-liitännäinen +Comment[fr]=Modules de KSplash +Comment[fy]=KSplash-plugin +Comment[ga]=Breiseán KSplash +Comment[gl]=Plugin de KSplash +Comment[he]=תוסף KSplash +Comment[hi]=के-स्प्लैश प्लगइन +Comment[hr]=KSplash dodatak +Comment[hu]=KSplash bővítőmodul +Comment[is]=KSplash íforrit +Comment[it]=Plugin KSplash +Comment[ja]=KSplash プラグイン +Comment[ka]=KSplash პლაგინი +Comment[kk]=KSplash модулі +Comment[km]=កម្មវិធីជំនួយខាងក្នុងរបស់ KSplash +Comment[lt]=KSplash įskiepis +Comment[lv]=KSplash spraudnis +Comment[mk]=Приклучок за KSplash +Comment[ms]=Plugin KSplash +Comment[mt]=Plugin ta' KSplash +Comment[nb]=Programtillegg Ksplash +Comment[ne]=के स्प्लयास प्लगइन +Comment[nl]=KSplash-plugin +Comment[nn]=KSplash-programtillegg +Comment[pa]=ਕੇ-ਸਪਲੇਸ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka KSplash +Comment[pt]='Plugin' do KSplash +Comment[pt_BR]=Plug-in do KSplash +Comment[ro]=Modul KSplash +Comment[ru]=Модуль KSplash +Comment[rw]=Icomeka rya K-Gukwiza +Comment[se]=KSplash-lassemoduvla +Comment[sk]=Modul KSplash +Comment[sl]=Vstavek KSplash +Comment[sr]=KSplash прикључак +Comment[sr@Latn]=KSplash priključak +Comment[sv]=Insticksprogram för startskärm +Comment[ta]=Kஸ்ப்ளாஷ் செருகு பொருள் +Comment[tg]=Мутассалкунандаи KSplash +Comment[th]=ปลั๊กอิน KSplash +Comment[tr]=KSplash Eklentisi +Comment[tt]=KSplash atlı Östämä +Comment[uk]=Втулок KSplash +Comment[uz]=KSplash plagini +Comment[uz@cyrillic]=KSplash плагини +Comment[vi]=Trình bổ sung Chào mừng KDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashRedmond +Name[af]=KSplash Redmond +Name[be]=Тэма Redmond +Name[ca]=KSplash de Redmond +Name[cs]=Redmond +Name[cy]=KCroesoRedmond +Name[de]=KSplash Redmond +Name[eo]=Redmondo +Name[et]=KSplash Redmond +Name[hi]=के-स्प्लैश-रेडमण्ड +Name[ne]=के स्प्लयास रेडमोन्ड +Name[pa]=ਕੇਸਪਲੇਸਰੀਮੋਂਡ +Name[pt_BR]=Tela de Apresentação de Redmond +Name[sv]=Redmond startskärm +Name[ta]=Kஸ்ப்ளாஷ்ரெட்மான் +Name[tg]=РайдмондиKSplash +Name[th]=KSplash แบบเรดมอนด์ +Name[vi]=Chào mừng KDE Redmond +Name[zh_TW]=KSplachRedmond +ServiceTypes=KSplash/Plugin +X-KDE-Library=ksplashredmond +X-KSplash-Default=true +X-KSplash-PluginName=Redmond +X-KSplash-ObjectName=ThemeRedmond diff --git a/ksplashml/themeengine/redmond/main.cpp b/ksplashml/themeengine/redmond/main.cpp new file mode 100644 index 000000000..2da3c5f09 --- /dev/null +++ b/ksplashml/themeengine/redmond/main.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 <kstandarddirs.h> + +#include <qlabel.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include "themeredmond.h" + +extern "C" +{ + ThemeEngineConfig *KsThemeConfig( QWidget *parent, KConfig *config ) + { + return new CfgRedmond( parent, config ); + } + + QStringList KsThemeSupports() + { + return ThemeRedmond::names(); + } + + void* KsThemeInit( QWidget *parent, ObjKsTheme *theme ) + { + return new ThemeRedmond( parent, theme ); + } +} + diff --git a/ksplashml/themeengine/redmond/pics/Background.png b/ksplashml/themeengine/redmond/pics/Background.png Binary files differnew file mode 100644 index 000000000..a38a55d42 --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Background.png diff --git a/ksplashml/themeengine/redmond/pics/Makefile.am b/ksplashml/themeengine/redmond/pics/Makefile.am new file mode 100644 index 000000000..31181e3ae --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Preview.png Background.png + +themedir = $(kde_datadir)/ksplash/Themes/Redmond +theme_DATA = $(EXTRA_DIST) diff --git a/ksplashml/themeengine/redmond/pics/Preview.png b/ksplashml/themeengine/redmond/pics/Preview.png Binary files differnew file mode 100644 index 000000000..a52ec2644 --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Preview.png diff --git a/ksplashml/themeengine/redmond/previewredmond.cpp b/ksplashml/themeengine/redmond/previewredmond.cpp new file mode 100644 index 000000000..6685a6987 --- /dev/null +++ b/ksplashml/themeengine/redmond/previewredmond.cpp @@ -0,0 +1,113 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 <klocale.h> + +#include <qpainter.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include "previewredmond.h" +#include "previewredmond.moc" +/* + * PreviewRedmond::PreviewRedmond(): Constructor. Set up some basic + * things. + */ +PreviewRedmond::PreviewRedmond( QWidget* parent ) + :QWidget( parent ), + + /* Using direct constructors to prevent memory blit. */ + m_welcomeString (i18n("Welcome")), + m_userString (i18n("(Your Name)")), + + m_welcomeFont (QFont( "Arial", 16, QFont::Bold )), + m_userFont (QFont( "Arial", 16 )), + m_statusFont (QFont( "Arial", 12, QFont::Bold )), + + m_welcomeColor (Qt::white), + m_welcomeShadowColor (Qt::darkGray), + m_userColor (Qt::darkGray), + m_statusColor (Qt::white), + + m_icon (DesktopIcon("kmenu")), + + m_showWelcomeString (true), + m_showUserString (true), + m_showUserIcon (true), + m_showStatusString (true) +{ + _updateCache(); +} + +void PreviewRedmond::paintEvent( QPaintEvent* pe ) +{ + QPainter p; + p.begin( this ); + p.drawPixmap( pe->rect(), m_cache ); + p.end(); +} + +void PreviewRedmond::resizeEvent( QResizeEvent *re ) +{ + QWidget::resizeEvent( re ); + _updateCache(); +} + +// PreviewRedmond::_updateCache(): Based on our current settings, we need +// to adjust our cached image. We'll slick it and create a new QPixmap +// from size(), just to be sure we're not missing anything. +void PreviewRedmond::_updateCache() +{ + m_cache = QPixmap( size() ); + QPainter p; + p.begin( &m_cache ); + + p.fillRect( rect(), Qt::gray ); + + m_welcomeFont.setItalic( true ); + p.setFont( m_welcomeFont ); + + QPoint welcomeTextPos( rect().width()/2 - p.fontMetrics().width( m_welcomeString ), + rect().height()/2 + p.fontMetrics().height()/2 ); + + if( m_showWelcomeString ) + { + p.setPen( m_welcomeShadowColor ); + p.drawText( welcomeTextPos.x()+2, welcomeTextPos.y()+2, m_welcomeString ); + p.setPen( m_welcomeColor ); + p.drawText( welcomeTextPos, m_welcomeString ); + } + + if( m_showUserString ) + { + p.setPen( m_userColor ); + p.setFont( m_userFont ); + QPoint userTextPos( rect().width()/2 + m_icon.width() + 20, + rect().height()/2 + p.fontMetrics().height()/2 ); + p.drawText( userTextPos, m_userString ); + } + + if( m_showUserIcon ) + p.drawPixmap( rect().width()/2 + 10, rect().height()/2, m_icon ); + + if( m_showStatusString ) + { + QPoint statusTextPos( rect().width()/2 + m_icon.width() + 20, + rect().height()/2 + (int)(p.fontMetrics().height()*0.85) + 15 ); + p.setPen( m_statusColor ); + p.setFont( m_statusFont ); + p.drawText( statusTextPos, i18n("Starting KDE...") ); + } + + p.end(); + update( rect() ); +} diff --git a/ksplashml/themeengine/redmond/previewredmond.h b/ksplashml/themeengine/redmond/previewredmond.h new file mode 100644 index 000000000..3b67f293b --- /dev/null +++ b/ksplashml/themeengine/redmond/previewredmond.h @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 __PREVIEWREDMOND_H__ +#define __PREVIEWREDMOND_H__ + +#include <kiconloader.h> + +#include <qcolor.h> +#include <qfont.h> +#include <qwidget.h> + +/* + * class PreviewRedmond: Provides a sneak peek at how certain Redmond + * settings will look. This will not be able to render any background + * images, so we'll just use a nice shade of gray or black as the + * background... + */ +class PreviewRedmond: public QWidget +{ + Q_OBJECT +public: + + PreviewRedmond( QWidget* ); + + inline void setWelcomeString( const QString& s ) + { + m_welcomeString = s; + _updateCache(); + } + inline void setUserString( const QString& s ) + { + m_userString = s; + _updateCache(); + } + + inline void setWelcomeFont( const QFont& f ) + { + m_welcomeFont = f; + _updateCache(); + } + inline void setUserFont( const QFont& f ) + { + m_userFont = f; + _updateCache(); + } + inline void setStatusFont( const QFont& f ) + { + m_statusFont = f; + _updateCache(); + } + + inline void setWelcomeColor( const QColor& c ) + { + m_welcomeColor = c; + _updateCache(); + } + inline void setWelcomeShadowColor( const QColor& c ) + { + m_welcomeShadowColor = c; + _updateCache(); + } + inline void setUserColor( const QColor& c ) + { + m_userColor = c; + _updateCache(); + } + inline void setStatusColor( const QColor& c ) + { + m_statusColor = c; + _updateCache(); + } + + inline void setIcon( const QString& s ) + { + m_icon = DesktopIcon( s ); + _updateCache(); + } + +protected: + void _updateCache(); + void paintEvent( QPaintEvent* ); + void resizeEvent( QResizeEvent* ); + + QPixmap m_cache; + + QString m_welcomeString, m_userString; + QFont m_welcomeFont, m_userFont, m_statusFont; + QColor m_welcomeColor, m_welcomeShadowColor, m_userColor, m_statusColor; + QPixmap m_icon; + + bool m_showWelcomeString, m_showUserString, m_showUserIcon, m_showStatusString; +}; + +#endif diff --git a/ksplashml/themeengine/redmond/themeredmond.cpp b/ksplashml/themeengine/redmond/themeredmond.cpp new file mode 100644 index 000000000..6181980b6 --- /dev/null +++ b/ksplashml/themeengine/redmond/themeredmond.cpp @@ -0,0 +1,365 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 <pwd.h> +#include <sys/types.h> +#include <unistd.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kfontcombo.h> +#include <kgenericfactory.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kuser.h> +#include <kemailsettings.h> + +#include <qcheckbox.h> +#include <qdesktopwidget.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qrect.h> +#include <qstringlist.h> +#include <qwidget.h> + +#include <objkstheme.h> +#include "themeredmond.h" +#include "previewredmond.h" +#include "themeredmond.moc" + +K_EXPORT_COMPONENT_FACTORY( ksplashredmond, KGenericFactory<ThemeRedmond>( "ksplash" ) ) + +CfgRedmond::CfgRedmond( QWidget *p, KConfig *c ) + :ThemeEngineConfig( p, c ) +{ + QVBox *vbox = new QVBox( this ); + vbox->setSpacing( KDialog::spacingHint() ); + + QFont defaultFont( "Arial", 48, QFont::Bold ); + defaultFont.setItalic( true ); + QFont defaultUsernameFont( "Arial", 16, QFont::Bold ); + QFont defaultActionFont( "Arial", 12, QFont::Bold ); + QColor defaultDarkColor( 3, 47, 156 ); + QColor defaultWhiteColor( Qt::white ); + + QHBox *hbox = new QHBox( vbox ); + hbox->setFrameStyle( QFrame::WinPanel ); + hbox->setFrameShadow( QFrame::Sunken ); + PreviewRedmond* _preview = new PreviewRedmond( hbox ); + _preview->setFixedSize( 320, 200 ); + + _preview->setWelcomeString( c->readEntry( "Welcome Text", i18n("Welcome") ) ); + + _preview->setWelcomeFont( c->readFontEntry( "Welcome Font", &defaultFont ) ); + _preview->setUserFont( c->readFontEntry( "Username Font", &defaultUsernameFont ) ); + _preview->setStatusFont( c->readFontEntry( "Action Font", &defaultActionFont ) ); + + _preview->setWelcomeColor( c->readColorEntry( "Welcome Text Color", &defaultWhiteColor ) ); + _preview->setWelcomeShadowColor( c->readColorEntry( "Welcome Shadow Color", &defaultDarkColor ) ); + _preview->setUserColor( c->readColorEntry( "Username Text Color", &defaultWhiteColor ) ); + _preview->setStatusColor( c->readColorEntry( "Action Text Color", &defaultDarkColor ) ); + + _preview->setIcon( c->readEntry( "User Icon", "kmenu" ) ); + + QLabel *lbl = new QLabel( vbox ); + lbl->setText( i18n("(Sorry, but I haven't finished writing this one yet...)") ); +} + +ThemeRedmond::ThemeRedmond( QWidget *parent, const char *name, const QStringList &args ) + :ThemeEngine( parent, name, args ) +{ + _readSettings(); + _initUi(); +} + +void ThemeRedmond::_initUi() +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //QRect fullScreen = KGlobalSettings::desktopGeometry(0L); + + mImage.resize( screen.width(), screen.height() ); + + QPainter p; + p.begin( &mImage ); + p.fillRect( screen, QColor(3,47,156) ); + p.setPen( mActionTextColor ); + + QString bgimg; + + // Start by seeing if the theme prefers a particular image. + if( !mBackgroundImage.isEmpty() ) + bgimg = mTheme->locateThemeData( mBackgroundImage ); + + /* + * See if there is a resolution-specific background in THEMEDIR + * before looking for the "generic" one. Having a Background.png + * file for each resolution will greatly reduce the amount of time + * it takes to initialize this ThemeEngine when running, due to + * the fact that no scaling will be necessary to display the image. + * + * File must be named THEMEDIR/Background-WWWxHHH.png -- for example, + * Mytheme/Background-1024x768.png + * + * ADDITIONAL NOTE: The resolution you specify will be obtained from + * the PRIMARY SCREEN ONLY when running in XINERAMA mode. Be sure to + * provide backgrounds using common resolutions (I recommend at least + * providing 640x480 [unofficially unsupported by KDE], 800x600, and + * 1024x768 images.) + */ + if( bgimg.isEmpty() ) + bgimg = mTheme->locateThemeData( QString( "Background-%2x%3.png" ).arg( screen.width() ).arg( screen.height() ) ); + + // If that can't be found, look for THEMEDIR/Background.png + if( bgimg.isNull() && !mTheme->themeDir().isNull() ) + bgimg = mTheme->locateThemeData( "Background.png" ); + + if( mPixmap.isNull() ) + mPixmap = DesktopIcon( "kmenu", 48 ); + + QPixmap pix( bgimg ); + + if( !pix.isNull() ) + { + + QPixmap tmp( QSize(screen.width(), screen.height() ) ); + float sw = (float)screen.width() / pix.width(); + float sh = (float)(screen.height()) / pix.height(); + + QWMatrix matrix; + matrix.scale( sw, sh ); + tmp = pix.xForm( matrix ); + + p.drawPixmap( 0, 0, tmp ); + } + + QFont f = mWelcomeFont; + if( mWelcomeFontItalic ) + f.setItalic( true ); // this SHOULD BE stored in the QFont entry, dang it. + p.setFont( f ); + QFontMetrics met( f ); + QSize fmet = met.size( 0L, mWelcomeText ); + + // Paint the "Welcome" message, if we are instructed to. Optionally dispense with the + // shadow. + if ( mShowWelcomeText ) + { + if( mWelcomeTextPosition == QPoint( 0, 0 ) ) + { + mWelcomeTextPosition = QPoint( (screen.width()/2) - fmet.width() - 25, + (screen.height()/2) - (fmet.height()/2) + fmet.height() ); + } + } + + if( mShowWelcomeText ) + { + if( mShowWelcomeTextShadow ) + { + p.setPen( mWelcomeTextShadowColor ); + p.drawText( mWelcomeTextPosition+QPoint(2,2), mWelcomeText ); + } + p.setPen( mWelcomeTextColor ); + p.drawText( mWelcomeTextPosition, mWelcomeText ); + } + + // The current theme wants to say something in particular, rather than display the + // account's fullname. + KUser user; + QString greetingString = ( !mUsernameText.isNull() ) ? mUsernameText : user.fullName(); + // when we use KUser (system account data) we should also check KEMailSettings (e-mail settings and kcm_useraccount) + // people often write real names only in e-mail settings + if ( greetingString.isEmpty() ) + { + KEMailSettings kes; + greetingString = kes.getSetting( KEMailSettings::RealName ); + } + + // Try to load the user's KDM icon... TODO: Make this overridable by the Theme. + if( mUseKdmUserIcon ) + { + const QString defSys( ".default.face.icon" ); // The system-wide default image + const int fAdminOnly = 1; + const int fAdminFirst = fAdminOnly+1; + const int fUserFirst = fAdminFirst+1; + const int fUserOnly = fUserFirst+1; + + int faceSource = fAdminOnly; + KConfig *kdmconfig = new KConfig("kdm/kdmrc", true); + kdmconfig->setGroup("X-*-Greeter"); + QString userPicsDir = kdmconfig->readEntry( "FaceDir", KGlobal::dirs()->resourceDirs("data").last() + "kdm/faces" ) + '/'; + QString fs = kdmconfig->readEntry( "FaceSource" ); + if (fs == QString::fromLatin1("UserOnly")) + faceSource = fUserOnly; + else if (fs == QString::fromLatin1("PreferUser")) + faceSource = fUserFirst; + else if (fs == QString::fromLatin1("PreferAdmin")) + faceSource = fAdminFirst; + else + faceSource = fAdminOnly; // Admin Only + delete kdmconfig; + + QPixmap userp; + if ( faceSource == fAdminFirst ) + { + // If the administrator's choice takes preference + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + faceSource = fUserOnly; + } + if ( faceSource >= fUserFirst) + { + // If the user's choice takes preference + userp = QPixmap( user.homeDir() + "/.face.icon" ); + if ( userp.isNull() && faceSource == fUserFirst ) // The user has no face, should we check for the admin's setting? + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = QPixmap( userPicsDir + defSys ); + } + else if ( faceSource <= fAdminOnly ) + { + // Admin only + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = QPixmap( userPicsDir + defSys ); + } + if( !userp.isNull() ) + mPixmap = userp; + } + + if( mShowIcon ) + { + QPoint pos = mIconPosition; + if( pos == QPoint( 0, 0 ) ) + { + pos = QPoint( (screen.width()/2) + 10, (screen.height()/2) ); + } + p.drawPixmap( pos, mPixmap ); + } + + // User name font. Leave this nailed-up for now. + f = mUsernameFont; + p.setFont( f ); + met = QFontMetrics( f ); + fmet = met.size( 0L, greetingString ); + + if( mShowUsernameText ) + { + QPoint pos = mUsernameTextPosition; + if( pos == QPoint( 0, 0 ) ) + { + pos = QPoint( + (screen.width()/2) + mPixmap.width() + 20, + (screen.height()/2) - (fmet.height()/2) + fmet.height() + ); + } + p.setPen( mUsernameTextColor ); + p.drawText( pos, greetingString ); + } + + p.end(); + + setFixedSize( screen.width(), screen.height() ); + move( screen.topLeft() ); +} + +void ThemeRedmond::paintEvent( QPaintEvent *pe ) +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + + QPainter p; + p.begin( this ); + + QRect r = pe->rect(); + + bitBlt( this, r.x(), r.y(), + &mImage, r.x(), r.y(), r.width(), r.height() ); + + if (mShowActionText) + { + p.setPen( mActionTextColor ); + QFont f = mActionFont; + p.setFont( f ); + QFontMetrics met( f ); + QSize fmet = met.size( 0L, mText ); + + mMsgPos = mActionTextPosition; + if( mMsgPos == QPoint( 0, 0 ) ) + { + mMsgPos = QPoint( + (screen.width()/2) + mPixmap.width() + 20, + (screen.height()/2) + (int)(fmet.height()*0.85) + 15 + ); + } + p.drawText( mMsgPos, mText ); + } + p.end(); +} + +void ThemeRedmond::_readSettings() +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //QRect fullScreen = KGlobalSettings::desktopGeometry(0L); + + if( !mTheme ) + return; + KConfig *cfg = mTheme->themeConfig(); + if( !cfg ) + return; + + //if( !cfg->hasGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ); + + // Overall appearance + mBackgroundImage = cfg->readEntry( "Background Image", QString::null ); + mIcon = cfg->readEntry( "User Icon", "kmenu" ); + mWelcomeText = cfg->readEntry( "Welcome Text", i18n("Welcome") ); + mUsernameText = cfg->readEntry( "Username Text", QString::null ); + + // If any of these are set to (0,0), then we will autoposition the text later (and it _will_ + // be centered on the screen!). The Theme may move this text however the author desires. + QPoint absZero( 0, 0 ); + mWelcomeTextPosition = cfg->readPointEntry( QString("Welcome Text Position %1").arg(screen.width()), &absZero ); + mUsernameTextPosition = cfg->readPointEntry( QString("Username Text Position %1").arg(screen.width()), &absZero ); + mActionTextPosition = cfg->readPointEntry( QString("Action Text Position %1").arg(screen.width()), &absZero ); + mIconPosition = cfg->readPointEntry( QString("Icon Position %1").arg(screen.width()), &absZero ); + + // Allow the Theme to hide particular components. + mShowWelcomeText = cfg->readBoolEntry( "Show Welcome Text", true ); + mShowWelcomeTextShadow = cfg->readBoolEntry( "Show Welcome Shadow", true ); + mShowUsernameText = cfg->readBoolEntry( "Show Username", true ); + mShowActionText = cfg->readBoolEntry( "Show Action", true ); + mShowIcon = cfg->readBoolEntry( "Show Icon", true ); + mUseKdmUserIcon = cfg->readBoolEntry( "Use KDM User Icon", true ); + + // Setup our fonts. There are only 3 elements which use 'em, so this is fairly + // straightforward. + QFont defaultFont( "Arial", 48, QFont::Bold ); + defaultFont.setItalic( true ); + QFont defaultUsernameFont( "Arial", 16, QFont::Bold ); + QFont defaultActionFont( "Arial", 12, QFont::Bold ); + + mWelcomeFont = cfg->readFontEntry( "Welcome Font", &defaultFont ); + mWelcomeFontItalic = cfg->readBoolEntry( "Welcome Font Italic", true ); + mUsernameFont = cfg->readFontEntry( "Username Font", &defaultUsernameFont ); + mActionFont = cfg->readFontEntry( "Action Font", &defaultActionFont ); + + QColor defaultDarkColor( 3, 47, 156 ); + QColor defaultWhiteColor( Qt::white ); + + mWelcomeTextColor = cfg->readColorEntry( "Welcome Text Color", &defaultWhiteColor ); + mWelcomeTextShadowColor = cfg->readColorEntry( "Welcome Shadow Color", &defaultDarkColor ); + mUsernameTextColor = cfg->readColorEntry( "Username Text Color", &defaultWhiteColor ); + mActionTextColor = cfg->readColorEntry( "Action Text Color", &defaultWhiteColor ); +} diff --git a/ksplashml/themeengine/redmond/themeredmond.h b/ksplashml/themeengine/redmond/themeredmond.h new file mode 100644 index 000000000..a35662181 --- /dev/null +++ b/ksplashml/themeengine/redmond/themeredmond.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 __THEMEREDMOND_H__ +#define __THEMEREDMOND_H__ + +#include <kdebug.h> +#include <kpixmap.h> + +#include <themeengine.h> + +class KFontCombo; +class QCheckBox; + +class CfgRedmond: public ThemeEngineConfig +{ + Q_OBJECT +public: + CfgRedmond( QWidget *, KConfig * ); + +protected: + QCheckBox *mShowUsername; + QCheckBox *mShowIcon; + QCheckBox *mShowWelcome; + KFontCombo *mWelcomeFont; + KFontCombo *mUsernameFont; + KFontCombo *mActionFont; +}; + +class ObjKsTheme; +class ThemeRedmond: public ThemeEngine +{ + Q_OBJECT +public: + ThemeRedmond( QWidget *, const char *, const QStringList& ); + + inline const QString name() { return( QString("Redmond") ); } + static QStringList names() + { + QStringList Names; + Names << "Redmond"; + return( Names ); + }; + +public slots: + inline void slotSetText( const QString& s ) + { + if( mText != s ) + { + mText = s; + repaint( false ); + } + }; + +private: + void paintEvent( QPaintEvent * ); + + void _initUi(); + void _readSettings(); + + QString mText; + QPixmap mPixmap; + bool mRedrawKonqi; + QPoint mMsgPos; + KPixmap mImage; + + // ThemeEngine configuration. + bool mShowWelcomeText; + bool mShowWelcomeTextShadow; + bool mWelcomeFontItalic; + bool mShowUsernameText; + bool mShowActionText; + bool mShowIcon; + bool mUseKdmUserIcon; + QString mBackgroundImage; + QString mWelcomeText; + QString mUsernameText; // Leave this undefined to autodetect the username. + QString mIcon; + QFont mWelcomeFont; + QFont mUsernameFont; + QFont mActionFont; + QColor mWelcomeTextColor; + QColor mWelcomeTextShadowColor; + QColor mUsernameTextColor; + QColor mActionTextColor; + QPoint mWelcomeTextPosition; // Set this to (0,0) to autoposition the text. + QPoint mUsernameTextPosition; // Likewise. + QPoint mActionTextPosition; // Likewise likewise. + QPoint mIconPosition; // ... + +} +; + +#endif diff --git a/ksplashml/themeengine/simple/Makefile.am b/ksplashml/themeengine/simple/Makefile.am new file mode 100644 index 000000000..8f1e8ac93 --- /dev/null +++ b/ksplashml/themeengine/simple/Makefile.am @@ -0,0 +1,7 @@ + +INCLUDES = $(all_includes) + +bin_PROGRAMS = ksplashsimple +ksplashsimple_SOURCES = main.cpp +ksplashsimple_LDFLAGS = $(all_libraries) $(KDE_RPATH) +ksplashsimple_LDADD = $(LIB_XINERAMA) $(LIB_X11) diff --git a/ksplashml/themeengine/simple/configure.in.in b/ksplashml/themeengine/simple/configure.in.in new file mode 100644 index 000000000..e049bf94d --- /dev/null +++ b/ksplashml/themeengine/simple/configure.in.in @@ -0,0 +1,27 @@ +LIB_XINERAMA= + +AC_ARG_WITH([xinerama], + AC_HELP_STRING([--without-xinerama], [Disable xinerama extension support (default: check)]) ) + +if test "x$with_xinerama" != "xno"; then + xinerama_save_ldflags="$LDFLAGS" + LDFLAGS="$X_LDFLAGS" + + KDE_CHECK_HEADER(X11/extensions/Xinerama.h, + [ + AC_CHECK_LIB(Xinerama,XineramaQueryExtension, + [ + AC_DEFINE(HAVE_XINERAMA, 1, [Define if you have the Xinerama extension]) + LIB_XINERAMA="-lXinerama -lXext" + ], + [], + [ $X_PRE_LIBS -lXext -lX11 $X_EXTRA_LIBS ]) + ], [], + [ + #include <X11/Xlib.h> + ] ) + + AC_SUBST(LIB_XINERAMA) + LDFLAGS="$xinerama_save_ldflags" +fi + diff --git a/ksplashml/themeengine/simple/main.cpp b/ksplashml/themeengine/simple/main.cpp new file mode 100644 index 000000000..940ecc874 --- /dev/null +++ b/ksplashml/themeengine/simple/main.cpp @@ -0,0 +1,182 @@ +/*************************************************************************** + * Copyright 2004 Lubos Lunak <l.lunak@kde.org> * + * * + * 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 <config.h> + +#include <X11/Xlib.h> +#ifdef HAVE_XINERAMA +extern "C" { // for older XFree86 versions +#include <X11/extensions/Xinerama.h> +} +#endif +#include <stdio.h> +#include <unistd.h> +#include <string.h> + +#ifdef TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + + +//#define DEBUG + +int main( int argc, char* argv[]) + { + if( fork() != 0 ) + return 0; + Display* dpy = XOpenDisplay( NULL ); + if( dpy == NULL ) + return 1; + bool test = false; + if( argc == 2 && strcmp( argv[ 1 ], "--test" ) == 0 ) + test = true; + int sx, sy, sw, sh; +#ifdef HAVE_XINERAMA + // Xinerama code from Qt + XineramaScreenInfo *xinerama_screeninfo = 0; + int unused; + bool use_xinerama = XineramaQueryExtension( dpy, &unused, &unused ) + && XineramaIsActive( dpy ); + if (use_xinerama) + { + int screenCount; + xinerama_screeninfo = XineramaQueryScreens( dpy, &screenCount ); + sx = xinerama_screeninfo[ 0 ].x_org; + sy = xinerama_screeninfo[ 0 ].y_org; + sw = xinerama_screeninfo[ 0 ].width; + sh = xinerama_screeninfo[ 0 ].height; + } + else +#endif + { + sx = sy = 0; + sw = WidthOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy ))); + sh = HeightOfScreen( ScreenOfDisplay( dpy, DefaultScreen( dpy ))); + } + XSetWindowAttributes attrs; + attrs.override_redirect = True; + const int states = 6; + const int frame = 3; + const int segment = sw / 2 / states; + const int w = segment * states + 2 * frame; + const int h = sh / 20 + frame; + Window win = XCreateWindow( dpy, DefaultRootWindow( dpy ), sx + ( sw - w ) / 2, sy + ( sh - h ) /2, w, h, + 0, CopyFromParent, CopyFromParent, CopyFromParent, CWOverrideRedirect, &attrs ); + Pixmap pix = XCreatePixmap( dpy, DefaultRootWindow( dpy ), w, h, DefaultDepth( dpy, 0 )); + XGCValues values; + values.foreground = WhitePixel( dpy, 0 ); + GC gc = XCreateGC( dpy, pix, GCForeground, &values ); + XFillRectangle( dpy, pix, gc, 0, 0, w, h ); + values.foreground = BlackPixel( dpy, 0 ); + XChangeGC( dpy, gc, GCForeground, &values ); +// XFillRectangle( dpy, pix, gc, 0, 0, w, frame ); +// XFillRectangle( dpy, pix, gc, 0, h - frame, w, frame ); +// XFillRectangle( dpy, pix, gc, 0, 0, frame, h ); +// XFillRectangle( dpy, pix, gc, w - frame, 0, frame, h ); + XSetWindowBackgroundPixmap( dpy, win, pix ); + XSelectInput( dpy, win, ButtonPressMask ); + XSelectInput( dpy, DefaultRootWindow( dpy ), SubstructureNotifyMask ); + XMapWindow( dpy, win ); + int pos = 0; + int state = 1; // cannot check dcop connection - make this state initial + const int delay = 200; // ms + time_t final_time = time( NULL ) + 60; + time_t test_time = time( NULL ) + 1; + Atom kde_splash_progress = XInternAtom( dpy, "_KDE_SPLASH_PROGRESS", False ); + for(;;) + { + while( XPending( dpy )) + { + XEvent ev; + XNextEvent( dpy, &ev ); + if( ev.type == ButtonPress && ev.xbutton.window == win && ev.xbutton.button == Button1 ) + { + final_time = time( NULL ); + break; + } + if( ev.type == ConfigureNotify && ev.xconfigure.event == DefaultRootWindow( dpy )) + XRaiseWindow( dpy, win ); + if( ev.type == ClientMessage && ev.xclient.window == DefaultRootWindow( dpy ) + && ev.xclient.message_type == kde_splash_progress ) + { + // based on ksplash + const char* s = ev.xclient.data.b; +#ifdef DEBUG + fprintf( stderr,"MESSAGE: %s\n", s ); +#endif + if( strcmp( s, "dcop" ) == 0 && state < 1 ) + state = 1; // not actually used, state starts from 1, because dcop cannot be checked + else if( strcmp( s, "kded" ) == 0 && state < 2 ) + state = 2; + else if( strcmp( s, "kcminit" ) == 0 ) + ; // unused + else if( strcmp( s, "ksmserver" ) == 0 && state < 3 ) + state = 3; + else if( strcmp( s, "wm started" ) == 0 && state < 4 ) + state = 4; + else if( strcmp( s, "kdesktop" ) == 0 && state < 5 ) + state = 5; + else if(( strcmp( s, "kicker" ) == 0 || strcmp( s, "session ready" ) == 0 ) && state < 6 ) + state = 6; + } + } + if( test && time( NULL ) >= test_time ) + { + ++state; + test_time = time( NULL ) + 1; + } + if( pos != state ) + { + while( pos < state && pos < states ) + { +#ifdef DEBUG + fprintf( stderr, "POS: %d\n", pos ); +#endif + final_time = time( NULL ) + 60; + XFillRectangle( dpy, pix, gc, frame + pos * segment, frame, segment, h - 2 * frame ); + XSetWindowBackgroundPixmap( dpy, win, pix ); + XClearWindow( dpy, win ); + ++pos; + if( pos >= states ) + { +#ifdef DEBUG + fprintf( stderr, "CLOSING DOWN\n" ); +#endif + final_time = time( NULL ) + 2; + } + } + } + fd_set set; + FD_ZERO( &set ); + FD_SET( XConnectionNumber( dpy ), &set ); + struct timeval tv; + tv.tv_sec = 0; + tv.tv_usec = delay * 1000; + select( XConnectionNumber( dpy ) + 1, &set, NULL, NULL, &tv ); + if( time( NULL ) >= final_time ) + { +#ifdef DEBUG + fprintf( stderr, "EXITING\n" ); +#endif + break; // ---> + } + } + XFreePixmap( dpy, pix ); + XDestroyWindow( dpy, win ); + XFreeGC( dpy, gc ); + XCloseDisplay( dpy ); + } diff --git a/ksplashml/themeengine/standard/Makefile.am b/ksplashml/themeengine/standard/Makefile.am new file mode 100644 index 000000000..c627f6d3c --- /dev/null +++ b/ksplashml/themeengine/standard/Makefile.am @@ -0,0 +1,23 @@ +SUBDIRS = pics + +INCLUDES = -I$(top_srcdir)/ksplashml/themeengine $(all_includes) + +noinst_LTLIBRARIES = libthemestandard.la +libthemestandard_la_SOURCES = themestandard.cpp wndicon.cpp wndstatus.cpp +libthemestandard_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) +libthemestandard_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la + +kde_module_LTLIBRARIES = ksplashstandard.la + +ksplashstandard_la_SOURCES = themestandardlib.cpp +ksplashstandard_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(KDE_PLUGIN) -module +ksplashstandard_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la libthemestandard.la +METASOURCES = AUTO + +noinst_HEADERS = themestandard.h wndicon.h wndstatus.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashstandard.desktop + +themedir = $(kde_datadir)/ksplash/Themes/Standard +theme_DATA = Theme.rc diff --git a/ksplashml/themeengine/standard/Preview.png b/ksplashml/themeengine/standard/Preview.png Binary files differnew file mode 100644 index 000000000..58603e1e6 --- /dev/null +++ b/ksplashml/themeengine/standard/Preview.png diff --git a/ksplashml/themeengine/standard/Theme.rc b/ksplashml/themeengine/standard/Theme.rc new file mode 100644 index 000000000..2ae13af53 --- /dev/null +++ b/ksplashml/themeengine/standard/Theme.rc @@ -0,0 +1,2 @@ +[KSplash Theme: Standard] +Engine=Standard diff --git a/ksplashml/themeengine/standard/ksplashstandard.desktop b/ksplashml/themeengine/standard/ksplashstandard.desktop new file mode 100644 index 000000000..125c2a54d --- /dev/null +++ b/ksplashml/themeengine/standard/ksplashstandard.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +Comment=KSplash Plugin +Comment[af]=KSplash Inprop module +Comment[ar]=ملحق للشاشة الافتتاحية +Comment[az]=KSplash Əlavəsi +Comment[be]=Утулка KSplash +Comment[bg]=Приставка KSplash +Comment[bn]=কে-স্প্ল্যাশ প্লাগ-ইন +Comment[br]=Lugent KSplash +Comment[bs]=KSplash dodatak +Comment[ca]=Connector per a KSplash +Comment[cs]=Modul aplikaci KSplash +Comment[csb]=Plugins KSplash +Comment[cy]=Ategyn KCroeso +Comment[da]=KSplash-plugin +Comment[de]=KSplash-Plugin +Comment[el]=Πρόσθετο KSplash +Comment[eo]=Ksalutŝilda kromaĵo +Comment[es]=Complemento KSplash +Comment[et]=KSplashi plugin +Comment[eu]=KSplash plugina +Comment[fa]=وصلۀ KSplash +Comment[fi]=KSplash-liitännäinen +Comment[fr]=Modules de KSplash +Comment[fy]=KSplash-plugin +Comment[ga]=Breiseán KSplash +Comment[gl]=Plugin de KSplash +Comment[he]=תוסף KSplash +Comment[hi]=के-स्प्लैश प्लगइन +Comment[hr]=KSplash dodatak +Comment[hu]=KSplash bővítőmodul +Comment[is]=KSplash íforrit +Comment[it]=Plugin KSplash +Comment[ja]=KSplash プラグイン +Comment[ka]=KSplash პლაგინი +Comment[kk]=KSplash модулі +Comment[km]=កម្មវិធីជំនួយខាងក្នុងរបស់ KSplash +Comment[lt]=KSplash įskiepis +Comment[lv]=KSplash spraudnis +Comment[mk]=Приклучок за KSplash +Comment[ms]=Plugin KSplash +Comment[mt]=Plugin ta' KSplash +Comment[nb]=Programtillegg Ksplash +Comment[ne]=के स्प्लयास प्लगइन +Comment[nl]=KSplash-plugin +Comment[nn]=KSplash-programtillegg +Comment[pa]=ਕੇ-ਸਪਲੇਸ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka KSplash +Comment[pt]='Plugin' do KSplash +Comment[pt_BR]=Plug-in do KSplash +Comment[ro]=Modul KSplash +Comment[ru]=Модуль KSplash +Comment[rw]=Icomeka rya K-Gukwiza +Comment[se]=KSplash-lassemoduvla +Comment[sk]=Modul KSplash +Comment[sl]=Vstavek KSplash +Comment[sr]=KSplash прикључак +Comment[sr@Latn]=KSplash priključak +Comment[sv]=Insticksprogram för startskärm +Comment[ta]=Kஸ்ப்ளாஷ் செருகு பொருள் +Comment[tg]=Мутассалкунандаи KSplash +Comment[th]=ปลั๊กอิน KSplash +Comment[tr]=KSplash Eklentisi +Comment[tt]=KSplash atlı Östämä +Comment[uk]=Втулок KSplash +Comment[uz]=KSplash plagini +Comment[uz@cyrillic]=KSplash плагини +Comment[vi]=Trình bổ sung Chào mừng KDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashStandard +Name[af]=KSplash Standaard +Name[be]=Стандартная тэма +Name[ca]=KSplash estàndard +Name[cs]=Standardní +Name[cy]=KCroesoSafonol +Name[de]=KSplash Standard +Name[eo]=Normala +Name[et]=KSplash Standard +Name[hi]=के-स्प्लैश-स्टैण्डर्ड +Name[ne]=के स्प्लयास मानक +Name[pa]=ਕੇਸਪਲੇਸ ਸਟੈਂਡਰਡ +Name[pt_BR]=Tela de Apresentação Padrão +Name[rw]=K-GukwizaBisanzwe +Name[sv]=Vanlig startskärm +Name[ta]=Kஸ்ப்ளாஷ்நிலையான +Name[tg]=СтандартиKSplash +Name[th]=KSplash แบบมาตรฐาน +Name[vi]=Chào mừng KDE Tiêu chuẩn +Name[wa]=KSplashStandård +ServiceTypes=KSplash/Plugin +X-KDE-Library=ksplashstandard +X-KSplash-Default=true +X-KSplash-PluginName=Standard +X-KSplash-ObjectName=ThemeStandard diff --git a/ksplashml/themeengine/standard/pics/Makefile.am b/ksplashml/themeengine/standard/pics/Makefile.am new file mode 100644 index 000000000..54a91876d --- /dev/null +++ b/ksplashml/themeengine/standard/pics/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Preview.png + +themedir = $(kde_datadir)/ksplash/Themes/Standard +theme_DATA = $(EXTRA_DIST) diff --git a/ksplashml/themeengine/standard/pics/Preview.png b/ksplashml/themeengine/standard/pics/Preview.png Binary files differnew file mode 100644 index 000000000..b4e7d4a88 --- /dev/null +++ b/ksplashml/themeengine/standard/pics/Preview.png diff --git a/ksplashml/themeengine/standard/themestandard.cpp b/ksplashml/themeengine/standard/themestandard.cpp new file mode 100644 index 000000000..ff7929bfe --- /dev/null +++ b/ksplashml/themeengine/standard/themestandard.cpp @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 <kapplication.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kconfig.h> + +#include <qdesktopwidget.h> +#include <qlabel.h> +#include <qpalette.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include <objkstheme.h> +#include "themestandard.h" +#include "themestandard.moc" +#include "wndicon.h" +#include "wndstatus.h" + +ThemeStandard::ThemeStandard( QWidget *parent, const char *name, const QStringList &args ) + :ThemeEngine( parent, name, args ), mIcon(0L), mPrevIcon(0L), mIconCount(0), mStdIconWidth(-1), + mIconPos(WndIcon::HBottomLeft), mSbAtTop(false), mSbVisible(true), mSbPbVisible(true), mSbFontName("helvetica"), + mSbFontSz(16), mSbFontBold(true), mSbFontItalic(false), mSbFont(QFont()), mSbFg(QColor()), mSbBg(QColor()), + mSbIcon("run"), mIconsVisible(true), mIconsJumping(true), mSplashScreen("(Default)") +{ + _readSettings(); + _initUi(); +} + +void ThemeStandard::_initUi() +{ + setFrameStyle( QFrame::NoFrame ); + + QString pixName = mTheme->locateThemeData( mSplashScreen ); + + if( mSplashScreen == "(Default)" || pixName.isEmpty() ) + { + QString resource_prefix = "pics/"; + if ( mTheme->loColor() ) + resource_prefix += "locolor/"; + pixName = locate( "appdata", resource_prefix + "splash.png"); + } + + QPixmap px = QPixmap( pixName ); + + if( !px.isNull() ) + { + //kdDebug() << "Loaded splash " << mSplashScreen << endl; + int pw = px.width(); + int ph = px.height(); + + QLabel *lbl = new QLabel( this ); + lbl->setBackgroundMode( NoBackground ); + lbl->setFixedSize( pw, ph ); + lbl->setPixmap( px ); + + resize( pw, ph ); + } + else + { + //kdDebug() << "Couldn't load splash " << mSplashScreen << endl; + resize( 0, 0 ); + } + + const QRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + move( rect.x() + (rect.width() - size().width())/2, + rect.y() + (rect.height() - size().height())/2 ); + + mStatus = new WndStatus( QPalette(), mTheme->xineramaScreen(), mSbAtTop, mSbPbVisible, mSbFont, mSbFg, mSbBg, mSbIcon ); +} + +void ThemeStandard::showEvent( QShowEvent * ) +{ + + ThemeEngine::show(); + + if( mSbVisible ) + { + mStatus->show(); + mStatusBarHeight = mStatus->height(); + } + else + { + mStatusBarHeight = 0L; + } +} + +// Adjust the visible icon. +void ThemeStandard::slotSetPixmap( const QString& pxn ) +{ + QPixmap px = DesktopIcon( pxn ); + + if ( px.isNull() ) + px = DesktopIcon( "go" ); + + if ( !mIconsVisible ) + return; + + /* (We only use prev_i if jumping is enabled...) */ + if ( mIconsJumping && mPrevIcon ) + emit mPrevIcon->slotStopJumping(); + + if ( mStdIconWidth < 0 ) + mStdIconWidth = DesktopIcon( "go" ).width(); + + mIcon = new WndIcon( ++mIconCount, mStdIconWidth, mStatusBarHeight, mTheme->xineramaScreen(), + px, QString::null, mIconPos, mSbAtTop, mIconsJumping ); + mIcon->show(); + + if( mIconsJumping ) + { + emit mIcon->slotJump(); + mPrevIcon = mIcon; + } +} + +void ThemeStandard::_readSettings() +{ + + if ( !mTheme ) + return; + + KConfig *cfg = mTheme->themeConfig(); + if ( !cfg ) + return; + + //if ( !cfg->hasGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ); + + QString sbpos = cfg->readEntry( "Statusbar Position", "Bottom" ).upper(); + mSbAtTop = ( sbpos == "TOP" ); + mSbVisible = cfg->readBoolEntry( "Statusbar Visible", true); + mSbPbVisible = cfg->readBoolEntry( "Progress Visible", true); + + mSbFontName = cfg->readEntry( "Statusbar Font", "Sans Serif" ); + mSbFontSz = cfg->readNumEntry( "Statusbar Font Size", 16 ); + mSbFontBold = cfg->readBoolEntry( "Statusbar Font Bold", true ); + mSbFontItalic = cfg->readBoolEntry( "Statusbar Font Italic", false ); + mSbFont = QFont( mSbFontName, mSbFontSz, ( mSbFontBold? QFont::Bold : QFont::Normal ) ); + if( mSbFontItalic ) + mSbFont.setItalic( true ); + + mSbFg = cfg->readColorEntry( "Statusbar Foreground", &Qt::white ); + mSbBg = cfg->readColorEntry( "Statusbar Background", &Qt::black ); + mSbIcon = cfg->readEntry( "Statusbar Icon", "run" ); + mIconsVisible = cfg->readBoolEntry( "Icons Visible", true); + mIconsJumping = cfg->readBoolEntry( "Icons Jumping", true); + mIconPos = (WndIcon::Position)cfg->readNumEntry( "Icon Position", 0 ); + mSplashScreen = cfg->readEntry( "Splash Screen", "(Default)"); + // cfg->readBoolEntry( "Allow Configuration", true ); +} diff --git a/ksplashml/themeengine/standard/themestandard.h b/ksplashml/themeengine/standard/themestandard.h new file mode 100644 index 000000000..a24f668db --- /dev/null +++ b/ksplashml/themeengine/standard/themestandard.h @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 __THEMESTANDARD_H__ +#define __THEMESTANDARD_H__ + +#include <themeengine.h> + +#include "wndicon.h" +#include "wndstatus.h" + +/* + * Special Note: The "Standard" engine is treated a little bit differently than + * the other ThemeEngines in this program. Because we don't ever want to end up + * in a situation in which there is _no_ user interface, this ThemeEngine will + * be statically linked in with the ksplash binary itself, so that no dynamic + * loading is necessary to access it. The disadvantage that this presents is + * immediately obvious: The control center module is no longer able to dynamically + * load a configuration object for this theme, since this engine doesn't reside in + * a shared-object library like the other ones do. Therefore, we will have to + * implement the ThemeEngineConfig object for this engine in the kcmksplash + * subsystem, in such a manner that it is statically linked in with the control + * panel. I know, this is really nasty, but I would rather have slightly uglier + * code, so long as it makes the End User Experience of this program somewhat more + * predictable (i.e., even if we can't do exactly what the user wants, we can still + * do _something_...) + * + * Therefore, you will find the CfgStandard class in the ../kcmksplash/ directory. + */ + +/** + * @short The default KSplash splash screen. + */ +class ThemeStandard: public ThemeEngine +{ + Q_OBJECT +public: + ThemeStandard( QWidget *, const char*, const QStringList& ); + //inline const ThemeEngineConfig *config( QWidget *p, KConfig *kc ) { return 0L; } + +public slots: + inline void slotUpdateProgress( int i ) + { + if( mStatus ) mStatus->slotUpdateProgress( i ); + } + inline void slotUpdateSteps( int i ) + { + if( mStatus ) mStatus->slotUpdateSteps( i ); + } + inline void slotSetText( const QString& s ) + { + if( mStatus ) mStatus->slotSetMessage( s ); + } + void slotSetPixmap( const QString& ); + +private: + void showEvent( QShowEvent * ); + void _readSettings(); + void _initUi(); + + WndStatus *mStatus; + WndIcon *mIcon, *mPrevIcon; + int mIconCount; + int mStatusBarHeight; + int mStdIconWidth; + + WndIcon::Position mIconPos; + bool mSbAtTop; + bool mSbVisible; + bool mSbPbVisible; + QString mSbFontName; + int mSbFontSz; + bool mSbFontBold; + bool mSbFontItalic; + QFont mSbFont; + QColor mSbFg; + QColor mSbBg; + QString mSbIcon; + bool mIconsVisible; + bool mIconsJumping; + QString mSplashScreen; +}; + +#endif diff --git a/ksplashml/themeengine/standard/themestandardlib.cpp b/ksplashml/themeengine/standard/themestandardlib.cpp new file mode 100644 index 000000000..acdb6958f --- /dev/null +++ b/ksplashml/themeengine/standard/themestandardlib.cpp @@ -0,0 +1,15 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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. * + * * + ***************************************************************************/ + +#include <kgenericfactory.h> + +#include "themestandard.h" + +K_EXPORT_COMPONENT_FACTORY( ksplashstandard, KGenericFactory<ThemeStandard>( "ksplash" ) ) diff --git a/ksplashml/themeengine/standard/wndicon.cpp b/ksplashml/themeengine/standard/wndicon.cpp new file mode 100644 index 000000000..0440a0181 --- /dev/null +++ b/ksplashml/themeengine/standard/wndicon.cpp @@ -0,0 +1,310 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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.) * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <kapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kdebug.h> +#include <kglobalsettings.h> +#include <kwin.h> + +#include <qdesktopwidget.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qpixmap.h> +#include <qpoint.h> +#include <qtimer.h> +#include <qwidget.h> + +#include "wndicon.h" +#include "wndicon.moc" + +WndIcon::WndIcon( + unsigned int icon_num, + unsigned int icon_std_width, + unsigned int status_height, + int xineramaScreen, + const KPixmap& pix, + const QString& text, + Position icon_position, + bool statusAtTop, + bool iconsJumping ) + :QHBox( 0, "wndSplash", WStyle_Customize|WX11BypassWM ), + mStatusText(text), mIconPos(icon_position), mXineramaScreen( xineramaScreen ), mPosX(0), mPosY(0), mGroundX(0), mGroundY(0), + mVelocity(8.0), mInitialVelocity(8.0), mGravity(0.8), + mIconNum(icon_num), mStatusHeight(status_height), mIconSize(icon_std_width), mStatusAtTop(statusAtTop), + mStopJump(false), mIconJumping(iconsJumping) +{ + setFrameStyle( QFrame::NoFrame ); + + QLabel *w = new QLabel( this ); + w->setFixedSize( pix.width(), pix.height() ); + w->setPixmap( pix ); + if(pix.mask()) + { + setMask(*pix.mask()); + w->setMask(*pix.mask()); + } + + resize( pix.width(), pix.height() ); + + // Set initial position of icon, and ground. + QPoint p = determinePosition(); + mGroundX = mPosX = p.x(); + mGroundY = mPosY = p.y(); + move( p + kapp->desktop()->screenGeometry( mXineramaScreen ).topLeft() ); + + if( mIconJumping ) + { + QTimer *t = new QTimer( this ); + connect(t, SIGNAL(timeout()), SLOT(slotJump())); + t->start( 50, false ); + } +} + +void WndIcon::show() +{ + emit setStatusText( mStatusText ); + QHBox::show(); +} + +// Emit our EXTRA signal without becoming visible. +void WndIcon::noshow() +{ + emit setStatusText( mStatusText ); +} + +/* + * WndIcon::determinePosition(): Based on the information we've + * stored within us, determine where we should be placed on the + * screen. This is placed in its own function due to the massive + * complexity required by the variables involved. + */ +QPoint WndIcon::determinePosition() +{ + int DW, DH, SBH, wid, X, Y, x, y, nSlot, topshift, bottomshift; + + bottomshift = topshift = 0; + const QRect srect = kapp->desktop()->screenGeometry( mXineramaScreen ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + DW = srect.width(); + DH = srect.height(); + SBH = mStatusHeight; + wid = mIconSize; + x = mIconNum; + y = 1; + + if(mStatusAtTop) + topshift = mStatusHeight; + else + bottomshift = mStatusHeight; + + // Different starting positions require different positioning + // rules. The horizontal rules and the vertical rules can be + // grouped together, as they are innately similar. + switch( mIconPos ) + { + // HORIZONTAL: Top Left -> Top Right + case( WndIcon::HTopLeft ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + ((x - 1) * wid); + Y = topshift + 3 + ( (y-1) * wid ); + break; + + // HORIZONTAL: Bottom Left -> Bottom Right + case( WndIcon::HBottomLeft ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + ((x - 1) * wid); + Y = (DH-3) - (y * wid) - bottomshift; + break; + + // HORIZONTAL: Top Right -> Top Left + case( WndIcon::HTopRight ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( x ) * wid ); + Y = topshift + (3) + ( (y-1) * wid ); + break; + + // HORIZONTAL: Bottom Right -> Bottom Left + case( WndIcon::HBottomRight ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( x ) * wid ); + Y = (DH-3) - (y * wid) - bottomshift; + break; + + // VERTICAL: Top Left -> Bottom Left + case( WndIcon::VTopLeft ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + (( y - 1 ) * wid ); + Y = topshift + (3) + ((x-1) * wid); + break; + + // VERTICAL: Top Right -> Bottom Right + case( WndIcon::VTopRight ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( y ) * wid ); + Y = topshift + (3) + ((x-1) * wid); + break; + + // VERTICAL: Bottom Left -> Top Left + case( WndIcon::VBottomLeft ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + (( y - 1 ) * wid ); + Y = (DH-3) - (x * wid) - bottomshift; + break; + + // VERTICAL: Bottom Right -> Top Right + case( WndIcon::VBottomRight ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( y ) * wid ); + Y = (DH-3) - (x * wid) - bottomshift; + break; + + // Unknown Condition. Reconfigure variable and + // retry. Recursively, of course! ;) + default: + mIconPos = HBottomLeft; + return(determinePosition()); + break; + } + return( QPoint( X, Y ) ); +} + +// Make the icons jump in a macosx-like way (Thanks, Jone!:) +void WndIcon::slotJump() +{ + // Based on our position, bounce around. + switch( mIconPos ) + { + // LEFT + case( WndIcon::VTopLeft ): + case( WndIcon::VBottomLeft ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosX <= mGroundX ) + { + mPosX = mGroundX; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosX <= mGroundX ) + mVelocity = mInitialVelocity; + mPosX = (int)((float)mPosX + mVelocity); + break; + + // RIGHT + case( WndIcon::VTopRight ): + case( WndIcon::VBottomRight ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosX >= mGroundX ) + { + mPosX = mGroundX; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosX >= mGroundX ) + mVelocity = mInitialVelocity; + mPosX = (int)((float)mPosX - mVelocity); + break; + + // TOP + case( WndIcon::HTopLeft ): + case( WndIcon::HTopRight ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosY <= mGroundY ) + { + mPosY = mGroundY; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosY <= mGroundY ) + mVelocity = mInitialVelocity; + mPosY = (int)((float)mPosY + mVelocity ); + break; + + // BOTTOM + case( WndIcon::HBottomLeft ): + case( WndIcon::HBottomRight ): default: + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosY >= mGroundY ) + { + mPosY = mGroundY; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosY >= mGroundY ) + mVelocity = mInitialVelocity; + mPosY = (int)((float)mPosY - mVelocity ); + break; + } + move( QPoint( mPosX, mPosY ) + kapp->desktop()->screenGeometry( mXineramaScreen ).topLeft() ); +} + +void WndIcon::slotStopJumping() +{ + mStopJump = true; +} diff --git a/ksplashml/themeengine/standard/wndicon.h b/ksplashml/themeengine/standard/wndicon.h new file mode 100644 index 000000000..a47082ae6 --- /dev/null +++ b/ksplashml/themeengine/standard/wndicon.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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.) * + * * + ***************************************************************************/ + +// This file exists for the convenience of other KDE headers. It may change between +// different versions of KDE, and may disappear altogether. Do NOT include this +// directly in your program. We mean it. + + +#ifndef __WNDICON_H__ +#define __WNDICON_H__ + +#include <kpixmap.h> + +#include <qhbox.h> + +/** + * @short Displays an icon on the screen. + */ +class WndIcon: + public QHBox +{ + Q_OBJECT +public: + + enum Position + { + HBottomLeft = 0, + HBottomRight = 1, + HTopLeft = 2, + HTopRight = 3, + VBottomLeft = 10, + VBottomRight = 11, + VTopLeft = 12, + VTopRight = 13 + }; + + WndIcon( unsigned int, unsigned int, unsigned int, int, const KPixmap&, const QString&, Position, bool, bool ); + +signals: + void setStatusText( const QString& ); + +public slots: + void show(); + void noshow(); + void slotStopJumping(); + void slotJump(); + +private: + QPoint determinePosition(); + +protected: + QString mStatusText; + Position mIconPos; + int mXineramaScreen; + int mPosX, mPosY, mGroundX, mGroundY; + float mVelocity, mInitialVelocity, mGravity; + int mIconNum, mStatusHeight, mIconSize; + bool mStatusAtTop, mStopJump, mIconJumping; +}; + +#endif diff --git a/ksplashml/themeengine/standard/wndstatus.cpp b/ksplashml/themeengine/standard/wndstatus.cpp new file mode 100644 index 000000000..3b8582c89 --- /dev/null +++ b/ksplashml/themeengine/standard/wndstatus.cpp @@ -0,0 +1,101 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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 <kapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <kprogress.h> +#include <kwin.h> + +#include <qdesktopwidget.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qpoint.h> +#include <qrect.h> + +#include "wndstatus.h" +#include "wndstatus.moc" + +// WndStatus::WndStatus(): Display a nifty status bar at +// the bottom of the screen, so the user always knows what's +// happening to his system. +WndStatus::WndStatus( QPalette /*pal*/, + int xineramaScreen, + bool atTop, bool pbVisible, + const QFont& font, + const QColor& fgc, const QColor & bgc, + const QString& icon + ) + :QHBox( 0, "wndStatus", WStyle_Customize|WX11BypassWM ) +{ + setFrameStyle( QFrame::NoFrame ); + //setPalette( pal ); + setPaletteBackgroundColor( bgc ); + setPaletteForegroundColor( fgc ); + setCursor( KCursor::blankCursor() ); + setSpacing( 5 ); + + const QRect rect = kapp->desktop()->screenGeometry( xineramaScreen ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + QLabel *pix = new QLabel( this ); + QPixmap _icon( SmallIcon(icon.isNull()||icon.isEmpty()?QString("run"):icon) ); + pix->setPixmap( _icon ); + setStretchFactor(pix,0); + pix->setFixedWidth(16); + + m_label = new QLabel( this ); + m_label->setFont( font ); + m_label->setPaletteBackgroundColor( bgc ); + m_label->setPaletteForegroundColor( fgc ); + //QFontMetrics metrics( font ); + //m_label->setFixedHeight( metrics.height() ); + m_label->setText(QString("")); + m_label->setFixedWidth(rect.width()-105-16-10); // What's this magic number? + m_label->show(); + + m_progress = new KProgress( this ); + setStretchFactor(m_progress,0); + m_progress->setFixedWidth(100); + + QWidget *widg = new QWidget( this ); + setStretchFactor(widg,50); + + setFixedSize( rect.width(), QMAX(m_progress->height(),m_label->height()) ); + + if ( atTop ) + move( rect.topLeft() ); + else + move( rect.bottomLeft().x(), rect.bottomLeft().y()-height()+1 ); // The +1 is to work around a bug in screenGeometry(). + + if (!pbVisible) + m_progress->hide(); +} + +void WndStatus::slotSetMessage( const QString& msg ) +{ + raise(); + m_label->setText( msg ); +} + +void WndStatus::slotUpdateProgress( int i ) +{ + raise(); + m_progress->setProgress( i ); +} + +void WndStatus::slotUpdateSteps( int i ) +{ + m_progress->setTotalSteps( i ); +} diff --git a/ksplashml/themeengine/standard/wndstatus.h b/ksplashml/themeengine/standard/wndstatus.h new file mode 100644 index 000000000..fa1d735d9 --- /dev/null +++ b/ksplashml/themeengine/standard/wndstatus.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * 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.) * + * * + ***************************************************************************/ + +// This file exists for the convenience of other KDE headers. It may change between +// different versions of KDE, and may disappear altogether. Do NOT include this +// directly in your program. We mean it. + + +#ifndef __WNDSTATUS_H__ +#define __WNDSTATUS_H__ + +#include <qhbox.h> + +class QLabel; +class KProgress; + +/** @short Window displaying status and progress bar. */ +class WndStatus: + public QHBox +{ + Q_OBJECT +public: + WndStatus( QPalette, + int, // Xinerama screen + bool, // At top? + bool, // Progress indicator visible? + const QFont&, // Status bar font + const QColor&, const QColor &, // Foreground/Background color + const QString& // Icon + ); + +public slots: + void slotSetMessage( const QString& ); + void slotUpdateProgress( int ); + void slotUpdateSteps( int ); + +protected: + QLabel *m_label; + KProgress *m_progress; +}; +#endif diff --git a/ksplashml/themeengine/themeengine.cpp b/ksplashml/themeengine/themeengine.cpp new file mode 100644 index 000000000..0b58587f7 --- /dev/null +++ b/ksplashml/themeengine/themeengine.cpp @@ -0,0 +1,136 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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.) * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kwin.h> + +#include <qevent.h> +#include <qfile.h> +#include <qwidget.h> + +#include <X11/Xlib.h> + +#ifdef HAVE_XCURSOR +# include <X11/Xlib.h> +# include <X11/Xcursor/Xcursor.h> +#endif + +#include "objkstheme.h" +#include "themeengine.h" +#include "themeengine.moc" + +struct ThemeEngine::ThemeEnginePrivate +{ + QValueList< Window > mSplashWindows; +}; + +ThemeEngine::ThemeEngine( QWidget *, const char *, const QStringList& args ) + : QVBox( 0, "wndSplash", WStyle_Customize|WX11BypassWM ), d(0) +{ + d = new ThemeEnginePrivate; + kapp->installX11EventFilter( this ); + kapp->installEventFilter( this ); + (void)kapp->desktop(); + XWindowAttributes rootAttr; + XGetWindowAttributes(qt_xdisplay(), RootWindow(qt_xdisplay(), + qt_xscreen()), &rootAttr); + XSelectInput( qt_xdisplay(), qt_xrootwin(), + SubstructureNotifyMask | rootAttr.your_event_mask ); + if (args.isEmpty()) + mTheme = new ObjKsTheme( "Default" ); + else + mTheme = new ObjKsTheme( args.first() ); + mTheme->loadCmdLineArgs( KCmdLineArgs::parsedArgs() ); +} + +ThemeEngine::~ThemeEngine() +{ + delete d; +} + +/* + This is perhaps a bit crude, but I'm not aware of any better way + of fixing #85030 and keeping backwards compatibility if there + are any 3rd party splashscreens. Check all toplevel windows, + force them to be WX11BypassWM (so that ksplash can handle their stacking), + and keep them on top, even above all windows handled by KWin. +*/ +bool ThemeEngine::eventFilter( QObject* o, QEvent* e ) +{ + if( e->type() == QEvent::Show && o->isWidgetType()) + addSplashWindow( static_cast< QWidget* >( o )); + return false; +} + +namespace +{ +class HackWidget : public QWidget { friend class ::ThemeEngine; }; +} + +void ThemeEngine::addSplashWindow( QWidget* w ) +{ + if( !w->isTopLevel()) + return; + if( d->mSplashWindows.contains( w->winId())) + return; + if( !w->testWFlags( WX11BypassWM )) + { // All toplevel widgets should be probably required to be WX11BypassWM + // for KDE4 instead of this ugly hack. + static_cast< HackWidget* >( w )->setWFlags( WX11BypassWM ); + XSetWindowAttributes attrs; + attrs.override_redirect = True; + XChangeWindowAttributes( qt_xdisplay(), w->winId(), CWOverrideRedirect, &attrs ); + } + d->mSplashWindows.prepend( w->winId()); + connect( w, SIGNAL( destroyed( QObject* )), SLOT( splashWindowDestroyed( QObject* ))); + w->raise(); +} + +void ThemeEngine::splashWindowDestroyed( QObject* obj ) +{ + d->mSplashWindows.remove( static_cast< QWidget* >( obj )->winId()); +} + +bool ThemeEngine::x11Event( XEvent* e ) +{ + if( e->type != ConfigureNotify && e->type != MapNotify ) + return false; + if( e->type == ConfigureNotify && e->xconfigure.event != qt_xrootwin()) + return false; + if( e->type == MapNotify && e->xmap.event != qt_xrootwin()) + return false; + if( d->mSplashWindows.count() == 0 ) + return false; + // this restacking is written in a way so that + // if the stacking positions actually don't change, + // all restacking operations will be no-op, + // and no ConfigureNotify will be generated, + // thus avoiding possible infinite loops + XRaiseWindow( qt_xdisplay(), d->mSplashWindows.first()); // raise topmost + // and stack others below it + Window* stack = new Window[ d->mSplashWindows.count() ]; + int count = 0; + for( QValueList< Window >::ConstIterator it = d->mSplashWindows.begin(); + it != d->mSplashWindows.end(); + ++it ) + stack[ count++ ] = *it; + XRestackWindows( x11Display(), stack, count ); + delete[] stack; + return false; +} diff --git a/ksplashml/themeengine/themeengine.h b/ksplashml/themeengine/themeengine.h new file mode 100644 index 000000000..62461cd4e --- /dev/null +++ b/ksplashml/themeengine/themeengine.h @@ -0,0 +1,82 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 THEMEENGINE_H +#define THEMEENGINE_H + +#include <qstringlist.h> +#include <qvbox.h> +#include <qwidget.h> + +#include <kdemacros.h> + +class KConfig; +class ObjKsTheme; +class QMouseEvent; + +/** + * @short The base for the ThemeEngine's configuration widget. + */ +class KDE_EXPORT ThemeEngineConfig: public QVBox +{ + Q_OBJECT +public: + + ThemeEngineConfig( QWidget *p, KConfig *c ) + :QVBox( p ), mConfig( c ) + {} + + KConfig* config()const { return mConfig; } + +public slots: + virtual void load() {} + virtual void save() {} + +protected: + KConfig *mConfig; +}; + +/** + * @short Base class for all theme engines. Member functions need to be + * overridden by derived classes in order to provide actual functionality. + */ +class KDE_EXPORT ThemeEngine: public QVBox +{ + Q_OBJECT +public: + ThemeEngine( QWidget *parent, const char *name, const QStringList &args ); + virtual ~ThemeEngine() = 0; + virtual const ThemeEngineConfig *config( QWidget *, KConfig * ) { return 0L; } + virtual ObjKsTheme *ksTheme() { return mTheme; } + virtual bool eventFilter( QObject* o, QEvent* e ); + +public slots: + virtual void slotUpdateProgress( int ) {} + virtual void slotUpdateSteps( int ) {} + virtual void slotSetText( const QString& ) {} + virtual void slotSetPixmap( const QString& ) {} // use DesktopIcon() to load this. + +protected: + void addSplashWindow( QWidget* ); + +protected: + ObjKsTheme *mTheme; + virtual bool x11Event( XEvent* ); + +private slots: + void splashWindowDestroyed( QObject* ); + +private: + class ThemeEnginePrivate; + ThemeEnginePrivate *d; +}; + +#endif diff --git a/ksplashml/wndmain.cpp b/ksplashml/wndmain.cpp new file mode 100644 index 000000000..b5cc45c12 --- /dev/null +++ b/ksplashml/wndmain.cpp @@ -0,0 +1,426 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 <unistd.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kiconloader.h> +#include <klibloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kstandarddirs.h> +#include <ktrader.h> +#include <kwin.h> +#include <dcopclient.h> + +#include <qdir.h> +#include <qpixmap.h> +#include <qtimer.h> + +#include "objkstheme.h" +#include "wndmain.h" +#include "wndmain.moc" + +#include "themeengine.h" +#include "themelegacy.h" + +// KSplash::KSplash(): This is a hidden object. Its sole purpose +// is to manage the other objects, which are presented on the screen. +KSplash::KSplash(const char *name) + : DCOPObject( name ), QWidget( 0, name, WStyle_Customize|WStyle_NoBorder|WX11BypassWM ), + mState( 0 ), mMaxProgress( 0 ), mStep( 0 ) +{ + hide(); // We never show this object. + mThemeLibName = QString::null; + mSessMgrCalled = false; + mTimeToGo = false; + + KConfig * config = kapp->config(); + slotReadProperties(config); + + prepareSplashScreen(); + prepareIconList(); + + mCurrentAction = mActionList.first(); + + config->setGroup( "General" ); + if ( config->readBoolEntry( "CloseOnClick", TRUE ) ) + mThemeEngine->installEventFilter( this ); + + connect( mThemeEngine, SIGNAL(destroyed()), this, SLOT(close()) ); + connect( this, SIGNAL(stepsChanged(int)), SLOT(slotUpdateSteps(int)) ); + connect( this, SIGNAL(progressChanged(int)), SLOT(slotUpdateProgress(int)) ); + + if( mKsTheme->testing() ) + { + slotUpdateSteps(7); + QTimer::singleShot( 1000, this, SLOT(slotExec())); + } + else + QTimer::singleShot( 100, this, SLOT(initDcop())); + + // Make sure we don't stay up forever. + if (!mKsTheme->managedMode()) + { + close_timer = new QTimer( this ); + connect( close_timer, SIGNAL( timeout() ), this, SLOT( close() ) ); + close_timer->start( 60000, TRUE ); + } +} + +KSplash::~KSplash() +{ + delete mThemeEngine; + delete mKsTheme; + delete close_timer; + if (!mThemeLibName.isEmpty()) + KLibLoader::self()->unloadLibrary( mThemeLibName.latin1() ); +} + +void KSplash::slotReadProperties( KConfig *config ) +{ + KCmdLineArgs *arg = KCmdLineArgs::parsedArgs(); + mTheme = arg->getOption("theme"); + if (mTheme.isEmpty()) + { + config->setGroup( "KSplash" ); + mTheme = config->readEntry( "Theme", "Default" ); + } + loadTheme( mTheme ); // Guaranteed to return a valid theme. +} + +void KSplash::prepareIconList() +{ + // Managed mode icons are specified via DCOP. + if( mKsTheme->managedMode() ) + return; + + slotInsertAction( mKsTheme->icon( 1 ), mKsTheme->text( 1 ) ); + + mCurrentAction = mActionList.first(); + slotSetText( mCurrentAction->ItemText ); + slotSetPixmap( mCurrentAction->ItemPixmap ); + emit progressChanged( mStep ); + + for (int indx = 2; indx <= 8; indx++) + slotInsertAction( mKsTheme->icon( indx ), mKsTheme->text( indx ) ); +} + +void KSplash::prepareSplashScreen() +{ + mThemeEngine->show(); +} + +void KSplash::slotInsertAction( const QString& pix, const QString& msg ) +{ + Action *a = new Action; + a->ItemText = msg; + a->ItemPixmap = pix; + mActionList.append( a ); +} + +void KSplash::slotExec() +{ + QTimer::singleShot( 200, this, SLOT(nextIcon())); +} + +void KSplash::nextIcon() +{ + if( !mCurrentAction || mTimeToGo ) + { + QTimer::singleShot( 1000, this, SLOT(close())); + return; + } + + mCurrentAction = mActionList.next(); + + if( mCurrentAction ) + { + slotSetText( mCurrentAction->ItemText ); + slotSetPixmap( mCurrentAction->ItemPixmap ); + emit progressChanged( ++mStep ); + } + + if( mKsTheme->testing() ) + QTimer::singleShot( 1000, this, SLOT(nextIcon())); +} + +void KSplash::initDcop() +{ + disconnect( kapp->dcopClient(), SIGNAL( attachFailed(const QString&) ), kapp, SLOT( dcopFailure(const QString&) ) ); + + if ( kapp->dcopClient()->isAttached() ) + return; + + if ( kapp->dcopClient()->attach() ) + { + if(!mKsTheme->managedMode()) + upAndRunning( "dcop" ); + kapp->dcopClient()->registerAs( "ksplash", false ); + kapp->dcopClient()->setDefaultObject( objId() ); + } + else + { + QTimer::singleShot( 100, this, SLOT(initDcop()) ); + } +} + +void KSplash::updateState( unsigned int state ) +{ +// The whole state updating in ksplashml is simply weird, +// nextIcon() and also the themes naively assume all states +// will come, and will come in the expected order, which +// is not guaranteed, and can happen easily with faster machines. +// And upAndRunning() even is written to handle it gracefully. + while( state > mState ) + { + ++mState; + nextIcon(); + } +} + +// For KDE startup only. +void KSplash::upAndRunning( QString s ) +{ +// This code is written to match ksmserver. Touch it without knowing +// what you are doing and prepare to bite the dust. + bool update = true; + static bool firstTime = true; + + if (firstTime) + { + emit stepsChanged(7); + firstTime = false; + } + if ( close_timer->isActive() ) + close_timer->start( 60000, TRUE ); + + if( s == "dcop" ) + { + if( mState > 1 ) return; + updateState( 1 ); + mStep = 1; + } + else if( s == "kded" ) + { + if( mState > 2 ) return; + updateState( 2 ); + mStep = 2; + } + else if( s == "kcminit" ) + ; // No icon + else if( s == "ksmserver" ) + { + if( mState > 3 ) return; + updateState( 3 ); + mStep = 3; + } + else if( s == "wm started" ) + { + if( mState > 4 ) return; + updateState( 4 ); + mStep = 4; + } + else if( s == "kdesktop" ) + { + if( mState > 5 ) return; + updateState( 5 ); + mStep = 5; + } + else if( s == "kicker" || s == "session ready" ) + { + updateState( 7 ); + mStep = 9; + //if(!mSessMgrCalled) emit nextIcon(); + mTimeToGo = true; + close_timer->stop(); + QTimer::singleShot( 1000, this, SLOT(close())); + } + else + { + kdDebug() << "KSplash::upAndRunning(): bad s: " << s << endl; + update = false; + } +} + +// For KDE startup only. +void KSplash::setMaxProgress(int max) +{ + if( max < 1 ) + max = 1; + if( mThemeEngine && mState >= 6 ) // show the progressbar only after kicker is ready + mThemeEngine->slotUpdateSteps( max ); + mMaxProgress = max; +} + +// For KDE startup only. +void KSplash::setProgress(int step) +{ + if( mThemeEngine ) + mThemeEngine->slotUpdateProgress( mMaxProgress - step ); +} + + +/* + * When a program starts, it sends a generic signal to KSplash indicating + * (a) which icon is to be displayed to the user //OR// a generic token-name + * indicating that KSplash can load a pre-configured icon, (b) the textual + * name of the process being started, and (c) a description of what the + * process is handling. Some examples: + * + * programStarted( QString("desktop"), QString("kdesktop"), QString("Preparing your desktop...")); + */ +void KSplash::programStarted( QString icon, QString name, QString desc ) +{ + if (mTimeToGo) + return; + // No isEmpty() here: empty strings are handled by the plugins and can be passed to update the counter. + if (name.isNull() && icon.isNull() && desc.isNull()) + return; + + slotInsertAction( icon, desc ); + mCurrentAction = mActionList.next(); + slotSetText( desc ); + slotSetPixmap( icon ); + emit progressChanged( ++mStep ); +} + +void KSplash::setStartupItemCount( int count ) +{ + emit stepsChanged( count ); + emit progressChanged( mStep ); +} + +void KSplash::startupComplete() +{ + mTimeToGo = true; + QTimer::singleShot( 1000, this, SLOT(close())); +} + +void KSplash::close() +{ + QWidget::close(); +} + +void KSplash::hide() +{ + QWidget::hide(); +} + +void KSplash::show() +{ + QWidget::show(); +} + +// Guaranteed to return a valid theme. +void KSplash::loadTheme( const QString& theme ) +{ + mKsTheme = new ObjKsTheme( theme ); + // kdDebug() << "KSplash::loadTheme: " << theme << " : "<< mKsTheme->themeEngine() << endl; + mThemeEngine = _loadThemeEngine( mKsTheme->themeEngine(), theme ); + if (!mThemeEngine) + { + mThemeEngine = new ThemeDefault( this, "", theme ); + kdDebug() << "Standard theme loaded." << endl; + } + // The theme engine we get may not be the theme engine we requested. + delete mKsTheme; + mKsTheme = mThemeEngine->ksTheme(); +} + +ThemeEngine *KSplash::_loadThemeEngine( const QString& pluginName, const QString& theme ) +{ + // Since we may be called before the DCOP server is active, we cannot use the KTrader framework for obtaining plugins. In its + // place, we use the following naive heuristic to locate plugins. If we are not in managed mode, and we are not in testing mode + // either, we assume that we have been called by startkde. In this case, we simply try to load the library whose name should + // conform to the following specification: + // QString("ksplash") + pluginName.lower() + // The object should be called as follows: + // QString("Theme") + pluginName + KLibFactory *factory = 0L; + QString libName; + QString objName; + // Replace this test by a "nodcop" command line option. + if ( /*!mKsTheme->managedMode() ||*/ !KCmdLineArgs::parsedArgs()->isSet( "dcop" ) ) + { + libName = QString("ksplash%1").arg(pluginName.lower()); + objName = QString("Theme%1").arg(pluginName); + // kdDebug() << "*KSplash::_loadThemeEngine: Loading " << objName << " from " << libName << endl; + // libname.latin1() instead of QFile::encodeName() because these are not user-modifiable files. + if ( (factory = KLibLoader::self()->factory ( libName.latin1() )) ) + mThemeLibName = libName; + } + else + { + // Fancier way of locating plugins. + KService::List list= KTrader::self()->query("KSplash/Plugin", QString("[X-KSplash-PluginName] == '%1'").arg(pluginName)); + KService::Ptr ptr; + if (!list.isEmpty()) + { + ptr = list.first(); + // libname.latin1() instead of QFile::encodeName() because these are not user-modifiable files. + if( (factory = KLibLoader::self()->factory( ptr->library().latin1() )) ) + { + mThemeLibName = ptr->library(); + objName = ptr->property("X-KSplash-ObjectName").toString(); + } + } + } + if (factory) + { + QStringList themeTitle; + themeTitle << theme; + return static_cast<ThemeEngine *>(factory->create(this, "theme", objName.latin1(), themeTitle)); + } + else + return 0L; +} + +void KSplash::slotSetText( const QString& s ) +{ + if( mThemeEngine ) + mThemeEngine->slotSetText( s ); +} + +void KSplash::slotSetPixmap( const QString& px ) +{ + if( mThemeEngine ) + mThemeEngine->slotSetPixmap( px ); +} + +void KSplash::slotUpdateSteps( int ) +{ +// ?? +} + +void KSplash::slotUpdateProgress( int ) +{ +// ?? +} + +QPtrList<Action> KSplash::actionList() +{ + return mActionList; +} + +bool KSplash::eventFilter( QObject *o, QEvent *e ) +{ + if ( ( e->type() == QEvent::MouseButtonRelease ) && ( o == mThemeEngine ) ) + { + QTimer::singleShot( 0, this, SLOT(close())); + return TRUE; + } + else + return FALSE; +} diff --git a/ksplashml/wndmain.h b/ksplashml/wndmain.h new file mode 100644 index 000000000..1bed2b734 --- /dev/null +++ b/ksplashml/wndmain.h @@ -0,0 +1,109 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * 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 __WNDMAIN_H__ +#define __WNDMAIN_H__ + +#include <kapplication.h> + +#include <qptrlist.h> +#include <qstring.h> +#include <qobject.h> + +#include "ksplashiface.h" + +// MAKE SURE THAT THIS MATCHES WHAT'S IN ../kcmksplash/kcmksplash.h!!! +#define N_ACTIONITEMS 8 + +// Action: This represents an "action entry" to any object which is interested +// in knowing this. +typedef struct +{ + QString ItemPixmap; + QString ItemText; +} Action; + +class WndStatus; +class ObjKsTheme; +class ThemeEngine; +class KConfig; + +class KSplash: public QWidget, virtual public KSplashIface +{ + Q_OBJECT + +public: + KSplash(const char *name = "ksplash"); + ~KSplash(); + + QPtrList<Action> actionList(); + + // DCOP interface + ASYNC upAndRunning( QString ); + ASYNC setMaxProgress(int); + ASYNC setProgress(int); + ASYNC setStartupItemCount( int count ); + ASYNC programStarted( QString programIcon, QString programName, QString description ); + ASYNC startupComplete(); + ASYNC close(); + ASYNC hide(); + ASYNC show(); + +signals: + void stepsChanged(int); + void progressChanged(int); + void actionListChanged(); + +protected: + bool eventFilter( QObject *o, QEvent *e ); + +public slots: + void slotUpdateSteps( int ); + void slotUpdateProgress( int ); + +private slots: + void initDcop(); + void prepareIconList(); + void prepareSplashScreen(); + void slotExec(); + void nextIcon(); + void slotInsertAction( const QString&, const QString& ); + void slotReadProperties( KConfig * ); + + void slotSetText( const QString& ); + void slotSetPixmap( const QString& ); + + void loadTheme( const QString& ); + +private: + ThemeEngine *_loadThemeEngine( const QString& pluginName, const QString& theme ); + void updateState( unsigned int state ); + +protected: + unsigned int mState; + unsigned int mMaxProgress; + unsigned int mStep; // ?? + QTimer* close_timer; + + bool mSessMgrCalled; + bool mTimeToGo; + + QString mTheme; + ObjKsTheme *mKsTheme; + + ThemeEngine *mThemeEngine; + QPtrList<Action> mActionList; + Action *mCurrentAction, *mPreviousAction; + + QString mThemeLibName; +}; + +#endif |