[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwallet] src/manager: Password contents can now always been shown when navigating the tree
From:       Valentin Rusu <kde () rusu ! info>
Date:       2013-03-31 22:37:26
Message-ID: 20130331223726.04CEAA604F () git ! kde ! org
[Download RAW message or body]

Git commit 5d3739b860aba731b644f2e02f3234e35cf742b2 by Valentin Rusu.
Committed on 01/04/2013 at 00:31.
Pushed by vrusu into branch 'master'.

Password contents can now always been shown when navigating the tree

The "show contents" and "hide contenst" buttons now received a menu
with a checkable action letting the user to change the behavior of
the editor when it selects a password entry.

The menu is displayed by long clicking the respective buttons. If
"always show contents" is checked, then the editor will show password
contents right away. No need to click "show contents".

The corresponding setting is put into the rc file so it'll be restored
upon kwalletmanager restart.

M  +42   -2    src/manager/kwalleteditor.cpp
M  +4    -0    src/manager/kwalleteditor.h
M  +17   -2    src/manager/walletwidget.ui

http://commits.kde.org/kwallet/5d3739b860aba731b644f2e02f3234e35cf742b2

diff --git a/src/manager/kwalleteditor.cpp b/src/manager/kwalleteditor.cpp
index fb3fa50..eb1058e 100644
--- a/src/manager/kwalleteditor.cpp
+++ b/src/manager/kwalleteditor.cpp
@@ -71,13 +71,15 @@ QAction *KWalletEditor::_importAction =0;
 KAction *KWalletEditor::_newEntryAction =0;
 KAction *KWalletEditor::_renameEntryAction =0;
 KAction *KWalletEditor::_deleteEntryAction =0;
-QAction *KWalletEditor::_copyPassAction;
+QAction *KWalletEditor::_copyPassAction =0;
+QAction *KWalletEditor::_alwaysShowContentsAction =0;
+QAction *KWalletEditor::_alwaysHideContentsAction =0;
 
 RegisterCreateActionsMethod \
KWalletEditor::_registerCreateActionMethod(&KWalletEditor::createActions);  
 
 KWalletEditor::KWalletEditor(QWidget* parent, const char *name)
