summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.cpp112
-rw-r--r--pwmanager/pwmanager/getmasterpwwnd_emb.h16
-rw-r--r--pwmanager/pwmanager/listviewpwm.cpp17
3 files changed, 143 insertions, 2 deletions
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
index 3519de8..ff4c28a 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.cpp
@@ -1,86 +1,196 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#include "getmasterpwwnd_emb.h" 26#include "getmasterpwwnd_emb.h"
27 27
28#include "klocale.h" 28#include "klocale.h"
29
29/* 30/*
30#include <qvariant.h> 31#include <qvariant.h>
31#include <qpushbutton.h> 32#include <qpushbutton.h>
32#include <qlabel.h> 33#include <qlabel.h>
33#include <qlineedit.h> 34#include <qlineedit.h>
34#include <qlayout.h> 35#include <qlayout.h>
35#include <qtooltip.h> 36#include <qtooltip.h>
36#include <qwhatsthis.h> 37#include <qwhatsthis.h>
37*/ 38*/
38 39
39#include <qwidget.h> 40#include <qwidget.h>
40#include <qlayout.h> 41#include <qlayout.h>
41#include <qlabel.h> 42#include <qlabel.h>
42#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qpushbutton.h>
43 45
44/* 46/*
45 * Constructs a getMasterPwWnd as a child of 'parent', with the 47 * Constructs a getMasterPwWnd as a child of 'parent', with the
46 * name 'name' 48 * name 'name'
47 */ 49 */
48getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name) 50getMasterPwWnd::getMasterPwWnd( QWidget* parent, const char* name)
49 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ), 51 : KDialogBase( KDialogBase::Plain, i18n( "Master-password" ),
50 KDialogBase::Ok | KDialogBase::Cancel, 52 KDialogBase::Ok | KDialogBase::Cancel,
51 KDialogBase::Ok, parent, name, true ) 53 KDialogBase::Ok, parent, name, true )
52{ 54{
53 QWidget *page = plainPage(); 55 QWidget *page = plainPage();
54 QVBoxLayout *pageLayout = new QVBoxLayout( page ); 56 QVBoxLayout *pageLayout = new QVBoxLayout( page );
55 57
56 pwLineEdit = new QLineEdit( page, "pwLineEdit" ); 58 pwLineEdit = new QLineEdit( page, "pwLineEdit" );
57 pwLineEdit->setEchoMode( QLineEdit::Password ); 59 pwLineEdit->setEchoMode( QLineEdit::Password );
58 60
59 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" ); 61 QLabel* textLabel1 = new QLabel( pwLineEdit, i18n("Please enter the master-password:"), page, "textLabel1" );
60 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) ); 62 textLabel1->setAlignment( int( QLabel::WordBreak | QLabel::AlignCenter ) );
61 pageLayout->addWidget(textLabel1); 63 pageLayout->addWidget(textLabel1);
62 pageLayout->addWidget(pwLineEdit); 64 pageLayout->addWidget(pwLineEdit);
63 65
66 QWidget* numberBox = new QWidget( page );
67 numberBox->setFixedHeight(100);
68 numberBox->setFixedWidth(100);
69
70 QGridLayout* numberLayout = new QGridLayout( numberBox, 4, 3 );
71 numberLayout->setMargin( 0 );
72 numberLayout->setSpacing( 0 );
73
74 QPushButton* p1 = new QPushButton( i18n("1"), numberBox );
75 numberLayout->addWidget( p1, 0, 0 );
76 QPushButton* p2 = new QPushButton( i18n("2"), numberBox );
77 numberLayout->addWidget( p2, 0, 1 );
78 QPushButton* p3 = new QPushButton( i18n("3"), numberBox );
79 numberLayout->addWidget( p3, 0, 2 );
80 QPushButton* p4 = new QPushButton( i18n("4"), numberBox );
81 numberLayout->addWidget( p4, 1, 0 );
82 QPushButton* p5 = new QPushButton( i18n("5"), numberBox );
83 numberLayout->addWidget( p5, 1, 1 );
84 QPushButton* p6 = new QPushButton( i18n("6"), numberBox );
85 numberLayout->addWidget( p6, 1, 2 );
86 QPushButton* p7 = new QPushButton( i18n("7"), numberBox );
87 numberLayout->addWidget( p7, 2, 0 );
88 QPushButton* p8 = new QPushButton( i18n("8"), numberBox );
89 numberLayout->addWidget( p8, 2, 1 );
90 QPushButton* p9 = new QPushButton( i18n("9"), numberBox );
91 numberLayout->addWidget( p9, 2, 2 );
92 QPushButton* clear = new QPushButton( i18n("x"), numberBox );
93 numberLayout->addWidget( clear, 3, 0 );
94 QPushButton* p0 = new QPushButton( i18n("0"), numberBox );
95 numberLayout->addWidget( p0, 3, 1 );
96 QPushButton* backspace = new QPushButton( i18n("-"), numberBox );
97 numberLayout->addWidget( backspace, 3, 2 );
98
99
100 pageLayout->addWidget(numberBox);
101
102 resize( QSize(200, 180) );
103
104 connect( p0, SIGNAL( clicked() ), this, SLOT( add0() ) );
105 connect( p1, SIGNAL( clicked() ), this, SLOT( add1() ) );
106 connect( p2, SIGNAL( clicked() ), this, SLOT( add2() ) );
107 connect( p3, SIGNAL( clicked() ), this, SLOT( add3() ) );
108 connect( p4, SIGNAL( clicked() ), this, SLOT( add4() ) );
109 connect( p5, SIGNAL( clicked() ), this, SLOT( add5() ) );
110 connect( p6, SIGNAL( clicked() ), this, SLOT( add6() ) );
111 connect( p7, SIGNAL( clicked() ), this, SLOT( add7() ) );
112 connect( p8, SIGNAL( clicked() ), this, SLOT( add8() ) );
113 connect( p9, SIGNAL( clicked() ), this, SLOT( add9() ) );
114 connect( backspace, SIGNAL( clicked() ), this, SLOT( backspace() ) );
115 connect( clear, SIGNAL( clicked() ), this, SLOT( clear() ) );
116
64 117
65 resize( QSize(200, 100) );
66 118
67} 119}
68 120
69/* 121/*
70 * Destroys the object and frees any allocated resources 122 * Destroys the object and frees any allocated resources
71 */ 123 */
72getMasterPwWnd::~getMasterPwWnd() 124getMasterPwWnd::~getMasterPwWnd()
73{ 125{
74 // no need to delete child widgets, Qt does it all for us 126 // no need to delete child widgets, Qt does it all for us
75} 127}
76 128
77void getMasterPwWnd::okButton_slot() 129void getMasterPwWnd::okButton_slot()
78{ 130{
79 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" ); 131 qWarning( "getMasterPwWnd::okButton_slot(): Not implemented yet" );
80} 132}
81 133
82void getMasterPwWnd::cancelButton_slot() 134void getMasterPwWnd::cancelButton_slot()
83{ 135{
84 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" ); 136 qWarning( "getMasterPwWnd::cancelButton_slot(): Not implemented yet" );
85} 137}
86 138
139void getMasterPwWnd::add0()
140{
141 addCharacter("0");
142}
143void getMasterPwWnd::add1()
144{
145 addCharacter("1");
146}
147void getMasterPwWnd::add2()
148{
149 addCharacter("2");
150}
151void getMasterPwWnd::add3()
152{
153 addCharacter("3");
154}
155void getMasterPwWnd::add4()
156{
157 addCharacter("4");
158}
159void getMasterPwWnd::add5()
160{
161 addCharacter("5");
162}
163void getMasterPwWnd::add6()
164{
165 addCharacter("6");
166}
167void getMasterPwWnd::add7()
168{
169 addCharacter("7");
170}
171void getMasterPwWnd::add8()
172{
173 addCharacter("8");
174}
175void getMasterPwWnd::add9()
176{
177 addCharacter("9");
178}
179void getMasterPwWnd::backspace()
180{
181 QString old = pwLineEdit->text();
182 old.truncate(old.length()-1);
183 pwLineEdit->setText(old);
184}
185
186void getMasterPwWnd::clear()
187{
188 pwLineEdit->setText("");
189}
190
191void getMasterPwWnd::addCharacter(const QString& s)
192{
193 QString old = pwLineEdit->text();
194 pwLineEdit->setText(old + s);
195}
196
diff --git a/pwmanager/pwmanager/getmasterpwwnd_emb.h b/pwmanager/pwmanager/getmasterpwwnd_emb.h
index 64121c4..90204d3 100644
--- a/pwmanager/pwmanager/getmasterpwwnd_emb.h
+++ b/pwmanager/pwmanager/getmasterpwwnd_emb.h
@@ -1,48 +1,64 @@
1/* 1/*
2 This file is part of PwManager/Platform independent. 2 This file is part of PwManager/Platform independent.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22 22
23$Id$ 23$Id$
24*/ 24*/
25 25
26#ifndef GETMASTERPWWND_EMB_H 26#ifndef GETMASTERPWWND_EMB_H
27#define GETMASTERPWWND_EMB_H 27#define GETMASTERPWWND_EMB_H
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30 30
31class QLineEdit; 31class QLineEdit;
32 32
33class getMasterPwWnd : public KDialogBase 33class getMasterPwWnd : public KDialogBase
34{ 34{
35 Q_OBJECT 35 Q_OBJECT
36 36
37public: 37public:
38 getMasterPwWnd( QWidget* parent = 0, const char* name = 0); 38 getMasterPwWnd( QWidget* parent = 0, const char* name = 0);
39 ~getMasterPwWnd(); 39 ~getMasterPwWnd();
40 40
41 QLineEdit* pwLineEdit; 41 QLineEdit* pwLineEdit;
42 42
43public slots: 43public slots:
44 virtual void okButton_slot(); 44 virtual void okButton_slot();
45 virtual void cancelButton_slot(); 45 virtual void cancelButton_slot();
46
47 void add0();
48 void add1();
49 void add2();
50 void add3();
51 void add4();
52 void add5();
53 void add6();
54 void add7();
55 void add8();
56 void add9();
57 void backspace();
58 void clear();
59
60 private:
61 void addCharacter(const QString &s);
46}; 62};
47 63
48#endif // GETMASTERPWWND_H 64#endif // GETMASTERPWWND_H
diff --git a/pwmanager/pwmanager/listviewpwm.cpp b/pwmanager/pwmanager/listviewpwm.cpp
index c53cfd7..9f351d6 100644
--- a/pwmanager/pwmanager/listviewpwm.cpp
+++ b/pwmanager/pwmanager/listviewpwm.cpp
@@ -1,97 +1,112 @@
1/*************************************************************************** 1/***************************************************************************
2 * * 2 * *
3 * copyright (C) 2004 by Michael Buesch * 3 * copyright (C) 2004 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 * copyright (C) 2004 by Ulf Schenk 13 * copyright (C) 2004 by Ulf Schenk
14 * This file is originaly based on version 1.0.1 of pwmanager 14 * This file is originaly based on version 1.0.1 of pwmanager
15 * and was modified to run on embedded devices that run microkde 15 * and was modified to run on embedded devices that run microkde
16 * 16 *
17 * $Id$ 17 * $Id$
18 **************************************************************************/ 18 **************************************************************************/
19 19
20#include "listviewpwm.h" 20#include "listviewpwm.h"
21#include "pwmexception.h" 21#include "pwmexception.h"
22#include "pwmview.h"
22 23
23#include <qpainter.h> 24#include <qpainter.h>
24#include <qpixmap.h> 25#include <qpixmap.h>
25 26
26#include <kiconloader.h> 27#include <kiconloader.h>
27 28
28#ifdef PWM_EMBEDDED 29#ifdef PWM_EMBEDDED
29#include <kglobal.h> 30#include <kglobal.h>
30#endif 31#endif
31 32
32ListViewPwM::ListViewPwM(QWidget *parent, const char *name) 33ListViewPwM::ListViewPwM(QWidget *parent, const char *name)
33 : KListView(parent, name) 34 : KListView(parent, name)
34{ 35{
35 //setResizeMode(QListView::AllColumns); 36 //setResizeMode(QListView::AllColumns);
36} 37}
37 38
38bool ListViewPwM::event(QEvent *e) 39bool ListViewPwM::event(QEvent *e)
39{ 40{
40 if (e->type() == QEvent::LayoutHint) 41 if (e->type() == QEvent::LayoutHint)
41 emit layoutChanged(); 42 emit layoutChanged();
42 return KListView::event(e); 43 return KListView::event(e);
43} 44}
44 45
45 46
46QPixmap * ListViewItemPwM::onPix = 0; 47QPixmap * ListViewItemPwM::onPix = 0;
47QPixmap * ListViewItemPwM::offPix = 0; 48QPixmap * ListViewItemPwM::offPix = 0;
48 49
49ListViewItemPwM::ListViewItemPwM(QListView *parent) 50ListViewItemPwM::ListViewItemPwM(QListView *parent)
50 : QCheckListItem(parent, "", QCheckListItem::CheckBox) 51 : QCheckListItem(parent, "", QCheckListItem::CheckBox)
51{ 52{
52 if (!onPix) { 53 if (!onPix) {
53 PWM_ASSERT(!offPix); 54 PWM_ASSERT(!offPix);
54 KIconLoader* picons; 55 KIconLoader* picons;
55#ifndef PWM_EMBEDDED 56#ifndef PWM_EMBEDDED
56 KIconLoader il; 57 KIconLoader il;
57 picons = &il; 58 picons = &il;
58#else 59#else
59 picons = KGlobal::iconLoader(); 60 picons = KGlobal::iconLoader();
60#endif 61#endif
61 62
62 KIconLoader il; 63 KIconLoader il;
64#ifndef PWM_EMBEDDED
63 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small)); 65 static QPixmap onP(picons->loadIcon("button_ok", KIcon::Small));
66#else
67 static QPixmap onP(picons->loadIcon("decrypted", KIcon::Small));
68#endif
64 onPix = &onP; 69 onPix = &onP;
65 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small)); 70 static QPixmap offP(picons->loadIcon("encrypted", KIcon::Small));
66 offPix = &offP; 71 offPix = &offP;
67 } 72 }
68} 73}
69 74
70void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg, 75void ListViewItemPwM::paintCell(QPainter *p, const QColorGroup &cg,
71 int column, int width, int align) 76 int column, int width, int align)
72{ 77{
78 // qDebug("ListViewItemPwM::paintCell column=%i", column);
73 if (!p) 79 if (!p)
74 return; 80 return;
75 if (column != 0) { 81 //US BUG:
82 if (column != COLUMN_DESC) {
76 QCheckListItem::paintCell(p, cg, column, width, align); 83 QCheckListItem::paintCell(p, cg, column, width, align);
77 return; 84 return;
78 } 85 }
79 QPixmap *curPix = isOn() ? onPix : offPix; 86 QPixmap *curPix = isOn() ? onPix : offPix;
80 int pixSpace = curPix->width(); 87 int pixSpace = curPix->width();
81 pixSpace += 4; 88 pixSpace += 4;
82#ifndef PWM_EMBEDDED 89#ifndef PWM_EMBEDDED
83 QRect window(p->viewport()); 90 QRect window(p->viewport());
84 // clear the rectangle (we have to clear it first. see QT doc) 91 // clear the rectangle (we have to clear it first. see QT doc)
85 p->eraseRect(0, 0, pixSpace, window.height()); 92 p->eraseRect(0, 0, pixSpace, window.height());
86 // now draw the pixmap 93 // now draw the pixmap
87 int y = (height() - curPix->height()) / 2; 94 int y = (height() - curPix->height()) / 2;
88 p->drawPixmap(1, y, *curPix); 95 p->drawPixmap(1, y, *curPix);
89 window.moveLeft(pixSpace); 96 window.moveLeft(pixSpace);
90 p->setViewport(window); 97 p->setViewport(window);
98#else
99 p->eraseRect(0, 0, pixSpace, height());
100 // now draw the pixmap
101 int y = (height() - curPix->height()) / 2;
102 p->drawPixmap(1, y, *curPix);
103 p->translate( pixSpace, 0 );
104
91#endif 105#endif
92 QListViewItem::paintCell(p, cg, column, width - pixSpace, align); 106 QListViewItem::paintCell(p, cg, column, width - pixSpace, align);
107
93} 108}
94 109
95#ifndef PWM_EMBEDDED 110#ifndef PWM_EMBEDDED
96#include "listviewpwm.moc" 111#include "listviewpwm.moc"
97#endif 112#endif