refactor: move serverconfigdialog visible to Settings
This commit is contained in:
parent
1e9f92c93f
commit
af17b14224
8 changed files with 45 additions and 88 deletions
|
|
@ -65,7 +65,7 @@ MainWindow::MainWindow(ConfigScopes &configScopes, AppConfig &appConfig)
|
||||||
m_appConfig(appConfig),
|
m_appConfig(appConfig),
|
||||||
m_serverConfig(appConfig, *this),
|
m_serverConfig(appConfig, *this),
|
||||||
m_coreProcess(m_serverConfig),
|
m_coreProcess(m_serverConfig),
|
||||||
m_serverConnection(this, m_serverConfig, m_serverConfigDialogState),
|
m_serverConnection(this, m_serverConfig),
|
||||||
m_clientConnection(this),
|
m_clientConnection(this),
|
||||||
m_tlsUtility(this),
|
m_tlsUtility(this),
|
||||||
m_trayIcon{new QSystemTrayIcon(this)},
|
m_trayIcon{new QSystemTrayIcon(this)},
|
||||||
|
|
@ -615,12 +615,12 @@ void MainWindow::updateSecurityIcon(bool visible)
|
||||||
|
|
||||||
void MainWindow::serverConnectionConfigureClient(const QString &clientName)
|
void MainWindow::serverConnectionConfigureClient(const QString &clientName)
|
||||||
{
|
{
|
||||||
m_serverConfigDialogState.setVisible(true);
|
Settings::setValue(Settings::Server::ConfigVisible, true);
|
||||||
ServerConfigDialog dialog(this, m_serverConfig);
|
ServerConfigDialog dialog(this, m_serverConfig);
|
||||||
if (dialog.addClient(clientName) && dialog.exec() == QDialog::Accepted) {
|
if (dialog.addClient(clientName) && dialog.exec() == QDialog::Accepted) {
|
||||||
m_coreProcess.restart();
|
m_coreProcess.restart();
|
||||||
}
|
}
|
||||||
m_serverConfigDialogState.setVisible(false);
|
Settings::setValue(Settings::Server::ConfigVisible, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
#include "VersionChecker.h"
|
#include "VersionChecker.h"
|
||||||
#include "gui/config/AppConfig.h"
|
#include "gui/config/AppConfig.h"
|
||||||
#include "gui/config/ConfigScopes.h"
|
#include "gui/config/ConfigScopes.h"
|
||||||
#include "gui/config/ServerConfigDialogState.h"
|
|
||||||
#include "gui/core/ClientConnection.h"
|
#include "gui/core/ClientConnection.h"
|
||||||
#include "gui/core/CoreProcess.h"
|
#include "gui/core/CoreProcess.h"
|
||||||
#include "gui/core/ServerConnection.h"
|
#include "gui/core/ServerConnection.h"
|
||||||
|
|
@ -195,7 +194,6 @@ private:
|
||||||
|
|
||||||
VersionChecker m_versionChecker;
|
VersionChecker m_versionChecker;
|
||||||
bool m_secureSocket = false;
|
bool m_secureSocket = false;
|
||||||
deskflow::gui::config::ServerConfigDialogState m_serverConfigDialogState;
|
|
||||||
bool m_saveOnExit = true;
|
bool m_saveOnExit = true;
|
||||||
deskflow::gui::core::WaylandWarnings m_waylandWarnings;
|
deskflow::gui::core::WaylandWarnings m_waylandWarnings;
|
||||||
deskflow::gui::ConfigScopes &m_configScopes;
|
deskflow::gui::ConfigScopes &m_configScopes;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ public:
|
||||||
struct Server
|
struct Server
|
||||||
{
|
{
|
||||||
inline static const auto Binary = QStringLiteral("server/binary");
|
inline static const auto Binary = QStringLiteral("server/binary");
|
||||||
|
inline static const auto ConfigVisible = QStringLiteral("server/configVisible");
|
||||||
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
|
inline static const auto ExternalConfig = QStringLiteral("server/externalConfig");
|
||||||
inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile");
|
inline static const auto ExternalConfigFile = QStringLiteral("server/externalConfigFile");
|
||||||
};
|
};
|
||||||
|
|
@ -163,37 +164,38 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline static const QStringList m_validKeys = {
|
inline static const QStringList m_validKeys = {
|
||||||
Client::Binary
|
Settings::Client::Binary
|
||||||
, Client::InvertScrollDirection
|
, Settings::Client::InvertScrollDirection
|
||||||
, Client::LanguageSync
|
, Settings::Client::LanguageSync
|
||||||
, Client::RemoteHost
|
, Settings::Client::RemoteHost
|
||||||
, Core::CoreMode
|
, Settings::Core::CoreMode
|
||||||
, Core::ElevateMode
|
, Settings::Core::ElevateMode
|
||||||
, Core::Interface
|
, Settings::Core::Interface
|
||||||
, Core::LastVersion
|
, Settings::Core::LastVersion
|
||||||
, Core::Port
|
, Settings::Core::Port
|
||||||
, Core::PreventSleep
|
, Settings::Core::PreventSleep
|
||||||
, Core::ProcessMode
|
, Settings::Core::ProcessMode
|
||||||
, Core::Scope
|
, Settings::Core::Scope
|
||||||
, Core::ScreenName
|
, Settings::Core::ScreenName
|
||||||
, Core::StartedBefore
|
, Settings::Core::StartedBefore
|
||||||
, Log::File
|
, Settings::Log::File
|
||||||
, Log::Level
|
, Settings::Log::Level
|
||||||
, Log::ToFile
|
, Settings::Log::ToFile
|
||||||
, Gui::Autohide
|
, Settings::Gui::Autohide
|
||||||
, Gui::AutoUpdateCheck
|
, Settings::Gui::AutoUpdateCheck
|
||||||
, Gui::CloseReminder
|
, Settings::Gui::CloseReminder
|
||||||
, Gui::CloseToTray
|
, Settings::Gui::CloseToTray
|
||||||
, Gui::LogExpanded
|
, Settings::Gui::LogExpanded
|
||||||
, Gui::SymbolicTrayIcon
|
, Settings::Gui::SymbolicTrayIcon
|
||||||
, Gui::WindowGeometry
|
, Settings::Gui::WindowGeometry
|
||||||
, Security::Certificate
|
, Settings::Security::Certificate
|
||||||
, Security::CheckPeers
|
, Settings::Security::CheckPeers
|
||||||
, Security::KeySize
|
, Settings::Security::KeySize
|
||||||
, Security::TlsEnabled
|
, Settings::Security::TlsEnabled
|
||||||
, Server::Binary
|
, Settings::Server::Binary
|
||||||
, Server::ExternalConfig
|
, Settings::Server::ConfigVisible
|
||||||
, Server::ExternalConfigFile
|
, Settings::Server::ExternalConfig
|
||||||
|
, Settings::Server::ExternalConfigFile
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ add_library(${target} STATIC
|
||||||
config/ScreenConfig.h
|
config/ScreenConfig.h
|
||||||
config/ScreenList.cpp
|
config/ScreenList.cpp
|
||||||
config/ScreenList.h
|
config/ScreenList.h
|
||||||
config/ServerConfigDialogState.h
|
|
||||||
core/ClientConnection.cpp
|
core/ClientConnection.cpp
|
||||||
core/ClientConnection.h
|
core/ClientConnection.h
|
||||||
core/CommandProcess.cpp
|
core/CommandProcess.cpp
|
||||||
|
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
|
||||||
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
|
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace deskflow::gui::config {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Represents the state of the server config dialog.
|
|
||||||
*
|
|
||||||
* Future design consideration: Once moving the server config dialog to the GUI
|
|
||||||
* lib, we can probably just pass a reference to that rather than needing an
|
|
||||||
* object to track it's state.
|
|
||||||
*/
|
|
||||||
class ServerConfigDialogState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
bool isVisible() const
|
|
||||||
{
|
|
||||||
return m_isVisible;
|
|
||||||
}
|
|
||||||
void setVisible(bool isVisible)
|
|
||||||
{
|
|
||||||
m_isVisible = isVisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_isVisible = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace deskflow::gui::config
|
|
||||||
|
|
@ -7,8 +7,9 @@
|
||||||
#include "ServerConnection.h"
|
#include "ServerConnection.h"
|
||||||
|
|
||||||
#include "ServerMessage.h"
|
#include "ServerMessage.h"
|
||||||
|
|
||||||
#include "common/Settings.h"
|
#include "common/Settings.h"
|
||||||
#include "gui/config/ServerConfigDialogState.h"
|
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
@ -31,13 +32,9 @@ messages::NewClientPromptResult ServerConnection::Deps::showNewClientPrompt(
|
||||||
// ServerConnection
|
// ServerConnection
|
||||||
//
|
//
|
||||||
|
|
||||||
ServerConnection::ServerConnection(
|
ServerConnection::ServerConnection(QWidget *parent, IServerConfig &serverConfig, std::shared_ptr<Deps> deps)
|
||||||
QWidget *parent, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState,
|
|
||||||
std::shared_ptr<Deps> deps
|
|
||||||
)
|
|
||||||
: m_pParent(parent),
|
: m_pParent(parent),
|
||||||
m_serverConfig(serverConfig),
|
m_serverConfig(serverConfig),
|
||||||
m_serverConfigDialogState(serverConfigDialogState),
|
|
||||||
m_pDeps(deps)
|
m_pDeps(deps)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +52,7 @@ void ServerConnection::handleLogLine(const QString &logLine)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_serverConfigDialogState.isVisible()) {
|
if (Settings::value(Settings::Server::ConfigVisible).toBool()) {
|
||||||
qDebug("server config dialog visible, skipping new client prompt");
|
qDebug("server config dialog visible, skipping new client prompt");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
#include "gui/config/IServerConfig.h"
|
#include "gui/config/IServerConfig.h"
|
||||||
#include "gui/config/ServerConfigDialogState.h"
|
|
||||||
#include "gui/messages.h"
|
#include "gui/messages.h"
|
||||||
|
|
||||||
namespace deskflow::gui {
|
namespace deskflow::gui {
|
||||||
|
|
@ -29,8 +28,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ServerConnection(
|
explicit ServerConnection(
|
||||||
QWidget *parent, IServerConfig &serverConfig, const config::ServerConfigDialogState &serverConfigDialogState,
|
QWidget *parent, IServerConfig &serverConfig, std::shared_ptr<Deps> deps = std::make_shared<Deps>()
|
||||||
std::shared_ptr<Deps> deps = std::make_shared<Deps>()
|
|
||||||
);
|
);
|
||||||
void handleLogLine(const QString &logLine);
|
void handleLogLine(const QString &logLine);
|
||||||
|
|
||||||
|
|
@ -43,7 +41,6 @@ private:
|
||||||
|
|
||||||
QWidget *m_pParent;
|
QWidget *m_pParent;
|
||||||
IServerConfig &m_serverConfig;
|
IServerConfig &m_serverConfig;
|
||||||
const config::ServerConfigDialogState &m_serverConfigDialogState;
|
|
||||||
std::shared_ptr<Deps> m_pDeps;
|
std::shared_ptr<Deps> m_pDeps;
|
||||||
QStringList m_receivedClients;
|
QStringList m_receivedClients;
|
||||||
bool m_messageShowing = false;
|
bool m_messageShowing = false;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gui/config/ServerConfigDialogState.h"
|
|
||||||
#include "gui/core/ServerConnection.h"
|
#include "gui/core/ServerConnection.h"
|
||||||
|
|
||||||
#include "shared/gui/mocks/ServerConfigMock.h"
|
#include "shared/gui/mocks/ServerConfigMock.h"
|
||||||
|
|
@ -36,12 +35,11 @@ class ServerConnectionTests : public testing::Test
|
||||||
public:
|
public:
|
||||||
std::shared_ptr<DepsMock> m_pDeps = std::make_shared<NiceMock<DepsMock>>();
|
std::shared_ptr<DepsMock> m_pDeps = std::make_shared<NiceMock<DepsMock>>();
|
||||||
NiceMock<ServerConfigMock> m_serverConfig;
|
NiceMock<ServerConfigMock> m_serverConfig;
|
||||||
config::ServerConfigDialogState m_serverConfigDialogState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
||||||
{
|
{
|
||||||
ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
ServerConnection serverConnection(nullptr, m_serverConfig, m_pDeps);
|
||||||
|
|
||||||
QString clientName = "test client";
|
QString clientName = "test client";
|
||||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, true)).Times(0);
|
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, clientName, true)).Times(0);
|
||||||
|
|
@ -51,7 +49,7 @@ TEST_F(ServerConnectionTests, handleLogLine_newClient_shouldShowPrompt)
|
||||||
|
|
||||||
TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt)
|
TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt)
|
||||||
{
|
{
|
||||||
ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
ServerConnection serverConnection(nullptr, m_serverConfig, m_pDeps);
|
||||||
ON_CALL(*m_pDeps, showNewClientPrompt(_, _, false))
|
ON_CALL(*m_pDeps, showNewClientPrompt(_, _, false))
|
||||||
.WillByDefault(testing::Return(messages::NewClientPromptResult::Ignore));
|
.WillByDefault(testing::Return(messages::NewClientPromptResult::Ignore));
|
||||||
serverConnection.handleLogLine(R"(unrecognised client name "stub")");
|
serverConnection.handleLogLine(R"(unrecognised client name "stub")");
|
||||||
|
|
@ -63,7 +61,7 @@ TEST_F(ServerConnectionTests, handleLogLine_ignoredClient_shouldNotShowPrompt)
|
||||||
|
|
||||||
TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt)
|
TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt)
|
||||||
{
|
{
|
||||||
ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
ServerConnection serverConnection(nullptr, m_serverConfig, m_pDeps);
|
||||||
ON_CALL(m_serverConfig, isFull()).WillByDefault(testing::Return(true));
|
ON_CALL(m_serverConfig, isFull()).WillByDefault(testing::Return(true));
|
||||||
|
|
||||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
||||||
|
|
@ -73,7 +71,7 @@ TEST_F(ServerConnectionTests, handleLogLine_serverConfigFull_shouldNotShowPrompt
|
||||||
|
|
||||||
TEST_F(ServerConnectionTests, handleLogLine_screenExists_shouldNotShowPrompt)
|
TEST_F(ServerConnectionTests, handleLogLine_screenExists_shouldNotShowPrompt)
|
||||||
{
|
{
|
||||||
ServerConnection serverConnection(nullptr, m_serverConfig, m_serverConfigDialogState, m_pDeps);
|
ServerConnection serverConnection(nullptr, m_serverConfig, m_pDeps);
|
||||||
ON_CALL(m_serverConfig, screenExists(_)).WillByDefault(testing::Return(true));
|
ON_CALL(m_serverConfig, screenExists(_)).WillByDefault(testing::Return(true));
|
||||||
|
|
||||||
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
EXPECT_CALL(*m_pDeps, showNewClientPrompt(_, _, false)).Times(0);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue