author | ulf69 <ulf69> | 2004-09-15 22:40:33 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-15 22:40:33 (UTC) |
commit | 56450c0322c2335a59ae8d8796e41397cdb09329 (patch) (unidiff) | |
tree | f2b331be957fc022fe7110671f7434755f21eca3 | |
parent | 610cf2a6c7aaf9855b54cd0453f347edf9c1a855 (diff) | |
download | kdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.zip kdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.tar.gz kdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.tar.bz2 |
better openfile dialogs / make dialogs explicit modal
-rw-r--r-- | pwmanager/pwmanager/addentrywndimpl.cpp | 3 | ||||
-rw-r--r-- | pwmanager/pwmanager/configwndimpl.cpp | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/pwmanager/pwmanager/addentrywndimpl.cpp b/pwmanager/pwmanager/addentrywndimpl.cpp index 9e0fde9..73ba36c 100644 --- a/pwmanager/pwmanager/addentrywndimpl.cpp +++ b/pwmanager/pwmanager/addentrywndimpl.cpp | |||
@@ -1,174 +1,177 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003, 2004 by Michael Buesch * | 3 | * copyright (C) 2003, 2004 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * Many very good improvements and the original implementations of * | 6 | * Many very good improvements and the original implementations of * |
7 | * them came from Matt Scifo <mscifo@o1.com> * | 7 | * them came from Matt Scifo <mscifo@o1.com> * |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License version 2 * | 10 | * it under the terms of the GNU General Public License version 2 * |
11 | * as published by the Free Software Foundation. * | 11 | * as published by the Free Software Foundation. * |
12 | * * | 12 | * * |
13 | ***************************************************************************/ | 13 | ***************************************************************************/ |
14 | 14 | ||
15 | /*************************************************************************** | 15 | /*************************************************************************** |
16 | * copyright (C) 2004 by Ulf Schenk | 16 | * copyright (C) 2004 by Ulf Schenk |
17 | * This file is originaly based on version 1.0.1 of pwmanager | 17 | * This file is originaly based on version 1.0.1 of pwmanager |
18 | * and was modified to run on embedded devices that run microkde | 18 | * and was modified to run on embedded devices that run microkde |
19 | * | 19 | * |
20 | * $Id$ | 20 | * $Id$ |
21 | **************************************************************************/ | 21 | **************************************************************************/ |
22 | 22 | ||
23 | #include "addentrywndimpl.h" | 23 | #include "addentrywndimpl.h" |
24 | #include "pwmexception.h" | 24 | #include "pwmexception.h" |
25 | #include "pwgenwndimpl.h" | 25 | #include "pwgenwndimpl.h" |
26 | #ifndef PWM_EMBEDDED | 26 | #ifndef PWM_EMBEDDED |
27 | #include "advcommeditimpl.h" | 27 | #include "advcommeditimpl.h" |
28 | #endif | 28 | #endif |
29 | #include "htmlgen.h" | 29 | #include "htmlgen.h" |
30 | 30 | ||
31 | #include <kmessagebox.h> | 31 | #include <kmessagebox.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | 33 | ||
34 | #include <qpushbutton.h> | 34 | #include <qpushbutton.h> |
35 | #include <qlabel.h> | 35 | #include <qlabel.h> |
36 | 36 | ||
37 | 37 | ||
38 | AddEntryWndImpl::AddEntryWndImpl() | 38 | AddEntryWndImpl::AddEntryWndImpl() |
39 | #ifdef PWM_EMBEDDED | ||
40 | : addEntryWnd( 0, "AddEntryWndImpl", TRUE) | ||
41 | #endif | ||
39 | { | 42 | { |
40 | editAdvCommentButton = 0; | 43 | editAdvCommentButton = 0; |
41 | commentTextEdit = 0; | 44 | commentTextEdit = 0; |
42 | switchComment(false); | 45 | switchComment(false); |
43 | pwGen = new PwGenWndImpl(this); | 46 | pwGen = new PwGenWndImpl(this); |
44 | } | 47 | } |
45 | 48 | ||
46 | AddEntryWndImpl::~AddEntryWndImpl() | 49 | AddEntryWndImpl::~AddEntryWndImpl() |
47 | { | 50 | { |
48 | delete_ifnot_null(editAdvCommentButton); | 51 | delete_ifnot_null(editAdvCommentButton); |
49 | delete_ifnot_null(commentTextEdit); | 52 | delete_ifnot_null(commentTextEdit); |
50 | delete pwGen; | 53 | delete pwGen; |
51 | } | 54 | } |
52 | 55 | ||
53 | void AddEntryWndImpl::okButton_slot() | 56 | void AddEntryWndImpl::okButton_slot() |
54 | { | 57 | { |
55 | if (pwLineEdit->text().isEmpty()) { | 58 | if (pwLineEdit->text().isEmpty()) { |
56 | KMessageBox::error(this, | 59 | KMessageBox::error(this, |
57 | i18n("Sorry, you haven't set a password."), | 60 | i18n("Sorry, you haven't set a password."), |
58 | i18n("no password")); | 61 | i18n("no password")); |
59 | return; | 62 | return; |
60 | } | 63 | } |
61 | if (descLineEdit->text().isEmpty()) { | 64 | if (descLineEdit->text().isEmpty()) { |
62 | KMessageBox::error(this, | 65 | KMessageBox::error(this, |
63 | i18n | 66 | i18n |
64 | ("You haven't set a \"Description\"."), | 67 | ("You haven't set a \"Description\"."), |
65 | i18n("Description not set")); | 68 | i18n("Description not set")); |
66 | return; | 69 | return; |
67 | } | 70 | } |
68 | done(1); | 71 | done(1); |
69 | } | 72 | } |
70 | 73 | ||
71 | void AddEntryWndImpl::cancelButton_slot() | 74 | void AddEntryWndImpl::cancelButton_slot() |
72 | { | 75 | { |
73 | done(2); | 76 | done(2); |
74 | } | 77 | } |
75 | 78 | ||
76 | void AddEntryWndImpl::setCurrCategory(const QString &cat) | 79 | void AddEntryWndImpl::setCurrCategory(const QString &cat) |
77 | { | 80 | { |
78 | int i, count = categoryComboBox->count(); | 81 | int i, count = categoryComboBox->count(); |
79 | 82 | ||
80 | for (i = 0; i < count; ++i) { | 83 | for (i = 0; i < count; ++i) { |
81 | if (categoryComboBox->text(i) == cat) { | 84 | if (categoryComboBox->text(i) == cat) { |
82 | categoryComboBox->setCurrentItem(i); | 85 | categoryComboBox->setCurrentItem(i); |
83 | return; | 86 | return; |
84 | } | 87 | } |
85 | } | 88 | } |
86 | BUG(); | 89 | BUG(); |
87 | } | 90 | } |
88 | 91 | ||
89 | void AddEntryWndImpl::revealButton_slot() | 92 | void AddEntryWndImpl::revealButton_slot() |
90 | { | 93 | { |
91 | if (revealButton->isOn()) { | 94 | if (revealButton->isOn()) { |
92 | pwLineEdit->setEchoMode(QLineEdit::Normal); | 95 | pwLineEdit->setEchoMode(QLineEdit::Normal); |
93 | } else { | 96 | } else { |
94 | pwLineEdit->setEchoMode(QLineEdit::Password); | 97 | pwLineEdit->setEchoMode(QLineEdit::Password); |
95 | } | 98 | } |
96 | } | 99 | } |
97 | 100 | ||
98 | void AddEntryWndImpl::generateButton_slot() | 101 | void AddEntryWndImpl::generateButton_slot() |
99 | { | 102 | { |
100 | if (!pwGen->exec()) | 103 | if (!pwGen->exec()) |
101 | return; | 104 | return; |
102 | setPassword(pwGen->getPassword()); | 105 | setPassword(pwGen->getPassword()); |
103 | } | 106 | } |
104 | 107 | ||
105 | QString AddEntryWndImpl::getComment() | 108 | QString AddEntryWndImpl::getComment() |
106 | { | 109 | { |
107 | if (isAdvancedComment()) { | 110 | if (isAdvancedComment()) { |
108 | return advCommentDta; | 111 | return advCommentDta; |
109 | } | 112 | } |
110 | return commentTextEdit->text(); | 113 | return commentTextEdit->text(); |
111 | } | 114 | } |
112 | 115 | ||
113 | void AddEntryWndImpl::setComment(const QString &comm) | 116 | void AddEntryWndImpl::setComment(const QString &comm) |
114 | { | 117 | { |
115 | if (HtmlGen::isHtml(comm)) { | 118 | if (HtmlGen::isHtml(comm)) { |
116 | advancedCommentButton->setOn(true); | 119 | advancedCommentButton->setOn(true); |
117 | advCommentDta = comm; | 120 | advCommentDta = comm; |
118 | } else { | 121 | } else { |
119 | advancedCommentButton->setOn(false); | 122 | advancedCommentButton->setOn(false); |
120 | commentTextEdit->setText(comm); | 123 | commentTextEdit->setText(comm); |
121 | } | 124 | } |
122 | } | 125 | } |
123 | 126 | ||
124 | void AddEntryWndImpl::advancedCommentButton_slot(bool on) | 127 | void AddEntryWndImpl::advancedCommentButton_slot(bool on) |
125 | { | 128 | { |
126 | switchComment(on); | 129 | switchComment(on); |
127 | } | 130 | } |
128 | 131 | ||
129 | void AddEntryWndImpl::switchComment(bool toAdvanced) | 132 | void AddEntryWndImpl::switchComment(bool toAdvanced) |
130 | { | 133 | { |
131 | useAdvComment = toAdvanced; | 134 | useAdvComment = toAdvanced; |
132 | if (toAdvanced) { | 135 | if (toAdvanced) { |
133 | if (commentTextEdit) { | 136 | if (commentTextEdit) { |
134 | savedCommentText = commentTextEdit->text(); | 137 | savedCommentText = commentTextEdit->text(); |
135 | delete_and_null(commentTextEdit); | 138 | delete_and_null(commentTextEdit); |
136 | } | 139 | } |
137 | if (editAdvCommentButton) | 140 | if (editAdvCommentButton) |
138 | return; | 141 | return; |
139 | editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."), | 142 | editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."), |
140 | commentDummy); | 143 | commentDummy); |
141 | editAdvCommentButton->resize(commentDummy->size().width(), 50); | 144 | editAdvCommentButton->resize(commentDummy->size().width(), 50); |
142 | connect(editAdvCommentButton, SIGNAL(clicked()), | 145 | connect(editAdvCommentButton, SIGNAL(clicked()), |
143 | this, SLOT(editAdvCommentButton_slot())); | 146 | this, SLOT(editAdvCommentButton_slot())); |
144 | editAdvCommentButton->show(); | 147 | editAdvCommentButton->show(); |
145 | } else { | 148 | } else { |
146 | delete_ifnot_null(editAdvCommentButton); | 149 | delete_ifnot_null(editAdvCommentButton); |
147 | if (commentTextEdit) | 150 | if (commentTextEdit) |
148 | return; | 151 | return; |
149 | #ifndef PWM_EMBEDDED | 152 | #ifndef PWM_EMBEDDED |
150 | commentTextEdit = new QTextEdit(commentDummy); | 153 | commentTextEdit = new QTextEdit(commentDummy); |
151 | commentTextEdit->setTextFormat(Qt::PlainText); | 154 | commentTextEdit->setTextFormat(Qt::PlainText); |
152 | #else | 155 | #else |
153 | commentTextEdit = new QMultiLineEdit(commentDummy); | 156 | commentTextEdit = new QMultiLineEdit(commentDummy); |
154 | #endif | 157 | #endif |
155 | commentTextEdit->resize(commentDummy->size()); | 158 | commentTextEdit->resize(commentDummy->size()); |
156 | commentTextEdit->setText(savedCommentText); | 159 | commentTextEdit->setText(savedCommentText); |
157 | commentTextEdit->show(); | 160 | commentTextEdit->show(); |
158 | } | 161 | } |
159 | } | 162 | } |
160 | 163 | ||
161 | void AddEntryWndImpl::editAdvCommentButton_slot() | 164 | void AddEntryWndImpl::editAdvCommentButton_slot() |
162 | { | 165 | { |
163 | #ifndef PWM_EMBEDDED | 166 | #ifndef PWM_EMBEDDED |
164 | AdvCommEditImpl editor(this); | 167 | AdvCommEditImpl editor(this); |
165 | editor.setHtmlDta(advCommentDta); | 168 | editor.setHtmlDta(advCommentDta); |
166 | if (editor.exec()) | 169 | if (editor.exec()) |
167 | return; | 170 | return; |
168 | advCommentDta = editor.getHtmlDta(); | 171 | advCommentDta = editor.getHtmlDta(); |
169 | #endif | 172 | #endif |
170 | } | 173 | } |
171 | 174 | ||
172 | #ifndef PWM_EMBEDDED | 175 | #ifndef PWM_EMBEDDED |
173 | #include "addentrywndimpl.moc" | 176 | #include "addentrywndimpl.moc" |
174 | #endif | 177 | #endif |
diff --git a/pwmanager/pwmanager/configwndimpl.cpp b/pwmanager/pwmanager/configwndimpl.cpp index 5aa38d4..595a6e7 100644 --- a/pwmanager/pwmanager/configwndimpl.cpp +++ b/pwmanager/pwmanager/configwndimpl.cpp | |||
@@ -1,126 +1,136 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * copyright (C) 2003 by Michael Buesch * | 3 | * copyright (C) 2003 by Michael Buesch * |
4 | * email: mbuesch@freenet.de * | 4 | * email: mbuesch@freenet.de * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License version 2 * | 7 | * it under the terms of the GNU General Public License version 2 * |
8 | * as published by the Free Software Foundation. * | 8 | * as published by the Free Software Foundation. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | 11 | ||
12 | 12 | ||
13 | /*************************************************************************** | 13 | /*************************************************************************** |
14 | * copyright (C) 2004 by Ulf Schenk | 14 | * copyright (C) 2004 by Ulf Schenk |
15 | * This file is originaly based on version 1.0.1 of pwmanager | 15 | * This file is originaly based on version 1.0.1 of pwmanager |
16 | * and was modified to run on embedded devices that run microkde | 16 | * and was modified to run on embedded devices that run microkde |
17 | * | 17 | * |
18 | * $Id$ | 18 | * $Id$ |
19 | **************************************************************************/ | 19 | **************************************************************************/ |
20 | 20 | ||
21 | #include "configwndimpl.h" | 21 | #include "configwndimpl.h" |
22 | #include "pwm.h" | 22 | #include "pwm.h" |
23 | #include "configuration.h" | 23 | #include "configuration.h" |
24 | 24 | ||
25 | #include <qfileinfo.h> | 25 | #include <qfileinfo.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | 27 | ||
28 | #include <kstandarddirs.h> | 28 | #include <kstandarddirs.h> |
29 | #include <kfiledialog.h> | 29 | #include <kfiledialog.h> |
30 | #include <klocale.h> | 30 | #include <klocale.h> |
31 | 31 | ||
32 | #include <stdlib.h> | 32 | #include <stdlib.h> |
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | 34 | ||
35 | #ifdef PWM_EMBEDDED | 35 | #ifdef PWM_EMBEDDED |
36 | #include <kfontdialog.h> | 36 | #include <kfontdialog.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | ConfigWndImpl::ConfigWndImpl() | 39 | ConfigWndImpl::ConfigWndImpl() |
40 | #ifdef PWM_EMBEDDED | ||
41 | : configWnd(0, "ConfigWndImpl", TRUE) | ||
42 | #endif | ||
43 | |||
40 | { | 44 | { |
41 | } | 45 | } |
42 | 46 | ||
43 | ConfigWndImpl::~ConfigWndImpl() | 47 | ConfigWndImpl::~ConfigWndImpl() |
44 | { | 48 | { |
45 | } | 49 | } |
46 | 50 | ||
47 | void ConfigWndImpl::okButton_slot() | 51 | void ConfigWndImpl::okButton_slot() |
48 | { | 52 | { |
49 | done(0); | 53 | done(0); |
50 | } | 54 | } |
51 | 55 | ||
52 | void ConfigWndImpl::cancelButton_slot() | 56 | void ConfigWndImpl::cancelButton_slot() |
53 | { | 57 | { |
54 | done(1); | 58 | done(1); |
55 | } | 59 | } |
56 | 60 | ||
57 | void ConfigWndImpl::browseAutoStButton_slot() | 61 | void ConfigWndImpl::browseAutoStButton_slot() |
58 | { | 62 | { |
63 | #ifndef PWM_EMBEDDED | ||
59 | QString path(KFileDialog::getOpenFileName(QString::null, | 64 | QString path(KFileDialog::getOpenFileName(QString::null, |
60 | i18n("*.pwm|PwM Password file\n" | 65 | i18n("*.pwm|PwM Password file\n" |
61 | "*|All files"), this)); | 66 | "*|All files"), this)); |
67 | #else | ||
68 | QString path = locateLocal( "data", KGlobal::getAppName() + "/*.pwm"); | ||
69 | path = KFileDialog::getOpenFileName(filename, | ||
70 | i18n("password filename(*.pwm)"), this); | ||
71 | #endif | ||
62 | if (path != QString::null) | 72 | if (path != QString::null) |
63 | autoStartLineEdit->setText(path); | 73 | autoStartLineEdit->setText(path); |
64 | } | 74 | } |
65 | 75 | ||
66 | void ConfigWndImpl::selEntrFontButton_slot() | 76 | void ConfigWndImpl::selEntrFontButton_slot() |
67 | { | 77 | { |
68 | bool ok; | 78 | bool ok; |
69 | #ifndef PWM_EMBEDDED | 79 | #ifndef PWM_EMBEDDED |
70 | QFont fnt = QFontDialog::getFont(&ok, currentEntryFont, this); | 80 | QFont fnt = QFontDialog::getFont(&ok, currentEntryFont, this); |
71 | #else | 81 | #else |
72 | QFont fnt = KFontDialog::getFont(currentEntryFont, ok); | 82 | QFont fnt = KFontDialog::getFont(currentEntryFont, ok); |
73 | #endif | 83 | #endif |
74 | if (!ok) | 84 | if (!ok) |
75 | return; | 85 | return; |
76 | currEntrFont->setFont(fnt); | 86 | currEntrFont->setFont(fnt); |
77 | currEntrFont->setText(fnt.family()); | 87 | currEntrFont->setText(fnt.family()); |
78 | currentEntryFont = fnt; | 88 | currentEntryFont = fnt; |
79 | } | 89 | } |
80 | 90 | ||
81 | int ConfigWndImpl::getFilePermissions() | 91 | int ConfigWndImpl::getFilePermissions() |
82 | { | 92 | { |
83 | char octalDigits[] = "01234567"; | 93 | char octalDigits[] = "01234567"; |
84 | bool isOctal; | 94 | bool isOctal; |
85 | QString permString(permissionLineEdit->text()); | 95 | QString permString(permissionLineEdit->text()); |
86 | int i, j, length = permString.length(); | 96 | int i, j, length = permString.length(); |
87 | if (length != 3) { | 97 | if (length != 3) { |
88 | printWarn("Wrong permission string length! Please enter " | 98 | printWarn("Wrong permission string length! Please enter " |
89 | "the string like the following example: 600"); | 99 | "the string like the following example: 600"); |
90 | return CONF_DEFAULT_FILEPERMISSIONS; | 100 | return CONF_DEFAULT_FILEPERMISSIONS; |
91 | } | 101 | } |
92 | for (i = 0; i < length; ++i) { | 102 | for (i = 0; i < length; ++i) { |
93 | isOctal = false; | 103 | isOctal = false; |
94 | for (j = 0; j < 8; ++j) { | 104 | for (j = 0; j < 8; ++j) { |
95 | if (permString.at(i) == octalDigits[j]) { | 105 | if (permString.at(i) == octalDigits[j]) { |
96 | isOctal = true; | 106 | isOctal = true; |
97 | break; | 107 | break; |
98 | } | 108 | } |
99 | } | 109 | } |
100 | if (!isOctal) { | 110 | if (!isOctal) { |
101 | printWarn("CONFIG: File-permissions: This is " | 111 | printWarn("CONFIG: File-permissions: This is " |
102 | "not an octal number "); | 112 | "not an octal number "); |
103 | return CONF_DEFAULT_FILEPERMISSIONS; | 113 | return CONF_DEFAULT_FILEPERMISSIONS; |
104 | } | 114 | } |
105 | } | 115 | } |
106 | 116 | ||
107 | int ret = strtol(permString.latin1(), 0, 8); | 117 | int ret = strtol(permString.latin1(), 0, 8); |
108 | if (ret == 0) { | 118 | if (ret == 0) { |
109 | /* either an error occured, or the user did really type 000 */ | 119 | /* either an error occured, or the user did really type 000 */ |
110 | printWarn("CONFIG: File-permissions: Hm, either conversion error, " | 120 | printWarn("CONFIG: File-permissions: Hm, either conversion error, " |
111 | "or you really typed 000. 8-)"); | 121 | "or you really typed 000. 8-)"); |
112 | return CONF_DEFAULT_FILEPERMISSIONS; | 122 | return CONF_DEFAULT_FILEPERMISSIONS; |
113 | } | 123 | } |
114 | return ret; | 124 | return ret; |
115 | } | 125 | } |
116 | 126 | ||
117 | void ConfigWndImpl::setFilePermissions(int perm) | 127 | void ConfigWndImpl::setFilePermissions(int perm) |
118 | { | 128 | { |
119 | char tmpBuf[30]; | 129 | char tmpBuf[30]; |
120 | sprintf(tmpBuf, "%o", perm); | 130 | sprintf(tmpBuf, "%o", perm); |
121 | permissionLineEdit->setText(tmpBuf); | 131 | permissionLineEdit->setText(tmpBuf); |
122 | } | 132 | } |
123 | 133 | ||
124 | #ifndef PWM_EMBEDDED | 134 | #ifndef PWM_EMBEDDED |
125 | #include "configwndimpl.moc" | 135 | #include "configwndimpl.moc" |
126 | #endif | 136 | #endif |