2
* client_viewer_widget.cpp - main-widget of ICV which contains all other widgets and provides general UI
5
* Copyright (c) 2004-2005 Tobias Doerffel <tobias@doerffel.de>
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.
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.
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.
25
#include <qapplication.h>
26
#include <qpushbutton.h>
27
#include <qscrollview.h>
30
#include "client_viewer_widget.h"
35
#include "client_viewer_widget.moc"
38
QPixmap * clientViewerWidget::s_topBarPixmap = NULL;
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;
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 ),
52
if( s_topBarPixmap == NULL )
53
s_topBarPixmap = new QPixmap( embed::getIconPixmap( "top_bar" ) );
55
setBackgroundMode( Qt::NoBackground );
57
setCaption( "iTALC "+m_helpPersonTxt );
60
f.setPointSize( HELP_PERSON_FONT_SIZE );
63
m_helpPersonTxtWidth = fm.width( m_helpPersonTxt );
66
f.setPointSize( INFO_FONT_SIZE );
68
fm = QFontMetrics( f );
70
int bx = HELP_PERSON_X + m_helpPersonTxtWidth + misc::max<int>( fm.width( m_pupilName ), fm.width( m_clientIP ) ) + 40;
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() ) );
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 ) ) );
82
m_scrollView = new QScrollView( this );
83
m_scrollView->move( 0, TOP_BAR_HEIGHT+1 );
84
m_scrollView->setFrameStyle( QFrame::NoFrame );
86
m_vncView = new QVncView( m_scrollView, 0, _cip, 5900, QString::null, QUALITY_HIGH, DOT_CURSOR_ON );
88
//m_vncView->enableScaling( TRUE );
89
m_scrollView->addChild( m_vncView );
94
m_vncView->grabKeyboard();
100
clientViewerWidget::~clientViewerWidget()
108
void clientViewerWidget::paintEvent( QPaintEvent * )
110
QPixmap draw_pm( this->rect().size() );
111
draw_pm.fill( QColor( 0, 0, 0 ) );
113
QPainter p( &draw_pm, this );
115
p.drawPixmap( 0, 0, *s_topBarPixmap );
118
f.setPointSize( HELP_PERSON_FONT_SIZE );
122
p.setPen( QColor( 255, 232, 0 ) );
123
p.drawText( HELP_PERSON_X, ( TOP_BAR_HEIGHT+HELP_PERSON_FONT_SIZE ) / 2 - 2, m_helpPersonTxt );
126
f.setPointSize( INFO_FONT_SIZE );
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 );
135
// and blit all drawn stuff on the screen...
136
bitBlt( this, this->rect().topLeft(), &draw_pm );
142
void clientViewerWidget::resizeEvent( QResizeEvent * )
144
m_scrollView->resize( width(), height()-TOP_BAR_HEIGHT );
150
void clientViewerWidget::toggleFullScreen( bool _on )
152
#if QT_VERSION >= 0x030300
154
setWindowState( windowState() | WindowFullScreen );
156
setWindowState( windowState() & ~WindowFullScreen );