Add (not yet functional) SettingsWidget.

This commit is contained in:
Felix Geyer 2012-05-27 11:09:52 +02:00
parent 9fc62a1d81
commit 21a2e9583b
7 changed files with 209 additions and 11 deletions

View File

@ -68,6 +68,7 @@ set(keepassx_SOURCES
gui/KeePass1OpenDialog.cpp
gui/LineEdit.cpp
gui/MainWindow.cpp
gui/SettingsWidget.cpp
gui/entry/EditEntryWidget.cpp
gui/entry/EntryAttachmentsModel.cpp
gui/entry/EntryAttributesModel.cpp
@ -110,6 +111,7 @@ set(keepassx_MOC
gui/KeePass1OpenDialog.h
gui/LineEdit.h
gui/MainWindow.h
gui/SettingsWidget.h
gui/entry/EditEntryWidget.h
gui/entry/EntryAttachmentsModel.h
gui/entry/EntryAttributesModel.h
@ -135,6 +137,7 @@ set(keepassx_FORMS
gui/EditWidgetIcons.ui
gui/MainWindow.ui
gui/SearchWidget.ui
gui/SettingsWidgetSecurity.ui
gui/entry/EditEntryWidgetAdvanced.ui
gui/entry/EditEntryWidgetHistory.ui
gui/entry/EditEntryWidgetMain.ui

View File

@ -52,6 +52,9 @@ MainWindow::MainWindow()
SLOT(updateWindowTitle()));
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
SLOT(updateWindowTitle()));
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState()));
connect(m_ui->settingsWidget, SIGNAL(accepted()), SLOT(switchToDatabases()));
connect(m_ui->settingsWidget, SIGNAL(rejected()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(newDatabase()));
@ -70,7 +73,6 @@ MainWindow::MainWindow()
connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(importKeePass1Database()));
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog()));
connect(m_ui->actionEntryNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(createEntry()));
@ -92,6 +94,10 @@ MainWindow::MainWindow()
connect(m_ui->actionGroupDelete, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(deleteGroup()));
connect(m_ui->actionSettings, SIGNAL(triggered()), SLOT(switchToSettings()));
connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog()));
connect(m_ui->actionSearch, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(toggleSearch()));
}
@ -109,8 +115,9 @@ const QString MainWindow::BaseWindowTitle = "KeePassX";
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
{
if (m_ui->tabWidget->currentIndex() != -1) {
m_ui->actionDatabaseClose->setEnabled(true);
bool inDatabaseTabWidget = (m_ui->stackedWidget->currentIndex() == 0);
if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) {
DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget();
Q_ASSERT(dbWidget);
@ -179,6 +186,10 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionDatabaseClose->setEnabled(false);
}
m_ui->actionDatabaseNew->setEnabled(inDatabaseTabWidget);
m_ui->actionDatabaseOpen->setEnabled(inDatabaseTabWidget);
m_ui->actionImportKeePass1->setEnabled(inDatabaseTabWidget);
}
void MainWindow::updateWindowTitle()
@ -198,6 +209,17 @@ void MainWindow::showAboutDialog()
aboutDialog->show();
}
void MainWindow::switchToDatabases()
{
m_ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::switchToSettings()
{
m_ui->settingsWidget->loadSettings();
m_ui->stackedWidget->setCurrentIndex(1);
}
void MainWindow::closeEvent(QCloseEvent* event) {
if (!m_ui->tabWidget->closeAllDatabases()) {
event->ignore();

View File

@ -45,6 +45,8 @@ private Q_SLOTS:
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
void updateWindowTitle();
void showAboutDialog();
void switchToDatabases();
void switchToSettings();
private:
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);

View File

@ -15,6 +15,13 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageDatabase">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="DatabaseTabWidget" name="tabWidget">
<property name="currentIndex">
@ -30,6 +37,17 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="pageSettings">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="SettingsWidget" name="settingsWidget" native="true"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
@ -81,9 +99,16 @@
<addaction name="actionGroupEdit"/>
<addaction name="actionGroupDelete"/>
</widget>
<widget class="QMenu" name="menuExtras">
<property name="title">
<string>Extras</string>
</property>
<addaction name="actionSettings"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEntries"/>
<addaction name="menuGroups"/>
<addaction name="menuExtras"/>
<addaction name="menuHelp"/>
</widget>
<widget class="QToolBar" name="toolBar">
@ -252,6 +277,11 @@
<string>Copy password to clipboard</string>
</property>
</action>
<action name="actionSettings">
<property name="text">
<string>Settings</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
@ -260,6 +290,12 @@
<header>gui/DatabaseTabWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>SettingsWidget</class>
<extends>QWidget</extends>
<header>gui/SettingsWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -0,0 +1,50 @@
/*
* 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 "SettingsWidget.h"
#include "ui_SettingsWidgetSecurity.h"
#include <QtGui/QLabel>
SettingsWidget::SettingsWidget(QWidget* parent)
: EditWidget(parent)
, m_secWidget(new QWidget())
, m_secUi(new Ui::SettingsWidgetSecurity())
{
headlineLabel()->setText(tr("Application Settings"));
m_secUi->setupUi(m_secWidget);
add(tr("Security"), m_secWidget);
connect(this, SIGNAL(accepted()), SLOT(saveSettings()));
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
}
SettingsWidget::~SettingsWidget()
{
}
void SettingsWidget::loadSettings()
{
setCurrentRow(0);
}
void SettingsWidget::saveSettings()
{
}

44
src/gui/SettingsWidget.h Normal file
View File

@ -0,0 +1,44 @@
/*
* 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_SETTINGSWIDGET_H
#define KEEPASSX_SETTINGSWIDGET_H
#include "gui/EditWidget.h"
namespace Ui {
class SettingsWidgetSecurity;
}
class SettingsWidget : public EditWidget
{
Q_OBJECT
public:
explicit SettingsWidget(QWidget* parent = 0);
~SettingsWidget();
void loadSettings();
private Q_SLOTS:
void saveSettings();
private:
QWidget* const m_secWidget;
const QScopedPointer<Ui::SettingsWidgetSecurity> m_secUi;
};
#endif // KEEPASSX_SETTINGSWIDGET_H

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsWidgetSecurity</class>
<widget class="QWidget" name="SettingsWidgetSecurity">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>374</width>
<height>303</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="clearClipboardCheckBox">
<property name="text">
<string>Clear clipboard after</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="clearClipboardSpinBox">
<property name="suffix">
<string> sec</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>999</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>