-: _displayedItem(0), _actionCollection(0) {
+: _displayedItem(0), _actionCollection(0), _alwaysShowContents(false) {
     setupUi( this );
 	setObjectName( QLatin1String( name ) );
 	_newWallet = false;
@@ -116,6 +118,7 @@ KWalletEditor::KWalletEditor(QWidget* parent, const char *name)
 		splitterSize.append(_splitter->width()/2);
 	}
 	_splitter->setSizes(splitterSize);
+    _alwaysShowContents = cg.readEntry("AlwaysShowContents", false);
 
     _searchLine->setFocus();
 
@@ -156,6 +159,7 @@ KWalletEditor::~KWalletEditor() {
 	// save splitter size
 	KConfigGroup cg(KGlobal::config(), "WalletEditor");
 	cg.writeEntry("SplitterSize", _splitter->sizes());
+    cg.writeEntry("AlwaysShowContents", _alwaysShowContents);
 	cg.sync();
 
 	delete _w;
@@ -235,6 +239,14 @@ void KWalletEditor::createActions(KActionCollection* \
actionCollection) {  _deleteEntryAction->setText( i18n( "&Delete" ) );
 	_deleteEntryAction->setShortcut( Qt::Key_Delete );
 	_deleteEntryAction->setEnabled(false);
+
+    _alwaysShowContentsAction = actionCollection->addAction( QLatin1String( \
"always_show_contents" )); +    _alwaysShowContentsAction->setText( i18n("Always show \
contents") ); +    _alwaysShowContentsAction->setCheckable(true);
+
+    _alwaysHideContentsAction = actionCollection->addAction( QLatin1String( \
"always_hide_contents") ); +    _alwaysHideContentsAction->setText( i18n("Always hide \
contents") ); +    _alwaysHideContentsAction->setCheckable(true);
 }
 
 void KWalletEditor::connectActions()
@@ -266,6 +278,14 @@ void KWalletEditor::connectActions()
 
     connect(_copyPassAction, SIGNAL(triggered(bool)), SLOT(copyPassword()));
     connect(this, SIGNAL(enableWalletActions(bool)), _copyPassAction, \
SLOT(setEnabled(bool))); +
+    _showContents->addAction(_alwaysShowContentsAction);
+    _alwaysShowContentsAction->setChecked(_alwaysShowContents);
+    connect(_alwaysShowContentsAction, SIGNAL(triggered(bool)), \
SLOT(onAlwaysShowContents(bool))); +
+    _hideContents->addAction(_alwaysHideContentsAction);
+    _alwaysHideContentsAction->setChecked(!_alwaysShowContents);
+    connect(_alwaysHideContentsAction, SIGNAL(triggered(bool)), \
SLOT(onAlwaysHideContents(bool)));  }
 
 void KWalletEditor::disconnectActions()
@@ -297,6 +317,9 @@ void KWalletEditor::disconnectActions()
 
     disconnect(_copyPassAction, SIGNAL(triggered(bool)), this, \
                SLOT(copyPassword()));
     disconnect(this, SIGNAL(enableWalletActions(bool)), _copyPassAction, \
SLOT(setEnabled(bool))); +
+    disconnect(_alwaysShowContentsAction, SIGNAL(triggered(bool)), this, \
SLOT(onAlwaysShowContents(bool))); +    disconnect(_alwaysHideContentsAction, \
SIGNAL(triggered(bool)), this, SLOT(onAlwaysHideContents(bool)));  }
 
 void KWalletEditor::walletClosed() {
@@ -528,6 +551,9 @@ void KWalletEditor::entrySelectionChanged(QTreeWidgetItem *item) \
{  // add a context-menu action for copying passwords
 					_contextMenu->addSeparator();
 					_contextMenu->addAction( _copyPassAction );
+                    if(_alwaysShowContents) {
+                        QTimer::singleShot(0, this, SLOT(showPasswordContents()));
+                    }
 				} else if (ci->entryType() == KWallet::Wallet::Map) {
 					_entryStack->setCurrentIndex(2);
 					_mapEditorShowHide->setChecked(false);
@@ -1288,5 +1314,19 @@ void KWalletEditor::onSearchTextChanged(const QString& text)
     QTimer::singleShot(300, _entryList, SLOT(refreshItemsCount()));
 }
 
+void KWalletEditor::onAlwaysShowContents(bool checked)
+{
+    _alwaysShowContents = checked;
+    _alwaysHideContentsAction->setChecked(!_alwaysShowContents);
+    showPasswordContents();
+}
+
+void KWalletEditor::onAlwaysHideContents(bool checked)
+{
+    _alwaysShowContents = !checked;
+    _alwaysShowContentsAction->setChecked(_alwaysShowContents);
+    hidePasswordContents();
+}
+
 #include "kwalleteditor.moc"
 
diff --git a/src/manager/kwalleteditor.h b/src/manager/kwalleteditor.h
index a56126c..5a0766c 100644
--- a/src/manager/kwalleteditor.h
+++ b/src/manager/kwalleteditor.h
@@ -90,6 +90,8 @@ protected:
 		void copyPassword();
 
         void onSearchTextChanged(const QString&);
+        void onAlwaysShowContents(bool);
+        void onAlwaysHideContents(bool);
 
 	signals:
 		void enableWalletActions(bool enable);
@@ -126,6 +128,8 @@ protected:
         KMenu *_controlMenu;
         KMenu *_walletSubmenu;
         KTreeWidgetSearchLine *_searchLine;
+        static QAction *_alwaysShowContentsAction, *_alwaysHideContentsAction;
+        bool _alwaysShowContents;
 };
 
 #endif
diff --git a/src/manager/walletwidget.ui b/src/manager/walletwidget.ui
index 9c12989..485e01a 100644
--- a/src/manager/walletwidget.ui
+++ b/src/manager/walletwidget.ui
@@ -134,10 +134,19 @@
            <item>
             <layout class="QHBoxLayout" name="horizontalLayout_3">
              <item>
-              <widget class="KPushButton" name="_hideContents">
+              <widget class="QToolButton" name="_hideContents">
                <property name="text">
                 <string>Hide &amp;Contents</string>
                </property>
+               <property name="popupMode">
+                <enum>QToolButton::DelayedPopup</enum>
+               </property>
+               <property name="toolButtonStyle">
+                <enum>Qt::ToolButtonTextOnly</enum>
+               </property>
+               <property name="arrowType">
+                <enum>Qt::DownArrow</enum>
+               </property>
               </widget>
              </item>
              <item>
@@ -245,10 +254,16 @@
            <item>
             <layout class="QHBoxLayout" name="horizontalLayout_2">
              <item>
-              <widget class="KPushButton" name="_showContents">
+              <widget class="QToolButton" name="_showContents">
                <property name="text">
                 <string>Show &amp;Contents</string>
                </property>
+               <property name="toolButtonStyle">
+                <enum>Qt::ToolButtonFollowStyle</enum>
+               </property>
+               <property name="arrowType">
+                <enum>Qt::NoArrow</enum>
+               </property>
               </widget>
              </item>
              <item>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic