Add an auto-type entry action.

This commit is contained in:
Felix Geyer 2012-07-12 22:35:51 +02:00
parent bc207714da
commit 651c00239a
6 changed files with 49 additions and 1 deletions

View File

@ -391,6 +391,11 @@ void DatabaseTabWidget::copyPassword()
currentDatabaseWidget()->copyPassword(); currentDatabaseWidget()->copyPassword();
} }
void DatabaseTabWidget::performAutoType()
{
currentDatabaseWidget()->performAutoType();
}
void DatabaseTabWidget::createGroup() void DatabaseTabWidget::createGroup()
{ {
currentDatabaseWidget()->createGroup(); currentDatabaseWidget()->createGroup();

View File

@ -73,6 +73,7 @@ public Q_SLOTS:
void deleteEntry(); void deleteEntry();
void copyUsername(); void copyUsername();
void copyPassword(); void copyPassword();
void performAutoType();
void createGroup(); void createGroup();
void editGroup(); void editGroup();
void deleteGroup(); void deleteGroup();

View File

@ -27,6 +27,7 @@
#include <QtGui/QMessageBox> #include <QtGui/QMessageBox>
#include <QtGui/QSplitter> #include <QtGui/QSplitter>
#include "autotype/AutoType.h"
#include "core/DataPath.h" #include "core/DataPath.h"
#include "core/Metadata.h" #include "core/Metadata.h"
#include "core/Tools.h" #include "core/Tools.h"
@ -144,6 +145,15 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
m_actionEntryCopyPassword = m_menuEntry->addAction(tr("Copy password to clipboard"), this, m_actionEntryCopyPassword = m_menuEntry->addAction(tr("Copy password to clipboard"), this,
SLOT(copyPassword()), Qt::CTRL + Qt::Key_C); SLOT(copyPassword()), Qt::CTRL + Qt::Key_C);
m_actionEntryCopyPassword->setEnabled(false); m_actionEntryCopyPassword->setEnabled(false);
m_actionEntryAutoType = m_menuEntry->addAction(tr("Perform Auto-Type"), this,
SLOT(performAutoType()));
if (!QKeySequence::keyBindings(QKeySequence::Paste).isEmpty()) {
m_actionEntryAutoType->setShortcuts(QKeySequence::Paste);
}
else {
m_actionEntryAutoType->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_V));
}
m_actionEntryAutoType->setEnabled(false);
m_actionGroupNew = m_menuGroup->addAction(tr("Add new group"), this, SLOT(createGroup())); m_actionGroupNew = m_menuGroup->addAction(tr("Add new group"), this, SLOT(createGroup()));
m_actionGroupNew->setIcon(dataPath()->icon("actions", "group-new", false)); m_actionGroupNew->setIcon(dataPath()->icon("actions", "group-new", false));
@ -223,6 +233,8 @@ bool DatabaseWidget::actionEnabled(Action action)
return m_actionEntryCopyUsername->isEnabled(); return m_actionEntryCopyUsername->isEnabled();
case EntryCopyPassword: case EntryCopyPassword:
return m_actionEntryCopyPassword->isEnabled(); return m_actionEntryCopyPassword->isEnabled();
case EntryAutoType:
return m_actionEntryAutoType->isEnabled();
default: default:
Q_ASSERT(false); Q_ASSERT(false);
return false; return false;
@ -324,6 +336,17 @@ void DatabaseWidget::copyPassword()
clipboard()->setText(currentEntry->password()); clipboard()->setText(currentEntry->password());
} }
void DatabaseWidget::performAutoType()
{
Entry* currentEntry = m_entryView->currentEntry();
if (!currentEntry) {
Q_ASSERT(false);
return;
}
autoType()->performAutoType(currentEntry, window());
}
void DatabaseWidget::createGroup() void DatabaseWidget::createGroup()
{ {
if (!m_groupView->currentGroup()) { if (!m_groupView->currentGroup()) {
@ -669,6 +692,7 @@ void DatabaseWidget::updateEntryActions()
m_actionEntryDelete->setEnabled(singleEntrySelected); m_actionEntryDelete->setEnabled(singleEntrySelected);
m_actionEntryCopyUsername->setEnabled(singleEntrySelected); m_actionEntryCopyUsername->setEnabled(singleEntrySelected);
m_actionEntryCopyPassword->setEnabled(singleEntrySelected); m_actionEntryCopyPassword->setEnabled(singleEntrySelected);
m_actionEntryAutoType->setEnabled(singleEntrySelected);
} }
void DatabaseWidget::showGroupContextMenu(const QPoint& pos) void DatabaseWidget::showGroupContextMenu(const QPoint& pos)

View File

@ -62,7 +62,8 @@ public:
EntryEditView, EntryEditView,
EntryDelete, EntryDelete,
EntryCopyUsername, EntryCopyUsername,
EntryCopyPassword EntryCopyPassword,
EntryAutoType
}; };
explicit DatabaseWidget(Database* db, QWidget* parent = Q_NULLPTR); explicit DatabaseWidget(Database* db, QWidget* parent = Q_NULLPTR);
@ -88,6 +89,7 @@ public Q_SLOTS:
void deleteEntry(); void deleteEntry();
void copyUsername(); void copyUsername();
void copyPassword(); void copyPassword();
void performAutoType();
void createGroup(); void createGroup();
void deleteGroup(); void deleteGroup();
void switchToEntryEdit(); void switchToEntryEdit();
@ -152,6 +154,7 @@ private:
QAction* m_actionEntryDelete; QAction* m_actionEntryDelete;
QAction* m_actionEntryCopyUsername; QAction* m_actionEntryCopyUsername;
QAction* m_actionEntryCopyPassword; QAction* m_actionEntryCopyPassword;
QAction* m_actionEntryAutoType;
}; };
#endif // KEEPASSX_DATABASEWIDGET_H #endif // KEEPASSX_DATABASEWIDGET_H

