author | conber <conber> | 2002-06-15 09:46:14 (UTC) |
---|---|---|
committer | conber <conber> | 2002-06-15 09:46:14 (UTC) |
commit | 7f2eef29708380844922f34f59ba4e9beefbf7c3 (patch) (unidiff) | |
tree | f57125fbaabddecc35d6677f1b9e48a4594165d5 /noncore/unsupported/mail2/configdiag.cpp | |
parent | 0acbdd392814589df303b6e50c79d9822e3db27a (diff) | |
download | opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.zip opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.gz opie-7f2eef29708380844922f34f59ba4e9beefbf7c3.tar.bz2 |
initial checkin
Diffstat (limited to 'noncore/unsupported/mail2/configdiag.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/mail2/configdiag.cpp | 144 |
1 files changed, 144 insertions, 0 deletions
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 @@ | |||
1 | #include <qmessagebox.h> | ||
2 | #include <qpushbutton.h> | ||
3 | #include <qtoolbutton.h> | ||
4 | #include <qgroupbox.h> | ||
5 | #include <qcheckbox.h> | ||
6 | #include <qspinbox.h> | ||
7 | #include <qheader.h> | ||
8 | #include <qtimer.h> | ||
9 | #include <qlabel.h> | ||
10 | |||
11 | #include <qpe/resource.h> | ||
12 | #include <qpe/config.h> | ||
13 | |||
14 | #include "accounteditor.h" | ||
15 | #include "zaurusstuff.h" | ||
16 | #include "configdiag.h" | ||
17 | #include "defines.h" | ||
18 | |||
19 | AccountListItem::AccountListItem(QListView *parent, Account &account) | ||
20 | : QListViewItem(parent), _account(account) | ||
21 | { | ||
22 | QString displayText; | ||
23 | if (!_account.realName().isEmpty() && !_account.email().isEmpty()) | ||
24 | setText(0, _account.realName() + " <" + _account.email() + ">"); | ||
25 | else if (_account.realName().isEmpty() && !_account.email().isEmpty()) | ||
26 | setText(0, _account.email()); | ||
27 | else if (!_account.realName().isEmpty() && _account.email().isEmpty()) | ||
28 | setText(0, _account.realName()); | ||
29 | else | ||
30 | setText(0, QObject::tr("(no name)")); | ||
31 | |||
32 | setPixmap(0, Resource::loadPixmap("mail/inbox")); | ||
33 | } | ||
34 | |||
35 | ConfigDiag::ConfigDiag(QWidget *parent, const char *name, bool modal, WFlags fl) | ||
36 | : ConfigDiagBase(parent, name, modal, fl) | ||
37 | { | ||
38 | _configBenD = new Config("mail"); | ||
39 | _configBenD->setGroup("Settings"); | ||
40 | disabled->setChecked(_configBenD->readBoolEntry("Disabled", false)); | ||
41 | playSound->setChecked(_configBenD->readBoolEntry("PlaySound", false)); | ||
42 | blinkLed->setChecked(_configBenD->readBoolEntry("BlinkLed", true)); | ||
43 | checkDelay->setValue(_configBenD->readNumEntry("CheckDelay", 5)); | ||
44 | |||
45 | accountList->header()->hide(); | ||
46 | disclaimer->setText(disclaimer->text().arg(VERSION)); | ||
47 | |||
48 | connect(accountNew, SIGNAL(clicked()), SLOT(slotNewAccount())); | ||
49 | connect(accountEdit, SIGNAL(clicked()), SLOT(slotEditAccount())); | ||
50 | connect(accountDelete, SIGNAL(clicked()), SLOT(slotDelAccount())); | ||
51 | |||
52 | connect(testbutton, SIGNAL(clicked()), SLOT(slotTestSettings())); | ||
53 | |||
54 | slotFillLists(); | ||
55 | } | ||
56 | |||
57 | void ConfigDiag::accept() | ||
58 | { | ||
59 | _configBenD->setGroup("Settings"); | ||
60 | _configBenD->writeEntry("Disabled", disabled->isChecked()); | ||
61 | _configBenD->writeEntry("PlaySound", playSound->isChecked()); | ||
62 | _configBenD->writeEntry("BlinkLed", blinkLed->isChecked()); | ||
63 | _configBenD->writeEntry("CheckDelay", checkDelay->value()); | ||
64 | _configBenD->write(); | ||
65 | |||
66 | QDialog::accept(); | ||
67 | } | ||
68 | |||
69 | void ConfigDiag::slotFillLists() | ||
70 | { | ||
71 | accountList->clear(); | ||
72 | |||
73 | QValueList<Account> accounts = ConfigFile::getAccounts(); | ||
74 | |||
75 | QValueList<Account>::Iterator it; | ||
76 | for (it = accounts.begin(); it != accounts.end(); it++) | ||
77 | (void) new AccountListItem(accountList, *it); | ||
78 | } | ||
79 | |||
80 | void ConfigDiag::slotNewAccount() | ||
81 | { | ||
82 | AccountEditor *editor = new AccountEditor(Account(), 0, 0, true); | ||
83 | editor->showMaximized(); | ||
84 | editor->show(); | ||
85 | |||
86 | if (QDialog::Accepted == editor->exec()) { | ||
87 | ConfigFile::updateAccount(editor->_account); | ||
88 | slotFillLists(); | ||
89 | emit changed(); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | void ConfigDiag::slotEditAccount() | ||
94 | { | ||
95 | if (!accountList->currentItem()) { | ||
96 | QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok")); | ||
97 | return; | ||
98 | } | ||
99 | Account account = ((AccountListItem *)accountList->currentItem())->account(); | ||
100 | |||
101 | AccountEditor *editor = new AccountEditor(account, 0, 0, true); | ||
102 | editor->showMaximized(); | ||
103 | editor->show(); | ||
104 | |||
105 | if (QDialog::Accepted == editor->exec()) { | ||
106 | ConfigFile::updateAccount(editor->_account); | ||
107 | slotFillLists(); | ||
108 | emit changed(); | ||
109 | } | ||
110 | } | ||
111 | |||
112 | void ConfigDiag::slotDelAccount() | ||
113 | { | ||
114 | if (!accountList->currentItem()) { | ||
115 | QMessageBox::information(this, tr("Error"), tr("<p>You have to select an account first.</p>"), tr("Ok")); | ||
116 | return; | ||
117 | } | ||
118 | Account account = ((AccountListItem *)accountList->currentItem())->account(); | ||
119 | |||
120 | int ret = QMessageBox::information(this, tr("Question"), tr("<p>Do you relly want to delete the selected account?</p>"), tr("Yes"), tr("No")); | ||
121 | if (1 == ret) return; | ||
122 | |||
123 | ConfigFile::deleteAccount(account); | ||
124 | slotFillLists(); | ||
125 | emit changed(); | ||
126 | } | ||
127 | |||
128 | void ConfigDiag::slotTestSettings() | ||
129 | { | ||
130 | testbutton->setEnabled(false); | ||
131 | |||
132 | if (blinkLed->isChecked()) ZaurusStuff::blinkLedOn(); | ||
133 | if (playSound->isChecked()) ZaurusStuff::buzzerOn(); | ||
134 | QTimer::singleShot(3000, this, SLOT(slotEndTest())); | ||
135 | } | ||
136 | |||
137 | void ConfigDiag::slotEndTest() | ||
138 | { | ||
139 | if (playSound->isChecked()) ZaurusStuff::buzzerOff(); | ||
140 | if (blinkLed->isChecked()) ZaurusStuff::blinkLedOff(); | ||
141 | |||
142 | testbutton->setEnabled(true); | ||
143 | } | ||
144 | |||