File indexing completed on 2024-05-19 04:50:18
0001 /**************************************************************************************** 0002 * Copyright (c) 2012 Edward "hades" Toroshchin <amarok@hades.name> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "MagnatuneNeedUpdateWidget.h" 0018 #include "ui_MagnatuneNeedUpdateWidget.h" 0019 0020 #include "MagnatuneConfig.h" 0021 0022 #include <core/support/Debug.h> 0023 0024 MagnatuneNeedUpdateWidget::MagnatuneNeedUpdateWidget(QWidget *parent) : 0025 QWidget(parent), ui(new Ui::MagnatuneNeedUpdateWidget) 0026 { 0027 ui->setupUi(this); 0028 0029 connect(ui->update, &QPushButton::clicked, this, &MagnatuneNeedUpdateWidget::startUpdate ); 0030 connect(ui->autoUpdate, &QCheckBox::stateChanged, this, &MagnatuneNeedUpdateWidget::saveSettings ); 0031 0032 ui->autoUpdate->setCheckState( MagnatuneConfig().autoUpdateDatabase()? 0033 Qt::Checked : Qt::Unchecked ); 0034 } 0035 0036 MagnatuneNeedUpdateWidget::~MagnatuneNeedUpdateWidget() 0037 { 0038 delete ui; 0039 } 0040 0041 void 0042 MagnatuneNeedUpdateWidget::enable() 0043 { 0044 ui->update->setEnabled(true); 0045 } 0046 0047 void 0048 MagnatuneNeedUpdateWidget::disable() 0049 { 0050 ui->update->setEnabled(false); 0051 } 0052 0053 void 0054 MagnatuneNeedUpdateWidget::startUpdate() 0055 { 0056 disable(); 0057 Q_EMIT wantUpdate(); 0058 } 0059 0060 void 0061 MagnatuneNeedUpdateWidget::saveSettings() 0062 { 0063 DEBUG_BLOCK 0064 0065 MagnatuneConfig config; 0066 config.setAutoUpdateDatabase( ui->autoUpdate->checkState() == Qt::Checked ); 0067 config.save(); 0068 }