From f53768fc84209d6f0d037ae9d4447307042be8cb Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Sun, 27 May 2012 20:06:03 +0200 Subject: [PATCH] Add welcome widget. --- src/CMakeLists.txt | 3 +++ src/gui/MainWindow.cpp | 10 +++++++--- src/gui/MainWindow.ui | 17 +++++++++++++++-- src/gui/WelcomeWidget.cpp | 30 ++++++++++++++++++++++++++++++ src/gui/WelcomeWidget.h | 39 +++++++++++++++++++++++++++++++++++++++ src/gui/WelcomeWidget.ui | 20 ++++++++++++++++++++ 6 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 src/gui/WelcomeWidget.cpp create mode 100644 src/gui/WelcomeWidget.h create mode 100644 src/gui/WelcomeWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6986be561..103e896a7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -69,6 +69,7 @@ set(keepassx_SOURCES gui/LineEdit.cpp gui/MainWindow.cpp gui/SettingsWidget.cpp + gui/WelcomeWidget.cpp gui/entry/EditEntryWidget.cpp gui/entry/EntryAttachmentsModel.cpp gui/entry/EntryAttributesModel.cpp @@ -112,6 +113,7 @@ set(keepassx_MOC gui/LineEdit.h gui/MainWindow.h gui/SettingsWidget.h + gui/WelcomeWidget.h gui/entry/EditEntryWidget.h gui/entry/EntryAttachmentsModel.h gui/entry/EntryAttributesModel.h @@ -138,6 +140,7 @@ set(keepassx_FORMS gui/MainWindow.ui gui/SearchWidget.ui gui/SettingsWidgetSecurity.ui + gui/WelcomeWidget.ui gui/entry/EditEntryWidgetAdvanced.ui gui/entry/EditEntryWidgetHistory.ui gui/entry/EditEntryWidgetMain.ui diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 332d417d7..8316b6ed1 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -80,8 +80,10 @@ MainWindow::MainWindow() connect(m_ui->settingsWidget, SIGNAL(accepted()), 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, SLOT(newDatabase())); + connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), SLOT(switchToDatabases())); connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_ui->tabWidget, SLOT(openDatabase())); connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_ui->tabWidget, @@ -94,6 +96,7 @@ MainWindow::MainWindow() SLOT(changeMasterKey())); connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget, SLOT(changeDatabaseSettings())); + connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), SLOT(switchToDatabases())); connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget, SLOT(importKeePass1Database())); connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close())); @@ -140,6 +143,7 @@ const QString MainWindow::BaseWindowTitle = "KeePassX"; void MainWindow::setMenuActionState(DatabaseWidget::Mode mode) { bool inDatabaseTabWidget = (m_ui->stackedWidget->currentIndex() == 0); + bool inWelcomeWidget = (m_ui->stackedWidget->currentIndex() == 2); if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) { DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget(); @@ -211,9 +215,9 @@ 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); + m_ui->actionDatabaseNew->setEnabled(inDatabaseTabWidget || inWelcomeWidget); + m_ui->actionDatabaseOpen->setEnabled(inDatabaseTabWidget || inWelcomeWidget); + m_ui->actionImportKeePass1->setEnabled(inDatabaseTabWidget || inWelcomeWidget); } void MainWindow::updateWindowTitle() diff --git a/src/gui/MainWindow.ui b/src/gui/MainWindow.ui index 21361072d..c26f003d0 100644 --- a/src/gui/MainWindow.ui +++ b/src/gui/MainWindow.ui @@ -21,7 +21,7 @@ - 0 + 2 @@ -53,6 +53,13 @@ + + + + + + + @@ -63,7 +70,7 @@ 0 0 800 - 21 + 20 @@ -305,6 +312,12 @@
gui/SettingsWidget.h
1 + + WelcomeWidget + QWidget +
gui/WelcomeWidget.h
+ 1 +
diff --git a/src/gui/WelcomeWidget.cpp b/src/gui/WelcomeWidget.cpp new file mode 100644 index 000000000..842546ecc --- /dev/null +++ b/src/gui/WelcomeWidget.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 . + */ + +#include "WelcomeWidget.h" +#include "ui_WelcomeWidget.h" + +WelcomeWidget::WelcomeWidget(QWidget* parent) + : QWidget(parent) + , m_ui(new Ui::WelcomeWidget()) +{ + m_ui->setupUi(this); +} + +WelcomeWidget::~WelcomeWidget() +{ +} diff --git a/src/gui/WelcomeWidget.h b/src/gui/WelcomeWidget.h new file mode 100644 index 000000000..b7daff033 --- /dev/null +++ b/src/gui/WelcomeWidget.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 . + */ + +#ifndef KEEPASSX_WELCOMEWIDGET_H +#define KEEPASSX_WELCOMEWIDGET_H + +#include + +namespace Ui { + class WelcomeWidget; +} + +class WelcomeWidget : public QWidget +{ + Q_OBJECT + +public: + explicit WelcomeWidget(QWidget* parent = 0); + ~WelcomeWidget(); + +private: + const QScopedPointer m_ui; +}; + +#endif // KEEPASSX_WELCOMEWIDGET_H diff --git a/src/gui/WelcomeWidget.ui b/src/gui/WelcomeWidget.ui new file mode 100644 index 000000000..4382e7c77 --- /dev/null +++ b/src/gui/WelcomeWidget.ui @@ -0,0 +1,20 @@ + + + WelcomeWidget + + + + + + Welcome! + + + Qt::AlignCenter + + + + + + + +