Skip to content

Commit

Permalink
Add filename & windowtitle checkbox status to save & load.
Browse files Browse the repository at this point in the history
Signed-off-by: Melvin Li <[email protected]>
  • Loading branch information
Zalafina committed Oct 30, 2022
1 parent 55620e4 commit 3e881d7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions QKeyMapper/qkeymapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static const QString CLEARALL("KeyMapData/ClearAll");
static const QString PROCESSINFO_FILENAME("ProcessInfo/FileName");
static const QString PROCESSINFO_WINDOWTITLE("ProcessInfo/WindowTitle");
static const QString PROCESSINFO_FILEPATH("ProcessInfo/FilePath");
static const QString PROCESSINFO_FILENAME_CHECKED("ProcessInfo/FileNameChecked");
static const QString PROCESSINFO_WINDOWTITLE_CHECKED("ProcessInfo/WindowTitleChecked");

static const QString SAO_FONTFILENAME(":/sao_ui.otf");

Expand Down Expand Up @@ -994,6 +996,9 @@ void QKeyMapper::saveKeyMapSetting(void)
qDebug() << "[saveKeyMapSetting]" << "FilePath is empty, unsaved.";
#endif
}

settingFile.setValue(PROCESSINFO_FILENAME_CHECKED, ui->nameCheckBox->isChecked());
settingFile.setValue(PROCESSINFO_WINDOWTITLE_CHECKED, ui->titleCheckBox->isChecked());
}
else{
#ifdef DEBUG_LOGOUT_ON
Expand Down Expand Up @@ -1108,6 +1113,32 @@ bool QKeyMapper::loadKeyMapSetting(void)
m_MapProcessInfo.FilePath = settingFile.value(PROCESSINFO_FILEPATH).toString();
}

if (true == settingFile.contains(PROCESSINFO_FILENAME_CHECKED)){
bool fileNameChecked = settingFile.value(PROCESSINFO_FILENAME_CHECKED).toBool();
if (true == fileNameChecked) {
ui->nameCheckBox->setChecked(true);
}
else {
ui->nameCheckBox->setChecked(false);
}
#ifdef DEBUG_LOGOUT_ON
qDebug() << "[loadKeyMapSetting]" << "FileNameChecked =" << fileNameChecked;
#endif
}

if (true == settingFile.contains(PROCESSINFO_WINDOWTITLE_CHECKED)){
bool windowTitleChecked = settingFile.value(PROCESSINFO_WINDOWTITLE_CHECKED).toBool();
if (true == windowTitleChecked) {
ui->titleCheckBox->setChecked(true);
}
else {
ui->titleCheckBox->setChecked(false);
}
#ifdef DEBUG_LOGOUT_ON
qDebug() << "[loadKeyMapSetting]" << "WindowTitleChecked =" << windowTitleChecked;
#endif
}

if (false == datavalidflag){
QMessageBox::warning(this, tr("QKeyMapper"), tr("<html><head/><body><p align=\"center\">Load invalid keymapdata from ini file.</p><p align=\"center\">Reset to default values.</p></body></html>"));
return false;
Expand Down

0 comments on commit 3e881d7

Please sign in to comment.