-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit aadaac2
Showing
17 changed files
with
1,354 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
cmake_minimum_required(VERSION 2.8.11) | ||
|
||
project(vncmanager-controller) | ||
|
||
include(GNUInstallDirs) | ||
|
||
set(CMAKE_INCLUDE_CURRENT_DIR ON) | ||
set(CMAKE_AUTOMOC ON) | ||
|
||
find_package(Qt5Widgets REQUIRED) | ||
find_package(Qt5Network REQUIRED) | ||
find_package(Qt5X11Extras REQUIRED) | ||
|
||
add_definitions(-std=c++11) | ||
|
||
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
set(vncmanager-controller_SRCS ConfigWindow.cpp StdinConnection.cpp VncConfiguration.cpp ManagerConnection.cpp main.cpp) | ||
|
||
set(vncmanager-controller_FORMS ConfigWindow.ui) | ||
|
||
qt5_wrap_ui(vncmanager-controller_FORMS_HEADERS ${vncmanager-controller_FORMS}) | ||
|
||
add_executable(vncmanager-controller ${vncmanager-controller_SRCS} ${vncmanager-controller_FORMS_HEADERS}) | ||
target_link_libraries(vncmanager-controller Qt5::Widgets Qt5::Network Qt5::X11Extras X11 Xvnc) | ||
|
||
install(TARGETS vncmanager-controller RUNTIME DESTINATION bin) | ||
install(FILES vncmanager-controller.desktop DESTINATION /${CMAKE_INSTALL_SYSCONFDIR}/xdg/autostart) | ||
install(DIRECTORY gnome-shell-extension DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/gnome-shell/extensions/[email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
#include "ConfigWindow.h" | ||
|
||
#include <QtWidgets/QLabel> | ||
#include <QtWidgets/QMenu> | ||
#include <QtWidgets/QMenuBar> | ||
#include <QtWidgets/QAction> | ||
#include <QtGui/QShowEvent> | ||
|
||
ConfigWindow::ConfigWindow(VncConfiguration &data, bool dontClose) | ||
: m_data(data) | ||
, m_dontClose(dontClose) | ||
{ | ||
ui.setupUi(this); | ||
|
||
// Disabled for now: | ||
ui.chkSecurityVncAuth->setVisible(false); | ||
ui.widgetVncAuth->setVisible(false); | ||
|
||
// Not supposed to be visible: | ||
ui.chkSecurityUnknown->setVisible(false); | ||
ui.chkSharingUnknown->setVisible(false); | ||
|
||
adjustSize(); | ||
|
||
connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonBarClicked(QAbstractButton *))); | ||
} | ||
|
||
ConfigWindow::~ConfigWindow() | ||
{} | ||
|
||
void ConfigWindow::showEvent(QShowEvent *event) | ||
{ | ||
QWidget::showEvent(event); | ||
|
||
m_data.read(); | ||
|
||
ui.editSessionName->setText(m_data.getSessionName()); | ||
|
||
ui.chkPersistencePersistent->setChecked(m_data.getPersistence() == VncConfiguration::Persistence::Persistent); | ||
ui.chkPersistenceNonPersistent->setChecked(m_data.getPersistence() == VncConfiguration::Persistence::NonPersistent); | ||
|
||
ui.chkSecurityUnknown->setChecked(m_data.getSecurity() == VncConfiguration::Security::Unknown); | ||
ui.chkSecurityNone-> setChecked(m_data.getSecurity() == VncConfiguration::Security::None); | ||
ui.chkSecurityVncAuth->setChecked(m_data.getSecurity() == VncConfiguration::Security::VncAuth); | ||
ui.chkSecurityPlain-> setChecked(m_data.getSecurity() == VncConfiguration::Security::Plain); | ||
|
||
ui.chkSharingUnknown-> setChecked(m_data.getSharing() == VncConfiguration::Sharing::Unknown); | ||
ui.chkSharingOneClient-> setChecked(m_data.getSharing() == VncConfiguration::Sharing::OneClient); | ||
ui.chkSharingMultipleClients->setChecked(m_data.getSharing() == VncConfiguration::Sharing::MultipleClients); | ||
|
||
ui.editAllowedUsers->setText(m_data.getPlainUsers().join(",")); | ||
} | ||
|
||
void ConfigWindow::closeEvent(QCloseEvent *event) | ||
{ | ||
if (m_dontClose) { | ||
event->ignore(); | ||
hide(); | ||
} else { | ||
event->accept(); | ||
} | ||
} | ||
|
||
void ConfigWindow::apply() | ||
{ | ||
m_data.setSessionName(ui.editSessionName->text()); | ||
|
||
if (ui.chkPersistencePersistent->isChecked()) { | ||
m_data.setPersistence(VncConfiguration::Persistence::Persistent); | ||
} else if (ui.chkPersistenceNonPersistent->isChecked()) { | ||
m_data.setPersistence(VncConfiguration::Persistence::NonPersistent); | ||
} | ||
|
||
if (ui.chkSecurityNone->isChecked()) { | ||
m_data.setSecurityNone(); | ||
} else if (ui.chkSecurityVncAuth->isChecked()) { | ||
m_data.setSecurityVncAuth(ui.editPassword->text(), ui.editViewonlyPassword->text()); | ||
} else if (ui.chkSecurityPlain->isChecked()) { | ||
m_data.setSecurityPlain(ui.editAllowedUsers->text().split(',')); | ||
} | ||
|
||
if (ui.chkSharingOneClient->isChecked()) { | ||
m_data.setSharing(VncConfiguration::Sharing::OneClient); | ||
} else if (ui.chkSharingMultipleClients->isChecked()) { | ||
m_data.setSharing(VncConfiguration::Sharing::MultipleClients); | ||
} | ||
|
||
m_data.apply(); | ||
} | ||
|
||
void ConfigWindow::done() | ||
{ | ||
if (m_dontClose) { | ||
hide(); | ||
} else { | ||
close(); | ||
} | ||
} | ||
|
||
void ConfigWindow::buttonBarClicked(QAbstractButton *button) | ||
{ | ||
switch (ui.buttonBox->buttonRole(button)) { | ||
case QDialogButtonBox::AcceptRole: | ||
apply(); | ||
done(); | ||
break; | ||
|
||
case QDialogButtonBox::ApplyRole: | ||
apply(); | ||
break; | ||
|
||
case QDialogButtonBox::RejectRole: | ||
done(); | ||
break; | ||
} | ||
} | ||
|
||
void ConfigWindow::trayActivated(QSystemTrayIcon::ActivationReason reason) | ||
{ | ||
switch (reason) { | ||
case QSystemTrayIcon::Trigger: | ||
toggleVisible(); | ||
|
||
break; | ||
} | ||
} | ||
|
||
void ConfigWindow::toggleVisible() | ||
{ | ||
if (isVisible()) { | ||
done(); | ||
} else { | ||
show(); | ||
} | ||
} | ||
|
||
|
||
#include "ConfigWindow.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef CONFIGURATION_H | ||
#define CONFIGURATION_H | ||
|
||
#include <QtWidgets/QMainWindow> | ||
#include <QtWidgets/QSystemTrayIcon> | ||
|
||
#include "VncConfiguration.h" | ||
|
||
#include "ui_ConfigWindow.h" | ||
|
||
class ConfigWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ConfigWindow(VncConfiguration &data, bool dontClose = false); | ||
virtual ~ConfigWindow(); | ||
|
||
virtual void showEvent(QShowEvent *); | ||
virtual void closeEvent(QCloseEvent *); | ||
|
||
private: | ||
void apply(); | ||
void done(); | ||
|
||
public slots: | ||
void trayActivated(QSystemTrayIcon::ActivationReason reason); | ||
void toggleVisible(); | ||
|
||
private slots: | ||
void buttonBarClicked(QAbstractButton *button); | ||
|
||
private: | ||
Ui_ConfigWindow ui; | ||
|
||
VncConfiguration &m_data; | ||
bool m_dontClose; | ||
}; | ||
|
||
#endif // CONFIGURATION_H |
Oops, something went wrong.