Merge pull request #6977 from symless/SYNERGY-799-Server-configuration-main-window

SYNERGY-799 Server configuration main window
This commit is contained in:
Andrey Batyiev 2021-04-14 16:34:03 +03:00 committed by GitHub
commit 39c151469b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 1565 additions and 908 deletions

View file

@ -15,6 +15,7 @@ Enhancements:
- #6959 Update synergy UI. Setup wizard
- #6969 Update synergy UI. Validation for aliases.
- #6973 Update synergy UI. Main window
- #6977 Update synergy UI. Configure server
- #6962 | #6965 Add macOS 10.13 builder
===========

View file

@ -1,48 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* 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 LICENSE 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 <http://www.gnu.org/licenses/>.
*/
#include "NewScreenWidget.h"
#include "ScreenSetupModel.h"
#include <QtCore>
#include <QtGui>
NewScreenWidget::NewScreenWidget(QWidget* parent) :
QLabel(parent)
{
}
void NewScreenWidget::mousePressEvent(QMouseEvent* event)
{
Screen newScreen(tr("Unnamed"));
QByteArray itemData;
QDataStream dataStream(&itemData, QIODevice::WriteOnly);
dataStream << -1 << -1 << newScreen;
QMimeData* pMimeData = new QMimeData;
pMimeData->setData(ScreenSetupModel::mimeType(), itemData);
QDrag* pDrag = new QDrag(this);
pDrag->setMimeData(pMimeData);
pDrag->setPixmap(*pixmap());
pDrag->setHotSpot(event->pos());
pDrag->exec(Qt::CopyAction, Qt::CopyAction);
}

View file

@ -1,40 +0,0 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012-2016 Symless Ltd.
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
*
* 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 LICENSE 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 <http://www.gnu.org/licenses/>.
*/
#if !defined(NEWSCREENWIDGET__H)
#define NEWSCREENWIDGET__H
#include <QLabel>
class QMouseEvent;
class QWidget;
class NewScreenWidget : public QLabel
{
Q_OBJECT
public:
NewScreenWidget(QWidget* parent);
protected:
void mousePressEvent(QMouseEvent* event);
};
#endif

View file

@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "validators/ScreenNameValidator.h"
#include "validators/AliasValidator.h"
#include "ScreenSettingsDialog.h"
#include "Screen.h"
@ -31,12 +33,10 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen,cons
setupUi(this);
m_pLineEditName->setText(m_pScreen->name());
m_NameValidator = std::make_unique<validators::ScreenNameValidator>(m_pLineEditName, m_pLabelNameError, pScreens);
m_pLineEditName->setValidator(m_NameValidator.get());
m_pLineEditName->setValidator(new validators::ScreenNameValidator(m_pLineEditName, m_pLabelNameError, pScreens));
m_pLineEditName->selectAll();
m_AliasValidator = std::make_unique<validators::AliasValidator>(m_pLineEditAlias, m_pLabelAliasError);
m_pLineEditAlias->setValidator(m_AliasValidator.get());
m_pLineEditAlias->setValidator(new validators::AliasValidator(m_pLineEditAlias, m_pLabelAliasError));
for (int i = 0; i < m_pScreen->aliases().count(); i++)
new QListWidgetItem(m_pScreen->aliases()[i], m_pListAliases);
@ -57,6 +57,8 @@ ScreenSettingsDialog::ScreenSettingsDialog(QWidget* parent, Screen* pScreen,cons
m_pCheckBoxNumLock->setChecked(m_pScreen->fix(Screen::NumLock));
m_pCheckBoxScrollLock->setChecked(m_pScreen->fix(Screen::ScrollLock));
m_pCheckBoxXTest->setChecked(m_pScreen->fix(Screen::XTest));
resize(400, 625);
}
void ScreenSettingsDialog::accept()

View file

@ -22,8 +22,6 @@
#include <memory>
#include <QDialog>
#include "validators/ScreenNameValidator.h"
#include "validators/AliasValidator.h"
#include "ui_ScreenSettingsDialogBase.h"
@ -51,8 +49,6 @@ class ScreenSettingsDialog : public QDialog, public Ui::ScreenSettingsDialogBase
private:
Screen* m_pScreen;
std::unique_ptr<validators::ScreenNameValidator> m_NameValidator;
std::unique_ptr<validators::AliasValidator> m_AliasValidator;
};

File diff suppressed because it is too large Load diff

View file

@ -141,3 +141,22 @@ bool ScreenSetupModel::dropMimeData(const QMimeData* data, Qt::DropAction action
return true;
}
void ScreenSetupModel::addScreen(const Screen& newScreen)
{
auto screenTest = std::find_if(m_Screens.begin(), m_Screens.end(),
[](const Screen& item) { return item.isNull(); });
if (screenTest != m_Screens.end())
{
(*screenTest) = newScreen;
}
}
bool ScreenSetupModel::isFull() const
{
auto emptyScreen = std::find_if(m_Screens.cbegin(), m_Screens.cend(),
[](const Screen& item) { return item.isNull(); });
return (emptyScreen == m_Screens.cend());
}

View file