View File

@ -45,6 +45,7 @@ MainWindow::MainWindow()
setShortcut(m_ui->actionSearch, QKeySequence::Find, Qt::CTRL + Qt::Key_F); setShortcut(m_ui->actionSearch, QKeySequence::Find, Qt::CTRL + Qt::Key_F);
m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B); m_ui->actionEntryCopyUsername->setShortcut(Qt::CTRL + Qt::Key_B);
m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C); m_ui->actionEntryCopyPassword->setShortcut(Qt::CTRL + Qt::Key_C);
setShortcut(m_ui->actionEntryAutoType, QKeySequence::Paste, Qt::CTRL + Qt::Key_V);
m_ui->actionDatabaseNew->setIcon(dataPath()->icon("actions", "document-new")); m_ui->actionDatabaseNew->setIcon(dataPath()->icon("actions", "document-new"));
m_ui->actionDatabaseOpen->setIcon(dataPath()->icon("actions", "document-open")); m_ui->actionDatabaseOpen->setIcon(dataPath()->icon("actions", "document-open"));
@ -113,6 +114,8 @@ MainWindow::MainWindow()
SLOT(copyUsername())); SLOT(copyUsername()));
connect(m_ui->actionEntryCopyPassword, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionEntryCopyPassword, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(copyPassword())); SLOT(copyPassword()));
connect(m_ui->actionEntryAutoType, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(performAutoType()));
connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionGroupNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(createGroup())); SLOT(createGroup()));
@ -161,6 +164,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryDelete)); m_ui->actionEntryDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryDelete));
m_ui->actionEntryCopyUsername->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyUsername)); m_ui->actionEntryCopyUsername->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyUsername));
m_ui->actionEntryCopyPassword->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyPassword)); m_ui->actionEntryCopyPassword->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryCopyPassword));
m_ui->actionEntryAutoType->setEnabled(dbWidget->actionEnabled(DatabaseWidget::EntryAutoType));
m_ui->actionGroupNew->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupNew)); m_ui->actionGroupNew->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupNew));
m_ui->actionGroupEdit->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupEdit)); m_ui->actionGroupEdit->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupEdit));
m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete)); m_ui->actionGroupDelete->setEnabled(dbWidget->actionEnabled(DatabaseWidget::GroupDelete));
@ -180,6 +184,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryDelete->setEnabled(false); m_ui->actionEntryDelete->setEnabled(false);
m_ui->actionEntryCopyUsername->setEnabled(false); m_ui->actionEntryCopyUsername->setEnabled(false);
m_ui->actionEntryCopyPassword->setEnabled(false); m_ui->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false); m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false); m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false); m_ui->actionGroupDelete->setEnabled(false);
@ -202,6 +207,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryDelete->setEnabled(false); m_ui->actionEntryDelete->setEnabled(false);
m_ui->actionEntryCopyUsername->setEnabled(false); m_ui->actionEntryCopyUsername->setEnabled(false);
m_ui->actionEntryCopyPassword->setEnabled(false); m_ui->actionEntryCopyPassword->setEnabled(false);
m_ui->actionEntryAutoType->setEnabled(false);
m_ui->actionGroupNew->setEnabled(false); m_ui->actionGroupNew->setEnabled(false);
m_ui->actionGroupEdit->setEnabled(false); m_ui->actionGroupEdit->setEnabled(false);
m_ui->actionGroupDelete->setEnabled(false); m_ui->actionGroupDelete->setEnabled(false);

View File

@ -106,6 +106,7 @@
<addaction name="actionEntryDelete"/> <addaction name="actionEntryDelete"/>
<addaction name="actionEntryCopyUsername"/> <addaction name="actionEntryCopyUsername"/>
<addaction name="actionEntryCopyPassword"/> <addaction name="actionEntryCopyPassword"/>
<addaction name="actionEntryAutoType"/>
</widget> </widget>
<widget class="QMenu" name="menuGroups"> <widget class="QMenu" name="menuGroups">
<property name="title"> <property name="title">
@ -304,6 +305,14 @@
<string>Settings</string> <string>Settings</string>
</property> </property>
</action> </action>
<action name="actionEntryAutoType">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Perform Auto-Type</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>