From bdae62d50226ab4584094324c74da9c04f36d158 Mon Sep 17 00:00:00 2001 From: Andrew Udvare Date: Sat, 27 Feb 2010 08:57:43 +0000 Subject: [PATCH] Move settings to be private member of class MainWindow --- src/mainwindow.cpp | 20 ++------------------ src/mainwindow.h | 2 ++ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index de3786266..b3a72ef27 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,6 @@ MainWindow::MainWindow(QWidget *parent) ui_.setupUi(this); tray_icon_->setIcon(windowIcon()); tray_icon_->setToolTip(QCoreApplication::applicationName()); - //tray_icon_->show(); ui_.volume->setValue(player_->GetVolume()); @@ -272,7 +271,6 @@ MainWindow::MainWindow(QWidget *parent) } // Load settings - QSettings settings; settings.beginGroup(kSettingsGroup); restoreGeometry(settings.value("geometry").toByteArray()); @@ -309,8 +307,6 @@ MainWindow::~MainWindow() { } void MainWindow::HideShowTrayIcon() { - QSettings settings; - if (!isHidden() && tray_icon_->isVisible()) { tray_icon_->setVisible(false); ui_.action_hide_tray_icon->setText(tr("&Show tray icon")); @@ -320,7 +316,6 @@ void MainWindow::HideShowTrayIcon() { ui_.action_hide_tray_icon->setText("&Hide tray icon"); } - settings.beginGroup(kSettingsGroup); settings.setValue("showtray", tray_icon_->isVisible()); } @@ -397,8 +392,6 @@ void MainWindow::resizeEvent(QResizeEvent*) { } void MainWindow::SaveGeometry() { - QSettings settings; - settings.beginGroup(kSettingsGroup); settings.setValue("geometry", saveGeometry()); settings.setValue("state", saveState(kStateVersion)); } @@ -452,15 +445,11 @@ void MainWindow::closeEvent(QCloseEvent* event) { SetHiddenInTray(true); } else { - QSettings settings; - settings.beginGroup(kSettingsGroup); settings.setValue("showtray", tray_icon_->isVisible()); } } void MainWindow::SetHiddenInTray(bool hidden) { - QSettings settings; - settings.beginGroup(kSettingsGroup); settings.setValue("hidden", hidden); if (hidden) { @@ -479,8 +468,6 @@ void MainWindow::ClearLibraryFilter() { } void MainWindow::FilePathChanged(const QString& path) { - QSettings settings; - settings.beginGroup(kSettingsGroup); settings.setValue("file_path", path); } @@ -616,11 +603,8 @@ void MainWindow::PlayerInitFinished() { } void MainWindow::AddMedia() { - QSettings s; - s.beginGroup(kSettingsGroup); - // Last used directory - QString directory = s.value("add_media_path", QDir::currentPath()).toString(); + QString directory = settings.value("add_media_path", QDir::currentPath()).toString(); // Show dialog QStringList file_names = QFileDialog::getOpenFileNames(this, "Add media", directory); @@ -628,7 +612,7 @@ void MainWindow::AddMedia() { return; // Save last used directory - s.setValue("add_media_path", file_names[0]); + settings.setValue("add_media_path", file_names[0]); // Add media QList urls; diff --git a/src/mainwindow.h b/src/mainwindow.h index 74af7515d..da00a3801 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include #include #include "ui_mainwindow.h" @@ -110,6 +111,7 @@ class MainWindow : public QMainWindow { QSortFilterProxyModel* library_sort_model_; QTimer* track_position_timer_; + QSettings settings; }; #endif // MAINWINDOW_H