mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 00:39:43 -05:00
Add database settings widget and ability to change transform rounds count.
This commit is contained in:
parent
8acd6f74d8
commit
1fc5f7a69f
@ -51,6 +51,7 @@ set(keepassx_SOURCES
|
||||
format/KeePass2XmlWriter.cpp
|
||||
gui/ChangeMasterKeyWidget.cpp
|
||||
gui/DatabaseOpenDialog.cpp
|
||||
gui/DatabaseSettingsWidget.cpp
|
||||
gui/DatabaseTabWidget.cpp
|
||||
gui/DatabaseWidget.cpp
|
||||
gui/EditEntryWidget.cpp
|
||||
@ -82,6 +83,7 @@ set(keepassx_MOC
|
||||
core/Metadata.h
|
||||
gui/ChangeMasterKeyWidget.h
|
||||
gui/DatabaseOpenDialog.h
|
||||
gui/DatabaseSettingsWidget.h
|
||||
gui/DatabaseTabWidget.h
|
||||
gui/DatabaseWidget.h
|
||||
gui/EditEntryWidget.h
|
||||
@ -102,6 +104,7 @@ set(keepassx_MOC
|
||||
set(keepassx_FORMS
|
||||
gui/ChangeMasterKeyWidget.ui
|
||||
gui/DatabaseOpenDialog.ui
|
||||
gui/DatabaseSettingsWidget.ui
|
||||
gui/EditEntryWidget.ui
|
||||
gui/EditEntryWidgetAdvanced.ui
|
||||
gui/EditEntryWidgetMain.ui
|
||||
|
@ -167,6 +167,7 @@ void Database::setTransformRounds(quint64 rounds)
|
||||
|
||||
void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed, bool updateChangedTime)
|
||||
{
|
||||
m_key = key;
|
||||
m_transformSeed = transformSeed;
|
||||
m_transformedMasterKey = key.transform(transformSeed, transformRounds());
|
||||
m_hasKey = true;
|
||||
@ -181,6 +182,16 @@ void Database::setKey(const CompositeKey& key)
|
||||
setKey(key, Random::randomArray(32));
|
||||
}
|
||||
|
||||
void Database::updateKey(quint64 rounds)
|
||||
{
|
||||
if (m_transformRounds != rounds) {
|
||||
m_transformRounds = rounds;
|
||||
m_transformedMasterKey = m_key.transform(m_transformSeed, transformRounds());
|
||||
m_metadata->setMasterKeyChanged(QDateTime::currentDateTimeUtc());
|
||||
Q_EMIT modified();
|
||||
}
|
||||
}
|
||||
|
||||
bool Database::hasKey()
|
||||
{
|
||||
return m_hasKey;
|
||||
|
@ -81,6 +81,7 @@ public:
|
||||
* Sets the database key and generates a random transform seed.
|
||||
*/
|
||||
void setKey(const CompositeKey& key);
|
||||
void updateKey(quint64 rounds);
|
||||
bool hasKey();
|
||||
void recycleEntry(Entry* entry);
|
||||
|
||||
@ -106,6 +107,8 @@ private:
|
||||
quint64 m_transformRounds;
|
||||
QByteArray m_transformedMasterKey;
|
||||
|
||||
CompositeKey m_key;
|
||||
|
||||
bool m_hasKey;
|
||||
};
|
||||
|
||||
|
56
src/gui/DatabaseSettingsWidget.cpp
Normal file
56
src/gui/DatabaseSettingsWidget.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* 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 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* 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 "DatabaseSettingsWidget.h"
|
||||
#include "ui_DatabaseSettingsWidget.h"
|
||||
|
||||
|
||||
DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::DatabaseSettingsWidget())
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(changeSettings()));
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||
}
|
||||
|
||||
DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
||||
{
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::setForms(int transformRounds)
|
||||
{
|
||||
m_ui->transformRoundsSpinBox->setValue(transformRounds);
|
||||
}
|
||||
|
||||
quint64 DatabaseSettingsWidget::transformRounds()
|
||||
{
|
||||
return m_transformRounds;
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::changeSettings()
|
||||
{
|
||||
m_transformRounds = m_ui->transformRoundsSpinBox->value();
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::reject()
|
||||
{
|
||||
Q_EMIT editFinished(false);
|
||||
}
|
||||
|
56
src/gui/DatabaseSettingsWidget.h
Normal file
56
src/gui/DatabaseSettingsWidget.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* 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 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* 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 KEEPASSX_DATABASESETTINGSWIDGET_H
|
||||
#define KEEPASSX_DATABASESETTINGSWIDGET_H
|
||||
|
||||
#include <QtCore/QScopedPointer>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
class QAbstractButton;
|
||||
|
||||
namespace Ui {
|
||||
class DatabaseSettingsWidget;
|
||||
}
|
||||
|
||||
class DatabaseSettingsWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DatabaseSettingsWidget(QWidget* parent = 0);
|
||||
~DatabaseSettingsWidget();
|
||||
|
||||
void setForms(int transformRounds);
|
||||
quint64 transformRounds();
|
||||
|
||||
Q_SIGNALS:
|
||||
void editFinished(bool accepted);
|
||||
|
||||
private Q_SLOTS:
|
||||
void changeSettings();
|
||||
void reject();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::DatabaseSettingsWidget> m_ui;
|
||||
|
||||
quint64 m_transformRounds;
|
||||
|
||||
Q_DISABLE_COPY(DatabaseSettingsWidget)
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_DATABASESETTINGSWIDGET_H
|
84
src/gui/DatabaseSettingsWidget.ui
Normal file
84
src/gui/DatabaseSettingsWidget.ui
Normal file
@ -0,0 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DatabaseSettingsWidget</class>
|
||||
<widget class="QWidget" name="DatabaseSettingsWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>399</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>1</width>
|
||||
<height>3</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="transformRoundsLabel">
|
||||
<property name="text">
|
||||
<string>Transform rounds:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="transformRoundsSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -258,6 +258,11 @@ void DatabaseTabWidget::changeMasterKey()
|
||||
currentDatabaseWidget()->switchToMasterKeyChange();
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::changeDatabaseSettings()
|
||||
{
|
||||
currentDatabaseWidget()->switchToDatabaseSettings();
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::createEntry()
|
||||
{
|
||||
currentDatabaseWidget()->createEntry();
|
||||
|
@ -58,6 +58,7 @@ public Q_SLOTS:
|
||||
void closeDatabaseFromSender();
|
||||
bool closeAllDatabases();
|
||||
void changeMasterKey();
|
||||
void changeDatabaseSettings();
|
||||
void createEntry();
|
||||
void editEntry();
|
||||
void deleteEntry();
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "core/Metadata.h"
|
||||
#include "core/Tools.h"
|
||||
#include "gui/ChangeMasterKeyWidget.h"
|
||||
#include "gui/DatabaseSettingsWidget.h"
|
||||
#include "gui/EditEntryWidget.h"
|
||||
#include "gui/EditGroupWidget.h"
|
||||
#include "gui/EntryView.h"
|
||||
@ -73,17 +74,19 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
headlineLabelFont.setBold(true);
|
||||
headlineLabelFont.setPointSize(headlineLabelFont.pointSize() + 2);
|
||||
m_changeMasterKeyWidget->headlineLabel()->setFont(headlineLabelFont);
|
||||
|
||||
m_databaseSettingsWidget = new DatabaseSettingsWidget();
|
||||
addWidget(m_mainWidget);
|
||||
addWidget(m_editEntryWidget);
|
||||
addWidget(m_editGroupWidget);
|
||||
addWidget(m_changeMasterKeyWidget);
|
||||
addWidget(m_databaseSettingsWidget);
|
||||
|
||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
|
||||
connect(m_entryView, SIGNAL(entryActivated(Entry*)), SLOT(switchToEntryEdit(Entry*)));
|
||||
connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
|
||||
connect(m_editGroupWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
|
||||
connect(m_changeMasterKeyWidget, SIGNAL(editFinished(bool)), SLOT(updateMasterKey(bool)));
|
||||
connect(m_databaseSettingsWidget, SIGNAL(editFinished(bool)), SLOT(updateSettings(bool)));
|
||||
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
@ -191,6 +194,15 @@ void DatabaseWidget::updateMasterKey(bool accepted)
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void DatabaseWidget::updateSettings(bool accepted)
|
||||
{
|
||||
if (accepted) {
|
||||
m_db->updateKey(m_databaseSettingsWidget->transformRounds());
|
||||
}
|
||||
|
||||
setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void DatabaseWidget::switchToEntryEdit()
|
||||
{
|
||||
switchToEntryEdit(m_entryView->currentEntry(), false);
|
||||
@ -207,6 +219,12 @@ void DatabaseWidget::switchToMasterKeyChange()
|
||||
setCurrentIndex(3);
|
||||
}
|
||||
|
||||
void DatabaseWidget::switchToDatabaseSettings()
|
||||
{
|
||||
m_databaseSettingsWidget->setForms(m_db->transformRounds());
|
||||
setCurrentIndex(4);
|
||||
}
|
||||
|
||||
bool DatabaseWidget::dbHasKey()
|
||||
{
|
||||
return m_db->hasKey();
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <QtGui/QStackedWidget>
|
||||
|
||||
class ChangeMasterKeyWidget;
|
||||
class DatabaseSettingsWidget;
|
||||
class Database;
|
||||
class EditEntryWidget;
|
||||
class EditGroupWidget;
|
||||
@ -49,6 +50,7 @@ public Q_SLOTS:
|
||||
void switchToEntryEdit();
|
||||
void switchToGroupEdit();
|
||||
void switchToMasterKeyChange();
|
||||
void switchToDatabaseSettings();
|
||||
|
||||
private Q_SLOTS:
|
||||
void switchToView(bool accepted);
|
||||
@ -56,6 +58,7 @@ private Q_SLOTS:
|
||||
void switchToEntryEdit(Entry* entry, bool create);
|
||||
void switchToGroupEdit(Group* entry, bool create);
|
||||
void updateMasterKey(bool accepted);
|
||||
void updateSettings(bool accepted);
|
||||
|
||||
private:
|
||||
Database* m_db;
|
||||
@ -63,6 +66,7 @@ private:
|
||||
EditEntryWidget* m_editEntryWidget;
|
||||
EditGroupWidget* m_editGroupWidget;
|
||||
ChangeMasterKeyWidget* m_changeMasterKeyWidget;
|
||||
DatabaseSettingsWidget* m_databaseSettingsWidget;
|
||||
GroupView* m_groupView;
|
||||
EntryView* m_entryView;
|
||||
Group* m_newGroup;
|
||||
|
@ -42,6 +42,7 @@ MainWindow::MainWindow()
|
||||
connect(m_ui->actionDatabaseSaveAs, SIGNAL(triggered()), m_ui->tabWidget, SLOT(saveDatabaseAs()));
|
||||
connect(m_ui->actionDatabaseClose, SIGNAL(triggered()), m_ui->tabWidget, SLOT(closeDatabase()));
|
||||
connect(m_ui->actionChangeMasterKey, SIGNAL(triggered()), m_ui->tabWidget, SLOT(changeMasterKey()));
|
||||
connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget, SLOT(changeDatabaseSettings()));
|
||||
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_ui->tabWidget, SLOT(createEntry()));
|
||||
connect(m_ui->actionEntryEdit, SIGNAL(triggered()), m_ui->tabWidget, SLOT(editEntry()));
|
||||
connect(m_ui->actionEntryDelete, SIGNAL(triggered()), m_ui->tabWidget, SLOT(deleteEntry()));
|
||||
@ -88,12 +89,14 @@ void MainWindow::setMenuActionState(int index)
|
||||
}
|
||||
*/
|
||||
m_ui->actionChangeMasterKey->setEnabled(true);
|
||||
m_ui->actionChangeDatabaseSettings->setEnabled(true);
|
||||
m_ui->actionDatabaseSave->setEnabled(true);
|
||||
m_ui->actionDatabaseSaveAs->setEnabled(true);
|
||||
break;
|
||||
case 1: // entry edit
|
||||
case 2: // group edit
|
||||
case 3: // change master key
|
||||
case 4: // database settings
|
||||
m_ui->actionEntryNew->setEnabled(false);
|
||||
m_ui->actionGroupNew->setEnabled(false);
|
||||
m_ui->actionEntryEdit->setEnabled(false);
|
||||
@ -101,6 +104,7 @@ void MainWindow::setMenuActionState(int index)
|
||||
m_ui->actionEntryDelete->setEnabled(false);
|
||||
m_ui->actiocGroupDelete->setEnabled(false);
|
||||
m_ui->actionChangeMasterKey->setEnabled(false);
|
||||
m_ui->actionChangeDatabaseSettings->setEnabled(false);
|
||||
m_ui->actionDatabaseSave->setEnabled(false);
|
||||
m_ui->actionDatabaseSaveAs->setEnabled(false);
|
||||
break;
|
||||
@ -117,6 +121,7 @@ void MainWindow::setMenuActionState(int index)
|
||||
m_ui->actionEntryDelete->setEnabled(false);
|
||||
m_ui->actiocGroupDelete->setEnabled(false);
|
||||
m_ui->actionChangeMasterKey->setEnabled(false);
|
||||
m_ui->actionChangeDatabaseSettings->setEnabled(false);
|
||||
m_ui->actionDatabaseSave->setEnabled(false);
|
||||
m_ui->actionDatabaseSaveAs->setEnabled(false);
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
<addaction name="actionDatabaseClose"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionChangeMasterKey"/>
|
||||
<addaction name="actionChangeDatabaseSettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
@ -198,6 +199,17 @@
|
||||
<string>Change master key</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeDatabaseSettings">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Database settings</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Database settings</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user