summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-09-15 22:40:33 (UTC)
committer ulf69 <ulf69>2004-09-15 22:40:33 (UTC)
commit56450c0322c2335a59ae8d8796e41397cdb09329 (patch) (side-by-side diff)
treef2b331be957fc022fe7110671f7434755f21eca3
parent610cf2a6c7aaf9855b54cd0453f347edf9c1a855 (diff)
downloadkdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.zip
kdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.tar.gz
kdepimpi-56450c0322c2335a59ae8d8796e41397cdb09329.tar.bz2
better openfile dialogs / make dialogs explicit modal
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/addentrywndimpl.cpp3
-rw-r--r--pwmanager/pwmanager/configwndimpl.cpp10
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 @@
/***************************************************************************
* *
* copyright (C) 2003, 2004 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* Many very good improvements and the original implementations of *
* them came from Matt Scifo <mscifo@o1.com> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "addentrywndimpl.h"
#include "pwmexception.h"
#include "pwgenwndimpl.h"
#ifndef PWM_EMBEDDED
#include "advcommeditimpl.h"
#endif
#include "htmlgen.h"
#include <kmessagebox.h>
#include <klocale.h>
#include <qpushbutton.h>
#include <qlabel.h>
AddEntryWndImpl::AddEntryWndImpl()
+#ifdef PWM_EMBEDDED
+ : addEntryWnd( 0, "AddEntryWndImpl", TRUE)
+#endif
{
editAdvCommentButton = 0;
commentTextEdit = 0;
switchComment(false);
pwGen = new PwGenWndImpl(this);
}
AddEntryWndImpl::~AddEntryWndImpl()
{
delete_ifnot_null(editAdvCommentButton);
delete_ifnot_null(commentTextEdit);
delete pwGen;
}
void AddEntryWndImpl::okButton_slot()
{
if (pwLineEdit->text().isEmpty()) {
KMessageBox::error(this,
i18n("Sorry, you haven't set a password."),
i18n("no password"));
return;
}
if (descLineEdit->text().isEmpty()) {
KMessageBox::error(this,
i18n
("You haven't set a \"Description\"."),
i18n("Description not set"));
return;
}
done(1);
}
void AddEntryWndImpl::cancelButton_slot()
{
done(2);
}
void AddEntryWndImpl::setCurrCategory(const QString &cat)
{
int i, count = categoryComboBox->count();
for (i = 0; i < count; ++i) {
if (categoryComboBox->text(i) == cat) {
categoryComboBox->setCurrentItem(i);
return;
}
}
BUG();
}
void AddEntryWndImpl::revealButton_slot()
{
if (revealButton->isOn()) {
pwLineEdit->setEchoMode(QLineEdit::Normal);
} else {
pwLineEdit->setEchoMode(QLineEdit::Password);
}
}
void AddEntryWndImpl::generateButton_slot()
{
if (!pwGen->exec())
return;
setPassword(pwGen->getPassword());
}
QString AddEntryWndImpl::getComment()
{
if (isAdvancedComment()) {
return advCommentDta;
}
return commentTextEdit->text();
}
void AddEntryWndImpl::setComment(const QString &comm)
{
if (HtmlGen::isHtml(comm)) {
advancedCommentButton->setOn(true);
advCommentDta = comm;
} else {
advancedCommentButton->setOn(false);
commentTextEdit->setText(comm);
}
}
void AddEntryWndImpl::advancedCommentButton_slot(bool on)
{
switchComment(on);
}
void AddEntryWndImpl::switchComment(bool toAdvanced)
{
useAdvComment = toAdvanced;
if (toAdvanced) {
if (commentTextEdit) {
savedCommentText = commentTextEdit->text();
delete_and_null(commentTextEdit);
}
if (editAdvCommentButton)
return;
editAdvCommentButton = new QPushButton(i18n("Edit advanced comment..."),
commentDummy);
editAdvCommentButton->resize(commentDummy->size().width(), 50);
connect(editAdvCommentButton, SIGNAL(clicked()),
this, SLOT(editAdvCommentButton_slot()));
editAdvCommentButton->show();
} else {
delete_ifnot_null(editAdvCommentButton);
if (commentTextEdit)
return;
#ifndef PWM_EMBEDDED
commentTextEdit = new QTextEdit(commentDummy);
commentTextEdit->setTextFormat(Qt::PlainText);
#else
commentTextEdit = new QMultiLineEdit(commentDummy);
#endif
commentTextEdit->resize(commentDummy->size());
commentTextEdit->setText(savedCommentText);
commentTextEdit->show();
}
}
void AddEntryWndImpl::editAdvCommentButton_slot()
{
#ifndef PWM_EMBEDDED
AdvCommEditImpl editor(this);
editor.setHtmlDta(advCommentDta);
if (editor.exec())
return;
advCommentDta = editor.getHtmlDta();
#endif
}
#ifndef PWM_EMBEDDED
#include "addentrywndimpl.moc"
#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 @@
/***************************************************************************
* *
* copyright (C) 2003 by Michael Buesch *
* email: mbuesch@freenet.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2 *
* as published by the Free Software Foundation. *
* *
***************************************************************************/
/***************************************************************************
* copyright (C) 2004 by Ulf Schenk
* This file is originaly based on version 1.0.1 of pwmanager
* and was modified to run on embedded devices that run microkde
*
* $Id$
**************************************************************************/
#include "configwndimpl.h"
#include "pwm.h"
#include "configuration.h"
#include <qfileinfo.h>
#include <qlineedit.h>
#include <kstandarddirs.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef PWM_EMBEDDED
#include <kfontdialog.h>
#endif
ConfigWndImpl::ConfigWndImpl()
+#ifdef PWM_EMBEDDED
+ : configWnd(0, "ConfigWndImpl", TRUE)
+#endif
+
{
}
ConfigWndImpl::~ConfigWndImpl()
{
}
void ConfigWndImpl::okButton_slot()
{
done(0);
}
void ConfigWndImpl::cancelButton_slot()
{
done(1);
}
void ConfigWndImpl::browseAutoStButton_slot()
{
+#ifndef PWM_EMBEDDED
QString path(KFileDialog::getOpenFileName(QString::null,
i18n("*.pwm|PwM Password file\n"
"*|All files"), this));
+#else
+ QString path = locateLocal( "data", KGlobal::getAppName() + "/*.pwm");
+ path = KFileDialog::getOpenFileName(filename,
+ i18n("password filename(*.pwm)"), this);
+#endif
if (path != QString::null)
autoStartLineEdit->setText(path);
}
void ConfigWndImpl::selEntrFontButton_slot()
{
bool ok;
#ifndef PWM_EMBEDDED
QFont fnt = QFontDialog::getFont(&ok, currentEntryFont, this);
#else
QFont fnt = KFontDialog::getFont(currentEntryFont, ok);
#endif
if (!ok)
return;
currEntrFont->setFont(fnt);
currEntrFont->setText(fnt.family());
currentEntryFont = fnt;
}
int ConfigWndImpl::getFilePermissions()
{
char octalDigits[] = "01234567";
bool isOctal;
QString permString(permissionLineEdit->text());
int i, j, length = permString.length();
if (length != 3) {
printWarn("Wrong permission string length! Please enter "
"the string like the following example: 600");
return CONF_DEFAULT_FILEPERMISSIONS;
}
for (i = 0; i < length; ++i) {
isOctal = false;
for (j = 0; j < 8; ++j) {
if (permString.at(i) == octalDigits[j]) {
isOctal = true;
break;
}
}
if (!isOctal) {
printWarn("CONFIG: File-permissions: This is "
"not an octal number ");
return CONF_DEFAULT_FILEPERMISSIONS;
}
}
int ret = strtol(permString.latin1(), 0, 8);
if (ret == 0) {
/* either an error occured, or the user did really type 000 */
printWarn("CONFIG: File-permissions: Hm, either conversion error, "
"or you really typed 000. 8-)");
return CONF_DEFAULT_FILEPERMISSIONS;
}
return ret;
}
void ConfigWndImpl::setFilePermissions(int perm)
{
char tmpBuf[30];
sprintf(tmpBuf, "%o", perm);
permissionLineEdit->setText(tmpBuf);
}
#ifndef PWM_EMBEDDED
#include "configwndimpl.moc"
#endif