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