mirror of
https://github.com/KDE/krfb
synced 2026-07-01 15:51:18 -07:00
Adding new front end user interface
TODO: Server not started, All Incoming requests will fail
This commit is contained in:
@@ -54,7 +54,7 @@ set (krfb_SRCS
|
||||
invitedialog.cpp
|
||||
invitationmanager.cpp
|
||||
main.cpp
|
||||
manageinvitationsdialog.cpp
|
||||
mainwindow.cpp
|
||||
personalinvitedialog.cpp
|
||||
sockethelpers.cpp
|
||||
trayicon.cpp
|
||||
@@ -82,7 +82,7 @@ kde4_add_ui_files (krfb_SRCS
|
||||
ui/configsecurity.ui
|
||||
ui/connectionwidget.ui
|
||||
ui/invitewidget.ui
|
||||
ui/manageinvitations.ui
|
||||
ui/mainwidget.ui
|
||||
ui/personalinvitewidget.ui
|
||||
)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "manageinvitationsdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "trayicon.h"
|
||||
#include "invitationsrfbserver.h"
|
||||
|
||||
@@ -108,13 +108,13 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
//init the GUI
|
||||
ManageInvitationsDialog invitationsDialog;
|
||||
TrayIcon trayicon(&invitationsDialog);
|
||||
MainWindow mainWindow;
|
||||
TrayIcon trayicon(&mainWindow);
|
||||
|
||||
if (app.isSessionRestored() && KMainWindow::canBeRestored(1)) {
|
||||
invitationsDialog.restore(1, false);
|
||||
mainWindow.restore(1, false);
|
||||
} else if (KCmdLineArgs::parsedArgs()->isSet("dialog")) {
|
||||
invitationsDialog.show();
|
||||
mainWindow.show();
|
||||
}
|
||||
|
||||
sigset_t sigs;
|
||||
|
||||
187
krfb/mainwindow.cpp
Normal file
187
krfb/mainwindow.cpp
Normal file
@@ -0,0 +1,187 @@
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
|
||||
Copyright (C) 2013 Amandeep Singh <aman.dedman@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "krfbconfig.h"
|
||||
#include "ui_configtcp.h"
|
||||
#include "ui_configsecurity.h"
|
||||
|
||||
#include <KConfigDialog>
|
||||
#include <KIcon>
|
||||
#include <KLocale>
|
||||
#include <KMessageBox>
|
||||
#include <KStandardGuiItem>
|
||||
#include <KSystemTimeZone>
|
||||
#include <KToolInvocation>
|
||||
#include <KStandardAction>
|
||||
#include <KActionCollection>
|
||||
#include <KRandom>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtNetwork/QNetworkInterface>
|
||||
|
||||
class TCP: public QWidget, public Ui::TCP
|
||||
{
|
||||
public:
|
||||
TCP(QWidget *parent = 0) : QWidget(parent) {
|
||||
setupUi(this);
|
||||
}
|
||||
};
|
||||
|
||||
class Security: public QWidget, public Ui::Security
|
||||
{
|
||||
public:
|
||||
Security(QWidget *parent = 0) : QWidget(parent) {
|
||||
setupUi(this);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: KXmlGuiWindow(parent)
|
||||
{
|
||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||
|
||||
m_passwordEditable = false;
|
||||
m_passwordLineEdit = new KLineEdit(this);
|
||||
m_passwordLineEdit->setVisible(false);
|
||||
m_passwordLineEdit->setAlignment(Qt::AlignHCenter);
|
||||
|
||||
QWidget *mainWidget = new QWidget;
|
||||
m_ui.setupUi(mainWidget);
|
||||
m_ui.krfbIconLabel->setPixmap(KIcon("krfb").pixmap(128));
|
||||
setCentralWidget(mainWidget);
|
||||
|
||||
connect(m_ui.passwordEditButton,SIGNAL(clicked()),
|
||||
this,SLOT(editPassword()));
|
||||
connect(m_ui.enableSharingCheckBox,SIGNAL(toggled(bool)),
|
||||
this, SLOT(toggleDesktopSharing(bool)));
|
||||
|
||||
// Figure out the address
|
||||
int port = KrfbConfig::port();
|
||||
QList<QNetworkInterface> interfaceList = QNetworkInterface::allInterfaces();
|
||||
foreach(const QNetworkInterface & interface, interfaceList) {
|
||||
if(interface.flags() & QNetworkInterface::IsLoopBack)
|
||||
continue;
|
||||
|
||||
if(interface.flags() & QNetworkInterface::IsRunning &&
|
||||
!interface.addressEntries().isEmpty())
|
||||
m_ui.addressDisplayLabel->setText(QString("%1 : %2")
|
||||
.arg(interface.addressEntries().first().ip().toString())
|
||||
.arg(port));
|
||||
}
|
||||
|
||||
//Figure out the password
|
||||
m_password = readableRandomString(4) + '-' + readableRandomString(3);
|
||||
m_ui.passwordDisplayLabel->setText(m_password);
|
||||
|
||||
KStandardAction::quit(QCoreApplication::instance(), SLOT(quit()), actionCollection());
|
||||
KStandardAction::preferences(this, SLOT(showConfiguration()), actionCollection());
|
||||
|
||||
setupGUI();
|
||||
setFixedSize(QSize(580, 250));
|
||||
|
||||
// setAutoSaveSettings();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::editPassword()
|
||||
{
|
||||
if(m_passwordEditable) {
|
||||
m_passwordEditable = false;
|
||||
m_ui.passwordEditButton->setIcon(KIcon("document-properties"));
|
||||
m_password = m_passwordLineEdit->text();
|
||||
m_ui.passwordDisplayLabel->setText(m_password);
|
||||
m_passwordLineEdit->setVisible(false);
|
||||
m_ui.passwordGridLayout->removeWidget(m_passwordLineEdit);
|
||||
} else {
|
||||
m_passwordEditable = true;
|
||||
m_ui.passwordEditButton->setIcon(KIcon("document-save"));
|
||||
m_passwordLineEdit->setText(m_password);
|
||||
m_passwordLineEdit->setVisible(true);
|
||||
m_ui.passwordGridLayout->addWidget(m_passwordLineEdit,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleDesktopSharing(bool enable)
|
||||
{
|
||||
if(enable) {
|
||||
//TODO Start Server
|
||||
kWarning() << "This build is broken. No incoming request can be accepted.";
|
||||
} else {
|
||||
if(m_passwordEditable) {
|
||||
m_passwordEditable = false;
|
||||
m_passwordLineEdit->setVisible(false);
|
||||
m_ui.passwordEditButton->setIcon(KIcon("document-properties"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::showConfiguration()
|
||||
{
|
||||
if (KConfigDialog::showDialog("settings")) {
|
||||
return;
|
||||
}
|
||||
|
||||
KConfigDialog *dialog = new KConfigDialog(this, "settings", KrfbConfig::self());
|
||||
dialog->addPage(new TCP, i18n("Network"), "network-workgroup");
|
||||
dialog->addPage(new Security, i18n("Security"), "security-high");
|
||||
dialog->setHelp(QString(), "krfb");
|
||||
dialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::readProperties(const KConfigGroup& group)
|
||||
{
|
||||
if (group.readEntry("Visible", true)) {
|
||||
show();
|
||||
}
|
||||
KMainWindow::readProperties(group);
|
||||
}
|
||||
|
||||
void MainWindow::saveProperties(KConfigGroup& group)
|
||||
{
|
||||
group.writeEntry("Visible", isVisible());
|
||||
KMainWindow::saveProperties(group);
|
||||
}
|
||||
|
||||
// a random string that doesn't contain i, I, o, O, 1, l, 0
|
||||
// based on KRandom::randomString()
|
||||
QString MainWindow::readableRandomString(int length)
|
||||
{
|
||||
QString str;
|
||||
while (length) {
|
||||
int r = KRandom::random() % 62;
|
||||
r += 48;
|
||||
if (r > 57) {
|
||||
r += 7;
|
||||
}
|
||||
if (r > 90) {
|
||||
r += 6;
|
||||
}
|
||||
char c = char(r);
|
||||
if ((c == 'i') ||
|
||||
(c == 'I') ||
|
||||
(c == '1') ||
|
||||
(c == 'l') ||
|
||||
(c == 'o') ||
|
||||
(c == 'O') ||
|
||||
(c == '0')) {
|
||||
continue;
|
||||
}
|
||||
str += c;
|
||||
length--;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
#include "mainwindow.moc"
|
||||
47
krfb/mainwindow.h
Normal file
47
krfb/mainwindow.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* This file is part of the KDE project
|
||||
Copyright (C) 2007 Alessandro Praduroux <pradu@pradu.it>
|
||||
Copyright (C) 2013 Amandeep Singh <aman.dedman@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef MANAGEINVITATIONSDIALOG_H
|
||||
#define MANAGEINVITATIONSDIALOG_H
|
||||
|
||||
#include "ui_mainwidget.h"
|
||||
|
||||
#include <KXmlGuiWindow>
|
||||
|
||||
class KLineEdit;
|
||||
|
||||
class MainWindow : public KXmlGuiWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
public Q_SLOTS:
|
||||
void showConfiguration();
|
||||
|
||||
protected:
|
||||
virtual void readProperties(const KConfigGroup & group);
|
||||
virtual void saveProperties(KConfigGroup & group);
|
||||
|
||||
private Q_SLOTS:
|
||||
void editPassword();
|
||||
void toggleDesktopSharing(bool enable);
|
||||
|
||||
private:
|
||||
Ui::MainWidget m_ui;
|
||||
QString m_password;
|
||||
bool m_passwordEditable;
|
||||
KLineEdit *m_passwordLineEdit;
|
||||
|
||||
static QString readableRandomString(int length);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -18,8 +18,7 @@
|
||||
*/
|
||||
#include "trayicon.h"
|
||||
|
||||
#include "invitedialog.h"
|
||||
#include "manageinvitationsdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "rfbservermanager.h"
|
||||
#include "rfbclient.h"
|
||||
|
||||
|
||||
240
krfb/ui/mainwidget.ui
Normal file
240
krfb/ui/mainwidget.ui
Normal file
@@ -0,0 +1,240 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWidget</class>
|
||||
<widget class="QWidget" name="MainWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>580</width>
|
||||
<height>230</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>580</width>
|
||||
<height>230</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>580</width>
|
||||
<height>230</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="krfbIconLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="rightLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KDE Desktop Sharing</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="aboutLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>KDE Desktop Sharing allows you to grant permission to someone at a remote location for viewing and possibly controlling your desktop.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enableSharingCheckBox">
|
||||
<property name="text">
|
||||
<string>Enable Desktop Sharing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="detailsGroupBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Connection Details</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="addressFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="addressLabel">
|
||||
<property name="text">
|
||||
<string>Address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="addressGridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="addressAboutButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="help-about">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="addressDisplayLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>127.0.0.1 : 5900</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="passwordFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="passwordGridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="passwordEditButton">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="document-edit">
|
||||
<normaloff/>
|
||||
</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="passwordDisplayLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TemporaryPassword</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>enableSharingCheckBox</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>detailsGroupBox</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>245</x>
|
||||
<y>118</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>245</x>
|
||||
<y>140</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user