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 =3D0; KAction *KWalletEditor::_newEntryAction =3D0; KAction *KWalletEditor::_renameEntryAction =3D0; KAction *KWalletEditor::_deleteEntryAction =3D0; -QAction *KWalletEditor::_copyPassAction; +QAction *KWalletEditor::_copyPassAction =3D0; +QAction *KWalletEditor::_alwaysShowContentsAction =3D0; +QAction *KWalletEditor::_alwaysHideContentsAction =3D0; = RegisterCreateActionsMethod KWalletEditor::_registerCreateActionMethod(&KW= alletEditor::createActions); = = KWalletEditor::KWalletEditor(QWidget* parent, const char *name) -: _displayedItem(0), _actionCollection(0) { +: _displayedItem(0), _actionCollection(0), _alwaysShowContents(false) { setupUi( this ); setObjectName( QLatin1String( name ) ); _newWallet =3D false; @@ -116,6 +118,7 @@ KWalletEditor::KWalletEditor(QWidget* parent, const cha= r *name) splitterSize.append(_splitter->width()/2); } _splitter->setSizes(splitterSize); + _alwaysShowContents =3D 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* a= ctionCollection) { _deleteEntryAction->setText( i18n( "&Delete" ) ); _deleteEntryAction->setShortcut( Qt::Key_Delete ); _deleteEntryAction->setEnabled(false); + + _alwaysShowContentsAction =3D actionCollection->addAction( QLatin1Stri= ng( "always_show_contents" )); + _alwaysShowContentsAction->setText( i18n("Always show contents") ); + _alwaysShowContentsAction->setCheckable(true); + + _alwaysHideContentsAction =3D actionCollection->addAction( QLatin1Stri= ng( "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(onAlw= aysShowContents(bool))); + + _hideContents->addAction(_alwaysHideContentsAction); + _alwaysHideContentsAction->setChecked(!_alwaysShowContents); + connect(_alwaysHideContentsAction, SIGNAL(triggered(bool)), SLOT(onAlw= aysHideContents(bool))); } = void KWalletEditor::disconnectActions() @@ -297,6 +317,9 @@ void KWalletEditor::disconnectActions() = disconnect(_copyPassAction, SIGNAL(triggered(bool)), this, SLOT(copyPa= ssword())); disconnect(this, SIGNAL(enableWalletActions(bool)), _copyPassAction, S= LOT(setEnabled(bool))); + + disconnect(_alwaysShowContentsAction, SIGNAL(triggered(bool)), this, S= LOT(onAlwaysShowContents(bool))); + disconnect(_alwaysHideContentsAction, SIGNAL(triggered(bool)), this, S= LOT(onAlwaysHideContents(bool))); } = void KWalletEditor::walletClosed() { @@ -528,6 +551,9 @@ void KWalletEditor::entrySelectionChanged(QTreeWidgetIt= em *item) { // add a context-menu action for copying passwords _contextMenu->addSeparator(); _contextMenu->addAction( _copyPassAction ); + if(_alwaysShowContents) { + QTimer::singleShot(0, this, SLOT(showPasswordConte= nts())); + } } else if (ci->entryType() =3D=3D KWallet::Wallet::Map) { _entryStack->setCurrentIndex(2); _mapEditorShowHide->setChecked(false); @@ -1288,5 +1314,19 @@ void KWalletEditor::onSearchTextChanged(const QStrin= g& text) QTimer::singleShot(300, _entryList, SLOT(refreshItemsCount())); } = +void KWalletEditor::onAlwaysShowContents(bool checked) +{ + _alwaysShowContents =3D checked; + _alwaysHideContentsAction->setChecked(!_alwaysShowContents); + showPasswordContents(); +} + +void KWalletEditor::onAlwaysHideContents(bool checked) +{ + _alwaysShowContents =3D !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, *_alwaysHideContentsAct= ion; + 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 @@ - + Hide &Contents + + QToolButton::DelayedPopup + + + Qt::ToolButtonTextOnly + + + Qt::DownArrow + @@ -245,10 +254,16 @@ - + Show &Contents + + Qt::ToolButtonFollowStyle + + + Qt::NoArrow +