@ -51,6 +51,7 @@ class ScreenSetupModel : public QAbstractTableModel
Qt::ItemFlags flags(const QModelIndex& index) const;
QStringList mimeTypes() const;
QMimeData* mimeData(const QModelIndexList& indexes) const;
bool isFull() const;
protected:
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
@ -58,6 +59,7 @@ class ScreenSetupModel : public QAbstractTableModel
Screen& screen(const QModelIndex& index) { return screen(index.column(), index.row()); }
const Screen& screen(int column, int row) const { return m_Screens[row * m_NumColumns + column]; }
Screen& screen(int column, int row) { return m_Screens[row * m_NumColumns + column]; }
void addScreen(const Screen& newScreen);
private:
ScreenList& m_Screens;

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScreenSettingsDialog.h"
#include "ServerConfigDialog.h"
#include "ServerConfig.h"
#include "HotkeyDialog.h"
@ -82,6 +83,9 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config) :
}
}
}
m_pButtonAddComputer->setEnabled(!model().isFull());
connect(m_pTrashScreenWidget, SIGNAL(screenRemoved()), this, SLOT(onScreenRemoved()));
}
void ServerConfigDialog::showEvent(QShowEvent* event)
@ -262,6 +266,24 @@ void ServerConfigDialog::on_m_pListActions_itemSelectionChanged()
m_pButtonRemoveAction->setEnabled(!m_pListActions->selectedItems().isEmpty());
}
void ServerConfigDialog::on_m_pButtonAddComputer_clicked()
{
Screen newScreen("");
ScreenSettingsDialog dlg(this, &newScreen, &model().m_Screens);
if (dlg.exec() == QDialog::Accepted)
{
model().addScreen(newScreen);
}
m_pButtonAddComputer->setEnabled(!model().isFull());
}
void ServerConfigDialog::onScreenRemoved()
{
m_pButtonAddComputer->setEnabled(true);
}
void ServerConfigDialog::on_m_pCheckBoxUseExternalConfig_toggled(bool checked)
{
m_pLabelConfigFile->setEnabled(checked);

View file

@ -50,6 +50,8 @@ class ServerConfigDialog : public QDialog, public Ui::ServerConfigDialogBase
void on_m_pButtonEditAction_clicked();
void on_m_pButtonRemoveAction_clicked();
void on_m_pCheckBoxEnableClipboard_stateChanged(int state);
void on_m_pButtonAddComputer_clicked();
void onScreenRemoved();
void on_m_pCheckBoxUseExternalConfig_toggled(bool checked = false);
bool on_m_pButtonBrowseConfigFile_clicked();

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "SettingsDialog.h"
#include "validators/ScreenNameValidator.h"
#include "CoreInterface.h"
#include "SynergyLocale.h"
@ -52,8 +53,7 @@ SettingsDialog::SettingsDialog(QWidget* parent, AppConfig& config) :
enableControls(appConfig().isWritable());
const auto& serveConfig = m_pMainWindow->serverConfig();
m_ScreenNameValidator = std::make_unique<validators::ScreenNameValidator>(m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens()));
m_pLineEditScreenName->setValidator(m_ScreenNameValidator.get());
m_pLineEditScreenName->setValidator(new validators::ScreenNameValidator(m_pLineEditScreenName, m_pLabelNameError, (&serveConfig.screens())));
connect(m_pLineEditLogFilename, SIGNAL(textChanged(QString)), this, SLOT(onChange()));
connect(m_pComboLogLevel, SIGNAL(currentIndexChanged(int)), this, SLOT(onChange()));

View file

@ -23,7 +23,7 @@
#include <memory>
#include <QDialog>
#include "ui_SettingsDialogBase.h"
#include "validators/ScreenNameValidator.h"
#include "SynergyLocale.h"
#include "CoreInterface.h"
@ -70,7 +70,6 @@ class SettingsDialog : public QDialog, public Ui::SettingsDialogBase
SynergyLocale m_Locale;
CoreInterface m_CoreInterface;
BonjourWindows* m_pBonjourWindows;
std::unique_ptr<validators::ScreenNameValidator> m_ScreenNameValidator;
/// @brief Stores settings scope at start of settings dialog
/// This is neccessary to restore state if user changes

View file

@ -25,8 +25,7 @@ SetupWizard::SetupWizard(MainWindow& mainWindow) :
setupUi(this);
m_pLineEditName->setText(m_MainWindow.appConfig().screenName());
m_ScreenNameValidator = std::make_unique<validators::ScreenNameValidator>(m_pLineEditName, label_ErrorMessage);
m_pLineEditName->setValidator(m_ScreenNameValidator.get());
m_pLineEditName->setValidator(new validators::ScreenNameValidator(m_pLineEditName, label_ErrorMessage));
connect(m_pButtonApply, SIGNAL(clicked()), this, SLOT(accept()));
connect(m_pLineEditName, SIGNAL(textEdited(QString)), this, SLOT(onNameChanged()));

View file

@ -19,7 +19,6 @@
#include <memory>
#include "ui_SetupWizardBase.h"
#include <QDialog>
#include "validators/ScreenNameValidator.h"
class MainWindow;
@ -36,7 +35,6 @@ protected:
private:
MainWindow& m_MainWindow;
std::unique_ptr<validators::ScreenNameValidator> m_ScreenNameValidator;
private slots:
void onNameChanged();

View file

@ -36,8 +36,13 @@ void TrashScreenWidget::dragEnterEvent(QDragEnterEvent* event)
void TrashScreenWidget::dropEvent(QDropEvent* event)
{
if (event->mimeData()->hasFormat(ScreenSetupModel::mimeType()))
{
event->acceptProposedAction();
emit screenRemoved();
}
else
{
event->ignore();
}
}

View file

@ -36,6 +36,10 @@ class TrashScreenWidget : public QLabel
public:
void dragEnterEvent(QDragEnterEvent* event);
void dropEvent(QDropEvent* event);
signals:
void screenRemoved();
};
#endif