Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore focus when checking toolbar state #3893

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <QLineEdit>
#include <QProcess>
#include <QSplitter>
#include <QTextEdit>

#include "autotype/AutoType.h"
#include "core/Config.h"
Expand Down Expand Up @@ -638,6 +639,14 @@ void DatabaseWidget::copyUsername()

void DatabaseWidget::copyPassword()
{
// QTextEdit does not properly trap Ctrl+C copy shortcut
// if a text edit has focus pass the copy operation to it
auto textEdit = qobject_cast<QTextEdit*>(focusWidget());
if (textEdit) {
textEdit->copy();
return;
}

auto currentEntry = currentSelectedEntry();
if (currentEntry) {
setClipboardTextAndMinimize(currentEntry->resolveMultiplePlaceholders(currentEntry->password()));
Expand Down Expand Up @@ -1566,11 +1575,6 @@ bool DatabaseWidget::isGroupSelected() const
return m_groupView->currentGroup();
}

bool DatabaseWidget::currentEntryHasFocus()
{
return m_entryView->numberOfSelectedEntries() > 0 && m_entryView->hasFocus();
}

bool DatabaseWidget::currentEntryHasTitle()
{
auto currentEntry = currentSelectedEntry();
Expand Down
1 change: 0 additions & 1 deletion src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ class DatabaseWidget : public QStackedWidget
bool isPasswordsHidden() const;
void setPasswordsHidden(bool hide);
void clearAllWidgets();
bool currentEntryHasFocus();
bool currentEntryHasTitle();
bool currentEntryHasUsername();
bool currentEntryHasPassword();
Expand Down
8 changes: 3 additions & 5 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,8 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)

switch (mode) {
case DatabaseWidget::Mode::ViewMode: {
bool hasFocus = m_contextMenuFocusLock || menuBar()->hasFocus() || m_searchWidget->hasFocus()
|| dbWidget->currentEntryHasFocus();
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1 && hasFocus;
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0 && hasFocus;
bool singleEntrySelected = dbWidget->numberOfSelectedEntries() == 1;
bool entriesSelected = dbWidget->numberOfSelectedEntries() > 0;
bool groupSelected = dbWidget->isGroupSelected();
bool currentGroupHasChildren = dbWidget->currentGroup()->hasChildren();
bool currentGroupHasEntries = !dbWidget->currentGroup()->entries().isEmpty();
Expand Down Expand Up @@ -1192,7 +1190,7 @@ void MainWindow::showEntryContextMenu(const QPoint& globalPos)
bool entrySelected = false;
auto dbWidget = m_ui->tabWidget->currentDatabaseWidget();
if (dbWidget) {
entrySelected = dbWidget->currentEntryHasFocus();
entrySelected = dbWidget->numberOfSelectedEntries() > 0;
}

if (entrySelected) {
Expand Down