Two more usability fixes
[kdenetwork.git] / krfb / personalinvitedialog.cpp
blob6d4fc9da8cf05d0bc9fd35e68354002921e70e52
1 /* This file is part of the KDE project
2 Copyright (C) 2004 Nadeem Hasan <nhasan@kde.org>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
20 #include "personalinvitedialog.h"
21 #include "personalinvitedialog.moc"
23 #include <QtGui/QLabel>
24 #include <QtGui/QToolTip>
25 #include <QNetworkInterface>
27 #include <kiconloader.h>
28 #include <klocale.h>
29 #include <KStandardDirs>
31 #include "krfbconfig.h"
33 PersonalInviteDialog::PersonalInviteDialog( QWidget *parent )
34 : KDialog( parent )
36 setCaption(i18n("Personal Invitation"));
37 setButtons(Close);
38 setDefaultButton(Close);
39 setModal(true);
41 int port = KrfbConfig::port();
43 m_inviteWidget = new QWidget ( this );
44 setupUi(m_inviteWidget);
45 pixmapLabel->setPixmap(KStandardDirs::locate("data", "krfb/pics/connection-side-image.png"));
47 QList<QNetworkInterface> ifl = QNetworkInterface::allInterfaces();
49 foreach (QNetworkInterface nif, ifl) {
50 if (nif.flags() & QNetworkInterface::IsLoopBack) continue;
51 if (nif.flags() & QNetworkInterface::IsRunning && !nif.addressEntries().isEmpty()) {
52 hostLabel->setText( QString( "%1:%2" ).arg(nif.addressEntries().first().ip().toString()).arg(port));
56 connect( mainTextLabel, SIGNAL( linkActivated ( QString ) ),
57 SLOT( showWhatsthis( QString ) ));
59 connect( hostHelpLabel, SIGNAL( linkActivated ( QString ) ),
60 SLOT( showWhatsthis( QString ) ));
62 setMainWidget( m_inviteWidget );
66 void PersonalInviteDialog::setHost( const QString &host, uint port )
68 hostLabel->setText( QString( "%1:%2" )
69 .arg( host ).arg( port ) );
72 void PersonalInviteDialog::setPassword( const QString &passwd )
74 passwordLabel->setText( passwd );
77 void PersonalInviteDialog::setExpiration( const QDateTime &expire )
79 expirationLabel->setText( expire.toString( Qt::LocalDate ) );
82 void PersonalInviteDialog::showWhatsthis(const QString &link)
84 if (link == "htc") {
85 QToolTip::showText(QCursor::pos(),
86 i18n("Desktop Sharing uses the VNC protocol. You can use any VNC client to connect. \n"
87 "In KDE the client is called 'Remote Desktop Connection'. Enter the host information\n"
88 "into the client and it will connect.."));
89 } else if (link == "help") {
90 QToolTip::showText(QCursor::pos(),
91 i18n("This field contains the address of your computer and the display number, separated by a colon.\n"
92 "The address is just a hint - you can use any address that can reach your computer. \n"
93 "Desktop Sharing tries to guess your address from your network configuration, but does\n"
94 "not always succeed in doing so. If your computer is behind a firewall it may have a\n"
95 "different address or be unreachable for other computers."));