~ubuntu-branches/ubuntu/warty/kdebase/warty

« back to all changes in this revision

Viewing changes to ksplashml/themeengine/standard/themestandard.cpp

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2004-09-16 04:51:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040916045145-9vr63kith3k1cpza
Tags: upstream-3.2.2
ImportĀ upstreamĀ versionĀ 3.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright Brian Ledbetter 2001-2003 <brian@shadowcom.net>             *
 
3
 *   Copyright Ravikiran Rajagopal 2003 <ravi@kde.org>                     *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License (version 2) as   *
 
7
 *   published by the Free Software Foundation. (The original KSplash/ML   *
 
8
 *   codebase (upto version 0.95.3) is BSD-licensed.)                      *
 
9
 *                                                                         *
 
10
 ***************************************************************************/
 
11
 
 
12
#include <kapplication.h>
 
13
#include <kdebug.h>
 
14
#include <kdialogbase.h>
 
15
#include <kglobalsettings.h>
 
16
#include <kiconloader.h>
 
17
#include <klocale.h>
 
18
#include <kstandarddirs.h>
 
19
#include <kconfig.h>
 
20
 
 
21
#include <qdesktopwidget.h>
 
22
#include <qlabel.h>
 
23
#include <qpalette.h>
 
24
#include <qpixmap.h>
 
25
#include <qwidget.h>
 
26
 
 
27
#include <objkstheme.h>
 
28
#include "themestandard.h"
 
29
#include "themestandard.moc"
 
30
#include "wndicon.h"
 
31
#include "wndstatus.h"
 
32
 
 
33
ThemeStandard::ThemeStandard( QWidget *parent, const char *name, const QStringList &args )
 
34
  :ThemeEngine( parent, name, args ), mIcon(0L), mPrevIcon(0L), mIconCount(0), mStdIconWidth(-1),
 
35
  mIconPos(WndIcon::HBottomLeft), mSbAtTop(false), mSbVisible(true), mSbPbVisible(true), mSbFontName("helvetica"),
 
36
  mSbFontSz(16), mSbFontBold(true), mSbFontItalic(false), mSbFont(QFont()), mSbFg(QColor()), mSbBg(QColor()),
 
37
  mSbIcon("run"), mIconsVisible(true), mIconsJumping(true), mSplashScreen("(Default)")
 
38
{
 
39
  _readSettings();
 
40
  _initUi();
 
41
}
 
42
 
 
43
void ThemeStandard::_initUi()
 
44
{
 
45
  setFrameStyle( QFrame::NoFrame );
 
46
 
 
47
  QString pixName = mTheme->locateThemeData( mSplashScreen );
 
48
 
 
49
  if( mSplashScreen == "(Default)" || pixName.isEmpty() )
 
50
  {
 
51
    QString resource_prefix = "pics/";
 
52
    if ( mTheme->loColor() )
 
53
      resource_prefix += "locolor/";
 
54
    pixName = locate( "appdata", resource_prefix + "splash.png");
 
55
  }
 
56
 
 
57
  QPixmap px = QPixmap( pixName );
 
58
 
 
59
  if( !px.isNull() )
 
60
  {
 
61
    //kdDebug() << "Loaded splash " << mSplashScreen << endl;
 
62
    int pw = px.width();
 
63
    int ph = px.height();
 
64
 
 
65
    QLabel *lbl = new QLabel( this );
 
66
    lbl->setBackgroundMode( NoBackground );
 
67
    lbl->setFixedSize( pw, ph );
 
68
    lbl->setPixmap( px );
 
69
 
 
70
    resize( pw, ph );
 
71
  }
 
72
  else
 
73
  {
 
74
    //kdDebug() << "Couldn't load splash " << mSplashScreen << endl;
 
75
    resize( 0, 0 );
 
76
  }
 
77
 
 
78
  const QRect rect = kapp->desktop()->screenGeometry( mTheme->xineramaScreen() );
 
79
  // KGlobalSettings::splashScreenDesktopGeometry(); cannot be used here.
 
80
 
 
81
  move( rect.x() + (rect.width() - size().width())/2,
 
82
        rect.y() + (rect.height() - size().height())/2 );
 
83
 
 
84
  mStatus = new WndStatus( QPalette(), mTheme->xineramaScreen(), mSbAtTop, mSbPbVisible, mSbFont, mSbFg, mSbBg, mSbIcon );
 
85
}
 
