Skip to content

Commit

Permalink
refactor: Remove unused "map" and "display" argument options with lin…
Browse files Browse the repository at this point in the history
…ked code #350
  • Loading branch information
pktiuk authored Jan 24, 2022
2 parents 0d9ff04 + 9d9c9ce commit 94a9523
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 275 deletions.
4 changes: 0 additions & 4 deletions src/antimicrosettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ void AntiMicroSettings::importFromCommandLine(CommandLineUtility &cmdutility)
{
getCmdSettings().setValue("LaunchInTray", 1);
}
if (cmdutility.shouldMapController())
{
getCmdSettings().setValue("DisplaySDLMapping", 1);
}
}
/**
* @brief applies settings from command line to logger
Expand Down
60 changes: 1 addition & 59 deletions src/commandlineutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ CommandLineUtility::CommandLineUtility(QObject *parent)
showRequest = false;
unloadProfile = false;
startSetNumber = 0;
displayString = "";
listControllers = false;
mappingController = false;
currentLogLevel = Logger::LOG_NONE;

currentListsIndex = 0;
Expand Down Expand Up @@ -102,17 +100,10 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app)
"only if you have sdl "
"library. You can check your controller index, name or "
"even GUID.")},
// {"display",
// QCoreApplication::translate("main", "Use specified display for
// X11 calls")},
// {"next",
// QCoreApplication::translate("main", "Advance profile loading set
// options")},
// {"map",
// QCoreApplication::translate("main", "Open game controller
// mapping window of selected controller. Value can be
// a controller index or GUID."),
// QCoreApplication::translate("main", "value")},

});

parser.process(parsed_app);
Expand Down Expand Up @@ -177,24 +168,6 @@ void CommandLineUtility::parseArguments(const QApplication &parsed_app)
listControllers = true;
}

if (parser.isSet("map"))
{
parseArgsMap(parser);
}

#ifdef WITH_X11
if (parser.isSet("display"))
{
if (!parser.value("display").isEmpty())
{
displayString = parser.value("display");
} else
{
throw std::runtime_error(QObject::tr("No display string was specified.").toStdString());
}
}
#endif

#if (defined(WITH_UINPUT) && defined(WITH_XTEST))

if (parser.isSet("eventgen"))
Expand Down Expand Up @@ -397,33 +370,6 @@ void CommandLineUtility::parseArgsStartSet(const QCommandLineParser &parser)
}
}

void CommandLineUtility::parseArgsMap(const QCommandLineParser &parser)
{
QString mapOptionText = parser.value("map");

if (!mapOptionText.isEmpty())
{
bool validNumber = false;
int tempNumber = mapOptionText.toInt(&validNumber);

if (validNumber)
{
controllerNumber = tempNumber;
mappingController = true;
} else if (!mapOptionText.isEmpty())
{
controllerIDString = mapOptionText;
mappingController = true;
} else
{
throw std::runtime_error(QObject::tr("Controller identifier is not a valid value.").toStdString());
}
} else
{
throw std::runtime_error(QObject::tr("No controller was specified.").toStdString());
}
}

bool CommandLineUtility::isLaunchInTrayEnabled() { return launchInTray; }

bool CommandLineUtility::isTrayHidden() { return hideTrayIcon; }
Expand Down Expand Up @@ -452,12 +398,8 @@ int CommandLineUtility::getJoyStartSetNumber() { return startSetNumber - 1; }

bool CommandLineUtility::shouldListControllers() { return listControllers; }

bool CommandLineUtility::shouldMapController() { return mappingController; }

QString CommandLineUtility::getEventGenerator() { return eventGenerator; }

QString CommandLineUtility::getDisplayString() { return displayString; }

Logger::LogLevel CommandLineUtility::getCurrentLogLevel() { return currentLogLevel; }

QString CommandLineUtility::getCurrentLogFile() { return currentLogFile; }
Expand Down
6 changes: 0 additions & 6 deletions src/commandlineutility.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class CommandLineUtility : public QObject
bool isShowRequested();
bool isUnloadRequested();
bool shouldListControllers();
bool shouldMapController();
bool hasProfileInOptions();

int getControllerNumber();
Expand All @@ -117,8 +116,6 @@ class CommandLineUtility : public QObject
QList<int> *getJoyStartSetNumberList();
QList<ControllerOptionsInfo> const &getControllerOptionsList();

QString getDisplayString();

Logger::LogLevel getCurrentLogLevel();

protected:
Expand All @@ -129,15 +126,13 @@ class CommandLineUtility : public QObject
bool showRequest;
bool unloadProfile;
bool listControllers;
bool mappingController;

int startSetNumber;
int controllerNumber;
int currentListsIndex;

QString profileLocation;
QString controllerIDString;
QString displayString;
QString eventGenerator;
QString currentLogFile;

Expand All @@ -151,7 +146,6 @@ class CommandLineUtility : public QObject
void parseArgsPrControle(const QCommandLineParser &parser);
void parseArgsUnload(const QCommandLineParser &parser);
void parseArgsStartSet(const QCommandLineParser &parser);
void parseArgsMap(const QCommandLineParser &parser);
};

#endif // COMMANDLINEPARSER_H
6 changes: 0 additions & 6 deletions src/gui/gamecontrollermappingdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,8 @@ void GameControllerMappingDialog::saveChanges()
settings->setValue(QString("Mappings/%1%2").arg(device->getUniqueIDString()).arg("Disable"), "0");
settings->sync();

bool displayMapping = settings->runtimeValue("DisplaySDLMapping", false).toBool();
settings->getLock()->unlock();

if (displayMapping)
{
PRINT_STDOUT() << generateSDLMappingString();
}

emit mappingUpdate(mappingString, device);
}

Expand Down
92 changes: 1 addition & 91 deletions src/gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ MainWindow::MainWindow(QMap<SDL_JoystickID, InputDevice *> *joysticks, CommandLi
#endif

signalDisconnect = false;
showTrayIcon = !cmdutility->isTrayHidden() && graphical && !cmdutility->shouldListControllers() &&
!cmdutility->shouldMapController();
showTrayIcon = !cmdutility->isTrayHidden() && graphical && !cmdutility->shouldListControllers();

m_joysticks = joysticks;

Expand Down Expand Up @@ -174,7 +173,6 @@ MainWindow::MainWindow(QMap<SDL_JoystickID, InputDevice *> *joysticks, CommandLi
connect(ui->actionOptions, &QAction::triggered, this, &MainWindow::openMainSettingsDialog);
connect(ui->actionWiki, &QAction::triggered, this, &MainWindow::openWikiPage);
connect(ui->actionCalibration, &QAction::triggered, this, &MainWindow::openCalibration);
connect(ui->actionGameController_Mapping, &QAction::triggered, this, &MainWindow::openGameControllerMappingWindow);

#if defined(WITH_X11)
if (QApplication::platformName() == QStringLiteral("xcb"))
Expand Down Expand Up @@ -299,44 +297,6 @@ void MainWindow::alterConfigFromSettings()
}
}

void MainWindow::controllerMapOpening()
{
if (m_cmdutility->shouldMapController())
{
m_graphical = false;

const QList<ControllerOptionsInfo> tempList = m_cmdutility->getControllerOptionsList();
ControllerOptionsInfo temp = tempList.at(0);

if (temp.hasControllerNumber())
{
int joypadIndex = m_cmdutility->getControllerNumber();

qDebug() << "It was antimicrox --map controllerNumber";
qDebug() << "controllerNumber: " << joypadIndex;

selectControllerJoyTab(joypadIndex);
openGameControllerMappingWindow(true);
} else if (temp.hasControllerID())
{
QString joypadGUID = m_cmdutility->getControllerID();

qDebug() << "It was antimicrox --map controllerID";
qDebug() << "controllerID: " << joypadGUID;

selectControllerJoyTab(joypadGUID);
openGameControllerMappingWindow(true);
} else
{
qDebug() << "Could not find a proper controller identifier. Exiting";

qInfo() << tr("Could not find a proper controller identifier. "
"Exiting.");
qApp->quit();
}
}
}

void MainWindow::fillButtons() { fillButtonsMap(m_joysticks); }

void MainWindow::makeJoystickTabs()
Expand Down Expand Up @@ -1468,36 +1428,6 @@ void MainWindow::restartAsElevated()
}
#endif

void MainWindow::openGameControllerMappingWindow(bool openAsMain)
{
int index = ui->tabWidget->currentIndex();
if (index >= 0)
{
JoyTabWidget *joyTab = qobject_cast<JoyTabWidget *>(ui->tabWidget->widget(index)); // static_cast
InputDevice *joystick = joyTab->getJoystick();
if (joystick != nullptr)
{
GameControllerMappingDialog *dialog = new GameControllerMappingDialog(joystick, m_settings, this);

if (openAsMain)
{
dialog->setParent(nullptr);
dialog->setWindowFlags(Qt::Window);
connect(dialog, &GameControllerMappingDialog::finished, qApp, &QApplication::quit);
} else
{
connect(dialog, &GameControllerMappingDialog::mappingUpdate, this, &MainWindow::propogateMappingUpdate);
}

dialog->show();
}
} else if (openAsMain)
{
qInfo() << tr("Could not find controller. Exiting.");
qApp->quit();
}
}

void MainWindow::propogateMappingUpdate(QString mapping, InputDevice *device) { emit mappingUpdated(mapping, device); }

void MainWindow::testMappingUpdateNow(int index, InputDevice *device)
Expand Down Expand Up @@ -1806,26 +1736,6 @@ void MainWindow::updateButtonPressed()

#endif

/**
* @brief Select appropriate tab with the specified index.
* @param Index of appropriate tab.
*/
void MainWindow::selectControllerJoyTab(int index)
{
if ((index > 0) && m_joysticks->contains(index - 1))
{
JoyTabWidget *widget = qobject_cast<JoyTabWidget *>(ui->tabWidget->widget(index - 1)); // static_cast
if (widget != nullptr)
{
qDebug() << "JoyTabWidget was not a null pointer in selectControllerJoyTab of index";
ui->tabWidget->setCurrentIndex(index - 1);
} else
{
qDebug() << "JoyTabWidget was a NULL POINTER in selectControllerJoyTab of index";
}
}
}

/**
* @brief Select appropriate tab that has a device with the specified GUID.
* @param GUID of joystick device.
Expand Down
3 changes: 0 additions & 3 deletions src/gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ class MainWindow : public QMainWindow
void quitProgram();
void changeWindowStatus();
void refreshTabHelperThreads();
void controllerMapOpening();
void testMappingUpdateNow(int index, InputDevice *device);
void removeJoyTab(SDL_JoystickID deviceID);
void addJoyTab(InputDevice *device);
void selectControllerJoyTab(QString GUID);
void selectControllerJoyTab(int index);
void handleInstanceDisconnect();

private slots:
Expand Down Expand Up @@ -144,7 +142,6 @@ class MainWindow : public QMainWindow
void restartAsElevated();
#endif

void openGameControllerMappingWindow(bool openAsMain = false);
void propogateMappingUpdate(QString mapping, InputDevice *device);
void autoprofileLoad(AutoProfileInfo *info); // MainConfiguration class
void checkAutoProfileWatcherTimer(); // MainConfiguration class
Expand Down
Loading

0 comments on commit 94a9523

Please sign in to comment.