]> icculus.org git repositories - duncan/yast2-qt4.git/blob - src/YQAlignment.cc
disabling the style for now as the theming causes terrible
[duncan/yast2-qt4.git] / src / YQAlignment.cc
1 /*---------------------------------------------------------------------\
2 |                                                                      |
3 |                      __   __    ____ _____ ____                      |
4 |                      \ \ / /_ _/ ___|_   _|___ \                     |
5 |                       \ V / _` \___ \ | |   __) |                    |
6 |                        | | (_| |___) || |  / __/                     |
7 |                        |_|\__,_|____/ |_| |_____|                    |
8 |                                                                      |
9 |                               core system                            |
10 |                                                        (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12
13   File:       YQAlignment.cc
14
15   Author:     Stefan Hundhammer <sh@suse.de>
16
17 /-*/
18
19
20 #define y2log_component "qt-ui"
21 #include <ycp/y2log.h>
22 #include <qpixmap.h>
23 #include "YQAlignment.h"
24
25 using std::string;
26
27
28 YQAlignment::YQAlignment( YWidget *             parent,
29                           YAlignmentType        horAlign,
30                           YAlignmentType        vertAlign )
31     : QWidget( (QWidget *) parent->widgetRep() )
32     , YAlignment( parent, horAlign, vertAlign )
33 {
34     setWidgetRep( this );
35 }
36
37
38 YQAlignment::YQAlignment( YWidget *             yParent,
39                           QWidget *             qParent,
40                           YAlignmentType        horAlign,
41                           YAlignmentType        vertAlign )
42     : QWidget( qParent )
43     , YAlignment( yParent, horAlign, vertAlign )
44 {
45     setWidgetRep( this );
46 }
47
48
49 void YQAlignment::setEnabled( bool enabled )
50 {
51     QWidget::setEnabled( enabled );
52     YWidget::setEnabled( enabled );
53 }
54
55
56 void YQAlignment::moveChild( YWidget * child, int newX, int newY )
57 {
58     QWidget * qw = (QWidget *) ( child->widgetRep() );
59     qw->move( newX, newY );
60 }
61
62
63 void YQAlignment::setSize( int newWidth, int newHeight )
64 {
65     resize( newWidth, newHeight );
66     YAlignment::setSize( newWidth, newHeight );
67 }
68
69
70 void YQAlignment::setBackgroundPixmap( const string & pixmapFileName )
71 {
72     string pixmapName = pixmapFileName;
73     
74     YAlignment::setBackgroundPixmap( pixmapName );      // Prepend path etc.
75     pixmapName = YAlignment::backgroundPixmap();
76
77     if ( pixmapName.empty() )   // Delete any old background pixmap
78     {
79         setPalette(QPalette());
80     }
81     else                        // Set a new background pixmap
82     {
83         QPixmap pixmap( pixmapName.c_str() );
84
85         if ( pixmap.isNull() )
86         {
87             y2error( "Can't load background pixmap %s", pixmapName.c_str() );
88         }
89         else
90         {
91         QPalette palette;
92         palette.setBrush(backgroundRole(), QBrush(pixmap));
93         setPalette(palette);
94         }
95     }
96 }
97
98 #include "YQAlignment.moc"