86
 
 
87
void ThemeStandard::showEvent( QShowEvent * )
 
88
{
 
89
 
 
90
  ThemeEngine::show();
 
91
 
 
92
  if( mSbVisible )
 
93
  {
 
94
    mStatus->show();
 
95
    mStatusBarHeight = mStatus->height();
 
96
  }
 
97
  else
 
98
  {
 
99
    mStatusBarHeight = 0L;
 
100
  }
 
101
}
 
102
 
 
103
// Adjust the visible icon.
 
104
void ThemeStandard::slotSetPixmap( const QString& pxn )
 
105
{
 
106
  QPixmap px = DesktopIcon( pxn );
 
107
 
 
108
  if ( px.isNull() )
 
109
    px = DesktopIcon( "go" );
 
110
 
 
111
  if ( !mIconsVisible )
 
112
    return;
 
113
 
 
114
  /* (We only use prev_i if jumping is enabled...) */
 
115
  if ( mIconsJumping && mPrevIcon )
 
116
    emit mPrevIcon->slotStopJumping();
 
117
 
 
118
  if ( mStdIconWidth < 0 )
 
119
    mStdIconWidth = DesktopIcon( "go" ).width();
 
120
 
 
121
  mIcon = new WndIcon( ++mIconCount, mStdIconWidth, mStatusBarHeight, mTheme->xineramaScreen(),
 
122
                       px, QString::null, mIconPos, mSbAtTop, mIconsJumping );
 
123
  mIcon->show();
 
124
 
 
125
  if( mIconsJumping )
 
126
  {
 
127
    emit mIcon->slotJump();
 
128
    mPrevIcon = mIcon;
 
129
  }
 
130
}
 
131
 
 
132
void ThemeStandard::_readSettings()
 
133
{
 
134
 
 
135
  if ( !mTheme )
 
136
    return;
 
137
 
 
138
  KConfig *cfg = mTheme->themeConfig();
 
139
  if ( !cfg )
 
140
    return;
 
141
 
 
142
  //if ( !cfg->hasGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) ) )
 
143
  //  return;
 
144
  cfg->setGroup( QString("KSplash Theme: %1").arg(mTheme->theme()) );
 
145
 
 
146
  QString sbpos = cfg->readEntry( "Statusbar Position", "Bottom" ).upper();
 
147
  mSbAtTop = ( sbpos == "TOP" );
 
148
  mSbVisible = cfg->readBoolEntry( "Statusbar Visible", true);
 
149
  mSbPbVisible = cfg->readBoolEntry( "Progress Visible", true);
 
150
 
 
151
  mSbFontName = cfg->readEntry( "Statusbar Font", "helvetica" );
 
152
  mSbFontSz = cfg->readNumEntry( "Statusbar Font Size", 16 );
 
153
  mSbFontBold = cfg->readBoolEntry( "Statusbar Font Bold", true );
 
154
  mSbFontItalic = cfg->readBoolEntry( "Statusbar Font Italic", false );
 
155
  mSbFont = QFont( mSbFontName, mSbFontSz, ( mSbFontBold? QFont::Bold : QFont::Normal ) );
 
156
  if( mSbFontItalic )
 
157
    mSbFont.setItalic( true );
 
158
 
 
159
  mSbFg = cfg->readColorEntry( "Statusbar Foreground", &Qt::white );
 
160
  mSbBg = cfg->readColorEntry( "Statusbar Background", &Qt::black );
 
161
  mSbIcon = cfg->readEntry( "Statusbar Icon", "run" );
 
162
  mIconsVisible = cfg->readBoolEntry( "Icons Visible", true);
 
163
  mIconsJumping = cfg->readBoolEntry( "Icons Jumping", true);
 
164
  mIconPos = (WndIcon::Position)cfg->readNumEntry( "Icon Position", 0 );
 
165
  mSplashScreen = cfg->readEntry( "Splash Screen", "(Default)");
 
166
  // cfg->readBoolEntry( "Allow Configuration", true );
 
167
}