MCPcopy Create free account
hub / github.com/AntiMicroX/antimicrox / openConfigFileDialog

Method openConfigFileDialog

src/gui/joytabwidget.cpp:525–579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525void JoyTabWidget::openConfigFileDialog()
526{
527 m_settings->getLock()->lock();
528
529 int numberRecentProfiles = m_settings->value("NumberRecentProfiles", DEFAULTNUMBERPROFILES).toInt();
530 QString lookupDir = PadderCommon::preferredProfileDir(m_settings);
531
532 QString filename = QFileDialog::getOpenFileName(this, tr("Open Config"), lookupDir, tr("Config Files (*.amgp *.xml)"));
533
534 m_settings->getLock()->unlock();
535
536 if (!filename.isNull() && !filename.isEmpty())
537 {
538 QFileInfo fileinfo(filename);
539 int searchIndex = configBox->findData(fileinfo.absoluteFilePath());
540 if (searchIndex == -1)
541 {
542 if ((numberRecentProfiles > 0) && (configBox->count() == (numberRecentProfiles + 1)))
543 {
544 configBox->removeItem(numberRecentProfiles);
545 }
546
547 configBox->insertItem(1, PadderCommon::getProfileName(fileinfo), fileinfo.absoluteFilePath());
548 configBox->setCurrentIndex(1);
549 saveDeviceSettings();
550 emit joystickConfigChanged(m_joystick->getJoyNumber());
551 } else
552 {
553 configBox->setCurrentIndex(searchIndex);
554 saveDeviceSettings();
555 emit joystickConfigChanged(m_joystick->getJoyNumber());
556 }
557
558 QString outputFilename = fileinfo.absoluteDir().absolutePath();
559
560#if defined(Q_OS_WIN) && defined(WIN_PORTABLE_PACKAGE)
561 if (fileinfo.absoluteDir().isAbsolute())
562 {
563 QDir tempDir = fileinfo.dir();
564 tempDir.cdUp();
565 if (tempDir.path() == qApp->applicationDirPath())
566 {
567 outputFilename = QString("%1/").arg(fileinfo.dir().dirName());
568 }
569 }
570#endif
571
572 m_settings->getLock()->lock();
573
574 m_settings->setValue("LastProfileDir", outputFilename);
575 m_settings->sync();
576
577 m_settings->getLock()->unlock();
578 }
579}
580
581/**
582 * @brief Create and render all push buttons corresponding to joystick

Callers

nothing calls this directly

Calls 6

preferredProfileDirFunction · 0.85
getProfileNameFunction · 0.85
getLockMethod · 0.80
isEmptyMethod · 0.80
getJoyNumberMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected