diff --git a/src/profileimporter.cpp b/src/profileimporter.cpp index f5d163908..007410f5d 100644 --- a/src/profileimporter.cpp +++ b/src/profileimporter.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,7 @@ char ProfileImporter::convertHexToString_char(string const & hexValue) void ProfileImporter::putGamecontrMapping() { -/* QString mappingString = generateSDLMappingString(); +/* QString mappingString = generateSDLMappingString(); settings->getLock()->lock(); @@ -101,7 +102,7 @@ void ProfileImporter::putGamecontrMapping() out << generateSDLMappingString(); } - emit mappingUpdate(mappingString, device);*/ + emit mappingUpdate(mappingString, device); */ } @@ -163,28 +164,24 @@ void ProfileImporter::putSettingsToApp() */ -bool ProfileImporter::allFilled() -{ - return ((!ui->profileLineEdit->text().isEmpty()) && (radioBtnProfiles.checkedButton() != nullptr)); -} - -void ProfileImporter::on_AcceptBtn_clicked() +bool ProfileImporter::allFilled() { - if (!allFilled()) + if ((!ui->profileLineEdit->text().isEmpty()) && (radioBtnProfiles.checkedButton() != nullptr)) { - QMessageBox box; - box.setText(trUtf8("Could not import profile. Choose profile type and profile's file.")); - box.setWindowTitle(trUtf8("Insufficient data")); - box.setStandardButtons(QMessageBox::Close); - box.raise(); - box.exec(); - + if (ui->fullSettCheckBox->isChecked()) + { + if (ui->configLineEdit->text().isEmpty()) return false; + else return true; + } + else + { + return true; + } } else { - - + return false; } } @@ -194,8 +191,8 @@ void ProfileImporter::changeExtensionFile(QString filePath) QFileInfo info(filePath); if (properExtension(filePath)) { - if ((radioBtnProfiles.checkedButton()->text().remove('&') == "JoyToKey")) { - + if ((radioBtnProfiles.checkedButton()->text().remove('&') == "JoyToKey")) + { QString strNewName = info.path() + "/" + info.completeBaseName() + ".ini"; QFile renamed(filePath); renamed.rename(filePath, strNewName); @@ -220,7 +217,6 @@ void ProfileImporter::backExtensionFile(QString filePath) QString strNewName = info.path() + "/" + info.completeBaseName() + "." + extensionProfile(); QFile renamed(filePath); renamed.rename(filePath, strNewName); - } @@ -234,9 +230,8 @@ QString ProfileImporter::extensionProfile() } -bool ProfileImporter::properExtension(QString profilePath) +bool ProfileImporter::properExtension(const QString& profilePath) { - QFileInfo info(profilePath); if ((radioBtnProfiles.checkedButton()->text().remove('&') == "JoyToKey") && (info.completeSuffix() == "cfg")) @@ -256,63 +251,41 @@ bool ProfileImporter::properExtension(QString profilePath) } -void ProfileImporter::openFile(QString profilePath) +bool ProfileImporter::properExtensionSett(const QString & settfilePath) { + QFileInfo info(settfilePath); + if (info.completeSuffix() == "ini") return true; + return false; } -void ProfileImporter::readSettGroups() +void ProfileImporter::openFile(QString importedFilePath) { + QSettings settings(importedFilePath, QSettings::NativeFormat); + } -QString ProfileImporter::displayModeJoyToKey() +void ProfileImporter::readSettGroups() { - return ""; -} -void ProfileImporter::on_cancelBtn_clicked() -{ - close(); } -void ProfileImporter::on_findProfileBtn_clicked() +const QString ProfileImporter::displayModeJoyToKey() { - if (radioBtnProfiles.checkedButton() == nullptr) { - - QMessageBox box; - box.setText(trUtf8("Could not define file's extension. Choose profile's type first above.")); - box.setWindowTitle(trUtf8("Insufficient data")); - box.setStandardButtons(QMessageBox::Close); - box.raise(); - box.exec(); - - } else { - - QString profile = profilePath(); - if (!properExtension(profile)) { - - QMessageBox box; - box.setText(trUtf8("Could not choose a file. Find a file with proper extension.")); - box.setWindowTitle(trUtf8("Incorrect filename")); - box.setStandardButtons(QMessageBox::Close); - box.raise(); - box.exec(); - - } else { + return displayedModeJoyToKey; +} - ui->profileLineEdit->setText(profilePath()); - QFileInfo info(profile); - chosenFile = info.completeBaseName(); - } - } +void ProfileImporter::setDisplayModeJoyToKey(QString const & displayMode) +{ + displayedModeJoyToKey = displayMode; } @@ -326,13 +299,13 @@ QString ProfileImporter::filedialogDescExt() } -QString ProfileImporter::profilePath() +const QString ProfileImporter::importedFilePath(QString title, QString extensionFile) { QString fileName = QFileDialog::getOpenFileName( - this, trUtf8("Choose game profile"), + this, title, QFileDialog::getExistingDirectory(this, trUtf8("Find"), QDir::currentPath()), - filedialogDescExt()); + extensionFile); return fileName; } @@ -340,7 +313,6 @@ QString ProfileImporter::profilePath() void ProfileImporter::rewriteButtonGroup() { - QList allButtons = ui->groupBox->findChildren(); qDebug() << allButtons.size(); @@ -355,6 +327,27 @@ void ProfileImporter::rewriteButtonGroup() } +void ProfileImporter::putSettingsFromJoyToKey() +{ + +} + + +void ProfileImporter::putSettingsFromXPadder() +{ + +} + + +void ProfileImporter::putSettingsFromPinnacle() +{ + +} + + +// ----------------------------- SLOTS ------------------------------------- // + + // 0 - unchecked // 2 - checked void ProfileImporter::on_fullSettCheckBox_stateChanged(int state) @@ -388,3 +381,98 @@ void ProfileImporter::on_fullSettCheckBox_stateChanged(int state) break; } } + + +void ProfileImporter::on_AcceptBtn_clicked() +{ + if (!allFilled()) + { + QMessageBox box; + box.setText(trUtf8("Could not import profile. Choose profile type and profile's file.")); + box.setWindowTitle(trUtf8("Insufficient data")); + box.setStandardButtons(QMessageBox::Close); + box.raise(); + box.exec(); + } + else + { + + + } +} + + +void ProfileImporter::on_cancelBtn_clicked() +{ + close(); +} + + +void ProfileImporter::on_findProfileBtn_clicked() +{ + if (radioBtnProfiles.checkedButton() == nullptr) { + + QMessageBox box; + box.setText(trUtf8("Could not define file's extension. Choose profile's type first above.")); + box.setWindowTitle(trUtf8("Insufficient data")); + box.setStandardButtons(QMessageBox::Close); + box.raise(); + box.exec(); + + } else { + + QString profile = importedFilePath(trUtf8("Choose game profile"), filedialogDescExt()); + + if (!properExtension(profile)) + { + QMessageBox box; + box.setText(trUtf8("Could not choose a file. Find a file with proper extension.")); + box.setWindowTitle(trUtf8("Incorrect filename")); + box.setStandardButtons(QMessageBox::Close); + box.raise(); + box.exec(); + + } else { + + ui->profileLineEdit->setText(profile); + + QFileInfo info(profile); + chosenFile = info.completeBaseName(); + } + } +} + + +void ProfileImporter::on_findConfigBtn_clicked() +{ + if (radioBtnProfiles.checkedButton() == nullptr) + { + QMessageBox box; + box.setText(trUtf8("Could not define file's extension. Choose profile's type first above.")); + box.setWindowTitle(trUtf8("Insufficient data")); + box.setStandardButtons(QMessageBox::Close); + box.raise(); + box.exec(); + + } else { + + QString settingsFile = importedFilePath(trUtf8("Choose app settings file"), trUtf8("Settings file (*.ini)")); + + if (!properExtensionSett(settingsFile)) + { + QMessageBox box; + box.setText(trUtf8("Could not choose a file. Find a file with proper extension.")); + box.setWindowTitle(trUtf8("Incorrect filename")); + box.setStandardButtons(QMessageBox::Close); + box.raise(); + box.exec(); + + } else { + + ui->configLineEdit->setText(settingsFile); + + QFileInfo info(settingsFile); + chosenFileSett = info.completeBaseName(); + } + } +} diff --git a/src/profileimporter.h b/src/profileimporter.h index 7ebd9292c..0b14734d5 100644 --- a/src/profileimporter.h +++ b/src/profileimporter.h @@ -133,17 +133,20 @@ class ProfileImporter : public QWidget void changeExtensionFile(QString filePath); void backExtensionFile(QString filePath); - QString profilePath(); - void openFile(QString profilePath); + void openFile(QString importedFilePath); void readSettGroups(); - int convertStringToQtKey(QString const & keyString); + const QString importedFilePath(QString title, QString extensionFile); + const QString displayModeJoyToKey(); QChar convertHexToString_QChar(QString const & hexValue); char convertHexToString_char(std::string const & hexValue); + int convertStringToQtKey(QString const & keyString); protected: bool allFilled(); - bool properExtension(QString profilePath); + bool properExtension(const QString& profilePath); + bool properExtensionSett(const QString& settfilePath); + void setDisplayModeJoyToKey(QString const & displayMode); QString extensionProfile(); @@ -152,6 +155,7 @@ private slots: void on_cancelBtn_clicked(); void on_findProfileBtn_clicked(); void on_fullSettCheckBox_stateChanged(int state); + void on_findConfigBtn_clicked(); private: @@ -160,15 +164,19 @@ private slots: QHash antToCurrGamepads; AntiMicroSettings *settings; - QString chosenFile; QButtonGroup radioBtnProfiles; + QString chosenFile; + QString chosenFileSett; QString displayedModeJoyToKey; QString buttonMode; void putSettingsToApp(); void putGamecontrMapping(); - QString displayModeJoyToKey(); void rewriteButtonGroup(); + void putSettingsFromJoyToKey(); + void putSettingsFromXPadder(); + void putSettingsFromPinnacle(); + QString filedialogDescExt(); }; diff --git a/src/profileimporter.ui b/src/profileimporter.ui index 14b57d3e8..42be293ae 100644 --- a/src/profileimporter.ui +++ b/src/profileimporter.ui @@ -7,7 +7,7 @@ 0 0 457 - 459 + 555