From 7f2eef29708380844922f34f59ba4e9beefbf7c3 Mon Sep 17 00:00:00 2001 From: conber Date: Sat, 15 Jun 2002 09:46:14 +0000 Subject: initial checkin --- (limited to 'noncore/unsupported/mail2/configdiag.cpp') diff --git a/noncore/unsupported/mail2/configdiag.cpp b/noncore/unsupported/mail2/configdiag.cpp new file mode 100644 index 0000000..be1f1f4 --- a/dev/null +++ b/noncore/unsupported/mail2/configdiag.cpp @@ -0,0 +1,144 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "accounteditor.h" +#include "zaurusstuff.h" +#include "configdiag.h" +#include "defines.h" + +AccountListItem::AccountListItem(QListView *parent, Account &account) + : QListViewItem(parent), _account(account) +{ + QString displayText; + if (!_account.realName().isEmpty() && !_account.email().isEmpty()) + setText(0, _account.realName() + " <" + _account.email() + ">"); + else if (_account.realName().isEmpty() && !_account.email().isEmpty()) + setText(0, _account.email()); + else if (!_account.realName().isEmpty() && _account.email().isEmpty()) + setText(0, _account.realName()); + else + setText(0, QObject::tr("(no name)")); + + setPixmap(0, Resource::loadPixmap("mail/inbox")); +} + +ConfigDiag::ConfigDiag(QWidget *parent, const char *name, bool modal, WFlags fl) + : ConfigDiagBase(parent, name, modal, fl) +{ + _configBenD = new Config("mail"); + _configBenD->setGroup("Settings"); + disabled->setChecked(_configBenD->readBoolEntry("Disabled", false)); + playSound->setChecked(_configBenD->readBoolEntry("PlaySound", false)); + blinkLed->setChecked(_configBenD->readBoolEntry("BlinkLed", true)); + checkDelay->setValue(_configBenD->readNumEntry("CheckDelay", 5)); + + accountList->header()->hide(); + disclaimer->setText(disclaimer->text().arg(VERSION)); + + connect(accountNew, SIGNAL(clicked()), SLOT(slotNewAccount())); + connect(accountEdit, SIGNAL(clicked()), SLOT(slotEditAccount())); + connect(accountDelete, SIGNAL(clicked()), SLOT(slotDelAccount())); + + connect(testbutton, SIGNAL(clicked()), SLOT(slotTestSettings())); + + slotFillLists(); +} + +void ConfigDiag::accept() +{ + _configBenD->setGroup("Settings"); + _configBenD->writeEntry("Disabled", disabled->isChecked()); + _configBenD->writeEntry("PlaySound", playSound->isChecked()); + _configBenD->writeEntry("BlinkLed", blinkLed->isChecked()); + _configBenD->writeEntry("CheckDelay", checkDelay->value()); + _configBenD->write(); + + QDialog::accept(); +} + +void ConfigDiag::slotFillLists() +{ + accountList->clear(); + + QValueList accounts = ConfigFile::getAccounts(); + + QValueList::Iterator it; + for (it = accounts.begin(); it != accounts.end(); it++) + (void) new AccountListItem(accountList, *it); +} + +void ConfigDiag::slotNewAccount() +{ + AccountEditor *editor = new AccountEditor(Account(), 0, 0, true); + editor->showMaximized(); + editor->show(); + + if (QDialog::Accepted == editor->exec()) { + ConfigFile::updateAccount(editor->_account); + slotFillLists(); + emit changed(); + } +} + +void ConfigDiag::slotEditAccount() +{ + if (!accountList->currentItem()) { + QMessageBox::information(this, tr("Error"), tr("

You have to select an account first.

"), tr("Ok")); + return; + } + Account account = ((AccountListItem *)accountList->currentItem())->account(); + + AccountEditor *editor = new AccountEditor(account, 0, 0, true); + editor->showMaximized(); + editor->show(); + + if (QDialog::Accepted == editor->exec()) { + ConfigFile::updateAccount(editor->_account); + slotFillLists(); + emit changed(); + } +} + +void ConfigDiag::slotDelAccount() +{ + if (!accountList->currentItem()) { + QMessageBox::information(this, tr("Error"), tr("

You have to select an account first.

"), tr("Ok")); + return; + } + Account account = ((AccountListItem *)accountList->currentItem())->account(); + + int ret = QMessageBox::information(this, tr("Question"), tr("

Do you relly want to delete the selected account?

"), tr("Yes"), tr("No")); + if (1 == ret) return; + + ConfigFile::deleteAccount(account); + slotFillLists(); + emit changed(); +} + +void ConfigDiag::slotTestSettings() +{ + testbutton->setEnabled(false); + + if (blinkLed->isChecked()) ZaurusStuff::blinkLedOn(); + if (playSound->isChecked()) ZaurusStuff::buzzerOn(); + QTimer::singleShot(3000, this, SLOT(slotEndTest())); +} + +void ConfigDiag::slotEndTest() +{ + if (playSound->isChecked()) ZaurusStuff::buzzerOff(); + if (blinkLed->isChecked()) ZaurusStuff::blinkLedOff(); + + testbutton->setEnabled(true); +} + -- cgit v0.9.0.2