Cleanup qsettings parameter

* Set Organization- and ApplicationName QApp wide
  - Setting this here removes the redundancy to write the names every time a QSettings object is needed
* removed redundant QSettings parameter
This commit is contained in:
C. Balles 2017-04-03 02:18:09 +02:00 committed by Sergi Àlvarez i Capilla
parent c99759825a
commit f91b9dd4a9
5 changed files with 16 additions and 15 deletions

View File

@ -11,7 +11,8 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
a.setApplicationName("Iaito"); a.setOrganizationName("iaito");
a.setApplicationName("iaito");
a.setApplicationVersion(APP_VERSION); a.setApplicationVersion(APP_VERSION);
// Set QString codec to UTF-8 // Set QString codec to UTF-8

View File

@ -339,7 +339,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel); QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
//qDebug() << ret; //qDebug() << ret;
if (ret == QMessageBox::Save) { if (ret == QMessageBox::Save) {
QSettings settings("iaito", "iaito"); QSettings settings;
settings.setValue("geometry", saveGeometry()); settings.setValue("geometry", saveGeometry());
settings.setValue("size", size()); settings.setValue("size", size());
settings.setValue("pos", pos()); settings.setValue("pos", pos());
@ -350,7 +350,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
this->core->cmd("Pnj " + notes); this->core->cmd("Pnj " + notes);
QMainWindow::closeEvent(event); QMainWindow::closeEvent(event);
} else if (ret == QMessageBox::Discard) { } else if (ret == QMessageBox::Discard) {
QSettings settings("iaito", "iaito"); QSettings settings;
settings.setValue("geometry", saveGeometry()); settings.setValue("geometry", saveGeometry());
settings.setValue("size", size()); settings.setValue("size", size());
settings.setValue("pos", pos()); settings.setValue("pos", pos());
@ -362,7 +362,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::readSettings() void MainWindow::readSettings()
{ {
QSettings settings("iaito", "iaito"); QSettings settings;
QByteArray geo = settings.value("geometry", QByteArray()).toByteArray(); QByteArray geo = settings.value("geometry", QByteArray()).toByteArray();
restoreGeometry(geo); restoreGeometry(geo);
QByteArray state = settings.value("state", QByteArray()).toByteArray(); QByteArray state = settings.value("state", QByteArray()).toByteArray();
@ -376,14 +376,14 @@ void MainWindow::readSettings()
void MainWindow::dark() { void MainWindow::dark() {
qApp->setStyleSheet("QPlainTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} QTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} "); qApp->setStyleSheet("QPlainTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} QTextEdit { background-color: rgb(64, 64, 64); color: rgb(222, 222, 222);} ");
this->memoryDock->switchTheme(true); this->memoryDock->switchTheme(true);
QSettings settings("iaito", "iaito"); QSettings settings;
settings.setValue("dark", true); settings.setValue("dark", true);
} }
void MainWindow::def_theme() { void MainWindow::def_theme() {
qApp->setStyleSheet(""); qApp->setStyleSheet("");
this->memoryDock->switchTheme(false); this->memoryDock->switchTheme(false);
QSettings settings("iaito", "iaito"); QSettings settings;
settings.setValue("dark", false); settings.setValue("dark", false);
} }
@ -1091,7 +1091,7 @@ void MainWindow::on_actionForward_triggered()
void MainWindow::toggleResponsive(bool maybe) { void MainWindow::toggleResponsive(bool maybe) {
this->responsive = maybe; this->responsive = maybe;
// Save options in settings // Save options in settings
QSettings settings("iaito", "iaito"); QSettings settings;
settings.setValue("responsive", this->responsive); settings.setValue("responsive", this->responsive);
} }
@ -1107,7 +1107,7 @@ void MainWindow::on_actionReset_settings_triggered()
QMessageBox::Ok | QMessageBox::Cancel); QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok) { if (ret == QMessageBox::Ok) {
// Save options in settings // Save options in settings
QSettings settings("iaito", "iaito"); QSettings settings;
settings.clear(); settings.clear();
} }
} }

View File

@ -52,7 +52,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
ui->recentsList->setIconSize(QSize(48, 48)); ui->recentsList->setIconSize(QSize(48, 48));
// Fill list with recent opened files // Fill list with recent opened files
QSettings settings("iaito", "iaito"); QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
@ -116,7 +116,7 @@ void NewFileDialog::on_newFileButton_clicked()
ui->newFileEdit->setText(fileName); ui->newFileEdit->setText(fileName);
// Add file to recent file list // Add file to recent file list
QSettings settings("iaito", "iaito"); QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(fileName); files.removeAll(fileName);
files.prepend(fileName); files.prepend(fileName);
@ -158,7 +158,7 @@ void NewFileDialog::on_actionRemove_item_triggered()
QVariant data = item->data( Qt::UserRole ); QVariant data = item->data( Qt::UserRole );
QString sitem = data.toString(); QString sitem = data.toString();
QSettings settings("iaito", "iaito"); QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(sitem); files.removeAll(sitem);
settings.setValue("recentFileList", files); settings.setValue("recentFileList", files);
@ -179,7 +179,7 @@ void NewFileDialog::on_createButton_clicked()
void NewFileDialog::on_actionClear_all_triggered() void NewFileDialog::on_actionClear_all_triggered()
{ {
// Clear recent file list // Clear recent file list
QSettings settings("iaito", "iaito"); QSettings settings;
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
files.clear(); files.clear();

View File

@ -28,7 +28,7 @@ OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
ui->processorComboBox->insertItems(1, plugins); ui->processorComboBox->insertItems(1, plugins);
// Restore settings // Restore settings
QSettings settings("iaito", "iaito"); QSettings settings;
ui->bytesCheckBox->setChecked(settings.value("bytes").toBool()); ui->bytesCheckBox->setChecked(settings.value("bytes").toBool());
ui->attCheckBox->setChecked(settings.value("syntax").toBool()); ui->attCheckBox->setChecked(settings.value("syntax").toBool());
ui->descriptionCheckBox->setChecked(settings.value("describe").toBool()); ui->descriptionCheckBox->setChecked(settings.value("describe").toBool());
@ -100,7 +100,7 @@ void OptionsDialog::on_okButton_clicked()
} }
// Save options in settings // Save options in settings
QSettings settings("iaito", "iaito"); QSettings settings;
// Show asm bytes // Show asm bytes
if (ui->bytesCheckBox->isChecked()) { if (ui->bytesCheckBox->isChecked()) {

View File

@ -13,7 +13,7 @@ SideBar::SideBar(MainWindow *main) :
{ {
ui->setupUi(this); ui->setupUi(this);
QSettings settings("iaito", "iaito"); QSettings settings;
if (settings.value("responsive").toBool()) { if (settings.value("responsive").toBool()) {
ui->respButton->setChecked(true); ui->respButton->setChecked(true);
} else { } else {