diff options
Diffstat (limited to 'ksplashml/themeengine')
51 files changed, 3640 insertions, 0 deletions
diff --git a/ksplashml/themeengine/CMakeLists.txt b/ksplashml/themeengine/CMakeLists.txt new file mode 100644 index 000000000..f5437b9bb --- /dev/null +++ b/ksplashml/themeengine/CMakeLists.txt @@ -0,0 +1,43 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( default ) +add_subdirectory( unified ) +add_subdirectory( standard ) +add_subdirectory( redmond ) +add_subdirectory( simple ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES themeengine.h objkstheme.h DESTINATION ${INCLUDE_INSTALL_DIR}/ksplash ) +install( FILES ksplashplugins.desktop DESTINATION ${SERVICETYPES_INSTALL_DIR} ) + + +##### ksplashthemes (shared) #################### + +tde_add_library( ksplashthemes SHARED AUTOMOC + SOURCES themeengine.cpp objkstheme.cpp + VERSION 0.0.0 + LINK tdeui-shared + DESTINATION ${LIB_INSTALL_DIR} +) diff --git a/ksplashml/themeengine/Makefile.am b/ksplashml/themeengine/Makefile.am new file mode 100644 index 000000000..558404e31 --- /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_TDEUI) $(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/CMakeLists.txt b/ksplashml/themeengine/default/CMakeLists.txt new file mode 100644 index 000000000..ba3866e35 --- /dev/null +++ b/ksplashml/themeengine/default/CMakeLists.txt @@ -0,0 +1,45 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + #${CMAKE_CURRENT_SOURCE_DIR} + #${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ksplashml/themeengine + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES ksplashdefault.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + + +##### ksplashdefault (module) ################### + +tde_add_kpart( ksplashdefault AUTOMOC + SOURCES main.cpp + LINK themedefault-static ksplashthemes-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### themedefault (static) ##################### + +tde_add_library( themedefault STATIC_PIC AUTOMOC + SOURCES themelegacy.cpp + LINK ksplashthemes-shared +) diff --git a/ksplashml/themeengine/default/Makefile.am b/ksplashml/themeengine/default/Makefile.am new file mode 100644 index 000000000..b117cbb29 --- /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) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +libthemedefault_la_LIBADD = $(LIB_TDEUI) ../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_TDEUI) ../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..079f29e92 --- /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 TDE +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 TDE Gia tài +Name[wa]=KSplashTayons +X-TDE-ServiceTypes=KSplash/Plugin +X-TDE-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..0e1242120 --- /dev/null +++ b/ksplashml/themeengine/default/themelegacy.cpp @@ -0,0 +1,319 @@ +/*************************************************************************** + * 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 <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <tdeglobalsettings.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kprogress.h> + +#include <tqcheckbox.h> +#include <tqdesktopwidget.h> +#include <tqlabel.h> +#include <tqpainter.h> +#include <tqpixmap.h> +#include <tqwidget.h> +#include <tqtimer.h> +#include <tqvaluelist.h> + +#include "objkstheme.h" +#include "themeengine.h" +#include "themelegacy.h" +#include "themelegacy.moc" + +const int MAX_STATES=8; + +DefaultConfig::DefaultConfig( TQWidget *parent, TDEConfig *config ) + :ThemeEngineConfig( parent, config ) +{ + mConfig->setGroup( TQString("KSplash Theme: Default") ); + TQVBox *hbox = new TQVBox( this ); + mFlash = new TQCheckBox( i18n("Icons flash while they are starting"), hbox ); + mFlash->setChecked( mConfig->readBoolEntry("Icons Flashing",true) ); + mAlwaysShow = new TQCheckBox( i18n("Always show progress bar"), hbox ); + mAlwaysShow->setChecked( mConfig->readBoolEntry("Always Show Progress",true) ); +} + +void DefaultConfig::save() +{ + kdDebug() << "DefaultConfig::save()" << endl; + mConfig->setGroup( TQString("KSplash Theme: Default") ); + mConfig->writeEntry( "Icons Flashing", mFlash->isChecked() ); + mConfig->writeEntry( "Always Show Progress", mAlwaysShow->isChecked() ); + mConfig->sync(); +} + +#define BIDI 0 + +ThemeDefault::ThemeDefault( TQWidget *parent, const char *name, const TQStringList &args ) + :ThemeEngine( parent, name, args ) +{ + + mActivePixmap = mInactivePixmap = 0L; + mState = 0; + for (int i=0; i<MAX_ICONS; ++i) + mIconOffsets[i]=0; + + _readSettings(); + _initUi(); + + if( mIconsFlashing ) + { + mFlashTimer = new TQTimer( this ); + connect( mFlashTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(flash()) ); + mFlashPixmap1 = new TQPixmap(); + mFlashPixmap2 = new TQPixmap(); + + } + else + { + mFlashTimer = 0L; + mFlashPixmap1 = 0L; + mFlashPixmap2 = 0L; + } +} + +ThemeDefault::~ThemeDefault() +{ + delete mFlashPixmap1; + delete mFlashPixmap2; +} + +void ThemeDefault::_initUi() +{ + TQString resource_prefix; + + TQVBox *vbox = new TQVBox( this ); + vbox->setBackgroundMode(NoBackground); + + + TQString activePix, inactivePix; +#if BIDI + if ( TQApplication::reverseLayout() ) + { + activePix = _findPicture(TQString("splash_active_bar_bidi.png")); + inactivePix = _findPicture(TQString("splash_inactive_bar_bidi.png")); + } + else +#endif + { + activePix = _findPicture(TQString("splash_active_bar.png")); + inactivePix = _findPicture(TQString("splash_inactive_bar.png")); + } + kdDebug() << "Inactive pixmap: " << inactivePix << endl; + kdDebug() << "Active pixmap: " << activePix << endl; + + mActivePixmap = new TQPixmap( activePix ); + mInactivePixmap = new TQPixmap( inactivePix ); + + if (mActivePixmap->isNull()) + { + mActivePixmap->resize(200,100); + mActivePixmap->fill(Qt::blue); + } + if (mInactivePixmap->isNull()) + { + mInactivePixmap->resize(200,100); + mInactivePixmap->fill(Qt::black); + } + + TQPixmap tlimage( _findPicture(TQString("splash_top.png")) ); + if (tlimage.isNull()) + { + tlimage.resize(200,100); + tlimage.fill(Qt::blue); + } + TQLabel *top_label = new TQLabel( vbox ); + top_label->setPixmap( tlimage ); + top_label->setFixedSize( tlimage.width(), tlimage.height() ); + top_label->setBackgroundMode(NoBackground); + + mBarLabel = new TQLabel( vbox ); + mBarLabel->setPixmap(*mInactivePixmap); + mBarLabel->setBackgroundMode(NoBackground); + + TQPixmap blimage( _findPicture(TQString("splash_bottom.png")) ); + if (blimage.isNull()) + { + blimage.resize(200,100); + blimage.fill(Qt::black); + } + TQLabel *bottom_label = new TQLabel( vbox ); + bottom_label->setPaletteBackgroundPixmap( blimage ); + + + mLabel = new TQLabel( bottom_label ); + mLabel->setBackgroundOrigin( TQWidget::ParentOrigin ); + mLabel->setPaletteForegroundColor( mLabelForeground ); + mLabel->setPaletteBackgroundPixmap( blimage ); + TQFont f(mLabel->font()); + f.setBold(TRUE); + mLabel->setFont(f); + + mProgressBar = new KProgress( mLabel ); + int h, s, v; + mLabelForeground.getHsv( &h, &s, &v ); + mProgressBar->setPalette( TQPalette( v > 128 ? black : white )); + mProgressBar->setBackgroundOrigin( TQWidget::ParentOrigin ); + mProgressBar->setPaletteBackgroundPixmap( blimage ); + + bottom_label->setFixedWidth( TQMAX(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 (TQApplication::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 TQRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + // TDEGlobalSettings::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; + + TDEConfig *cfg = mTheme->themeConfig(); + if (!cfg) + return; + + cfg->setGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ); + + mIconsFlashing = cfg->readBoolEntry( "Icons Flashing", true ); + TQColor df(Qt::white); + mLabelForeground = cfg->readColorEntry( "Label Foreground", &df ); + TQValueList<int> io_list=cfg->readIntListEntry("Icon Offsets"); + if (io_list.size() == MAX_ICONS) + { + TQValueList<int>::iterator io_it; + int i=0; + for (io_it = io_list.begin(); io_it != io_list.end(); ++io_it, ++i) + mIconOffsets[i]=*io_it; + } +} + +/* + * 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 >= MAX_STATES) + mState = MAX_STATES-1; + + if( mIconsFlashing ) + { + + *mFlashPixmap1 = updateBarPixmap( mState ); + *mFlashPixmap2 = updateBarPixmap( mState+1 ); + mBarLabel->setPixmap(*mFlashPixmap2); + mFlashTimer->stop(); + + if( mState < MAX_STATES ) + 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. + */ +TQPixmap ThemeDefault::updateBarPixmap( int state ) +{ + int offs; + + TQPixmap x; + if( !mActivePixmap ) return( x ); +#if BIDI + if( TQApplication::reverseLayout() ) + { + if ( state > 7 ) + return ( x ); + } +#endif + + offs = state*58; + if (state>=0 && state<MAX_ICONS) + offs += mIconOffsets[state]; + + TQPixmap tmp(*mActivePixmap); + TQPainter p(&tmp); +#if BIDI + if ( TQApplication::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; + TQPixmap *swap = mFlashPixmap1; + mFlashPixmap1 = mFlashPixmap2; + mFlashPixmap2 = swap; + mBarLabel->setPixmap(*mFlashPixmap2); +} + +TQString ThemeDefault::_findPicture( const TQString &pic ) +{ + // Don't use ObjKsTheme::locateThemeData here for compatibility reasons. + TQString f = pic; + if (mTheme->loColor()) + f = TQString("locolor/")+f; + //kdDebug() << "Searching for " << f << endl; + //kdDebug() << "Theme directory: " << mTheme->themeDir() << endl; + //kdDebug() << "Theme name: " << mTheme->theme() << endl; + TQString p = TQString::null; + if ((p = locate("appdata",mTheme->themeDir()+f)).isEmpty()) + if ((p = locate("appdata",mTheme->themeDir()+"pics/"+f)).isEmpty()) + if ((p = locate("appdata", TQString("pics/")+mTheme->theme()+"/"+f)).isEmpty()) + if ((p = locate("appdata",f)).isEmpty()) + if ((p = locate("appdata",TQString("pics/")+f)).isEmpty()) + if ((p = locate("data",TQString("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..1f56d05b0 --- /dev/null +++ b/ksplashml/themeengine/default/themelegacy.h @@ -0,0 +1,107 @@ +/*************************************************************************** + * 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 <tqlabel.h> +#include <tqwidget.h> + +#include "themeengine.h" + +static const int MAX_ICONS=7; + +class TQPixmap; +class TQTimer; + +class TQCheckBox; + +class DefaultConfig: public ThemeEngineConfig +{ + Q_OBJECT +public: + DefaultConfig( TQWidget *, TDEConfig * ); + void save(); +protected: + TQCheckBox *mFlash, *mAlwaysShow; +}; + +/** + * @short Traditional Trinity splash screen. + */ +class ObjKsTheme; +class KDE_EXPORT ThemeDefault : public ThemeEngine +{ + Q_OBJECT +public: + ThemeDefault( TQWidget *, const char *, const TQStringList& ); + virtual ~ThemeDefault(); + + inline const DefaultConfig *config( TQWidget *p, TDEConfig *c ) + { + return new DefaultConfig( p, c ); + }; + + static TQStringList names() + { + TQStringList Names; + Names << "Default"; + Names << "Classic"; + Names << "Klassic"; + return( Names ); + } + +public slots: + inline void slotSetText( const TQString& 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(); + TQPixmap updateBarPixmap( int ); + void flash(); + +private: + void _initUi(); + void _readSettings(); + TQString _findPicture( const TQString &pic ); + + // Configurable Options + bool mIconsFlashing; + TQColor mLabelForeground; + int mIconOffsets[MAX_ICONS]; + + // Internals. + KProgress *mProgressBar; + TQLabel *mLabel, *mBarLabel; + TQPixmap *mActivePixmap, *mInactivePixmap; + int mState; + TQTimer *mFlashTimer; + TQPixmap *mFlashPixmap1, *mFlashPixmap2; +}; + +#endif diff --git a/ksplashml/themeengine/ksplashplugins.desktop b/ksplashml/themeengine/ksplashplugins.desktop new file mode 100644 index 000000000..09f453bb8 --- /dev/null +++ b/ksplashml/themeengine/ksplashplugins.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=ServiceType +X-TDE-ServiceType=KSplash/Plugin + +[PropertyDef::X-KSplash-PluginName] +Type=TQString + +[PropertyDef::X-KSplash-ObjectName] +Type=TQString + +[PropertyDef::X-KSplash-Default] +Type=bool diff --git a/ksplashml/themeengine/objkstheme.cpp b/ksplashml/themeengine/objkstheme.cpp new file mode 100644 index 000000000..9de990099 --- /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 <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <tdelocale.h> +#include <kstandarddirs.h> + +#include <tqcolor.h> +#include <tqcursor.h> +#include <tqdesktopwidget.h> +#include <tqfont.h> +#include <tqpixmap.h> +#include <tqrect.h> +#include <tqstring.h> + +#include "objkstheme.h" +#include "objkstheme.moc" + +ObjKsTheme::ObjKsTheme( const TQString& theme ) + :mActiveTheme (theme), mThemeDir("/"), mThemeConfig (0L), mThemePrefix( "Themes/" ), d(0) +{ + // Get Xinerama config. + TDEConfig *config = kapp->config(); + config->setGroup( "Xinerama" ); + TQDesktopWidget *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) + { + TQRect rect = desktop->screenGeometry( mXineramaScreen ); + if (!rect.contains(TQCursor::pos())) + TQCursor::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(TDECmdLineArgs::parsedArgs()); + mThemePrefix += ( mActiveTheme + "/" ); +} + +ObjKsTheme::~ObjKsTheme() +{ +} + +bool ObjKsTheme::loadThemeRc( const TQString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadThemeRc: " << activeTheme << endl; + TQString prefix("Themes/"); + TQString themeFile; + TDEConfig *cf = 0L; + + // Try our best to find a theme file. + themeFile = locate( "appdata", prefix + activeTheme + "/" + TQString("Theme.rc") ); + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+TQString("Theme.RC")):themeFile; + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+TQString("theme.rc")):themeFile; + themeFile = themeFile.isEmpty() ? locate("appdata",prefix+activeTheme+"/"+activeTheme+TQString(".rc")):themeFile; + + if( !themeFile.isEmpty() ) + cf = new TDEConfig( themeFile ); + + if( cf ) + { + mActiveTheme = activeTheme; + mThemeDir = prefix + activeTheme+"/"; + if( loadTDEConfig( cf, activeTheme, force ) ) + { + mThemeConfig = cf; + return true; + } + else + delete cf; + } + return false; +} + +bool ObjKsTheme::loadLocalConfig( const TQString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadLocalConfig" << endl; + TDEConfig *cfg = kapp->config(); + return( loadTDEConfig( cfg, activeTheme, force ) ); +} + +// ObjKsConfig::loadTDEConfig(): Load our settings from a TDEConfig object. +bool ObjKsTheme::loadTDEConfig( TDEConfig *cfg, const TQString& activeTheme, bool force ) +{ + //kdDebug() << "ObjKsTheme::loadTDEConfig" << 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( TQString("KSplash Theme: %1").arg(activeTheme) ) && !force ) + return false; + + cfg->setGroup( TQString("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", "application-x-executable" ) ); + 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", "preferences-system" ) ); + 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("Trinity is up and running") ) ); + + return true; +} + +/* + * ObjKsTheme::loadCmdLineArgs(): Handle any overrides which the user might have + * specified. + */ +void ObjKsTheme::loadCmdLineArgs( TDECmdLineArgs *args ) +{ + + mManagedMode = args->isSet( "managed" ); + mTesting = args->isSet("test"); + mLoColor = ( TQPixmap::defaultDepth() <= 8 ); + TQString theme = args->getOption( "theme" ); + if( theme != mActiveTheme && !theme.isNull() ) + if( loadThemeRc( theme, false ) ) + mActiveTheme = theme; + //args->clear(); +} + +TQString ObjKsTheme::locateThemeData( const TQString &resource ) +{ + if ( !mLoColor ) + return locate( "appdata", mThemePrefix+resource ); + else + { + TQString 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..8959c5537 --- /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 <tdecmdlineargs.h> + +#include <tqstring.h> +#include <tqstringlist.h> + +class TDEConfig; +/** + * @short Theme reader. + * A Theme is read in from the file + * <TDEDIR>/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 TQString& ); + virtual ~ObjKsTheme(); + + void loadCmdLineArgs( TDECmdLineArgs * ); + + TQString theme() const { return( mActiveTheme ); } + TQString themeEngine() const { return( mThemeEngine ); } + TDEConfig *themeConfig() const { return( mThemeConfig ); } + TQString themeDir() const { return( mThemeDir ); } + bool loColor() const { return( mLoColor ); } + bool testing() const { return( mTesting ); } + bool managedMode() const { return( mManagedMode ); } + TQString icon( int i ) { return (m_icons[i-1].isNull()?(TQString::null):m_icons[i-1]); } + TQString text( int i ) { return (m_text[i-1].isNull()?(TQString::null):m_text[i-1]); } + TQString locateThemeData( const TQString &resource ); + int xineramaScreen() const { return mXineramaScreen; } + +protected: + bool loadThemeRc( const TQString&, bool ); + bool loadLocalConfig( const TQString&, bool ); + bool loadTDEConfig( TDEConfig *, const TQString&, bool ); + +private: + TQString mActiveTheme, mThemeDir; + TDEConfig *mThemeConfig; + + int mXineramaScreen; + bool mLoColor, mTesting, mManagedMode; + TQString mThemeEngine; + TQString mThemePrefix; + + TQStringList m_icons, m_text; + + class ObjKsThemePrivate; + ObjKsThemePrivate *d; +}; + +#endif diff --git a/ksplashml/themeengine/redmond/CMakeLists.txt b/ksplashml/themeengine/redmond/CMakeLists.txt new file mode 100644 index 000000000..a6e0b0229 --- /dev/null +++ b/ksplashml/themeengine/redmond/CMakeLists.txt @@ -0,0 +1,38 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( pics ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ksplashml/themeengine + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES Theme.rc DESTINATION ${DATA_INSTALL_DIR}/ksplash/Themes/Redmond ) +install( FILES ksplashredmond.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + + +##### ksplashredmond (module) ################### + +tde_add_kpart( ksplashredmond AUTOMOC + SOURCES previewredmond.cpp themeredmond.cpp + LINK ksplashthemes-shared tdeio-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/ksplashml/themeengine/redmond/Makefile.am b/ksplashml/themeengine/redmond/Makefile.am new file mode 100644 index 000000000..f3bd64329 --- /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_TDEUI) $(LIB_TDEIO) ../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..12b2dbd7a --- /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 TDE +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 TDE Redmond +Name[zh_TW]=KSplachRedmond +X-TDE-ServiceTypes=KSplash/Plugin +X-TDE-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..7b4a6bb2e --- /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 <tqlabel.h> +#include <tqpixmap.h> +#include <tqwidget.h> + +#include "themeredmond.h" + +extern "C" +{ + ThemeEngineConfig *KsThemeConfig( TQWidget *parent, TDEConfig *config ) + { + return new CfgRedmond( parent, config ); + } + + TQStringList KsThemeSupports() + { + return ThemeRedmond::names(); + } + + void* KsThemeInit( TQWidget *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/CMakeLists.txt b/ksplashml/themeengine/redmond/pics/CMakeLists.txt new file mode 100644 index 000000000..1b4f09de0 --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/CMakeLists.txt @@ -0,0 +1,12 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +install( FILES Preview.png Background.png DESTINATION ${DATA_INSTALL_DIR}/ksplash/Themes/Redmond ) 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..7a31a44b8 --- /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 <tdelocale.h> + +#include <tqpainter.h> +#include <tqpixmap.h> +#include <tqwidget.h> + +#include "previewredmond.h" +#include "previewredmond.moc" +/* + * PreviewRedmond::PreviewRedmond(): Constructor. Set up some basic + * things. + */ +PreviewRedmond::PreviewRedmond( TQWidget* parent ) + :TQWidget( parent ), + + /* Using direct constructors to prevent memory blit. */ + m_welcomeString (i18n("Welcome")), + m_userString (i18n("(Your Name)")), + + m_welcomeFont (TQFont( "Arial", 16, TQFont::Bold )), + m_userFont (TQFont( "Arial", 16 )), + m_statusFont (TQFont( "Arial", 12, TQFont::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( TQPaintEvent* pe ) +{ + TQPainter p; + p.begin( this ); + p.drawPixmap( pe->rect(), m_cache ); + p.end(); +} + +void PreviewRedmond::resizeEvent( TQResizeEvent *re ) +{ + TQWidget::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 = TQPixmap( size() ); + TQPainter p; + p.begin( &m_cache ); + + p.fillRect( rect(), Qt::gray ); + + m_welcomeFont.setItalic( true ); + p.setFont( m_welcomeFont ); + + TQPoint 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 ); + TQPoint 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 ) + { + TQPoint 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..5fc5558c2 --- /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 <tqcolor.h> +#include <tqfont.h> +#include <tqwidget.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 TQWidget +{ + Q_OBJECT +public: + + PreviewRedmond( TQWidget* ); + + inline void setWelcomeString( const TQString& s ) + { + m_welcomeString = s; + _updateCache(); + } + inline void setUserString( const TQString& s ) + { + m_userString = s; + _updateCache(); + } + + inline void setWelcomeFont( const TQFont& f ) + { + m_welcomeFont = f; + _updateCache(); + } + inline void setUserFont( const TQFont& f ) + { + m_userFont = f; + _updateCache(); + } + inline void setStatusFont( const TQFont& f ) + { + m_statusFont = f; + _updateCache(); + } + + inline void setWelcomeColor( const TQColor& c ) + { + m_welcomeColor = c; + _updateCache(); + } + inline void setWelcomeShadowColor( const TQColor& c ) + { + m_welcomeShadowColor = c; + _updateCache(); + } + inline void setUserColor( const TQColor& c ) + { + m_userColor = c; + _updateCache(); + } + inline void setStatusColor( const TQColor& c ) + { + m_statusColor = c; + _updateCache(); + } + + inline void setIcon( const TQString& s ) + { + m_icon = DesktopIcon( s ); + _updateCache(); + } + +protected: + void _updateCache(); + void paintEvent( TQPaintEvent* ); + void resizeEvent( TQResizeEvent* ); + + TQPixmap m_cache; + + TQString m_welcomeString, m_userString; + TQFont m_welcomeFont, m_userFont, m_statusFont; + TQColor m_welcomeColor, m_welcomeShadowColor, m_userColor, m_statusColor; + TQPixmap 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..b0e81ba72 --- /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 <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <tdefontcombo.h> +#include <kgenericfactory.h> +#include <tdeglobalsettings.h> +#include <kiconloader.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kuser.h> +#include <tdeemailsettings.h> + +#include <tqcheckbox.h> +#include <tqdesktopwidget.h> +#include <tqlabel.h> +#include <tqpainter.h> +#include <tqrect.h> +#include <tqstringlist.h> +#include <tqwidget.h> + +#include <objkstheme.h> +#include "themeredmond.h" +#include "previewredmond.h" +#include "themeredmond.moc" + +K_EXPORT_COMPONENT_FACTORY( ksplashredmond, KGenericFactory<ThemeRedmond>( "ksplash" ) ) + +CfgRedmond::CfgRedmond( TQWidget *p, TDEConfig *c ) + :ThemeEngineConfig( p, c ) +{ + TQVBox *vbox = new TQVBox( this ); + vbox->setSpacing( KDialog::spacingHint() ); + + TQFont defaultFont( "Arial", 48, TQFont::Bold ); + defaultFont.setItalic( true ); + TQFont defaultUsernameFont( "Arial", 16, TQFont::Bold ); + TQFont defaultActionFont( "Arial", 12, TQFont::Bold ); + TQColor defaultDarkColor( 3, 47, 156 ); + TQColor defaultWhiteColor( Qt::white ); + + TQHBox *hbox = new TQHBox( vbox ); + hbox->setFrameStyle( TQFrame::WinPanel ); + hbox->setFrameShadow( TQFrame::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" ) ); + + TQLabel *lbl = new TQLabel( vbox ); + lbl->setText( i18n("(Sorry, but I haven't finished writing this one yet...)") ); +} + +ThemeRedmond::ThemeRedmond( TQWidget *parent, const char *name, const TQStringList &args ) + :ThemeEngine( parent, name, args ) +{ + _readSettings(); + _initUi(); +} + +void ThemeRedmond::_initUi() +{ + const TQRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //TQRect fullScreen = TDEGlobalSettings::desktopGeometry(0L); + + mImage.resize( screen.width(), screen.height() ); + + TQPainter p; + p.begin( &mImage ); + p.fillRect( screen, TQColor(3,47,156) ); + p.setPen( mActionTextColor ); + + TQString 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( TQString( "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 ); + + TQPixmap pix( bgimg ); + + if( !pix.isNull() ) + { + + TQPixmap tmp( TQSize(screen.width(), screen.height() ) ); + float sw = (float)screen.width() / pix.width(); + float sh = (float)(screen.height()) / pix.height(); + + TQWMatrix matrix; + matrix.scale( sw, sh ); + tmp = pix.xForm( matrix ); + + p.drawPixmap( 0, 0, tmp ); + } + + TQFont f = mWelcomeFont; + if( mWelcomeFontItalic ) + f.setItalic( true ); // this SHOULD BE stored in the TQFont entry, dang it. + p.setFont( f ); + TQFontMetrics met( f ); + TQSize fmet = met.size( 0L, mWelcomeText ); + + // Paint the "Welcome" message, if we are instructed to. Optionally dispense with the + // shadow. + if ( mShowWelcomeText ) + { + if( mWelcomeTextPosition == TQPoint( 0, 0 ) ) + { + mWelcomeTextPosition = TQPoint( (screen.width()/2) - fmet.width() - 25, + (screen.height()/2) - (fmet.height()/2) + fmet.height() ); + } + } + + if( mShowWelcomeText ) + { + if( mShowWelcomeTextShadow ) + { + p.setPen( mWelcomeTextShadowColor ); + p.drawText( mWelcomeTextPosition+TQPoint(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; + TQString 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 TDM icon... TODO: Make this overridable by the Theme. + if( mUseKdmUserIcon ) + { + const TQString 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; + TDEConfig *tdmconfig = new TDEConfig("tdm/tdmrc", true); + tdmconfig->setGroup("X-*-Greeter"); + TQString userPicsDir = tdmconfig->readEntry( "FaceDir", TDEGlobal::dirs()->resourceDirs("data").last() + "tdm/faces" ) + '/'; + TQString fs = tdmconfig->readEntry( "FaceSource" ); + if (fs == TQString::fromLatin1("UserOnly")) + faceSource = fUserOnly; + else if (fs == TQString::fromLatin1("PreferUser")) + faceSource = fUserFirst; + else if (fs == TQString::fromLatin1("PreferAdmin")) + faceSource = fAdminFirst; + else + faceSource = fAdminOnly; // Admin Only + delete tdmconfig; + + TQPixmap userp; + if ( faceSource == fAdminFirst ) + { + // If the administrator's choice takes preference + userp = TQPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + faceSource = fUserOnly; + } + if ( faceSource >= fUserFirst) + { + // If the user's choice takes preference + userp = TQPixmap( user.homeDir() + "/.face.icon" ); + if ( userp.isNull() && faceSource == fUserFirst ) // The user has no face, should we check for the admin's setting? + userp = TQPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = TQPixmap( userPicsDir + defSys ); + } + else if ( faceSource <= fAdminOnly ) + { + // Admin only + userp = TQPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = TQPixmap( userPicsDir + defSys ); + } + if( !userp.isNull() ) + mPixmap = userp; + } + + if( mShowIcon ) + { + TQPoint pos = mIconPosition; + if( pos == TQPoint( 0, 0 ) ) + { + pos = TQPoint( (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 = TQFontMetrics( f ); + fmet = met.size( 0L, greetingString ); + + if( mShowUsernameText ) + { + TQPoint pos = mUsernameTextPosition; + if( pos == TQPoint( 0, 0 ) ) + { + pos = TQPoint( + (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( TQPaintEvent *pe ) +{ + const TQRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + + TQPainter p; + p.begin( this ); + + TQRect r = pe->rect(); + + bitBlt( this, r.x(), r.y(), + &mImage, r.x(), r.y(), r.width(), r.height() ); + + if (mShowActionText) + { + p.setPen( mActionTextColor ); + TQFont f = mActionFont; + p.setFont( f ); + TQFontMetrics met( f ); + TQSize fmet = met.size( 0L, mText ); + + mMsgPos = mActionTextPosition; + if( mMsgPos == TQPoint( 0, 0 ) ) + { + mMsgPos = TQPoint( + (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 TQRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //TQRect fullScreen = TDEGlobalSettings::desktopGeometry(0L); + + if( !mTheme ) + return; + TDEConfig *cfg = mTheme->themeConfig(); + if( !cfg ) + return; + + //if( !cfg->hasGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ); + + // Overall appearance + mBackgroundImage = cfg->readEntry( "Background Image", TQString::null ); + mIcon = cfg->readEntry( "User Icon", "kmenu" ); + mWelcomeText = cfg->readEntry( "Welcome Text", i18n("Welcome") ); + mUsernameText = cfg->readEntry( "Username Text", TQString::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. + TQPoint absZero( 0, 0 ); + mWelcomeTextPosition = cfg->readPointEntry( TQString("Welcome Text Position %1").arg(screen.width()), &absZero ); + mUsernameTextPosition = cfg->readPointEntry( TQString("Username Text Position %1").arg(screen.width()), &absZero ); + mActionTextPosition = cfg->readPointEntry( TQString("Action Text Position %1").arg(screen.width()), &absZero ); + mIconPosition = cfg->readPointEntry( TQString("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 TDM User Icon", true ); + + // Setup our fonts. There are only 3 elements which use 'em, so this is fairly + // straightforward. + TQFont defaultFont( "Arial", 48, TQFont::Bold ); + defaultFont.setItalic( true ); + TQFont defaultUsernameFont( "Arial", 16, TQFont::Bold ); + TQFont defaultActionFont( "Arial", 12, TQFont::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 ); + + TQColor defaultDarkColor( 3, 47, 156 ); + TQColor 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..d68e004da --- /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 TDEFontCombo; +class TQCheckBox; + +class CfgRedmond: public ThemeEngineConfig +{ + Q_OBJECT +public: + CfgRedmond( TQWidget *, TDEConfig * ); + +protected: + TQCheckBox *mShowUsername; + TQCheckBox *mShowIcon; + TQCheckBox *mShowWelcome; + TDEFontCombo *mWelcomeFont; + TDEFontCombo *mUsernameFont; + TDEFontCombo *mActionFont; +}; + +class ObjKsTheme; +class ThemeRedmond: public ThemeEngine +{ + Q_OBJECT +public: + ThemeRedmond( TQWidget *, const char *, const TQStringList& ); + + inline const TQString name() { return( TQString("Redmond") ); } + static TQStringList names() + { + TQStringList Names; + Names << "Redmond"; + return( Names ); + }; + +public slots: + inline void slotSetText( const TQString& s ) + { + if( mText != s ) + { + mText = s; + repaint( false ); + } + }; + +private: + void paintEvent( TQPaintEvent * ); + + void _initUi(); + void _readSettings(); + + TQString mText; + TQPixmap mPixmap; + bool mRedrawKonqi; + TQPoint mMsgPos; + KPixmap mImage; + + // ThemeEngine configuration. + bool mShowWelcomeText; + bool mShowWelcomeTextShadow; + bool mWelcomeFontItalic; + bool mShowUsernameText; + bool mShowActionText; + bool mShowIcon; + bool mUseKdmUserIcon; + TQString mBackgroundImage; + TQString mWelcomeText; + TQString mUsernameText; // Leave this undefined to autodetect the username. + TQString mIcon; + TQFont mWelcomeFont; + TQFont mUsernameFont; + TQFont mActionFont; + TQColor mWelcomeTextColor; + TQColor mWelcomeTextShadowColor; + TQColor mUsernameTextColor; + TQColor mActionTextColor; + TQPoint mWelcomeTextPosition; // Set this to (0,0) to autoposition the text. + TQPoint mUsernameTextPosition; // Likewise. + TQPoint mActionTextPosition; // Likewise likewise. + TQPoint mIconPosition; // ... + +} +; + +#endif diff --git a/ksplashml/themeengine/simple/CMakeLists.txt b/ksplashml/themeengine/simple/CMakeLists.txt new file mode 100644 index 000000000..2b486e4f1 --- /dev/null +++ b/ksplashml/themeengine/simple/CMakeLists.txt @@ -0,0 +1,28 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_BINARY_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### ksplashsimple (executable) ################ + +tde_add_executable( ksplashsimple + SOURCES main.cpp + LINK ${TQT_LIBRARIES} X11 ${XINERAMA_LIBRARIES} + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/ksplashml/themeengine/simple/Makefile.am b/ksplashml/themeengine/simple/Makefile.am new file mode 100644 index 000000000..bed3bd5d1 --- /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) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +ksplashsimple_LDADD = $(LIB_XINERAMA) $(LIB_X11) $(LIB_QT) 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/CMakeLists.txt b/ksplashml/themeengine/standard/CMakeLists.txt new file mode 100644 index 000000000..ca85efe96 --- /dev/null +++ b/ksplashml/themeengine/standard/CMakeLists.txt @@ -0,0 +1,47 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( pics ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ksplashml/themeengine + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES Theme.rc DESTINATION ${DATA_INSTALL_DIR}/ksplash/Themes/Standard ) +install( FILES ksplashstandard.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + + +##### ksplashstandard (module) ################## + +tde_add_kpart( ksplashstandard AUTOMOC + SOURCES themestandardlib.cpp + LINK themestandard-static + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### themestandard (static) #################### + +tde_add_library( themestandard STATIC_PIC AUTOMOC + SOURCES themestandard.cpp wndicon.cpp wndstatus.cpp + LINK ksplashthemes-shared +) diff --git a/ksplashml/themeengine/standard/Makefile.am b/ksplashml/themeengine/standard/Makefile.am new file mode 100644 index 000000000..efd1fbeb1 --- /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) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +libthemestandard_la_LIBADD = $(LIB_TDEUI) ../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_TDEUI) ../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..438d5490a --- /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..78b9c559b --- /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 TDE +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 TDE Tiêu chuẩn +Name[wa]=KSplashStandård +X-TDE-ServiceTypes=KSplash/Plugin +X-TDE-Library=ksplashstandard +X-KSplash-Default=true +X-KSplash-PluginName=Standard +X-KSplash-ObjectName=ThemeStandard diff --git a/ksplashml/themeengine/standard/pics/CMakeLists.txt b/ksplashml/themeengine/standard/pics/CMakeLists.txt new file mode 100644 index 000000000..01a6355d3 --- /dev/null +++ b/ksplashml/themeengine/standard/pics/CMakeLists.txt @@ -0,0 +1,12 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +install( FILES Preview.png DESTINATION ${DATA_INSTALL_DIR}/ksplash/Themes/Standard ) 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..3fd4ce9fe --- /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..8fd950eb5 --- /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 <tdeapplication.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <tdeglobalsettings.h> +#include <kiconloader.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <tdeconfig.h> + +#include <tqdesktopwidget.h> +#include <tqlabel.h> +#include <tqpalette.h> +#include <tqpixmap.h> +#include <tqwidget.h> + +#include <objkstheme.h> +#include "themestandard.h" +#include "themestandard.moc" +#include "wndicon.h" +#include "wndstatus.h" + +ThemeStandard::ThemeStandard( TQWidget *parent, const char *name, const TQStringList &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(TQFont()), mSbFg(TQColor()), mSbBg(TQColor()), + mSbIcon("system-run"), mIconsVisible(true), mIconsJumping(true), mSplashScreen("(Default)") +{ + _readSettings(); + _initUi(); +} + +void ThemeStandard::_initUi() +{ + setFrameStyle( TQFrame::NoFrame ); + + TQString pixName = mTheme->locateThemeData( mSplashScreen ); + + if( mSplashScreen == "(Default)" || pixName.isEmpty() ) + { + TQString resource_prefix = "pics/"; + if ( mTheme->loColor() ) + resource_prefix += "locolor/"; + pixName = locate( "appdata", resource_prefix + "splash.png"); + } + + TQPixmap px = TQPixmap( pixName ); + + if( !px.isNull() ) + { + //kdDebug() << "Loaded splash " << mSplashScreen << endl; + int pw = px.width(); + int ph = px.height(); + + TQLabel *lbl = new TQLabel( 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 TQRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + // TDEGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + move( rect.x() + (rect.width() - size().width())/2, + rect.y() + (rect.height() - size().height())/2 ); + + mStatus = new WndStatus( TQPalette(), mTheme->xineramaScreen(), mSbAtTop, mSbPbVisible, mSbFont, mSbFg, mSbBg, mSbIcon ); +} + +void ThemeStandard::showEvent( TQShowEvent * ) +{ + + ThemeEngine::show(); + + if( mSbVisible ) + { + mStatus->show(); + mStatusBarHeight = mStatus->height(); + } + else + { + mStatusBarHeight = 0L; + } +} + +// Adjust the visible icon. +void ThemeStandard::slotSetPixmap( const TQString& pxn ) +{ + TQPixmap 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, TQString::null, mIconPos, mSbAtTop, mIconsJumping ); + mIcon->show(); + + if( mIconsJumping ) + { + emit mIcon->slotJump(); + mPrevIcon = mIcon; + } +} + +void ThemeStandard::_readSettings() +{ + + if ( !mTheme ) + return; + + TDEConfig *cfg = mTheme->themeConfig(); + if ( !cfg ) + return; + + //if ( !cfg->hasGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ); + + TQString 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 = TQFont( mSbFontName, mSbFontSz, ( mSbFontBold? TQFont::Bold : TQFont::Normal ) ); + if( mSbFontItalic ) + mSbFont.setItalic( true ); + + mSbFg = cfg->readColorEntry( "Statusbar Foreground", &TQt::white ); + mSbBg = cfg->readColorEntry( "Statusbar Background", &TQt::black ); + mSbIcon = cfg->readEntry( "Statusbar Icon", "system-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..a1fb61ccf --- /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( TQWidget *, const char*, const TQStringList& ); + //inline const ThemeEngineConfig *config( TQWidget *p, TDEConfig *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 TQString& s ) + { + if( mStatus ) mStatus->slotSetMessage( s ); + } + void slotSetPixmap( const TQString& ); + +private: + void showEvent( TQShowEvent * ); + void _readSettings(); + void _initUi(); + + WndStatus *mStatus; + WndIcon *mIcon, *mPrevIcon; + int mIconCount; + int mStatusBarHeight; + int mStdIconWidth; + + WndIcon::Position mIconPos; + bool mSbAtTop; + bool mSbVisible; + bool mSbPbVisible; + TQString mSbFontName; + int mSbFontSz; + bool mSbFontBold; + bool mSbFontItalic; + TQFont mSbFont; + TQColor mSbFg; + TQColor mSbBg; + TQString mSbIcon; + bool mIconsVisible; + bool mIconsJumping; + TQString 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..856547895 --- /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 <tdeapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kdebug.h> +#include <tdeglobalsettings.h> +#include <twin.h> + +#include <tqdesktopwidget.h> +#include <tqhbox.h> +#include <tqlabel.h> +#include <tqpixmap.h> +#include <tqpoint.h> +#include <tqtimer.h> +#include <tqwidget.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 TQString& text, + Position icon_position, + bool statusAtTop, + bool iconsJumping ) + :TQHBox( 0, "wndSplash", (WFlags)(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( TQFrame::NoFrame ); + + TQLabel *w = new TQLabel( 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. + TQPoint p = determinePosition(); + mGroundX = mPosX = p.x(); + mGroundY = mPosY = p.y(); + move( p + kapp->desktop()->screenGeometry( mXineramaScreen ).topLeft() ); + + if( mIconJumping ) + { + TQTimer *t = new TQTimer( this ); + connect(t, TQT_SIGNAL(timeout()), TQT_SLOT(slotJump())); + t->start( 50, false ); + } +} + +void WndIcon::show() +{ + emit setStatusText( mStatusText ); + TQHBox::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. + */ +TQPoint WndIcon::determinePosition() +{ + int DW, DH, SBH, wid, X, Y, x, y, nSlot, topshift, bottomshift; + + bottomshift = topshift = 0; + const TQRect srect = kapp->desktop()->screenGeometry( mXineramaScreen ); + // TDEGlobalSettings::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 = TQMAX(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 = TQMAX(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 = TQMAX(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 = TQMAX(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 = TQMAX(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 = TQMAX(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 = TQMAX(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 = TQMAX(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( TQPoint( 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( TQPoint( 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..5338835a4 --- /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 <tqhbox.h> + +/** + * @short Displays an icon on the screen. + */ +class WndIcon: + public TQHBox +{ + 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 TQString&, Position, bool, bool ); + +signals: + void setStatusText( const TQString& ); + +public slots: + void show(); + void noshow(); + void slotStopJumping(); + void slotJump(); + +private: + TQPoint determinePosition(); + +protected: + TQString 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..db397a055 --- /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 <tdeapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <tdeglobalsettings.h> +#include <kiconloader.h> +#include <kprogress.h> +#include <twin.h> + +#include <tqdesktopwidget.h> +#include <tqhbox.h> +#include <tqlabel.h> +#include <tqpoint.h> +#include <tqrect.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( TQPalette /*pal*/, + int xineramaScreen, + bool atTop, bool pbVisible, + const TQFont& font, + const TQColor& fgc, const TQColor & bgc, + const TQString& icon + ) + :TQHBox( 0, "wndStatus", (WFlags)(WStyle_Customize|WX11BypassWM) ) +{ + setFrameStyle( TQFrame::NoFrame ); + //setPalette( pal ); + setPaletteBackgroundColor( bgc ); + setPaletteForegroundColor( fgc ); + setCursor( KCursor::blankCursor() ); + setSpacing( 5 ); + + const TQRect rect = kapp->desktop()->screenGeometry( xineramaScreen ); + // TDEGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + TQLabel *pix = new TQLabel( this ); + TQPixmap _icon( SmallIcon(icon.isNull()||icon.isEmpty()?TQString("system-run"):icon) ); + pix->setPixmap( _icon ); + setStretchFactor(pix,0); + pix->setFixedWidth(16); + + m_label = new TQLabel( this ); + m_label->setFont( font ); + m_label->setPaletteBackgroundColor( bgc ); + m_label->setPaletteForegroundColor( fgc ); + //TQFontMetrics metrics( font ); + //m_label->setFixedHeight( metrics.height() ); + m_label->setText(TQString("")); + 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); + + TQWidget *widg = new TQWidget( this ); + setStretchFactor(widg,50); + + setFixedSize( rect.width(), TQMAX(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 TQString& 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..bc908779d --- /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 <tqhbox.h> + +class TQLabel; +class KProgress; + +/** @short Window displaying status and progress bar. */ +class WndStatus: + public TQHBox +{ + Q_OBJECT +public: + WndStatus( TQPalette, + int, // Xinerama screen + bool, // At top? + bool, // Progress indicator visible? + const TQFont&, // Status bar font + const TQColor&, const TQColor &, // Foreground/Background color + const TQString& // Icon + ); + +public slots: + void slotSetMessage( const TQString& ); + void slotUpdateProgress( int ); + void slotUpdateSteps( int ); + +protected: + TQLabel *m_label; + KProgress *m_progress; +}; +#endif diff --git a/ksplashml/themeengine/themeengine.cpp b/ksplashml/themeengine/themeengine.cpp new file mode 100644 index 000000000..9a7d3aba5 --- /dev/null +++ b/ksplashml/themeengine/themeengine.cpp @@ -0,0 +1,139 @@ +/*************************************************************************** + * 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 <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <tdeglobal.h> +#include <twin.h> + +#include <tqevent.h> +#include <tqfile.h> +#include <tqwidget.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 +{ + TQValueList< Window > mSplashWindows; +}; + +ThemeEngine::ThemeEngine( TQWidget *, const char *, const TQStringList& args ) + : TQVBox( 0, "wndSplash", (WFlags)(WStyle_Customize|WX11BypassWM) ), d(0), mUseWM(false) +{ + d = new ThemeEnginePrivate; + kapp->installX11EventFilter( this ); + kapp->installEventFilter( this ); + (void)kapp->desktop(); + XWindowAttributes rootAttr; + XGetWindowAttributes(tqt_xdisplay(), RootWindow(tqt_xdisplay(), + tqt_xscreen()), &rootAttr); + XSelectInput( tqt_xdisplay(), tqt_xrootwin(), + SubstructureNotifyMask | rootAttr.your_event_mask ); + if (args.isEmpty()) + mTheme = new ObjKsTheme( "Default" ); + else + mTheme = new ObjKsTheme( args.first() ); + if (args.first() == "Unified") { + mUseWM = true; + } + mTheme->loadCmdLineArgs( TDECmdLineArgs::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( TQObject* o, TQEvent* e ) +{ + if( e->type() == TQEvent::Show && o->isWidgetType()) + addSplashWindow( TQT_TQWIDGET( o )); + return false; +} + +namespace +{ +class HackWidget : public TQWidget { friend class ::ThemeEngine; }; +} + +void ThemeEngine::addSplashWindow( TQWidget* w ) +{ + if( !w->isTopLevel()) + return; + if( d->mSplashWindows.contains( w->winId())) + return; + if( !w->testWFlags( WX11BypassWM ) && (mUseWM == false)) + { // 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( tqt_xdisplay(), w->winId(), CWOverrideRedirect, &attrs ); + } + d->mSplashWindows.prepend( w->winId()); + connect( w, TQT_SIGNAL( destroyed( TQObject* )), TQT_SLOT( splashWindowDestroyed( TQObject* ))); + w->raise(); +} + +void ThemeEngine::splashWindowDestroyed( TQObject* obj ) +{ + d->mSplashWindows.remove( TQT_TQWIDGET( obj )->winId()); +} + +bool ThemeEngine::x11Event( XEvent* e ) +{ + if( e->type != ConfigureNotify && e->type != MapNotify ) + return false; + if( e->type == ConfigureNotify && e->xconfigure.event != tqt_xrootwin()) + return false; + if( e->type == MapNotify && e->xmap.event != tqt_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( tqt_xdisplay(), d->mSplashWindows.first()); // raise topmost + // and stack others below it + Window* stack = new Window[ d->mSplashWindows.count() ]; + int count = 0; + for( TQValueList< 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..fa2f15a65 --- /dev/null +++ b/ksplashml/themeengine/themeengine.h @@ -0,0 +1,84 @@ +/*************************************************************************** + * 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 <tqstringlist.h> +#include <tqvbox.h> +#include <tqwidget.h> + +#include <kdemacros.h> + +class TDEConfig; +class ObjKsTheme; +class TQMouseEvent; + +/** + * @short The base for the ThemeEngine's configuration widget. + */ +class KDE_EXPORT ThemeEngineConfig: public TQVBox +{ + Q_OBJECT +public: + + ThemeEngineConfig( TQWidget *p, TDEConfig *c ) + :TQVBox( p ), mConfig( c ) + {} + + TDEConfig* config()const { return mConfig; } + +public slots: + virtual void load() {} + virtual void save() {} + +protected: + TDEConfig *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 TQVBox +{ + Q_OBJECT +public: + ThemeEngine( TQWidget *parent, const char *name, const TQStringList &args ); + virtual ~ThemeEngine() = 0; + virtual const ThemeEngineConfig *config( TQWidget *, TDEConfig * ) { return 0L; } + virtual ObjKsTheme *ksTheme() { return mTheme; } + virtual bool eventFilter( TQObject* o, TQEvent* e ); + +public slots: + virtual void slotUpdateProgress( int ) {} + virtual void slotUpdateSteps( int ) {} + virtual void slotSetText( const TQString& ) {} + virtual void slotSetTextIndex( const int ) {} + virtual void slotSetPixmap( const TQString& ) {} // use DesktopIcon() to load this. + +protected: + void addSplashWindow( TQWidget* ); + +protected: + ObjKsTheme *mTheme; + virtual bool x11Event( XEvent* ); + +private slots: + void splashWindowDestroyed( TQObject* ); + +private: + class ThemeEnginePrivate; + ThemeEnginePrivate *d; + bool mUseWM; +}; + +#endif diff --git a/ksplashml/themeengine/unified/CMakeLists.txt b/ksplashml/themeengine/unified/CMakeLists.txt new file mode 100644 index 000000000..5200fb060 --- /dev/null +++ b/ksplashml/themeengine/unified/CMakeLists.txt @@ -0,0 +1,45 @@ +################################################# +# +# (C) 2010-2011 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + #${CMAKE_CURRENT_SOURCE_DIR} + #${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/ksplashml/themeengine + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES ksplashunified.desktop DESTINATION ${SERVICES_INSTALL_DIR} ) + + +##### ksplashunified (module) ################### + +tde_add_kpart( ksplashunified AUTOMOC + SOURCES main.cpp + LINK themeunified-static ksplashthemes-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) + + +##### themeunified (static) ##################### + +tde_add_library( themeunified STATIC_PIC AUTOMOC + SOURCES themeunified.cpp + LINK ksplashthemes-shared +) diff --git a/ksplashml/themeengine/unified/Makefile.am b/ksplashml/themeengine/unified/Makefile.am new file mode 100644 index 000000000..b117cbb29 --- /dev/null +++ b/ksplashml/themeengine/unified/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) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_TDEIO) -ltdetexteditor +libthemedefault_la_LIBADD = $(LIB_TDEUI) ../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_TDEUI) ../libksplashthemes.la libthemedefault.la +METASOURCES = AUTO + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashdefault.desktop diff --git a/ksplashml/themeengine/unified/ksplashunified.desktop b/ksplashml/themeengine/unified/ksplashunified.desktop new file mode 100644 index 000000000..6b263eef2 --- /dev/null +++ b/ksplashml/themeengine/unified/ksplashunified.desktop @@ -0,0 +1,78 @@ +[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 TDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashUnified +X-TDE-ServiceTypes=KSplash/Plugin +X-TDE-Library=ksplashunified +X-KSplash-Default=true +X-KSplash-PluginName=Unified +X-KSplash-ObjectName=ThemeUnified diff --git a/ksplashml/themeengine/unified/main.cpp b/ksplashml/themeengine/unified/main.cpp new file mode 100644 index 000000000..a28cf5952 --- /dev/null +++ b/ksplashml/themeengine/unified/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 "themeunified.h" + +K_EXPORT_COMPONENT_FACTORY( ksplashunified, KGenericFactory<ThemeUnified>( "ksplash" ) ) diff --git a/ksplashml/themeengine/unified/themeunified.cpp b/ksplashml/themeengine/unified/themeunified.cpp new file mode 100644 index 000000000..0a2eb6343 --- /dev/null +++ b/ksplashml/themeengine/unified/themeunified.cpp @@ -0,0 +1,118 @@ +/*************************************************************************** + * 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 <tdeapplication.h> +#include <tdeconfig.h> +#include <kdebug.h> +#include <kgenericfactory.h> +#include <tdeglobalsettings.h> +#include <tdelocale.h> +#include <kstandarddirs.h> +#include <kprogress.h> + +#include <tqcheckbox.h> +#include <tqdesktopwidget.h> +#include <tqlabel.h> +#include <tqpainter.h> +#include <tqpixmap.h> +#include <tqwidget.h> +#include <tqtimer.h> +#include <tqcursor.h> + +#include "objkstheme.h" +#include "themeengine.h" +#include "themeunified.h" +#include "themeunified.moc" + +UnifiedConfig::UnifiedConfig( TQWidget *parent, TDEConfig *config ) + :ThemeEngineConfig( parent, config ) +{ + mConfig->setGroup( TQString("KSplash Theme: Default") ); + TQVBox *hbox = new TQVBox( this ); + mAlwaysShow = new TQCheckBox( i18n("Always show progress bar"), hbox ); + mAlwaysShow->setChecked( mConfig->readBoolEntry("Always Show Progress",true) ); +} + +void UnifiedConfig::save() +{ + kdDebug() << "UnifiedConfig::save()" << endl; + mConfig->setGroup( TQString("KSplash Theme: Default") ); + mConfig->writeEntry( "Always Show Progress", mAlwaysShow->isChecked() ); + mConfig->sync(); +} + +ThemeUnified::ThemeUnified( TQWidget *parent, const char *name, const TQStringList &args ) + :ThemeEngine( parent, name, args ) +{ + + mState = 0; + + _readSettings(); + _initUi(); +} + +ThemeUnified::~ThemeUnified() +{ + if (mSysModalDialog) { + KSMModalDialog* temp = mSysModalDialog; + mSysModalDialog = NULL; + temp->closeSMDialog(); + } +} + +void ThemeUnified::_initUi() +{ + resize(10,10); + + mSysModalDialog = new KSMModalDialog(this); + mSysModalDialog->setStatusMessage(i18n("Trinity is starting up").append("...")); + mSysModalDialog->show(); + mSysModalDialog->setActiveWindow(); + + const TQRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + + // Center the dialog + TQSize sh = sizeHint(); + TQRect rect1 = TDEGlobalSettings::desktopGeometry(TQCursor::pos()); + move(rect1.x() + (rect1.width() - sh.width())/2, rect1.y() + (rect1.height() - sh.height())/2); +} + +// Attempt to find overrides elsewhere? +void ThemeUnified::_readSettings() +{ + if( !mTheme ) + return; + + TDEConfig *cfg = mTheme->themeConfig(); + if( !cfg ) + return; + + cfg->setGroup( TQString("KSplash Theme: %1").arg(mTheme->theme()) ); + + TQColor df(Qt::white); + mLabelForeground = cfg->readColorEntry( "Label Foreground", &df ); +} + +/* + * ThemeUnified::slotUpdateState(): IF in Default mode, THEN adjust the bar + * pixmap label. Whee, phun! + * + * A similar method exists in the old KSplash. + */ +void ThemeUnified::slotUpdateState() +{ + if( mState > 8 ) + mState = 8; + +// mBarLabel->setPixmap( updateBarPixmap( mState ) ); + + mState++; +} diff --git a/ksplashml/themeengine/unified/themeunified.h b/ksplashml/themeengine/unified/themeunified.h new file mode 100644 index 000000000..cd6a1d1ca --- /dev/null +++ b/ksplashml/themeengine/unified/themeunified.h @@ -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.) * + * * + ***************************************************************************/ + +#ifndef __THEMEUNIFIED_H__ +#define __THEMEUNIFIED_H__ + +#include <kprogress.h> + +#include <tqlabel.h> +#include <tqwidget.h> + +#include <kdialog.h> + +#include "themeengine.h" +class TQPixmap; +class TQTimer; + +class TQCheckBox; + +class UnifiedConfig: public ThemeEngineConfig +{ + Q_OBJECT +public: + UnifiedConfig( TQWidget *, TDEConfig * ); + void save(); +protected: + TQCheckBox *mAlwaysShow; +}; + +/** + * @short Traditional Trinity splash screen. + */ +class ObjKsTheme; +class KDE_EXPORT ThemeUnified : public ThemeEngine +{ + Q_OBJECT +public: + ThemeUnified( TQWidget *, const char *, const TQStringList& ); + virtual ~ThemeUnified(); + + inline const UnifiedConfig *config( TQWidget *p, TDEConfig *c ) + { + return new UnifiedConfig( p, c ); + }; + + static TQStringList names() + { + TQStringList Names; + Names << "Unified"; + return( Names ); + } + +public slots: + inline void slotSetText( const TQString& s ) + { + close(); + if (mSysModalDialog) mSysModalDialog->setStatusMessage(TQString(s).append("...")); + } + inline void slotSetTextIndex( const int i ) + { + if (i == 3) { + if (mSysModalDialog) { + KSMModalDialog* temp = mSysModalDialog; + mSysModalDialog = NULL; + temp->closeSMDialog(); + } + } + } + inline void slotUpdateSteps( int s ) + { + } + inline void slotUpdateProgress( int i ) + { + } + + +private slots: + void slotUpdateState(); + +private: + void _initUi(); + void _readSettings(); + + // Configurable Options + TQColor mLabelForeground; + + // Internals. + KSMModalDialog* mSysModalDialog; + int mState; +}; + +#endif |