refactor: anon enum in AddClientDialog to AddAction enum class
This commit is contained in:
parent
a88a67d47f
commit
9beea1abfe
3 changed files with 24 additions and 22 deletions
|
|
@ -324,6 +324,8 @@ int ServerConfig::numScreens() const
|
||||||
|
|
||||||
int ServerConfig::autoAddScreen(const QString name)
|
int ServerConfig::autoAddScreen(const QString name)
|
||||||
{
|
{
|
||||||
|
using enum AddAction;
|
||||||
|
|
||||||
int serverIndex = -1;
|
int serverIndex = -1;
|
||||||
int targetIndex = -1;
|
int targetIndex = -1;
|
||||||
const auto screenName = Settings::value(Settings::Core::ScreenName).toString();
|
const auto screenName = Settings::value(Settings::Core::ScreenName).toString();
|
||||||
|
|
@ -336,13 +338,13 @@ int ServerConfig::autoAddScreen(const QString name)
|
||||||
return kAutoAddScreenIgnore;
|
return kAutoAddScreenIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = showAddClientDialog(name);
|
auto result = static_cast<AddAction>(showAddClientDialog(name));
|
||||||
|
|
||||||
if (result == kAddClientIgnore) {
|
if (result == AddClientIgnore) {
|
||||||
return kAutoAddScreenIgnore;
|
return kAutoAddScreenIgnore;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == kAddClientOther) {
|
if (result == AddClientOther) {
|
||||||
addToFirstEmptyGrid(name);
|
addToFirstEmptyGrid(name);
|
||||||
return kAutoAddScreenManualClient;
|
return kAutoAddScreenManualClient;
|
||||||
}
|
}
|
||||||
|
|
@ -352,13 +354,13 @@ int ServerConfig::autoAddScreen(const QString name)
|
||||||
int offset = 1;
|
int offset = 1;
|
||||||
int dirIndex = 0;
|
int dirIndex = 0;
|
||||||
|
|
||||||
if (result == kAddClientLeft) {
|
if (result == AddClientLeft) {
|
||||||
offset = -1;
|
offset = -1;
|
||||||
dirIndex = 1;
|
dirIndex = 1;
|
||||||
} else if (result == kAddClientUp) {
|
} else if (result == AddClientUp) {
|
||||||
offset = -5;
|
offset = -5;
|
||||||
dirIndex = 2;
|
dirIndex = 2;
|
||||||
} else if (result == kAddClientDown) {
|
} else if (result == AddClientDown) {
|
||||||
offset = 5;
|
offset = 5;
|
||||||
dirIndex = 3;
|
dirIndex = 3;
|
||||||
}
|
}
|
||||||
|
|
@ -488,7 +490,7 @@ bool ServerConfig::fixNoServer(const QString &name, int &index)
|
||||||
|
|
||||||
int ServerConfig::showAddClientDialog(const QString &clientName)
|
int ServerConfig::showAddClientDialog(const QString &clientName)
|
||||||
{
|
{
|
||||||
int result = kAddClientIgnore;
|
auto result = static_cast<int>(AddAction::AddClientIgnore);
|
||||||
|
|
||||||
if (!m_pMainWindow->isActiveWindow()) {
|
if (!m_pMainWindow->isActiveWindow()) {
|
||||||
m_pMainWindow->showNormal();
|
m_pMainWindow->showNormal();
|
||||||
|
|
@ -497,7 +499,7 @@ int ServerConfig::showAddClientDialog(const QString &clientName)
|
||||||
|
|
||||||
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
AddClientDialog addClientDialog(clientName, m_pMainWindow);
|
||||||
addClientDialog.exec();
|
addClientDialog.exec();
|
||||||
result = addClientDialog.addResult();
|
result = static_cast<int>(addClientDialog.addResult());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,30 +65,30 @@ AddClientDialog::~AddClientDialog() = default;
|
||||||
|
|
||||||
void AddClientDialog::handleButtonLeft()
|
void AddClientDialog::handleButtonLeft()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientLeft;
|
m_AddResult = AddAction::AddClientLeft;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonUp()
|
void AddClientDialog::handleButtonUp()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientUp;
|
m_AddResult = AddAction::AddClientUp;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonRight()
|
void AddClientDialog::handleButtonRight()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientRight;
|
m_AddResult = AddAction::AddClientRight;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonDown()
|
void AddClientDialog::handleButtonDown()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientDown;
|
m_AddResult = AddAction::AddClientDown;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddClientDialog::handleButtonAdvanced()
|
void AddClientDialog::handleButtonAdvanced()
|
||||||
{
|
{
|
||||||
m_AddResult = kAddClientOther;
|
m_AddResult = AddAction::AddClientOther;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ namespace Ui {
|
||||||
class AddClientDialog;
|
class AddClientDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
enum class AddAction
|
||||||
{
|
{
|
||||||
kAddClientRight,
|
AddClientRight,
|
||||||
kAddClientLeft,
|
AddClientLeft,
|
||||||
kAddClientUp,
|
AddClientUp,
|
||||||
kAddClientDown,
|
AddClientDown,
|
||||||
kAddClientOther,
|
AddClientOther,
|
||||||
kAddClientIgnore
|
AddClientIgnore
|
||||||
};
|
};
|
||||||
|
|
||||||
class AddClientDialog : public QDialog
|
class AddClientDialog : public QDialog
|
||||||
|
|
@ -32,7 +32,7 @@ public:
|
||||||
AddClientDialog(const QString &clientName, QWidget *parent = nullptr);
|
AddClientDialog(const QString &clientName, QWidget *parent = nullptr);
|
||||||
~AddClientDialog() override;
|
~AddClientDialog() override;
|
||||||
|
|
||||||
int addResult() const
|
AddAction addResult() const
|
||||||
{
|
{
|
||||||
return m_AddResult;
|
return m_AddResult;
|
||||||
}
|
}
|
||||||
|
|
@ -51,5 +51,5 @@ private:
|
||||||
QPushButton *m_pButtonRight;
|
QPushButton *m_pButtonRight;
|
||||||
QPushButton *m_pButtonDown;
|
QPushButton *m_pButtonDown;
|
||||||
QLabel *m_pLabelCenter;
|
QLabel *m_pLabelCenter;
|
||||||
int m_AddResult = kAddClientIgnore;
|
AddAction m_AddResult = AddAction::AddClientIgnore;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue