Add welcome widget.

This commit is contained in:
Florian Geyer 2012-05-27 20:06:03 +02:00
parent d707fb4760
commit f53768fc84
6 changed files with 114 additions and 5 deletions

View File

@ -69,6 +69,7 @@ set(keepassx_SOURCES
gui/LineEdit.cpp gui/LineEdit.cpp
gui/MainWindow.cpp gui/MainWindow.cpp
gui/SettingsWidget.cpp gui/SettingsWidget.cpp
gui/WelcomeWidget.cpp
gui/entry/EditEntryWidget.cpp gui/entry/EditEntryWidget.cpp
gui/entry/EntryAttachmentsModel.cpp gui/entry/EntryAttachmentsModel.cpp
gui/entry/EntryAttributesModel.cpp gui/entry/EntryAttributesModel.cpp
@ -112,6 +113,7 @@ set(keepassx_MOC
gui/LineEdit.h gui/LineEdit.h
gui/MainWindow.h gui/MainWindow.h
gui/SettingsWidget.h gui/SettingsWidget.h
gui/WelcomeWidget.h
gui/entry/EditEntryWidget.h gui/entry/EditEntryWidget.h
gui/entry/EntryAttachmentsModel.h gui/entry/EntryAttachmentsModel.h
gui/entry/EntryAttributesModel.h gui/entry/EntryAttributesModel.h
@ -138,6 +140,7 @@ set(keepassx_FORMS
gui/MainWindow.ui gui/MainWindow.ui
gui/SearchWidget.ui gui/SearchWidget.ui
gui/SettingsWidgetSecurity.ui gui/SettingsWidgetSecurity.ui
gui/WelcomeWidget.ui
gui/entry/EditEntryWidgetAdvanced.ui gui/entry/EditEntryWidgetAdvanced.ui
gui/entry/EditEntryWidgetHistory.ui gui/entry/EditEntryWidgetHistory.ui
gui/entry/EditEntryWidgetMain.ui gui/entry/EditEntryWidgetMain.ui

View File

@ -80,8 +80,10 @@ MainWindow::MainWindow()
connect(m_ui->settingsWidget, SIGNAL(accepted()), SLOT(switchToDatabases())); connect(m_ui->settingsWidget, SIGNAL(accepted()), SLOT(switchToDatabases()));
connect(m_ui->settingsWidget, SIGNAL(rejected()), SLOT(switchToDatabases())); connect(m_ui->settingsWidget, SIGNAL(rejected()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(newDatabase())); SLOT(newDatabase()));
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(openDatabase())); SLOT(openDatabase()));
connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_ui->tabWidget,
@ -94,6 +96,7 @@ MainWindow::MainWindow()
SLOT(changeMasterKey())); SLOT(changeMasterKey()));
connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(changeDatabaseSettings())); SLOT(changeDatabaseSettings()));
connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(importKeePass1Database())); SLOT(importKeePass1Database()));
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close())); connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
@ -140,6 +143,7 @@ const QString MainWindow::BaseWindowTitle = "KeePassX";
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
{ {
bool inDatabaseTabWidget = (m_ui->stackedWidget->currentIndex() == 0); bool inDatabaseTabWidget = (m_ui->stackedWidget->currentIndex() == 0);
bool inWelcomeWidget = (m_ui->stackedWidget->currentIndex() == 2);
if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) { if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) {
DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget(); DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget();
@ -211,9 +215,9 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionDatabaseClose->setEnabled(false); m_ui->actionDatabaseClose->setEnabled(false);
} }
m_ui->actionDatabaseNew->setEnabled(inDatabaseTabWidget); m_ui->actionDatabaseNew->setEnabled(inDatabaseTabWidget || inWelcomeWidget);
m_ui->actionDatabaseOpen->setEnabled(inDatabaseTabWidget); m_ui->actionDatabaseOpen->setEnabled(inDatabaseTabWidget || inWelcomeWidget);
m_ui->actionImportKeePass1->setEnabled(inDatabaseTabWidget); m_ui->actionImportKeePass1->setEnabled(inDatabaseTabWidget || inWelcomeWidget);
} }
void MainWindow::updateWindowTitle() void MainWindow::updateWindowTitle()

View File

@ -21,7 +21,7 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="pageDatabase"> <widget class="QWidget" name="pageDatabase">
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
@ -53,6 +53,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="pageWelcome">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="WelcomeWidget" name="welcomeWidget" native="true"/>
</item>
</layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -63,7 +70,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>800</width> <width>800</width>
<height>21</height> <height>20</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -305,6 +312,12 @@
<header>gui/SettingsWidget.h</header> <header>gui/SettingsWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>WelcomeWidget</class>
<extends>QWidget</extends>
<header>gui/WelcomeWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

30
src/gui/WelcomeWidget.cpp Normal file
View File

@ -0,0 +1,30 @@
/*
* 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 "WelcomeWidget.h"
#include "ui_WelcomeWidget.h"
WelcomeWidget::WelcomeWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::WelcomeWidget())
{
m_ui->setupUi(this);
}
WelcomeWidget::~WelcomeWidget()
{
}

39
src/gui/WelcomeWidget.h Normal file
View File

@ -0,0 +1,39 @@
/*
* 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_WELCOMEWIDGET_H
#define KEEPASSX_WELCOMEWIDGET_H
#include <QtGui/QWidget>
namespace Ui {
class WelcomeWidget;
}
class WelcomeWidget : public QWidget
{
Q_OBJECT
public:
explicit WelcomeWidget(QWidget* parent = 0);
~WelcomeWidget();
private:
const QScopedPointer<Ui::WelcomeWidget> m_ui;
};
#endif // KEEPASSX_WELCOMEWIDGET_H

20
src/gui/WelcomeWidget.ui Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>WelcomeWidget</class>
<widget class="QWidget" name="WelcomeWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelWelcome">
<property name="text">
<string>Welcome!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>