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/standard | |
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/standard')
-rw-r--r-- | ksplashml/themeengine/standard/Makefile.am | 23 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/Preview.png | bin | 0 -> 290009 bytes | |||
-rw-r--r-- | ksplashml/themeengine/standard/Theme.rc | 2 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/ksplashstandard.desktop | 97 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/pics/Makefile.am | 4 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/pics/Preview.png | bin | 0 -> 51462 bytes | |||
-rw-r--r-- | ksplashml/themeengine/standard/themestandard.cpp | 167 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/themestandard.h | 93 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/themestandardlib.cpp | 15 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/wndicon.cpp | 310 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/wndicon.h | 70 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/wndstatus.cpp | 101 | ||||
-rw-r--r-- | ksplashml/themeengine/standard/wndstatus.h | 50 |
13 files changed, 932 insertions, 0 deletions
diff --git a/ksplashml/themeengine/standard/Makefile.am b/ksplashml/themeengine/standard/Makefile.am new file mode 100644 index 000000000..c627f6d3c --- /dev/null +++ b/ksplashml/themeengine/standard/Makefile.am @@ -0,0 +1,23 @@ +SUBDIRS = pics + +INCLUDES = -I$(top_srcdir)/ksplashml/themeengine $(all_includes) + +noinst_LTLIBRARIES = libthemestandard.la +libthemestandard_la_SOURCES = themestandard.cpp wndicon.cpp wndstatus.cpp +libthemestandard_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) +libthemestandard_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la + +kde_module_LTLIBRARIES = ksplashstandard.la + +ksplashstandard_la_SOURCES = themestandardlib.cpp +ksplashstandard_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(KDE_PLUGIN) -module +ksplashstandard_la_LIBADD = $(LIB_KDEUI) ../libksplashthemes.la libthemestandard.la +METASOURCES = AUTO + +noinst_HEADERS = themestandard.h wndicon.h wndstatus.h + +servicesdir = $(kde_servicesdir) +services_DATA = ksplashstandard.desktop + +themedir = $(kde_datadir)/ksplash/Themes/Standard +theme_DATA = Theme.rc diff --git a/ksplashml/themeengine/standard/Preview.png b/ksplashml/themeengine/standard/Preview.png Binary files differnew file mode 100644 index 000000000..58603e1e6 --- /dev/null +++ b/ksplashml/themeengine/standard/Preview.png diff --git a/ksplashml/themeengine/standard/Theme.rc b/ksplashml/themeengine/standard/Theme.rc new file mode 100644 index 000000000..2ae13af53 --- /dev/null +++ b/ksplashml/themeengine/standard/Theme.rc @@ -0,0 +1,2 @@ +[KSplash Theme: Standard] +Engine=Standard diff --git a/ksplashml/themeengine/standard/ksplashstandard.desktop b/ksplashml/themeengine/standard/ksplashstandard.desktop new file mode 100644 index 000000000..125c2a54d --- /dev/null +++ b/ksplashml/themeengine/standard/ksplashstandard.desktop @@ -0,0 +1,97 @@ +[Desktop Entry] +Type=Service +Comment=KSplash Plugin +Comment[af]=KSplash Inprop module +Comment[ar]=ملحق للشاشة الافتتاحية +Comment[az]=KSplash Əlavəsi +Comment[be]=Утулка KSplash +Comment[bg]=Приставка KSplash +Comment[bn]=কে-স্প্ল্যাশ প্লাগ-ইন +Comment[br]=Lugent KSplash +Comment[bs]=KSplash dodatak +Comment[ca]=Connector per a KSplash +Comment[cs]=Modul aplikaci KSplash +Comment[csb]=Plugins KSplash +Comment[cy]=Ategyn KCroeso +Comment[da]=KSplash-plugin +Comment[de]=KSplash-Plugin +Comment[el]=Πρόσθετο KSplash +Comment[eo]=Ksalutŝilda kromaĵo +Comment[es]=Complemento KSplash +Comment[et]=KSplashi plugin +Comment[eu]=KSplash plugina +Comment[fa]=وصلۀ KSplash +Comment[fi]=KSplash-liitännäinen +Comment[fr]=Modules de KSplash +Comment[fy]=KSplash-plugin +Comment[ga]=Breiseán KSplash +Comment[gl]=Plugin de KSplash +Comment[he]=תוסף KSplash +Comment[hi]=के-स्प्लैश प्लगइन +Comment[hr]=KSplash dodatak +Comment[hu]=KSplash bővítőmodul +Comment[is]=KSplash íforrit +Comment[it]=Plugin KSplash +Comment[ja]=KSplash プラグイン +Comment[ka]=KSplash პლაგინი +Comment[kk]=KSplash модулі +Comment[km]=កម្មវិធីជំនួយខាងក្នុងរបស់ KSplash +Comment[lt]=KSplash įskiepis +Comment[lv]=KSplash spraudnis +Comment[mk]=Приклучок за KSplash +Comment[ms]=Plugin KSplash +Comment[mt]=Plugin ta' KSplash +Comment[nb]=Programtillegg Ksplash +Comment[ne]=के स्प्लयास प्लगइन +Comment[nl]=KSplash-plugin +Comment[nn]=KSplash-programtillegg +Comment[pa]=ਕੇ-ਸਪਲੇਸ ਪਲੱਗਇਨ +Comment[pl]=Wtyczka KSplash +Comment[pt]='Plugin' do KSplash +Comment[pt_BR]=Plug-in do KSplash +Comment[ro]=Modul KSplash +Comment[ru]=Модуль KSplash +Comment[rw]=Icomeka rya K-Gukwiza +Comment[se]=KSplash-lassemoduvla +Comment[sk]=Modul KSplash +Comment[sl]=Vstavek KSplash +Comment[sr]=KSplash прикључак +Comment[sr@Latn]=KSplash priključak +Comment[sv]=Insticksprogram för startskärm +Comment[ta]=Kஸ்ப்ளாஷ் செருகு பொருள் +Comment[tg]=Мутассалкунандаи KSplash +Comment[th]=ปลั๊กอิน KSplash +Comment[tr]=KSplash Eklentisi +Comment[tt]=KSplash atlı Östämä +Comment[uk]=Втулок KSplash +Comment[uz]=KSplash plagini +Comment[uz@cyrillic]=KSplash плагини +Comment[vi]=Trình bổ sung Chào mừng KDE +Comment[wa]=Tchôke-divins KSplash (waitroûle d' enondaedje) +Comment[zh_CN]=KSplash 插件 +Comment[zh_TW]=KSplash 外掛程式 +Name=KSplashStandard +Name[af]=KSplash Standaard +Name[be]=Стандартная тэма +Name[ca]=KSplash estàndard +Name[cs]=Standardní +Name[cy]=KCroesoSafonol +Name[de]=KSplash Standard +Name[eo]=Normala +Name[et]=KSplash Standard +Name[hi]=के-स्प्लैश-स्टैण्डर्ड +Name[ne]=के स्प्लयास मानक +Name[pa]=ਕੇਸਪਲੇਸ ਸਟੈਂਡਰਡ +Name[pt_BR]=Tela de Apresentação Padrão +Name[rw]=K-GukwizaBisanzwe +Name[sv]=Vanlig startskärm +Name[ta]=Kஸ்ப்ளாஷ்நிலையான +Name[tg]=СтандартиKSplash +Name[th]=KSplash แบบมาตรฐาน +Name[vi]=Chào mừng KDE Tiêu chuẩn +Name[wa]=KSplashStandård +ServiceTypes=KSplash/Plugin +X-KDE-Library=ksplashstandard +X-KSplash-Default=true +X-KSplash-PluginName=Standard +X-KSplash-ObjectName=ThemeStandard diff --git a/ksplashml/themeengine/standard/pics/Makefile.am b/ksplashml/themeengine/standard/pics/Makefile.am new file mode 100644 index 000000000..54a91876d --- /dev/null +++ b/ksplashml/themeengine/standard/pics/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST=Preview.png + +themedir = $(kde_datadir)/ksplash/Themes/Standard +theme_DATA = $(EXTRA_DIST) diff --git a/ksplashml/themeengine/standard/pics/Preview.png b/ksplashml/themeengine/standard/pics/Preview.png Binary files differnew file mode 100644 index 000000000..b4e7d4a88 --- /dev/null +++ b/ksplashml/themeengine/standard/pics/Preview.png diff --git a/ksplashml/themeengine/standard/themestandard.cpp b/ksplashml/themeengine/standard/themestandard.cpp new file mode 100644 index 000000000..ff7929bfe --- /dev/null +++ b/ksplashml/themeengine/standard/themestandard.cpp @@ -0,0 +1,167 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 <ravi@kde.org> * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <kapplication.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kstandarddirs.h> +#include <kconfig.h> + +#include <qdesktopwidget.h> +#include <qlabel.h> +#include <qpalette.h> +#include <qpixmap.h> +#include <qwidget.h> + +#include <objkstheme.h> +#include "themestandard.h" +#include "themestandard.moc" +#include "wndicon.h" +#include "wndstatus.h" + +ThemeStandard::ThemeStandard( QWidget *parent, const char *name, const QStringList &args ) + :ThemeEngine( parent, name, args ), mIcon(0L), mPrevIcon(0L), mIconCount(0), mStdIconWidth(-1), + mIconPos(WndIcon::HBottomLeft), mSbAtTop(false), mSbVisible(true), mSbPbVisible(true), mSbFontName("helvetica"), + mSbFontSz(16), mSbFontBold(true), mSbFontItalic(false), mSbFont(QFont()), mSbFg(QColor()), mSbBg(QColor()), + mSbIcon("run"), mIconsVisible(true), mIconsJumping(true), mSplashScreen("(Default)") +{ + _readSettings(); + _initUi(); +} + +void ThemeStandard::_initUi() +{ + setFrameStyle( QFrame::NoFrame ); + + QString pixName = mTheme->locateThemeData( mSplashScreen ); + + if( mSplashScreen == "(Default)" || pixName.isEmpty() ) + { + QString resource_prefix = "pics/"; + if ( mTheme->loColor() ) + resource_prefix += "locolor/"; + pixName = locate( "appdata", resource_prefix + "splash.png"); + } + + QPixmap px = QPixmap( pixName ); + + if( !px.isNull() ) + { + //kdDebug() << "Loaded splash " << mSplashScreen << endl; + int pw = px.width(); + int ph = px.height(); + + QLabel *lbl = new QLabel( this ); + lbl->setBackgroundMode( NoBackground ); + lbl->setFixedSize( pw, ph ); + lbl->setPixmap( px ); + + resize( pw, ph ); + } + else + { + //kdDebug() << "Couldn't load splash " << mSplashScreen << endl; + resize( 0, 0 ); + } + + const QRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + move( rect.x() + (rect.width() - size().width())/2, + rect.y() + (rect.height() - size().height())/2 ); + + mStatus = new WndStatus( QPalette(), mTheme->xineramaScreen(), mSbAtTop, mSbPbVisible, mSbFont, mSbFg, mSbBg, mSbIcon ); +} + +void ThemeStandard::showEvent( QShowEvent * ) +{ + + ThemeEngine::show(); + + if( mSbVisible ) + { + mStatus->show(); + mStatusBarHeight = mStatus->height(); + } + else + { + mStatusBarHeight = 0L; + } +} + +// Adjust the visible icon. +void ThemeStandard::slotSetPixmap( const QString& pxn ) +{ + QPixmap px = DesktopIcon( pxn ); + + if ( px.isNull() ) + px = DesktopIcon( "go" ); + + if ( !mIconsVisible ) + return; + + /* (We only use prev_i if jumping is enabled...) */ + if ( mIconsJumping && mPrevIcon ) + emit mPrevIcon->slotStopJumping(); + + if ( mStdIconWidth < 0 ) + mStdIconWidth = DesktopIcon( "go" ).width(); + + mIcon = new WndIcon( ++mIconCount, mStdIconWidth, mStatusBarHeight, mTheme->xineramaScreen(), + px, QString::null, mIconPos, mSbAtTop, mIconsJumping ); + mIcon->show(); + + if( mIconsJumping ) + { + emit mIcon->slotJump(); + mPrevIcon = mIcon; + } +} + +void ThemeStandard::_readSettings() +{ + + if ( !mTheme ) + return; + + KConfig *cfg = mTheme->themeConfig(); + if ( !cfg ) + return; + + //if ( !cfg->hasGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ) ) + // return; + cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ); + + QString sbpos = cfg->readEntry( "Statusbar Position", "Bottom" ).upper(); + mSbAtTop = ( sbpos == "TOP" ); + mSbVisible = cfg->readBoolEntry( "Statusbar Visible", true); + mSbPbVisible = cfg->readBoolEntry( "Progress Visible", true); + + mSbFontName = cfg->readEntry( "Statusbar Font", "Sans Serif" ); + mSbFontSz = cfg->readNumEntry( "Statusbar Font Size", 16 ); + mSbFontBold = cfg->readBoolEntry( "Statusbar Font Bold", true ); + mSbFontItalic = cfg->readBoolEntry( "Statusbar Font Italic", false ); + mSbFont = QFont( mSbFontName, mSbFontSz, ( mSbFontBold? QFont::Bold : QFont::Normal ) ); + if( mSbFontItalic ) + mSbFont.setItalic( true ); + + mSbFg = cfg->readColorEntry( "Statusbar Foreground", &Qt::white ); + mSbBg = cfg->readColorEntry( "Statusbar Background", &Qt::black ); + mSbIcon = cfg->readEntry( "Statusbar Icon", "run" ); + mIconsVisible = cfg->readBoolEntry( "Icons Visible", true); + mIconsJumping = cfg->readBoolEntry( "Icons Jumping", true); + mIconPos = (WndIcon::Position)cfg->readNumEntry( "Icon Position", 0 ); + mSplashScreen = cfg->readEntry( "Splash Screen", "(Default)"); + // cfg->readBoolEntry( "Allow Configuration", true ); +} diff --git a/ksplashml/themeengine/standard/themestandard.h b/ksplashml/themeengine/standard/themestandard.h new file mode 100644 index 000000000..a24f668db --- /dev/null +++ b/ksplashml/themeengine/standard/themestandard.h @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#ifndef __THEMESTANDARD_H__ +#define __THEMESTANDARD_H__ + +#include <themeengine.h> + +#include "wndicon.h" +#include "wndstatus.h" + +/* + * Special Note: The "Standard" engine is treated a little bit differently than + * the other ThemeEngines in this program. Because we don't ever want to end up + * in a situation in which there is _no_ user interface, this ThemeEngine will + * be statically linked in with the ksplash binary itself, so that no dynamic + * loading is necessary to access it. The disadvantage that this presents is + * immediately obvious: The control center module is no longer able to dynamically + * load a configuration object for this theme, since this engine doesn't reside in + * a shared-object library like the other ones do. Therefore, we will have to + * implement the ThemeEngineConfig object for this engine in the kcmksplash + * subsystem, in such a manner that it is statically linked in with the control + * panel. I know, this is really nasty, but I would rather have slightly uglier + * code, so long as it makes the End User Experience of this program somewhat more + * predictable (i.e., even if we can't do exactly what the user wants, we can still + * do _something_...) + * + * Therefore, you will find the CfgStandard class in the ../kcmksplash/ directory. + */ + +/** + * @short The default KSplash splash screen. + */ +class ThemeStandard: public ThemeEngine +{ + Q_OBJECT +public: + ThemeStandard( QWidget *, const char*, const QStringList& ); + //inline const ThemeEngineConfig *config( QWidget *p, KConfig *kc ) { return 0L; } + +public slots: + inline void slotUpdateProgress( int i ) + { + if( mStatus ) mStatus->slotUpdateProgress( i ); + } + inline void slotUpdateSteps( int i ) + { + if( mStatus ) mStatus->slotUpdateSteps( i ); + } + inline void slotSetText( const QString& s ) + { + if( mStatus ) mStatus->slotSetMessage( s ); + } + void slotSetPixmap( const QString& ); + +private: + void showEvent( QShowEvent * ); + void _readSettings(); + void _initUi(); + + WndStatus *mStatus; + WndIcon *mIcon, *mPrevIcon; + int mIconCount; + int mStatusBarHeight; + int mStdIconWidth; + + WndIcon::Position mIconPos; + bool mSbAtTop; + bool mSbVisible; + bool mSbPbVisible; + QString mSbFontName; + int mSbFontSz; + bool mSbFontBold; + bool mSbFontItalic; + QFont mSbFont; + QColor mSbFg; + QColor mSbBg; + QString mSbIcon; + bool mIconsVisible; + bool mIconsJumping; + QString mSplashScreen; +}; + +#endif diff --git a/ksplashml/themeengine/standard/themestandardlib.cpp b/ksplashml/themeengine/standard/themestandardlib.cpp new file mode 100644 index 000000000..acdb6958f --- /dev/null +++ b/ksplashml/themeengine/standard/themestandardlib.cpp @@ -0,0 +1,15 @@ +/*************************************************************************** + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. * + * * + ***************************************************************************/ + +#include <kgenericfactory.h> + +#include "themestandard.h" + +K_EXPORT_COMPONENT_FACTORY( ksplashstandard, KGenericFactory<ThemeStandard>( "ksplash" ) ) diff --git a/ksplashml/themeengine/standard/wndicon.cpp b/ksplashml/themeengine/standard/wndicon.cpp new file mode 100644 index 000000000..0440a0181 --- /dev/null +++ b/ksplashml/themeengine/standard/wndicon.cpp @@ -0,0 +1,310 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <kapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kdebug.h> +#include <kglobalsettings.h> +#include <kwin.h> + +#include <qdesktopwidget.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qpixmap.h> +#include <qpoint.h> +#include <qtimer.h> +#include <qwidget.h> + +#include "wndicon.h" +#include "wndicon.moc" + +WndIcon::WndIcon( + unsigned int icon_num, + unsigned int icon_std_width, + unsigned int status_height, + int xineramaScreen, + const KPixmap& pix, + const QString& text, + Position icon_position, + bool statusAtTop, + bool iconsJumping ) + :QHBox( 0, "wndSplash", WStyle_Customize|WX11BypassWM ), + mStatusText(text), mIconPos(icon_position), mXineramaScreen( xineramaScreen ), mPosX(0), mPosY(0), mGroundX(0), mGroundY(0), + mVelocity(8.0), mInitialVelocity(8.0), mGravity(0.8), + mIconNum(icon_num), mStatusHeight(status_height), mIconSize(icon_std_width), mStatusAtTop(statusAtTop), + mStopJump(false), mIconJumping(iconsJumping) +{ + setFrameStyle( QFrame::NoFrame ); + + QLabel *w = new QLabel( this ); + w->setFixedSize( pix.width(), pix.height() ); + w->setPixmap( pix ); + if(pix.mask()) + { + setMask(*pix.mask()); + w->setMask(*pix.mask()); + } + + resize( pix.width(), pix.height() ); + + // Set initial position of icon, and ground. + QPoint p = determinePosition(); + mGroundX = mPosX = p.x(); + mGroundY = mPosY = p.y(); + move( p + kapp->desktop()->screenGeometry( mXineramaScreen ).topLeft() ); + + if( mIconJumping ) + { + QTimer *t = new QTimer( this ); + connect(t, SIGNAL(timeout()), SLOT(slotJump())); + t->start( 50, false ); + } +} + +void WndIcon::show() +{ + emit setStatusText( mStatusText ); + QHBox::show(); +} + +// Emit our EXTRA signal without becoming visible. +void WndIcon::noshow() +{ + emit setStatusText( mStatusText ); +} + +/* + * WndIcon::determinePosition(): Based on the information we've + * stored within us, determine where we should be placed on the + * screen. This is placed in its own function due to the massive + * complexity required by the variables involved. + */ +QPoint WndIcon::determinePosition() +{ + int DW, DH, SBH, wid, X, Y, x, y, nSlot, topshift, bottomshift; + + bottomshift = topshift = 0; + const QRect srect = kapp->desktop()->screenGeometry( mXineramaScreen ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + DW = srect.width(); + DH = srect.height(); + SBH = mStatusHeight; + wid = mIconSize; + x = mIconNum; + y = 1; + + if(mStatusAtTop) + topshift = mStatusHeight; + else + bottomshift = mStatusHeight; + + // Different starting positions require different positioning + // rules. The horizontal rules and the vertical rules can be + // grouped together, as they are innately similar. + switch( mIconPos ) + { + // HORIZONTAL: Top Left -> Top Right + case( WndIcon::HTopLeft ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + ((x - 1) * wid); + Y = topshift + 3 + ( (y-1) * wid ); + break; + + // HORIZONTAL: Bottom Left -> Bottom Right + case( WndIcon::HBottomLeft ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + ((x - 1) * wid); + Y = (DH-3) - (y * wid) - bottomshift; + break; + + // HORIZONTAL: Top Right -> Top Left + case( WndIcon::HTopRight ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( x ) * wid ); + Y = topshift + (3) + ( (y-1) * wid ); + break; + + // HORIZONTAL: Bottom Right -> Bottom Left + case( WndIcon::HBottomRight ): + nSlot = ( DW / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( x ) * wid ); + Y = (DH-3) - (y * wid) - bottomshift; + break; + + // VERTICAL: Top Left -> Bottom Left + case( WndIcon::VTopLeft ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + (( y - 1 ) * wid ); + Y = topshift + (3) + ((x-1) * wid); + break; + + // VERTICAL: Top Right -> Bottom Right + case( WndIcon::VTopRight ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( y ) * wid ); + Y = topshift + (3) + ((x-1) * wid); + break; + + // VERTICAL: Bottom Left -> Top Left + case( WndIcon::VBottomLeft ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (3) + (( y - 1 ) * wid ); + Y = (DH-3) - (x * wid) - bottomshift; + break; + + // VERTICAL: Bottom Right -> Top Right + case( WndIcon::VBottomRight ): + nSlot = ( DH / wid ); + while( x > nSlot ) + { + x = QMAX(0,x-nSlot); + y++; + } + X = (DW - 3) - (( y ) * wid ); + Y = (DH-3) - (x * wid) - bottomshift; + break; + + // Unknown Condition. Reconfigure variable and + // retry. Recursively, of course! ;) + default: + mIconPos = HBottomLeft; + return(determinePosition()); + break; + } + return( QPoint( X, Y ) ); +} + +// Make the icons jump in a macosx-like way (Thanks, Jone!:) +void WndIcon::slotJump() +{ + // Based on our position, bounce around. + switch( mIconPos ) + { + // LEFT + case( WndIcon::VTopLeft ): + case( WndIcon::VBottomLeft ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosX <= mGroundX ) + { + mPosX = mGroundX; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosX <= mGroundX ) + mVelocity = mInitialVelocity; + mPosX = (int)((float)mPosX + mVelocity); + break; + + // RIGHT + case( WndIcon::VTopRight ): + case( WndIcon::VBottomRight ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosX >= mGroundX ) + { + mPosX = mGroundX; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosX >= mGroundX ) + mVelocity = mInitialVelocity; + mPosX = (int)((float)mPosX - mVelocity); + break; + + // TOP + case( WndIcon::HTopLeft ): + case( WndIcon::HTopRight ): + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosY <= mGroundY ) + { + mPosY = mGroundY; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosY <= mGroundY ) + mVelocity = mInitialVelocity; + mPosY = (int)((float)mPosY + mVelocity ); + break; + + // BOTTOM + case( WndIcon::HBottomLeft ): + case( WndIcon::HBottomRight ): default: + mVelocity -= mGravity; + if( mStopJump ) + { + if( mPosY >= mGroundY ) + { + mPosY = mGroundY; + mVelocity = mGravity = 0.0; + } + } + else + if( mPosY >= mGroundY ) + mVelocity = mInitialVelocity; + mPosY = (int)((float)mPosY - mVelocity ); + break; + } + move( QPoint( mPosX, mPosY ) + kapp->desktop()->screenGeometry( mXineramaScreen ).topLeft() ); +} + +void WndIcon::slotStopJumping() +{ + mStopJump = true; +} diff --git a/ksplashml/themeengine/standard/wndicon.h b/ksplashml/themeengine/standard/wndicon.h new file mode 100644 index 000000000..a47082ae6 --- /dev/null +++ b/ksplashml/themeengine/standard/wndicon.h @@ -0,0 +1,70 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +// This file exists for the convenience of other KDE headers. It may change between +// different versions of KDE, and may disappear altogether. Do NOT include this +// directly in your program. We mean it. + + +#ifndef __WNDICON_H__ +#define __WNDICON_H__ + +#include <kpixmap.h> + +#include <qhbox.h> + +/** + * @short Displays an icon on the screen. + */ +class WndIcon: + public QHBox +{ + Q_OBJECT +public: + + enum Position + { + HBottomLeft = 0, + HBottomRight = 1, + HTopLeft = 2, + HTopRight = 3, + VBottomLeft = 10, + VBottomRight = 11, + VTopLeft = 12, + VTopRight = 13 + }; + + WndIcon( unsigned int, unsigned int, unsigned int, int, const KPixmap&, const QString&, Position, bool, bool ); + +signals: + void setStatusText( const QString& ); + +public slots: + void show(); + void noshow(); + void slotStopJumping(); + void slotJump(); + +private: + QPoint determinePosition(); + +protected: + QString mStatusText; + Position mIconPos; + int mXineramaScreen; + int mPosX, mPosY, mGroundX, mGroundY; + float mVelocity, mInitialVelocity, mGravity; + int mIconNum, mStatusHeight, mIconSize; + bool mStatusAtTop, mStopJump, mIconJumping; +}; + +#endif diff --git a/ksplashml/themeengine/standard/wndstatus.cpp b/ksplashml/themeengine/standard/wndstatus.cpp new file mode 100644 index 000000000..3b8582c89 --- /dev/null +++ b/ksplashml/themeengine/standard/wndstatus.cpp @@ -0,0 +1,101 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +#include <kapplication.h> +#include <kcursor.h> +#include <kdebug.h> +#include <kglobalsettings.h> +#include <kiconloader.h> +#include <kprogress.h> +#include <kwin.h> + +#include <qdesktopwidget.h> +#include <qhbox.h> +#include <qlabel.h> +#include <qpoint.h> +#include <qrect.h> + +#include "wndstatus.h" +#include "wndstatus.moc" + +// WndStatus::WndStatus(): Display a nifty status bar at +// the bottom of the screen, so the user always knows what's +// happening to his system. +WndStatus::WndStatus( QPalette /*pal*/, + int xineramaScreen, + bool atTop, bool pbVisible, + const QFont& font, + const QColor& fgc, const QColor & bgc, + const QString& icon + ) + :QHBox( 0, "wndStatus", WStyle_Customize|WX11BypassWM ) +{ + setFrameStyle( QFrame::NoFrame ); + //setPalette( pal ); + setPaletteBackgroundColor( bgc ); + setPaletteForegroundColor( fgc ); + setCursor( KCursor::blankCursor() ); + setSpacing( 5 ); + + const QRect rect = kapp->desktop()->screenGeometry( xineramaScreen ); + // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here. + + QLabel *pix = new QLabel( this ); + QPixmap _icon( SmallIcon(icon.isNull()||icon.isEmpty()?QString("run"):icon) ); + pix->setPixmap( _icon ); + setStretchFactor(pix,0); + pix->setFixedWidth(16); + + m_label = new QLabel( this ); + m_label->setFont( font ); + m_label->setPaletteBackgroundColor( bgc ); + m_label->setPaletteForegroundColor( fgc ); + //QFontMetrics metrics( font ); + //m_label->setFixedHeight( metrics.height() ); + m_label->setText(QString("")); + m_label->setFixedWidth(rect.width()-105-16-10); // What's this magic number? + m_label->show(); + + m_progress = new KProgress( this ); + setStretchFactor(m_progress,0); + m_progress->setFixedWidth(100); + + QWidget *widg = new QWidget( this ); + setStretchFactor(widg,50); + + setFixedSize( rect.width(), QMAX(m_progress->height(),m_label->height()) ); + + if ( atTop ) + move( rect.topLeft() ); + else + move( rect.bottomLeft().x(), rect.bottomLeft().y()-height()+1 ); // The +1 is to work around a bug in screenGeometry(). + + if (!pbVisible) + m_progress->hide(); +} + +void WndStatus::slotSetMessage( const QString& msg ) +{ + raise(); + m_label->setText( msg ); +} + +void WndStatus::slotUpdateProgress( int i ) +{ + raise(); + m_progress->setProgress( i ); +} + +void WndStatus::slotUpdateSteps( int i ) +{ + m_progress->setTotalSteps( i ); +} diff --git a/ksplashml/themeengine/standard/wndstatus.h b/ksplashml/themeengine/standard/wndstatus.h new file mode 100644 index 000000000..fa1d735d9 --- /dev/null +++ b/ksplashml/themeengine/standard/wndstatus.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net> * + * Copyright Ravikiran Rajagopal 2003 * + * ravi@ee.eng.ohio-state.edu * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License (version 2) as * + * published by the Free Software Foundation. (The original KSplash/ML * + * codebase (upto version 0.95.3) is BSD-licensed.) * + * * + ***************************************************************************/ + +// This file exists for the convenience of other KDE headers. It may change between +// different versions of KDE, and may disappear altogether. Do NOT include this +// directly in your program. We mean it. + + +#ifndef __WNDSTATUS_H__ +#define __WNDSTATUS_H__ + +#include <qhbox.h> + +class QLabel; +class KProgress; + +/** @short Window displaying status and progress bar. */ +class WndStatus: + public QHBox +{ + Q_OBJECT +public: + WndStatus( QPalette, + int, // Xinerama screen + bool, // At top? + bool, // Progress indicator visible? + const QFont&, // Status bar font + const QColor&, const QColor &, // Foreground/Background color + const QString& // Icon + ); + +public slots: + void slotSetMessage( const QString& ); + void slotUpdateProgress( int ); + void slotUpdateSteps( int ); + +protected: + QLabel *m_label; + KProgress *m_progress; +}; +#endif |