#include <QtGui/QVBoxLayout>
#include <QtGui/QHBoxLayout>
#include <QtGui/QIntValidator>
+#include <QtGui/QDialogButtonBox>
#include <QMaemo5ValueButton>
#include <QMaemo5InformationBox>
#include <QDebug>
#include "settings.h"
#include "db.h"
#include "daemon.h"
+#include "cache.h"
QMap <Eniro::Site, Eniro::SiteDetails> SettingsDialog::sites_ = Eniro::getSites();
QLabel* cacheLabel = new QLabel(tr("Cache size (numbers)"));
cacheInput_ = new QLineEdit(Settings::instance()->get("cache_size"));
cacheInput_->setValidator(new QIntValidator(0, 10000, this));
+ QPushButton* cacheResetButton = new QPushButton(tr("Clear"), this);
+ connect(cacheResetButton, SIGNAL(pressed()), this, SLOT(resetCache()));
siteSelector_ = new ButtonSelector(tr("Eniro site"), this);
QString site = Settings::instance()->get("eniro_site");
autostartSelector_->addItem(tr("Disabled"), "0");
autostartSelector_->setCurrentIndex(autostart == "1" ? 0 : 1);
- QPushButton* submitButton = new QPushButton(tr("Save"));
+ QPushButton* submitButton = new QPushButton(tr("Save"), this);
connect(submitButton, SIGNAL(pressed()), this, SLOT(saveSettings()));
username->addWidget(usernameLabel);
password->addWidget(passwordInput_);
cache->addWidget(cacheLabel);
cache->addWidget(cacheInput_);
+ cache->addWidget(cacheResetButton);
left->addLayout(username);
left->addLayout(password);
left->addLayout(cache);
left->addWidget(siteSelector_);
left->addWidget(autostartSelector_);
+ QDialogButtonBox* buttons = new QDialogButtonBox;
+ buttons->setCenterButtons(false);
+ buttons->addButton(submitButton, QDialogButtonBox::AcceptRole);
+
mainLayout->addLayout(left);
- mainLayout->addWidget(submitButton);
+ mainLayout->addWidget(buttons);
setLayout(mainLayout);
}
}
+
+void SettingsDialog::resetCache()
+{
+ int ret = Cache::instance().clear();
+
+ if(ret >= 0)
+ {
+ QMaemo5InformationBox::information(this, tr("%n number(s) were deleted from cache", "", ret));
+ }
+}