diff --git a/src/gui/gui.pro b/src/gui/gui.pro index a2b43e97..917552aa 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -13,7 +13,8 @@ FORMS += res/MainWindowBase.ui \ res/ActionDialogBase.ui \ res/HotkeyDialogBase.ui \ res/SettingsDialogBase.ui \ - res/SetupWizardBase.ui + res/SetupWizardBase.ui \ + res/AddClientDialogBase.ui SOURCES += src/main.cpp \ src/MainWindow.cpp \ src/AboutDialog.cpp \ @@ -47,7 +48,8 @@ SOURCES += src/main.cpp \ src/ZeroconfRegister.cpp \ src/ZeroconfBrowser.cpp \ src/ZeroconfService.cpp \ - src/DataDownloader.cpp + src/DataDownloader.cpp \ + src/AddClientDialog.cpp HEADERS += src/MainWindow.h \ src/AboutDialog.h \ src/ServerConfig.h \ @@ -81,7 +83,8 @@ HEADERS += src/MainWindow.h \ src/ZeroconfRecord.h \ src/ZeroconfBrowser.h \ src/ZeroconfService.h \ - src/DataDownloader.h + src/DataDownloader.h \ + src/AddClientDialog.h RESOURCES += res/Synergy.qrc RC_FILE = res/win/Synergy.rc macx { diff --git a/src/gui/res/AddClientDialogBase.ui b/src/gui/res/AddClientDialogBase.ui new file mode 100644 index 00000000..9e01dc68 --- /dev/null +++ b/src/gui/res/AddClientDialogBase.ui @@ -0,0 +1,94 @@ + + + AddClientDialog + + + + 0 + 0 + 400 + 350 + + + + + 0 + 0 + + + + Dialog + + + + + 50 + 320 + 341 + 20 + + + + + 0 + 0 + + + + Qt::Horizontal + + + QDialogButtonBox::Ignore + + + false + + + + + + 10 + 10 + 381 + 301 + + + + + + + + + m_pDialogButtonBox + accepted() + AddClientDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + m_pDialogButtonBox + rejected() + AddClientDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/src/AddClientDialog.cpp b/src/gui/src/AddClientDialog.cpp new file mode 100644 index 00000000..661c801a --- /dev/null +++ b/src/gui/src/AddClientDialog.cpp @@ -0,0 +1,121 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 Synergy Si, Inc. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "AddClientDialog.h" +#include "ui_AddClientDialogBase.h" + +#include +#include + +AddClientDialog::AddClientDialog(QWidget *parent) : + QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint), + Ui::AddClientDialog(), + m_AddResult(kAddClientIgnore) +{ + setupUi(this); + + m_pLabelHead = new QLabel(this); + m_pLabelHead->setText("Client wants to connect..."); + gridLayout->addWidget(m_pLabelHead, 0, 1, 1, 1, Qt::AlignCenter); + + QIcon icon(":res/icons/64x64/video-display.png"); + QSize IconSize(32,32); + + m_pButtonLeft = new QPushButton(this); + m_pButtonLeft->setIcon(icon); + m_pButtonLeft->setIconSize(IconSize); + gridLayout->addWidget(m_pButtonLeft, 2, 0, 1, 1, Qt::AlignCenter); + connect(m_pButtonLeft, SIGNAL(clicked()), this, SLOT(handleButtonLeft())); + + m_pButtonUp = new QPushButton(this); + m_pButtonUp->setIcon(icon); + m_pButtonUp->setIconSize(IconSize); + gridLayout->addWidget(m_pButtonUp, 1, 1, 1, 1, Qt::AlignCenter); + connect(m_pButtonUp, SIGNAL(clicked()), this, SLOT(handleButtonUp())); + + m_pButtonRight = new QPushButton(this); + m_pButtonRight->setIcon(icon); + m_pButtonRight->setIconSize(IconSize); + gridLayout->addWidget(m_pButtonRight, 2, 2, 1, 1, Qt::AlignCenter); + connect(m_pButtonRight, SIGNAL(clicked()), this, SLOT(handleButtonRight())); + + m_pButtonDown = new QPushButton(this); + m_pButtonDown->setIcon(icon); + m_pButtonDown->setIconSize(IconSize); + gridLayout->addWidget(m_pButtonDown, 3, 1, 1, 1, Qt::AlignCenter); + connect(m_pButtonDown, SIGNAL(clicked()), this, SLOT(handleButtonDown())); + + m_pLabelCenter = new QLabel(this); + m_pLabelCenter->setPixmap(QPixmap(":res/icons/64x64/video-display.png")); + gridLayout->addWidget(m_pLabelCenter, 2, 1, 1, 1, Qt::AlignCenter); + + QPushButton* advanced = m_pDialogButtonBox->addButton("Advanced", + QDialogButtonBox::HelpRole); + connect(advanced, SIGNAL(clicked()), this, SLOT(handleButtonAdvanced())); +} + +AddClientDialog::~AddClientDialog() +{ + delete m_pButtonUp; + delete m_pButtonDown; + delete m_pButtonLeft; + delete m_pButtonRight; + delete m_pLabelHead; + delete m_pLabelCenter; +} + +void AddClientDialog::changeEvent(QEvent *e) +{ + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + retranslateUi(this); + break; + default: + break; + } +} + +void AddClientDialog::handleButtonLeft() +{ + m_AddResult = kAddClientLeft; + close(); +} + +void AddClientDialog::handleButtonUp() +{ + m_AddResult = kAddClientUp; + close(); +} + +void AddClientDialog::handleButtonRight() +{ + m_AddResult = kAddClientRight; + close(); +} + +void AddClientDialog::handleButtonDown() +{ + m_AddResult = kAddClientDown; + close(); +} + +void AddClientDialog::handleButtonAdvanced() +{ + m_AddResult = kAddClientOther; + close(); +} diff --git a/src/gui/src/AddClientDialog.h b/src/gui/src/AddClientDialog.h new file mode 100644 index 00000000..a0fba00f --- /dev/null +++ b/src/gui/src/AddClientDialog.h @@ -0,0 +1,66 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 Synergy Si, Inc. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ADDCLIENTDIALOG_H +#define ADDCLIENTDIALOG_H + +#include "ui_AddClientDialogBase.h" + +#include + +class QPushButton; +class QLabel; + +enum { + kAddClientRight, + kAddClientLeft, + kAddClientUp, + kAddClientDown, + kAddClientOther, + kAddClientIgnore +}; + +class AddClientDialog : public QDialog, public Ui::AddClientDialog +{ + Q_OBJECT +public: + AddClientDialog(QWidget *parent = 0); + ~AddClientDialog(); + + int getAddResult() { return m_AddResult; } + +protected: + void changeEvent(QEvent *e); + +private slots: + void handleButtonLeft(); + void handleButtonUp(); + void handleButtonRight(); + void handleButtonDown(); + void handleButtonAdvanced(); + +private: + QPushButton* m_pButtonLeft; + QPushButton* m_pButtonUp; + QPushButton* m_pButtonRight; + QPushButton* m_pButtonDown; + QLabel* m_pLabelCenter; + QLabel* m_pLabelHead; + int m_AddResult; +}; + +#endif // ADDCLIENTDIALOG_H diff --git a/src/gui/src/ServerConfig.cpp b/src/gui/src/ServerConfig.cpp index 28b5da04..3153aa6d 100644 --- a/src/gui/src/ServerConfig.cpp +++ b/src/gui/src/ServerConfig.cpp @@ -19,6 +19,7 @@ #include "ServerConfig.h" #include "Hotkey.h" #include "MainWindow.h" +#include "AddClientDialog.h" #include #include @@ -39,13 +40,6 @@ static const struct }; -enum { - kAddClientRight, - kAddClientLeft, - kAddClientOther, - kAddClientIgnore -}; - const int serverDefaultIndex = 7; ServerConfig::ServerConfig(QSettings* settings, int numColumns, int numRows , @@ -294,7 +288,7 @@ int ServerConfig::autoAddScreen(const QString name) return kAutoAddScreenOk; } - int result = showAddClientMsgBox(name); + int result = showAddClientDialog(name); if (result == kAddClientIgnore) { return kAutoAddScreenIgnore; @@ -314,6 +308,15 @@ int ServerConfig::autoAddScreen(const QString name) offset = -1; dirIndex = 1; } + else if (result == kAddClientUp) { + offset = -5; + dirIndex = 2; + } + else if (result == kAddClientDown) { + offset = 5; + dirIndex = 3; + } + int idx = adjacentScreenIndex(startIndex, neighbourDirs[dirIndex].x, neighbourDirs[dirIndex].y); @@ -364,37 +367,11 @@ bool ServerConfig::fixNoServer(const QString& name, int& index) return fixed; } -int ServerConfig::showAddClientMsgBox(const QString& clientName) +int ServerConfig::showAddClientDialog(const QString& clientName) { - int result = kAddClientIgnore; - QWidget* w = dynamic_cast(m_pMainWindow); - QMessageBox msgBox(w); - msgBox.setIcon(QMessageBox::Question); - msgBox.setWindowTitle(QObject::tr("Incoming client")); - msgBox.setText(QObject::tr( - "A new client wants to connect. Which side\n" - "of this screen is the client (%1) located?") - .arg(clientName)); - - QPushButton* left = msgBox.addButton(QObject::tr("Left"), QMessageBox::AcceptRole); - QPushButton* right = msgBox.addButton(QObject::tr("Right"), QMessageBox::AcceptRole); - QPushButton* other = msgBox.addButton(QObject::tr("Other"), QMessageBox::AcceptRole); - QPushButton* ignore = msgBox.addButton(QObject::tr("Ignore"), QMessageBox::RejectRole); - msgBox.setDefaultButton(ignore); - - msgBox.exec(); - - QAbstractButton* button = msgBox.clickedButton(); - QPushButton* clickedButton = dynamic_cast(button); - if (clickedButton == right) { - result = kAddClientRight; - } - else if (clickedButton == left) { - result = kAddClientLeft; - } - else if (clickedButton == other) { - result = kAddClientOther; - } + AddClientDialog addClientDialog(m_pMainWindow); + addClientDialog.exec(); + int result = addClientDialog.getAddResult(); return result; } diff --git a/src/gui/src/ServerConfig.h b/src/gui/src/ServerConfig.h index ac194f1b..f770b0e7 100644 --- a/src/gui/src/ServerConfig.h +++ b/src/gui/src/ServerConfig.h @@ -95,7 +95,7 @@ class ServerConfig : public BaseConfig private: bool findScreenName(const QString& name, int& index); bool fixNoServer(const QString& name, int& index); - int showAddClientMsgBox(const QString& clientName); + int showAddClientDialog(const QString& clientName); void addToFirstEmptyGrid(const QString& clientName); private: