File indexing completed on 2024-04-21 04:58:40

0001 /* This file is part of the KDE project
0002    Copyright (C) 2010 Collabora Ltd <info@collabora.co.uk>
0003       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
0004    Copyright (C) 2004 Nadeem Hasan <nhasan@kde.org>
0005 
0006    This program is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This program is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    General Public License for more details.
0015 
0016    You should have received a copy of the GNU General Public License
0017    along with this program; see the file COPYING.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #include "connectiondialog.h"
0023 
0024 #include <QCheckBox>
0025 #include <QIcon>
0026 
0027 #include <KLocalizedString>
0028 #include <KStandardGuiItem>
0029 #include <KConfigGroup>
0030 #include <QDialogButtonBox>
0031 #include <QPushButton>
0032 #include <KGuiItem>
0033 #include <QVBoxLayout>
0034 
0035 template <typename UI>
0036 ConnectionDialog<UI>::ConnectionDialog(QWidget *parent)
0037     : QDialog(parent)
0038 {
0039     setWindowTitle(i18n("New Connection"));
0040     auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
0041     auto mainWidget = new QWidget(this);
0042     auto mainLayout = new QVBoxLayout;
0043     setLayout(mainLayout);
0044     mainLayout->addWidget(mainWidget);
0045     QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
0046     okButton->setDefault(true);
0047     okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
0048     connect(buttonBox, &QDialogButtonBox::accepted, this, &ConnectionDialog<UI>::accept);
0049     connect(buttonBox, &QDialogButtonBox::rejected, this, &ConnectionDialog<UI>::reject);
0050     buttonBox->button(QDialogButtonBox::Cancel)->setDefault(true);
0051     setModal(true);
0052 
0053     setMinimumSize(500, 200);
0054 
0055     m_connectWidget = new QWidget(this);
0056     m_ui.setupUi(m_connectWidget);
0057 
0058     m_ui.pixmapLabel->setPixmap(QIcon::fromTheme(QStringLiteral("krfb")).pixmap(128));
0059 
0060     KGuiItem accept = KStandardGuiItem::ok();
0061     accept.setText(i18n("Accept Connection"));
0062     KGuiItem::assign(okButton, accept);
0063 
0064     KGuiItem refuse = KStandardGuiItem::cancel();
0065     refuse.setText(i18n("Refuse Connection"));
0066     KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), refuse);
0067 
0068     mainLayout->addWidget(m_connectWidget);
0069     mainLayout->addWidget(buttonBox);
0070 }
0071 
0072 //**********
0073 
0074 InvitationsConnectionDialog::InvitationsConnectionDialog(QWidget *parent)
0075     : ConnectionDialog<Ui::ConnectionWidget>(parent)
0076 {
0077 }
0078 
0079 void InvitationsConnectionDialog::setRemoteHost(const QString &host)
0080 {
0081     m_ui.remoteHost->setText(host);
0082 }