Fixed plural usage and efficiency of function - using if (size()) rather than if...
[kdenetwork.git] / kopete / protocols / yahoo / ui / yahoowebcamdialog.cpp
blob64fd0caaaadf57dfd5f05501b3a81c00290a684b
1 /*
2 Kopete Yahoo Protocol
4 Copyright (c) 2005 by Matt Rogers <mattr@kde.org>
5 Kopete (c) 2002-2005 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 *************************************************************************
17 #include "yahoowebcamdialog.h"
19 #include <QObject>
20 #include <QWidget>
21 #include <QLabel>
22 #include <QLayout>
23 #include <QVBoxLayout>
24 #include <QPixmap>
25 #include <kdebug.h>
26 #include <klocale.h>
28 #include <webcamwidget.h>
30 YahooWebcamDialog::YahooWebcamDialog( const QString &contactId, QWidget * parent )
31 : KDialog( parent )
33 setCaption( i18n( "Webcam for %1", contactId ) );
34 setButtons( KDialog::Close );
35 setDefaultButton( KDialog::Close );
36 showButtonSeparator( true );
38 setInitialSize( QSize(320,290) );
40 setEscapeButton( KDialog::Close );
41 QObject::connect( this, SIGNAL( closeClicked() ), this, SIGNAL( closingWebcamDialog() ) );
43 contactName = contactId;
44 QWidget *page = new QWidget(this);
45 setMainWidget(page);
47 QVBoxLayout *topLayout = new QVBoxLayout( page );
48 topLayout->addSpacing( spacingHint() );
49 m_imageContainer = new Kopete::WebcamWidget( page );
50 m_imageContainer->setText( i18n( "No webcam image received" ) );
51 m_imageContainer->setMinimumSize(320,240);
52 m_imageContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
53 topLayout->addWidget( m_imageContainer );
55 m_Viewer = new QLabel( page );
56 m_Viewer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
57 m_Viewer->hide();
58 topLayout->addWidget( m_Viewer );
60 show();
63 YahooWebcamDialog::~ YahooWebcamDialog( )
68 void YahooWebcamDialog::newImage( const QPixmap &image )
70 m_imageContainer->updatePixmap( image );
73 void YahooWebcamDialog::webcamPaused()
75 m_imageContainer->setText( QLatin1String("*** Webcam paused ***") );
78 void YahooWebcamDialog::webcamClosed( int reason )
80 kDebug(14180) << "webcam closed with reason?? " << reason;
81 QString closeReason;
82 switch ( reason )
84 case 1:
85 closeReason = i18n( "%1 has stopped broadcasting", contactName ); break;
86 case 2:
87 closeReason = i18n( "%1 has cancelled viewing permission", contactName ); break;
88 case 3:
89 closeReason = i18n( "%1 has declined permission to view webcam", contactName ); break;
90 case 4:
91 closeReason = i18n( "%1 does not have his/her webcam online", contactName ); break;
92 default:
93 closeReason = i18n( "Unable to view %1's webcam for an unknown reason", contactName);
95 m_imageContainer->clear();
97 m_imageContainer->setText( closeReason );
100 void YahooWebcamDialog::setViewer( const QStringList &viewer )
102 QString s = i18np( "1 viewer", "%1 viewers", viewer.size() );
103 if( !viewer.empty() )
105 QStringList::ConstIterator it = viewer.begin();
106 const QStringList::ConstIterator itEnd = viewer.end();
108 s += ": " + *it++;
110 for ( ; it != itEnd; ++it ) {
111 s += ", " + *it;
114 m_Viewer->setText( s );
115 m_Viewer->show();
118 // kate: indent-mode csands; tab-width 4;
120 #include "yahoowebcamdialog.moc"