diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /ksplashml/themeengine/redmond | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ksplashml/themeengine/redmond')
-rw-r--r-- | ksplashml/themeengine/redmond/Makefile.am | 18 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/Theme.rc | 2 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/ksplashredmond.desktop | 96 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/main.cpp | 38 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/pics/Background.png | bin | 0 -> 32680 bytes | |||
-rw-r--r-- | ksplashml/themeengine/redmond/pics/Makefile.am | 4 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/pics/Preview.png | bin | 0 -> 10541 bytes | |||
-rw-r--r-- | ksplashml/themeengine/redmond/previewredmond.cpp | 113 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/previewredmond.h | 104 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/themeredmond.cpp | 365 | ||||
-rw-r--r-- | ksplashml/themeengine/redmond/themeredmond.h | 103 |
11 files changed, 843 insertions, 0 deletions
diff --git a/ksplashml/themeengine/redmond/Makefile.am b/ksplashml/themeengine/redmond/Makefile.am new file mode 100644 index 000000000..70f8cfb1c --- /dev/null +++ b/ksplashml/themeengine/redmond/Makefile.am @@ -0,0 +1,18 @@ +SUBDIRS = pics + +INCLUDES = -I$(top_srcdir)/ksplashml/themeengine $(all_includes) + +ksplashredmond_la_SOURCES = previewredmond.cpp themeredmond.cpp +ksplashredmond_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) +ksplashredmond_la_LIBADD = $(LIB_KDEUI) $(LIB_KIO) ../libksplashthemes.la +METASOURCES = AUTO + +kde_module_LTLIBRARIES = ksplashredmond.la + +noinst_HEADERS = themeredmond.h previewredmond.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashredmond.desktop + +themedir = $(kde_datadir)/ksplash/Themes/Redmond +theme_DATA = Theme.rc diff --git a/ksplashml/themeengine/redmond/Theme.rc b/ksplashml/themeengine/redmond/Theme.rc new file mode 100644 index 000000000..3c5b0687e --- /dev/null +++ b/ksplashml/themeengine/redmond/Theme.rc @@ -0,0 +1,2 @@ +[KSplash Theme: Redmond] +Engine=Redmond diff --git a/ksplashml/themeengine/redmond/ksplashredmond.desktop b/ksplashml/themeengine/redmond/ksplashredmond.desktop new file mode 100644 index 000000000..fd70c5f3a --- /dev/null +++ b/ksplashml/themeengine/redmond/ksplashredmond.desktop @@ -0,0 +1,96 @@ +[Desktop Entry] +Type=Service +Comment=KSplash Plugin +Comment[af]=KSplash Inprop module +Comment[ar]=ملحق للشاشة الافتتاحية +Comment[az]=KSplash Əlavəsi +Comment[be]=Утулка KSplash +Comment[bg]=Приставка KSplash +Comment[bn]=কে-স্প্ল্যাশ প্লাগ-ইন +Comment[br]=Lugent KSplash +Comment[bs]=KSplash dodatak +Comment[ca]=Connector per a KSplash +Comment[cs]=Modul aplikaci KSplash +Comment[csb]=Plugins KSplash +Comment[cy]=Ategyn KCroeso +Comment[da]=KSplash-plugin +Comment[de]=KSplash-Plugin +Comment[el]=Πρόσθετο KSplash +Comment[eo]=Ksalutŝilda kromaĵo +Comment[es]=Complemento KSplash +Comment[et]=KSplashi plugin +Comment[eu]=KSplash plugina +Comment[fa]=وصلۀ KSplash +Comment[fi]=KSplash-liitännäinen +Comment[fr]=Modules de KSplash +Comment[fy]=KSplash-plugin +Comment[ga]=Breiseán KSplash +Comment[gl]=Plugin de KSplash +Comment[he]=תוסף KSplash +Comment[hi]=के-स्प्लैश प्लगइन +Comment[hr]=KSplash dodatak +Comment[hu]=KSplash bővítőmodul +Comment[is]=KSplash íforrit +Comment[it]=Plugin KSplash +Comment[ja]=KSplash プラグイン +Comment[ka]=KSplash პლაგინი +Comment[kk]=KSplash модулі +Comment[km]=កម្មវិធីជំនួយខាងក្នុងរបស់ KSplash +Comment[lt]=KSplash įskiepis +Comment[lv]=KSplash spraudnis +Comment[mk]=Приклучок за KSplash +Comment[ms]=Plugin KSplash +Comment[mt]=Plugin ta' KSplash +Comment[nb]=Programtillegg Ksplash +Comment[ne]=के स्प्लयास प्लगइन +Comment[nl]=KSplash-plugin +Comment[nn]=KSplash-programtillegg +Comment[pa]=ਕੇ-ਸਪਲੇਸ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka KSplash +Comment[pt]='Plugin' do KSplash +Comment[pt_BR]=Plug-in do KSplash +Comment[ro]=Modul KSplash +Comment[ru]=Модуль KSplash +Comment[rw]=Icomeka rya K-Gukwiza +Comment[se]=KSplash-lassemoduvla +Comment[sk]=Modul KSplash +Comment[sl]=Vstavek KSplash +Comment[sr]=KSplash прикључак +Comment[sr@Latn]=KSplash priključak +Comment[sv]=Insticksprogram för startskärm +Comment[ta]=Kஸ்ப்ளாஷ் செருகு பொருள் +Comment[tg]=Мутассалкунандаи KSplash +Comment[th]=ปลั๊กอิน KSplash +Comment[tr]=KSplash Eklentisi +Comment[tt]=KSplash atlı Östämä +Comment[uk]=Втулок KSplash +Comment[uz]=KSplash plagini +Comment[uz@cyrillic]=KSplash плагини +Comment[vi]=Trình bổ sung Chào mừng KDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashRedmond +Name[af]=KSplash Redmond +Name[be]=Тэма Redmond +Name[ca]=KSplash de Redmond +Name[cs]=Redmond +Name[cy]=KCroesoRedmond +Name[de]=KSplash Redmond +Name[eo]=Redmondo +Name[et]=KSplash Redmond +Name[hi]=के-स्प्लैश-रेडमण्ड +Name[ne]=के स्प्लयास रेडमोन्ड +Name[pa]=ਕੇਸਪਲੇਸਰੀਮੋਂਡ +Name[pt_BR]=Tela de Apresentação de Redmond +Name[sv]=Redmond startskärm +Name[ta]=Kஸ்ப்ளாஷ்ரெட்மான் +Name[tg]=РайдмондиKSplash +Name[th]=KSplash แบบเรดมอนด์ +Name[vi]=Chào mừng KDE Redmond +Name[zh_TW]=KSplachRedmond +ServiceTypes=KSplash/Plugin +X-KDE-Library=ksplashredmond +X-KSplash-Default=true +X-KSplash-PluginName=Redmond +X-KSplash-ObjectName=ThemeRedmond diff --git a/ksplashml/themeengine/redmond/main.cpp b/ksplashml/themeengine/redmond/main.cpp new file mode 100644 index 000000000..2da3c5f09 --- /dev/null +++ b/ksplashml/themeengine/redmond/main.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <kstandarddirs.h> + +#include <qlabel.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include "themeredmond.h" + +extern "C" +{ + ThemeEngineConfig *KsThemeConfig( QWidget *parent, KConfig *config ) + { + return new CfgRedmond( parent, config ); + } + + QStringList KsThemeSupports() + { + return ThemeRedmond::names(); + } + + void* KsThemeInit( QWidget *parent, ObjKsTheme *theme ) + { + return new ThemeRedmond( parent, theme ); + } +} + diff --git a/ksplashml/themeengine/redmond/pics/Background.png b/ksplashml/themeengine/redmond/pics/Background.png Binary files differnew file mode 100644 index 000000000..a38a55d42 --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Background.png diff --git a/ksplashml/themeengine/redmond/pics/Makefile.am b/ksplashml/themeengine/redmond/pics/Makefile.am new file mode 100644 index 000000000..31181e3ae --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Preview.png Background.png + +themedir = $(kde_datadir)/ksplash/Themes/Redmond +theme_DATA = $(EXTRA_DIST) diff --git a/ksplashml/themeengine/redmond/pics/Preview.png b/ksplashml/themeengine/redmond/pics/Preview.png Binary files differnew file mode 100644 index 000000000..a52ec2644 --- /dev/null +++ b/ksplashml/themeengine/redmond/pics/Preview.png diff --git a/ksplashml/themeengine/redmond/previewredmond.cpp b/ksplashml/themeengine/redmond/previewredmond.cpp new file mode 100644 index 000000000..6685a6987 --- /dev/null +++ b/ksplashml/themeengine/redmond/previewredmond.cpp @@ -0,0 +1,113 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <klocale.h> + +#include <qpainter.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include "previewredmond.h" +#include "previewredmond.moc" +/* + * PreviewRedmond::PreviewRedmond(): Constructor. Set up some basic + * things. + */ +PreviewRedmond::PreviewRedmond( QWidget* parent ) + :QWidget( parent ), + + /* Using direct constructors to prevent memory blit. */ + m_welcomeString (i18n("Welcome")), + m_userString (i18n("(Your Name)")), + + m_welcomeFont (QFont( "Arial", 16, QFont::Bold )), + m_userFont (QFont( "Arial", 16 )), + m_statusFont (QFont( "Arial", 12, QFont::Bold )), + + m_welcomeColor (Qt::white), + m_welcomeShadowColor (Qt::darkGray), + m_userColor (Qt::darkGray), + m_statusColor (Qt::white), + + m_icon (DesktopIcon("kmenu")), + + m_showWelcomeString (true), + m_showUserString (true), + m_showUserIcon (true), + m_showStatusString (true) +{ + _updateCache(); +} + +void PreviewRedmond::paintEvent( QPaintEvent* pe ) +{ + QPainter p; + p.begin( this ); + p.drawPixmap( pe->rect(), m_cache ); + p.end(); +} + +void PreviewRedmond::resizeEvent( QResizeEvent *re ) +{ + QWidget::resizeEvent( re ); + _updateCache(); +} + +// PreviewRedmond::_updateCache(): Based on our current settings, we need +// to adjust our cached image. We'll slick it and create a new QPixmap +// from size(), just to be sure we're not missing anything. +void PreviewRedmond::_updateCache() +{ + m_cache = QPixmap( size() ); + QPainter p; + p.begin( &m_cache ); + + p.fillRect( rect(), Qt::gray ); + + m_welcomeFont.setItalic( true ); + p.setFont( m_welcomeFont ); + + QPoint welcomeTextPos( rect().width()/2 - p.fontMetrics().width( m_welcomeString ), + rect().height()/2 + p.fontMetrics().height()/2 ); + + if( m_showWelcomeString ) + { + p.setPen( m_welcomeShadowColor ); + p.drawText( welcomeTextPos.x()+2, welcomeTextPos.y()+2, m_welcomeString ); + p.setPen( m_welcomeColor ); + p.drawText( welcomeTextPos, m_welcomeString ); + } + + if( m_showUserString ) + { + p.setPen( m_userColor ); + p.setFont( m_userFont ); + QPoint userTextPos( rect().width()/2 + m_icon.width() + 20, + rect().height()/2 + p.fontMetrics().height()/2 ); + p.drawText( userTextPos, m_userString ); + } + + if( m_showUserIcon ) + p.drawPixmap( rect().width()/2 + 10, rect().height()/2, m_icon ); + + if( m_showStatusString ) + { + QPoint statusTextPos( rect().width()/2 + m_icon.width() + 20, + rect().height()/2 + (int)(p.fontMetrics().height()*0.85) + 15 ); + p.setPen( m_statusColor ); + p.setFont( m_statusFont ); + p.drawText( statusTextPos, i18n("Starting KDE...") ); + } + + p.end(); + update( rect() ); +} diff --git a/ksplashml/themeengine/redmond/previewredmond.h b/ksplashml/themeengine/redmond/previewredmond.h new file mode 100644 index 000000000..3b67f293b --- /dev/null +++ b/ksplashml/themeengine/redmond/previewredmond.h @@ -0,0 +1,104 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#ifndef __PREVIEWREDMOND_H__ +#define __PREVIEWREDMOND_H__ + +#include <kiconloader.h> + +#include <qcolor.h> +#include <qfont.h> +#include <qwidget.h> + +/* + * class PreviewRedmond: Provides a sneak peek at how certain Redmond + * settings will look. This will not be able to render any background + * images, so we'll just use a nice shade of gray or black as the + * background... + */ +class PreviewRedmond: public QWidget +{ + Q_OBJECT +public: + + PreviewRedmond( QWidget* ); + + inline void setWelcomeString( const QString& s ) + { + m_welcomeString = s; + _updateCache(); + } + inline void setUserString( const QString& s ) + { + m_userString = s; + _updateCache(); + } + + inline void setWelcomeFont( const QFont& f ) + { + m_welcomeFont = f; + _updateCache(); + } + inline void setUserFont( const QFont& f ) + { + m_userFont = f; + _updateCache(); + } + inline void setStatusFont( const QFont& f ) + { + m_statusFont = f; + _updateCache(); + } + + inline void setWelcomeColor( const QColor& c ) + { + m_welcomeColor = c; + _updateCache(); + } + inline void setWelcomeShadowColor( const QColor& c ) + { + m_welcomeShadowColor = c; + _updateCache(); + } + inline void setUserColor( const QColor& c ) + { + m_userColor = c; + _updateCache(); + } + inline void setStatusColor( const QColor& c ) + { + m_statusColor = c; + _updateCache(); + } + + inline void setIcon( const QString& s ) + { + m_icon = DesktopIcon( s ); + _updateCache(); + } + +protected: + void _updateCache(); + void paintEvent( QPaintEvent* ); + void resizeEvent( QResizeEvent* ); + + QPixmap m_cache; + + QString m_welcomeString, m_userString; + QFont m_welcomeFont, m_userFont, m_statusFont; + QColor m_welcomeColor, m_welcomeShadowColor, m_userColor, m_statusColor; + QPixmap m_icon; + + bool m_showWelcomeString, m_showUserString, m_showUserIcon, m_showStatusString; +}; + +#endif diff --git a/ksplashml/themeengine/redmond/themeredmond.cpp b/ksplashml/themeengine/redmond/themeredmond.cpp new file mode 100644 index 000000000..6181980b6 --- /dev/null +++ b/ksplashml/themeengine/redmond/themeredmond.cpp @@ -0,0 +1,365 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <pwd.h> +#include <sys/types.h> +#include <unistd.h> + +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kfontcombo.h> +#include <kgenericfactory.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kuser.h> +#include <kemailsettings.h> + +#include <qcheckbox.h> +#include <qdesktopwidget.h> +#include <qlabel.h> +#include <qpainter.h> +#include <qrect.h> +#include <qstringlist.h> +#include <qwidget.h> + +#include <objkstheme.h> +#include "themeredmond.h" +#include "previewredmond.h" +#include "themeredmond.moc" + +K_EXPORT_COMPONENT_FACTORY( ksplashredmond, KGenericFactory<ThemeRedmond>( "ksplash" ) ) + +CfgRedmond::CfgRedmond( QWidget *p, KConfig *c ) + :ThemeEngineConfig( p, c ) +{ + QVBox *vbox = new QVBox( this ); + vbox->setSpacing( KDialog::spacingHint() ); + + QFont defaultFont( "Arial", 48, QFont::Bold ); + defaultFont.setItalic( true ); + QFont defaultUsernameFont( "Arial", 16, QFont::Bold ); + QFont defaultActionFont( "Arial", 12, QFont::Bold ); + QColor defaultDarkColor( 3, 47, 156 ); + QColor defaultWhiteColor( Qt::white ); + + QHBox *hbox = new QHBox( vbox ); + hbox->setFrameStyle( QFrame::WinPanel ); + hbox->setFrameShadow( QFrame::Sunken ); + PreviewRedmond* _preview = new PreviewRedmond( hbox ); + _preview->setFixedSize( 320, 200 ); + + _preview->setWelcomeString( c->readEntry( "Welcome Text", i18n("Welcome") ) ); + + _preview->setWelcomeFont( c->readFontEntry( "Welcome Font", &defaultFont ) ); + _preview->setUserFont( c->readFontEntry( "Username Font", &defaultUsernameFont ) ); + _preview->setStatusFont( c->readFontEntry( "Action Font", &defaultActionFont ) ); + + _preview->setWelcomeColor( c->readColorEntry( "Welcome Text Color", &defaultWhiteColor ) ); + _preview->setWelcomeShadowColor( c->readColorEntry( "Welcome Shadow Color", &defaultDarkColor ) ); + _preview->setUserColor( c->readColorEntry( "Username Text Color", &defaultWhiteColor ) ); + _preview->setStatusColor( c->readColorEntry( "Action Text Color", &defaultDarkColor ) ); + + _preview->setIcon( c->readEntry( "User Icon", "kmenu" ) ); + + QLabel *lbl = new QLabel( vbox ); + lbl->setText( i18n("(Sorry, but I haven't finished writing this one yet...)") ); +} + +ThemeRedmond::ThemeRedmond( QWidget *parent, const char *name, const QStringList &args ) + :ThemeEngine( parent, name, args ) +{ + _readSettings(); + _initUi(); +} + +void ThemeRedmond::_initUi() +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //QRect fullScreen = KGlobalSettings::desktopGeometry(0L); + + mImage.resize( screen.width(), screen.height() ); + + QPainter p; + p.begin( &mImage ); + p.fillRect( screen, QColor(3,47,156) ); + p.setPen( mActionTextColor ); + + QString bgimg; + + // Start by seeing if the theme prefers a particular image. + if( !mBackgroundImage.isEmpty() ) + bgimg = mTheme->locateThemeData( mBackgroundImage ); + + /* + * See if there is a resolution-specific background in THEMEDIR + * before looking for the "generic" one. Having a Background.png + * file for each resolution will greatly reduce the amount of time + * it takes to initialize this ThemeEngine when running, due to + * the fact that no scaling will be necessary to display the image. + * + * File must be named THEMEDIR/Background-WWWxHHH.png -- for example, + * Mytheme/Background-1024x768.png + * + * ADDITIONAL NOTE: The resolution you specify will be obtained from + * the PRIMARY SCREEN ONLY when running in XINERAMA mode. Be sure to + * provide backgrounds using common resolutions (I recommend at least + * providing 640x480 [unofficially unsupported by KDE], 800x600, and + * 1024x768 images.) + */ + if( bgimg.isEmpty() ) + bgimg = mTheme->locateThemeData( QString( "Background-%2x%3.png" ).arg( screen.width() ).arg( screen.height() ) ); + + // If that can't be found, look for THEMEDIR/Background.png + if( bgimg.isNull() && !mTheme->themeDir().isNull() ) + bgimg = mTheme->locateThemeData( "Background.png" ); + + if( mPixmap.isNull() ) + mPixmap = DesktopIcon( "kmenu", 48 ); + + QPixmap pix( bgimg ); + + if( !pix.isNull() ) + { + + QPixmap tmp( QSize(screen.width(), screen.height() ) ); + float sw = (float)screen.width() / pix.width(); + float sh = (float)(screen.height()) / pix.height(); + + QWMatrix matrix; + matrix.scale( sw, sh ); + tmp = pix.xForm( matrix ); + + p.drawPixmap( 0, 0, tmp ); + } + + QFont f = mWelcomeFont; + if( mWelcomeFontItalic ) + f.setItalic( true ); // this SHOULD BE stored in the QFont entry, dang it. + p.setFont( f ); + QFontMetrics met( f ); + QSize fmet = met.size( 0L, mWelcomeText ); + + // Paint the "Welcome" message, if we are instructed to. Optionally dispense with the + // shadow. + if ( mShowWelcomeText ) + { + if( mWelcomeTextPosition == QPoint( 0, 0 ) ) + { + mWelcomeTextPosition = QPoint( (screen.width()/2) - fmet.width() - 25, + (screen.height()/2) - (fmet.height()/2) + fmet.height() ); + } + } + + if( mShowWelcomeText ) + { + if( mShowWelcomeTextShadow ) + { + p.setPen( mWelcomeTextShadowColor ); + p.drawText( mWelcomeTextPosition+QPoint(2,2), mWelcomeText ); + } + p.setPen( mWelcomeTextColor ); + p.drawText( mWelcomeTextPosition, mWelcomeText ); + } + + // The current theme wants to say something in particular, rather than display the + // account's fullname. + KUser user; + QString greetingString = ( !mUsernameText.isNull() ) ? mUsernameText : user.fullName(); + // when we use KUser (system account data) we should also check KEMailSettings (e-mail settings and kcm_useraccount) + // people often write real names only in e-mail settings + if ( greetingString.isEmpty() ) + { + KEMailSettings kes; + greetingString = kes.getSetting( KEMailSettings::RealName ); + } + + // Try to load the user's KDM icon... TODO: Make this overridable by the Theme. + if( mUseKdmUserIcon ) + { + const QString defSys( ".default.face.icon" ); // The system-wide default image + const int fAdminOnly = 1; + const int fAdminFirst = fAdminOnly+1; + const int fUserFirst = fAdminFirst+1; + const int fUserOnly = fUserFirst+1; + + int faceSource = fAdminOnly; + KConfig *kdmconfig = new KConfig("kdm/kdmrc", true); + kdmconfig->setGroup("X-*-Greeter"); + QString userPicsDir = kdmconfig->readEntry( "FaceDir", KGlobal::dirs()->resourceDirs("data").last() + "kdm/faces" ) + '/'; + QString fs = kdmconfig->readEntry( "FaceSource" ); + if (fs == QString::fromLatin1("UserOnly")) + faceSource = fUserOnly; + else if (fs == QString::fromLatin1("PreferUser")) + faceSource = fUserFirst; + else if (fs == QString::fromLatin1("PreferAdmin")) + faceSource = fAdminFirst; + else + faceSource = fAdminOnly; // Admin Only + delete kdmconfig; + + QPixmap userp; + if ( faceSource == fAdminFirst ) + { + // If the administrator's choice takes preference + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + faceSource = fUserOnly; + } + if ( faceSource >= fUserFirst) + { + // If the user's choice takes preference + userp = QPixmap( user.homeDir() + "/.face.icon" ); + if ( userp.isNull() && faceSource == fUserFirst ) // The user has no face, should we check for the admin's setting? + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = QPixmap( userPicsDir + defSys ); + } + else if ( faceSource <= fAdminOnly ) + { + // Admin only + userp = QPixmap( userPicsDir + user.loginName() + ".face.icon" ); + if ( userp.isNull() ) + userp = QPixmap( userPicsDir + defSys ); + } + if( !userp.isNull() ) + mPixmap = userp; + } + + if( mShowIcon ) + { + QPoint pos = mIconPosition; + if( pos == QPoint( 0, 0 ) ) + { + pos = QPoint( (screen.width()/2) + 10, (screen.height()/2) ); + } + p.drawPixmap( pos, mPixmap ); + } + + // User name font. Leave this nailed-up for now. + f = mUsernameFont; + p.setFont( f ); + met = QFontMetrics( f ); + fmet = met.size( 0L, greetingString ); + + if( mShowUsernameText ) + { + QPoint pos = mUsernameTextPosition; + if( pos == QPoint( 0, 0 ) ) + { + pos = QPoint( + (screen.width()/2) + mPixmap.width() + 20, + (screen.height()/2) - (fmet.height()/2) + fmet.height() + ); + } + p.setPen( mUsernameTextColor ); + p.drawText( pos, greetingString ); + } + + p.end(); + + setFixedSize( screen.width(), screen.height() ); + move( screen.topLeft() ); +} + +void ThemeRedmond::paintEvent( QPaintEvent *pe ) +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + + QPainter p; + p.begin( this ); + + QRect r = pe->rect(); + + bitBlt( this, r.x(), r.y(), + &mImage, r.x(), r.y(), r.width(), r.height() ); + + if (mShowActionText) + { + p.setPen( mActionTextColor ); + QFont f = mActionFont; + p.setFont( f ); + QFontMetrics met( f ); + QSize fmet = met.size( 0L, mText ); + + mMsgPos = mActionTextPosition; + if( mMsgPos == QPoint( 0, 0 ) ) + { + mMsgPos = QPoint( + (screen.width()/2) + mPixmap.width() + 20, + (screen.height()/2) + (int)(fmet.height()*0.85) + 15 + ); + } + p.drawText( mMsgPos, mText ); + } + p.end(); +} + +void ThemeRedmond::_readSettings() +{ + const QRect screen = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + //QRect fullScreen = KGlobalSettings::desktopGeometry(0L); + + if( !mTheme ) + return; + KConfig *cfg = mTheme->themeConfig(); + if( !cfg ) + return; + + //if( !cfg->hasGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ); + + // Overall appearance + mBackgroundImage = cfg->readEntry( "Background Image", QString::null ); + mIcon = cfg->readEntry( "User Icon", "kmenu" ); + mWelcomeText = cfg->readEntry( "Welcome Text", i18n("Welcome") ); + mUsernameText = cfg->readEntry( "Username Text", QString::null ); + + // If any of these are set to (0,0), then we will autoposition the text later (and it _will_ + // be centered on the screen!). The Theme may move this text however the author desires. + QPoint absZero( 0, 0 ); + mWelcomeTextPosition = cfg->readPointEntry( QString("Welcome Text Position %1").arg(screen.width()), &absZero ); + mUsernameTextPosition = cfg->readPointEntry( QString("Username Text Position %1").arg(screen.width()), &absZero ); + mActionTextPosition = cfg->readPointEntry( QString("Action Text Position %1").arg(screen.width()), &absZero ); + mIconPosition = cfg->readPointEntry( QString("Icon Position %1").arg(screen.width()), &absZero ); + + // Allow the Theme to hide particular components. + mShowWelcomeText = cfg->readBoolEntry( "Show Welcome Text", true ); + mShowWelcomeTextShadow = cfg->readBoolEntry( "Show Welcome Shadow", true ); + mShowUsernameText = cfg->readBoolEntry( "Show Username", true ); + mShowActionText = cfg->readBoolEntry( "Show Action", true ); + mShowIcon = cfg->readBoolEntry( "Show Icon", true ); + mUseKdmUserIcon = cfg->readBoolEntry( "Use KDM User Icon", true ); + + // Setup our fonts. There are only 3 elements which use 'em, so this is fairly + // straightforward. + QFont defaultFont( "Arial", 48, QFont::Bold ); + defaultFont.setItalic( true ); + QFont defaultUsernameFont( "Arial", 16, QFont::Bold ); + QFont defaultActionFont( "Arial", 12, QFont::Bold ); + + mWelcomeFont = cfg->readFontEntry( "Welcome Font", &defaultFont ); + mWelcomeFontItalic = cfg->readBoolEntry( "Welcome Font Italic", true ); + mUsernameFont = cfg->readFontEntry( "Username Font", &defaultUsernameFont ); + mActionFont = cfg->readFontEntry( "Action Font", &defaultActionFont ); + + QColor defaultDarkColor( 3, 47, 156 ); + QColor defaultWhiteColor( Qt::white ); + + mWelcomeTextColor = cfg->readColorEntry( "Welcome Text Color", &defaultWhiteColor ); + mWelcomeTextShadowColor = cfg->readColorEntry( "Welcome Shadow Color", &defaultDarkColor ); + mUsernameTextColor = cfg->readColorEntry( "Username Text Color", &defaultWhiteColor ); + mActionTextColor = cfg->readColorEntry( "Action Text Color", &defaultWhiteColor ); +} diff --git a/ksplashml/themeengine/redmond/themeredmond.h b/ksplashml/themeengine/redmond/themeredmond.h new file mode 100644 index 000000000..a35662181 --- /dev/null +++ b/ksplashml/themeengine/redmond/themeredmond.h @@ -0,0 +1,103 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#ifndef __THEMEREDMOND_H__ +#define __THEMEREDMOND_H__ + +#include <kdebug.h> +#include <kpixmap.h> + +#include <themeengine.h> + +class KFontCombo; +class QCheckBox; + +class CfgRedmond: public ThemeEngineConfig +{ + Q_OBJECT +public: + CfgRedmond( QWidget *, KConfig * ); + +protected: + QCheckBox *mShowUsername; + QCheckBox *mShowIcon; + QCheckBox *mShowWelcome; + KFontCombo *mWelcomeFont; + KFontCombo *mUsernameFont; + KFontCombo *mActionFont; +}; + +class ObjKsTheme; +class ThemeRedmond: public ThemeEngine +{ + Q_OBJECT +public: + ThemeRedmond( QWidget *, const char *, const QStringList& ); + + inline const QString name() { return( QString("Redmond") ); } + static QStringList names() + { + QStringList Names; + Names << "Redmond"; + return( Names ); + }; + +public slots: + inline void slotSetText( const QString& s ) + { + if( mText != s ) + { + mText = s; + repaint( false ); + } + }; + +private: + void paintEvent( QPaintEvent * ); + + void _initUi(); + void _readSettings(); + + QString mText; + QPixmap mPixmap; + bool mRedrawKonqi; + QPoint mMsgPos; + KPixmap mImage; + + // ThemeEngine configuration. + bool mShowWelcomeText; + bool mShowWelcomeTextShadow; + bool mWelcomeFontItalic; + bool mShowUsernameText; + bool mShowActionText; + bool mShowIcon; + bool mUseKdmUserIcon; + QString mBackgroundImage; + QString mWelcomeText; + QString mUsernameText; // Leave this undefined to autodetect the username. + QString mIcon; + QFont mWelcomeFont; + QFont mUsernameFont; + QFont mActionFont; + QColor mWelcomeTextColor; + QColor mWelcomeTextShadowColor; + QColor mUsernameTextColor; + QColor mActionTextColor; + QPoint mWelcomeTextPosition; // Set this to (0,0) to autoposition the text. + QPoint mUsernameTextPosition; // Likewise. + QPoint mActionTextPosition; // Likewise likewise. + QPoint mIconPosition; // ... + +} +; + +#endif |