summaryrefslogtreecommitdiffstats
path: root/src/k3bthemedheader.cpp
blob: 934af88a40944808ab4d2555029ed1568582cc10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* 
 *
 * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
 * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
 *
 * This file is part of the K3b project.
 * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * See the file "COPYING" for the exact licensing terms.
 */

#include "k3bthemedheader.h"
#include "k3bthememanager.h"
#include "k3bapplication.h"

#include <k3btitlelabel.h>

#include <tqlabel.h>
#include <tqlayout.h>


K3bThemedHeader::K3bThemedHeader( TQWidget* parent )
  : TQFrame( parent )
{
  init();
}


K3bThemedHeader::K3bThemedHeader( const TQString& title, const TQString& subtitle, TQWidget* parent )
  : TQFrame( parent )
{
  setTitle( title );
  setSubTitle( subtitle );

  init();
}


K3bThemedHeader::~K3bThemedHeader()
{
}

 
void K3bThemedHeader::setTitle( const TQString& title, const TQString& subtitle )
{
  m_titleLabel->setTitle( title, subtitle );
}


void K3bThemedHeader::setSubTitle( const TQString& subtitle )
{
  m_titleLabel->setSubTitle( subtitle );
}


void K3bThemedHeader::setLeftPixmap( K3bTheme::PixmapType p )
{
  m_leftPix = p;
  slotThemeChanged();
}


void K3bThemedHeader::setRightPixmap( K3bTheme::PixmapType p )
{
  m_rightPix = p;
  slotThemeChanged();
}


void K3bThemedHeader::setAlignment( int align )
{
  m_titleLabel->setAlignment( align );
}


void K3bThemedHeader::init()
{
  setFrameShape( TQFrame::StyledPanel );
  setFrameShadow( TQFrame::Sunken );
  setLineWidth( 1 );
  setMargin( 1 );

  TQHBoxLayout* tqlayout = new TQHBoxLayout( this );
  tqlayout->setMargin( 2 ); // to make sure the frame gets displayed
  tqlayout->setSpacing( 0 );

  m_leftLabel = new TQLabel( this );
  m_leftLabel->setScaledContents( false );
  m_titleLabel = new K3bTitleLabel( this );
  m_rightLabel = new TQLabel( this );
  m_rightLabel->setScaledContents( false );

  tqlayout->addWidget( m_leftLabel );
  tqlayout->addWidget( m_titleLabel );
  tqlayout->setStretchFactor( m_titleLabel, 1 );
  tqlayout->addWidget( m_rightLabel );

  m_leftPix = K3bTheme::DIALOG_LEFT;
  m_rightPix = K3bTheme::DIALOG_RIGHT;

  slotThemeChanged();

  connect( k3bappcore->themeManager(), TQT_SIGNAL(themeChanged()),
	   this, TQT_SLOT(slotThemeChanged()) );
  connect( kapp, TQT_SIGNAL(appearanceChanged()),
	   this, TQT_SLOT(slotThemeChanged()) );
}


void K3bThemedHeader::slotThemeChanged()
{
  if( K3bTheme* theme = k3bappcore->themeManager()->currentTheme() ) {
//     setPaletteBackgroundColor( theme->backgroundColor() );
//     setPaletteForegroundColor( theme->foregroundColor() );

    m_leftLabel->setPaletteBackgroundColor( theme->backgroundColor() );
    m_leftLabel->setPixmap( theme->pixmap( m_leftPix ) );
    m_rightLabel->setPaletteBackgroundColor( theme->backgroundColor() );
    m_rightLabel->setPixmap( theme->pixmap( m_rightPix ) );
    m_titleLabel->setPaletteBackgroundColor( theme->backgroundColor() );
    m_titleLabel->setPaletteForegroundColor( theme->foregroundColor() );
  }
}

#include "k3bthemedheader.moc"