-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Choose database for saving or updating entries from KeePassXC-Browser (…
- Loading branch information
1 parent
bb16dc6
commit b8d2d5d
Showing
13 changed files
with
307 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* Copyright (C) 2013 Francois Ferrand | ||
* Copyright (C) 2018 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "BrowserEntrySaveDialog.h" | ||
#include "ui_BrowserEntrySaveDialog.h" | ||
|
||
BrowserEntrySaveDialog::BrowserEntrySaveDialog(QWidget* parent) | ||
: QDialog(parent) | ||
, m_ui(new Ui::BrowserEntrySaveDialog()) | ||
{ | ||
this->setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); | ||
|
||
m_ui->setupUi(this); | ||
connect(m_ui->okButton, SIGNAL(clicked()), this, SLOT(accept())); | ||
connect(m_ui->cancelButton, SIGNAL(clicked()), this, SLOT(reject())); | ||
|
||
m_ui->itemsList->setSelectionMode(QAbstractItemView::SingleSelection); | ||
m_ui->label->setText(QString(tr("You have multiple databases open.\n" | ||
"Please select the correct database for saving credentials."))); | ||
} | ||
|
||
BrowserEntrySaveDialog::~BrowserEntrySaveDialog() | ||
{ | ||
} | ||
|
||
int BrowserEntrySaveDialog::setItems(QList<DatabaseWidget*>& databaseWidgets, DatabaseWidget* currentWidget) const | ||
{ | ||
uint counter = 0; | ||
int activeIndex = -1; | ||
for (const auto dbWidget : databaseWidgets) { | ||
QString databaseName = dbWidget->getDatabaseName(); | ||
QString databaseFileName = dbWidget->getDatabaseFileName(); | ||
|
||
QListWidgetItem* item = new QListWidgetItem(); | ||
item->setData(Qt::UserRole, counter); | ||
|
||
// Show database name (and filename if the name has been set in metadata) | ||
if (databaseName == databaseFileName) { | ||
item->setText(databaseFileName); | ||
} else { | ||
item->setText(QString("%1 (%2)").arg(databaseName, databaseFileName)); | ||
} | ||
|
||
if (currentWidget == dbWidget) { | ||
activeIndex = counter; | ||
} | ||
|
||
m_ui->itemsList->addItem(item); | ||
++counter; | ||
} | ||
|
||
// This must be done after the whole list is filled | ||
if (activeIndex >= 0) { | ||
m_ui->itemsList->item(activeIndex)->setSelected(true); | ||
} | ||
|
||
m_ui->itemsList->selectAll(); | ||
return databaseWidgets.length(); | ||
} | ||
|
||
QList<QListWidgetItem*> BrowserEntrySaveDialog::getSelected() const | ||
{ | ||
return m_ui->itemsList->selectedItems(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (C) 2013 Francois Ferrand | ||
* Copyright (C) 2018 KeePassXC Team <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef BROWSERENTRYSAVEDIALOG_H | ||
#define BROWSERENTRYSAVEDIALOG_H | ||
|
||
#include <QDialog> | ||
#include <QScopedPointer> | ||
#include <QListWidgetItem> | ||
#include "gui/DatabaseTabWidget.h" | ||
|
||
class Entry; | ||
|
||
namespace Ui | ||
{ | ||
class BrowserEntrySaveDialog; | ||
} | ||
|
||
class BrowserEntrySaveDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit BrowserEntrySaveDialog(QWidget* parent = nullptr); | ||
~BrowserEntrySaveDialog() override; | ||
|
||
int setItems(QList<DatabaseWidget*>& databaseWidgets, DatabaseWidget* currentWidget) const; | ||
QList<QListWidgetItem *> getSelected() const; | ||
|
||
private: | ||
QScopedPointer<Ui::BrowserEntrySaveDialog> m_ui; | ||
}; | ||
|
||
#endif // BROWSERENTRYSAVEDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>BrowserEntrySaveDialog</class> | ||
<widget class="QDialog" name="BrowserEntrySaveDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>221</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>KeePassXC-Browser Save Entry</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QListWidget" name="itemsList"/> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="okButton"> | ||
<property name="text"> | ||
<string>Ok</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="cancelButton"> | ||
<property name="text"> | ||
<string>Cancel</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.