summaryrefslogtreecommitdiffstats
path: root/redhat/tdelibs/kdelibs-3.5.13-add_dynamic_label_to_kpassword.patch
blob: b6f0ea0cbe213ded119d0790a9848c8c1a107759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
commit 3c75231601fb35f0c91022abeee5117c81f70a62
Author: Timothy Pearson <kb9vqf@pearsoncomputing.net>
Date:   1339293731 -0500

    Add dynamic label support to kpassworddialog

diff --git a/kdeui/kpassdlg.cpp b/kdeui/kpassdlg.cpp
index a9625b8..489e14d 100644
--- ./kdeui/kpassdlg.cpp.orig	2011-08-11 04:30:26.000000000 +0200
+++ ./kdeui/kpassdlg.cpp	2012-06-19 20:10:16.766136524 +0200
@@ -32,6 +32,7 @@
 #include <tqhbox.h>
 #include <tqwhatsthis.h>
 #include <tqptrdict.h>
+#include <tqtimer.h>
 
 #include <kglobal.h>
 #include <kdebug.h>
@@ -305,7 +306,7 @@
 KPasswordDialog::KPasswordDialog(Types type, bool enableKeep, int extraBttn,
                                  TQWidget *parent, const char *name)
     : KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
-                  Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
+                  Ok, true), m_Keep(enableKeep? 1 : 0), m_keepWarnLbl(0), m_Type(type), d(new KPasswordDialogPrivate)
 {
     d->iconName = "password";
     init();
@@ -314,7 +315,7 @@
 KPasswordDialog::KPasswordDialog(Types type, bool enableKeep, int extraBttn, const TQString& icon,
 				  TQWidget *parent, const char *name )
     : KDialogBase(parent, name, true, "", Ok|Cancel|extraBttn,
-                  Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
+                  Ok, true), m_Keep(enableKeep? 1 : 0), m_keepWarnLbl(0), m_Type(type), d(new KPasswordDialogPrivate)
 {
     if ( icon.stripWhiteSpace().isEmpty() )
 	d->iconName = "password";
@@ -326,7 +327,7 @@
 KPasswordDialog::KPasswordDialog(int type, TQString prompt, bool enableKeep,
                                  int extraBttn)
     : KDialogBase(0L, "Password Dialog", true, "", Ok|Cancel|extraBttn,
-                  Ok, true), m_Keep(enableKeep? 1 : 0), m_Type(type), d(new KPasswordDialogPrivate)
+                  Ok, true), m_Keep(enableKeep? 1 : 0), m_keepWarnLbl(0), m_Type(type), d(new KPasswordDialogPrivate)
 {
     d->iconName = "password";
     init();
@@ -393,12 +394,20 @@
 	m_pGrid->setRowStretch(8, 12);
 	TQCheckBox* const cb = new TQCheckBox(i18n("&Keep password"), m_pMain);
 	cb->setFixedSize(cb->tqsizeHint());
-	if (m_Keep > 1)
+	m_keepWarnLbl = new TQLabel(m_pMain);
+	m_keepWarnLbl->setAlignment(AlignLeft|AlignVCenter|WordBreak);
+	if (m_Keep > 1) {
 	    cb->setChecked(true);
-	else
+	    m_keepWarnLbl->show();
+	}
+	else {
 	    m_Keep = 0;
+	    m_keepWarnLbl->hide();
+	}
 	connect(cb, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotKeep(bool)));
 	m_pGrid->addWidget(cb, 9, 2, (TQ_Alignment)(AlignLeft|AlignVCenter));
+//	m_pGrid->addWidget(m_keepWarnLbl, 13, 2, (TQ_Alignment)(AlignLeft|AlignVCenter));
+	m_pGrid->addMultiCellWidget(m_keepWarnLbl, 13, 13, 0, 3);
     } else if (m_Type == NewPassword) {
 	m_pGrid->addRowSpacing(8, 10);
 	lbl = new TQLabel(m_pMain);
@@ -475,6 +484,13 @@
     m_pHelpLbl->setFixedSize(275, m_pHelpLbl->heightForWidth(275));
 }
 
+void KPasswordDialog::setKeepWarning(TQString warn)
+{
+    if (m_keepWarnLbl) {
+        m_keepWarnLbl->setText(warn);
+    }
+}
+
 
 TQString KPasswordDialog::prompt() const
 
@@ -550,9 +566,24 @@
 
 void KPasswordDialog::slotKeep(bool keep)
 {
+    if (m_keepWarnLbl->text() != "") {
+        if (keep) {
+            m_keepWarnLbl->show();
+        }
+        else {
+            m_keepWarnLbl->hide();
+        }
+        TQTimer::singleShot(0, this, SLOT(slotLayout()));
+    }
+
     m_Keep = keep;
 }
 
+void KPasswordDialog::slotLayout()
+{
+    resize(sizeHint());
+}
+
 
 // static . antlarr: KDE 4: Make it const TQString & prompt
 int KPasswordDialog::getPassword(TQCString &password, TQString prompt,
diff --git a/kdeui/kpassdlg.h b/kdeui/kpassdlg.h
index de83bb3..2d124b0 100644
--- a/kdeui/kpassdlg.h
+++ b/kdeui/kpassdlg.h
@@ -246,6 +246,11 @@ public:
     TQString prompt() const;
 
     /**
+     * Sets the text to be dynamically displayed when the keep checkbox is checked
+     */
+    void setKeepWarning(TQString warn);
+
+    /**
      * Adds a line of information to the dialog.
      */
     void addLine(TQString key, TQString value);
@@ -380,6 +385,7 @@ protected slots:
     void slotOk();
     void slotCancel();
     void slotKeep(bool);
+    void slotLayout();
 
 protected:
 
@@ -399,6 +405,7 @@ private:
 
     int m_Keep, m_Type, m_Row;
     TQLabel *m_pHelpLbl;
+    TQLabel *m_keepWarnLbl;
     TQGridLayout *m_pGrid;
     TQWidget *m_pMain;
     KPasswordEdit *m_pEdit, *m_pEdit2;