2 This file is part of Faster Application Manager.
4 Faster Application Manager is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 Faster Application Manager is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Faster Application Manager. If not, see <http://www.gnu.org/licenses/>.
17 (C) Heikki Holstila 2010
21 #include "ui_settings.h"
22 #include "mainwindow.h"
23 #include "aaptinterface.h"
24 #include "packageview.h"
25 #include "confirmdialog.h"
26 #include "searchoptions.h"
28 Settings::Settings(QWidget *parent) :
35 iQSettings = new QSettings("/root/.fapman/settings.ini",QSettings::IniFormat);
45 void Settings::changeEvent(QEvent *e)
47 QDialog::changeEvent(e);
49 case QEvent::LanguageChange:
50 ui->retranslateUi(this);
57 void Settings::openWin()
59 ui->checkBox_fetchdates->setChecked( iQSettings->value("fetch_dates", false).toBool() );
60 ui->checkBox_autorotation->setChecked( iQSettings->value("disable_autorotation", false).toBool() );
61 ui->checkBox_autoremove->setChecked( iQSettings->value("enable_autoremove", true).toBool() );
62 ui->checkBox_autoclean->setChecked( iQSettings->value("enable_autoclean", true).toBool() );
63 ui->checkBox_remove_readfull->setChecked( iQSettings->value("remove_readfull", false).toBool() );
65 ui->checkBox_proxies->setChecked( iQSettings->value("use_proxies", false).toBool() );
66 ui->lineEdit_http_proxy->setText( iQSettings->value("http_proxy","").toString() );
67 ui->lineEdit_https_proxy->setText( iQSettings->value("https_proxy","").toString() );
69 ui->comboBox_sortorder->setCurrentIndex( iQSettings->value("default_sort_order",0).toInt() );
71 ui->checkBox_playsound->setChecked( iQSettings->value("sound_notify", false).toBool() );
72 ui->lineEdit_soundfile->setText( iQSettings->value("sound_file","/usr/share/sounds/ui-operation_ready.wav").toString() );
77 void Settings::on_btn_OK_clicked()
79 if( ui->checkBox_fetchdates->isChecked() != iQSettings->value("fetch_dates",false).toBool() && iAptInterface ) {
80 iAptInterface->setNeedRefresh(-1,-1,-1,1);
82 if( ui->comboBox_sortorder->currentIndex() != iQSettings->value("default_sort_order",0).toInt() ) {
83 iPackageView->setSortOrder( (PackageView::sortOrder)ui->comboBox_sortorder->currentIndex() );
86 iQSettings->setValue("fetch_dates", ui->checkBox_fetchdates->isChecked() );
87 iQSettings->setValue("disable_autorotation", ui->checkBox_autorotation->isChecked() );
88 iQSettings->setValue("enable_autoremove", ui->checkBox_autoremove->isChecked() );
89 iQSettings->setValue("enable_autoclean", ui->checkBox_autoclean->isChecked() );
90 iQSettings->setValue("remove_readfull", ui->checkBox_remove_readfull->isChecked() );
92 iQSettings->setValue("use_proxies", ui->checkBox_proxies->isChecked() );
93 iQSettings->setValue("http_proxy", ui->lineEdit_http_proxy->text() );
94 iQSettings->setValue("https_proxy", ui->lineEdit_https_proxy->text() );
96 iQSettings->setValue("default_sort_order", ui->comboBox_sortorder->currentIndex() );
98 iQSettings->setValue("sound_notify", ui->checkBox_playsound->isChecked() );
99 iQSettings->setValue("sound_file", ui->lineEdit_soundfile->text() );
101 if( ui->comboBox_sortorder->currentIndex() == (int)PackageView::SortDateDesc && !ui->checkBox_fetchdates->isChecked() ) {
102 iQSettings->setValue("fetch_dates", true );
103 iAptInterface->setNeedRefresh(-1,-1,-1,1);
105 ConfirmDialog d(false, this);
106 d.setText("Notice","You have selected date as the default sorting criterion. Fetching dates has been automatically enabled.");
111 if( !iQSettings->value("disable_autorotation",false).toBool() ) {
112 dynamic_cast<MainWindow*>(this->parent())->setAttribute(Qt::WA_Maemo5AutoOrientation);
114 dynamic_cast<MainWindow*>(this->parent())->setAttribute(Qt::WA_Maemo5LandscapeOrientation);
121 void Settings::on_pushButton_picksound_clicked()
123 //QFileInfo i( ui->lineEdit_soundfile->text() );
124 QString f = QFileDialog::getOpenFileName(this, "Select sound file", "/", "Audio (*.wav *.mp3 *.ogg)");
126 ui->lineEdit_soundfile->setText(f);
130 void Settings::on_pushButton_searchOptions_clicked()
132 SearchOptions s(this);
133 s.setSelections( iQSettings->value("search_pkgnames",true).toBool(),
134 iQSettings->value("search_displaynames",true).toBool(),
135 iQSettings->value("search_descshort",true).toBool(),
136 iQSettings->value("search_desclong",false).toBool() );
139 iQSettings->setValue("search_pkgnames", s.searchPkgName() );
140 iQSettings->setValue("search_displaynames", s.searchDisplayName() );
141 iQSettings->setValue("search_descshort", s.searchDescShort() );
142 iQSettings->setValue("search_desclong", s.searchDescLong() );
144 iPackageView->setSearchOptions(s.searchPkgName(), s.searchDisplayName(),
145 s.searchDescShort(), s.searchDescLong() );