~ubuntu-branches/debian/lenny/italc/lenny

« back to all changes in this revision

Viewing changes to master/icv/src/client_viewer_widget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Winnertz
  • Date: 2008-06-17 13:46:54 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20080617134654-2y5m7ki93r5c1ysf
Tags: upstream-1.0.9~rc3
ImportĀ upstreamĀ versionĀ 1.0.9~rc3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * client_viewer_widget.cpp - main-widget of ICV which contains all other widgets and provides general UI
3
 
 *
4
 
 * iTALC
5
 
 * Copyright (c) 2004-2005 Tobias Doerffel <tobias@doerffel.de>
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU General Public
9
 
 * License as published by the Free Software Foundation; either
10
 
 * version 2 of the License, or (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
 
 * General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public
18
 
 * License along with this program (see COPYING); if not, write to the
19
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
 * Boston, MA 02111-1307, USA.
21
 
 *
22
 
 */
23
 
 
24
 
 
25
 
#include <qapplication.h>
26
 
#include <qpushbutton.h>
27
 
#include <qscrollview.h>
28
 
#include <qpainter.h>
29
 
 
30
 
#include "client_viewer_widget.h"
31
 
#include "qvncview.h"
32
 
#include "embed.h"
33
 
#include "misc.h"
34
 
 
35
 
#include "client_viewer_widget.moc"
36
 
 
37
 
 
38
 
QPixmap * clientViewerWidget::s_topBarPixmap = NULL;
39
 
 
40
 
const int TOP_BAR_HEIGHT = 32;
41
 
const int HELP_PERSON_FONT_SIZE = 16;
42
 
const int HELP_PERSON_X = 130;
43
 
const int INFO_FONT_SIZE = 10;
44
 
 
45
 
 
46
 
clientViewerWidget::clientViewerWidget( const QString & _pname, const QString & _cip ) :
47
 
        QWidget(/* 0, 0, WNoAutoErase*/ ),
48
 
        m_helpPersonTxt( "- " + tr( "Help a person" ) ),
49
 
        m_pupilName( _pname ),
50
 
        m_clientIP( _cip )
51
 
{
52
 
        if( s_topBarPixmap == NULL )
53
 
                s_topBarPixmap = new QPixmap( embed::getIconPixmap( "top_bar" ) );
54
 
 
55
 
        setBackgroundMode( Qt::NoBackground );
56
 
 
57
 
        setCaption( "iTALC "+m_helpPersonTxt );
58
 
 
59
 
        QFont f;
60
 
        f.setPointSize( HELP_PERSON_FONT_SIZE );
61
 
        f.setBold( TRUE );
62
 
        QFontMetrics fm( f );
63
 
        m_helpPersonTxtWidth = fm.width( m_helpPersonTxt );
64
 
 
65
 
 
66
 
        f.setPointSize( INFO_FONT_SIZE );
67
 
        f.setBold( FALSE );
68
 
        fm = QFontMetrics( f );
69
 
 
70
 
        int bx = HELP_PERSON_X + m_helpPersonTxtWidth + misc::max<int>( fm.width( m_pupilName ), fm.width( m_clientIP ) ) + 40;
71
 
 
72
 
        m_quitBtn = new QPushButton( embed::getIconPixmap( "cancel" ), tr( "Quit" ), this );
73
 
        m_quitBtn->setGeometry( bx, 4, 120, 24 );
74
 
        connect( m_quitBtn, SIGNAL( clicked() ), qApp, SLOT( closeAllWindows() ) );
75
 
        
76
 
        m_toggleFullScreenBtn = new QPushButton( embed::getIconPixmap( "toggle_fullscreen" ), tr( "Fullscreen" ), this );
77
 
        m_toggleFullScreenBtn->setGeometry( bx+140, 4, 120, 24 );
78
 
        m_toggleFullScreenBtn->setToggleButton( TRUE );
79
 
        m_toggleFullScreenBtn->setOn( TRUE );
80
 
        connect( m_toggleFullScreenBtn, SIGNAL( toggled( bool ) ), this, SLOT( toggleFullScreen( bool ) ) );
81
 
 
82
 
        m_scrollView = new QScrollView( this );
83
 
        m_scrollView->move( 0, TOP_BAR_HEIGHT+1 );
84
 
        m_scrollView->setFrameStyle( QFrame::NoFrame );
85
 
 
86
 
        m_vncView = new QVncView( m_scrollView, 0, _cip, 5900, QString::null, QUALITY_HIGH, DOT_CURSOR_ON );
87
 
        m_vncView->start();
88
 
        //m_vncView->enableScaling( TRUE );
89
 
        m_scrollView->addChild( m_vncView );
90
 
 
91
 
        showMaximized();
92
 
        showFullScreen();
93
 
 
94
 
        m_vncView->grabKeyboard();
95
 
}
96
 
 
97
 
 
98
 
 
99
 
 
100
 
clientViewerWidget::~clientViewerWidget()
101
 
{
102
 
 
103
 
}
104
 
 
105
 
 
106
 
 
107
 
 
108
 
void clientViewerWidget::paintEvent( QPaintEvent * )
109
 
{
110
 
        QPixmap draw_pm( this->rect().size() );
111
 
        draw_pm.fill( QColor( 0, 0, 0 ) );
112
 
 
113
 
        QPainter p( &draw_pm, this );
114
 
 
115
 
        p.drawPixmap( 0, 0, *s_topBarPixmap );
116
 
 
117
 
        QFont f;
118
 
        f.setPointSize( HELP_PERSON_FONT_SIZE );
119
 
        f.setBold( TRUE );
120
 
        p.setFont( f );
121
 
 
122
 
        p.setPen( QColor( 255, 232, 0 ) );
123
 
        p.drawText( HELP_PERSON_X, ( TOP_BAR_HEIGHT+HELP_PERSON_FONT_SIZE ) / 2 - 2, m_helpPersonTxt );
124
 
 
125
 
 
126
 
        f.setPointSize( INFO_FONT_SIZE );
127
 
        f.setBold( FALSE );
128
 
        p.setFont( f );
129
 
 
130
 
        int info_x = HELP_PERSON_X+m_helpPersonTxtWidth+15;
131
 
        p.setPen( QColor( 0, 255, 0 ) );
132
 
        p.drawText( info_x, INFO_FONT_SIZE + 3, m_pupilName );
133
 
        p.drawText( info_x, 2*INFO_FONT_SIZE + 7, m_clientIP );
134
 
        
135
 
        // and blit all drawn stuff on the screen...
136
 
        bitBlt( this, this->rect().topLeft(), &draw_pm );
137
 
}
138
 
 
139
 
 
140
 
 
141
 
 
142
 
void clientViewerWidget::resizeEvent( QResizeEvent * )
143
 
{
144
 
        m_scrollView->resize( width(), height()-TOP_BAR_HEIGHT );
145
 
}
146
 
 
147
 
 
148
 
 
149
 
 
150
 
void clientViewerWidget::toggleFullScreen( bool _on )
151
 
{
152
 
#if QT_VERSION >= 0x030300
153
 
        if( _on )
154
 
                setWindowState( windowState() | WindowFullScreen );
155
 
        else
156
 
                setWindowState( windowState() & ~WindowFullScreen );
157
 
#else
158
 
        if( _on )
159
 
                showFullScreen();
160
 
        else
161
 
                showNormal();
162
 
#endif
163
 
}
164
 
 
165