Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Welcome screen redesign #292

Merged
merged 2 commits into from
Feb 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ MainWindow::MainWindow()
connect(m_ui->actionPasswordGenerator, SIGNAL(toggled(bool)), SLOT(switchToPasswordGen(bool)));
connect(m_ui->passwordGeneratorWidget, SIGNAL(dialogTerminated()), SLOT(closePasswordGen()));

connect(m_ui->welcomeWidget, SIGNAL(newDatabase()), SLOT(switchToNewDatabase()));
connect(m_ui->welcomeWidget, SIGNAL(openDatabase()), SLOT(switchToOpenDatabase()));
connect(m_ui->welcomeWidget, SIGNAL(openDatabaseFile(QString)), SLOT(switchToDatabaseFile(QString)));
connect(m_ui->welcomeWidget, SIGNAL(importKeePass1Database()), SLOT(switchToKeePass1Database()));

connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog()));

connect(m_ui->tabWidget, SIGNAL(messageGlobal(QString,MessageWidget::MessageType)), this, SLOT(displayGlobalMessage(QString, MessageWidget::MessageType)));
Expand Down Expand Up @@ -537,6 +542,30 @@ void MainWindow::closePasswordGen()
switchToPasswordGen(false);
}

void MainWindow::switchToNewDatabase()
{
m_ui->tabWidget->newDatabase();
switchToDatabases();
}

void MainWindow::switchToOpenDatabase()
{
m_ui->tabWidget->openDatabase();
switchToDatabases();
}

void MainWindow::switchToDatabaseFile(QString file)
{
m_ui->tabWidget->openDatabase(file);
switchToDatabases();
}

void MainWindow::switchToKeePass1Database()
{
m_ui->tabWidget->importKeePass1Database();
switchToDatabases();
}

void MainWindow::databaseStatusChanged(DatabaseWidget *)
{
updateTrayIcon();
Expand Down
4 changes: 4 additions & 0 deletions src/gui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ private Q_SLOTS:
void switchToDatabases();
void switchToSettings();
void switchToPasswordGen(bool enabled);
void switchToNewDatabase();
void switchToOpenDatabase();
void switchToDatabaseFile(QString file);
void switchToKeePass1Database();
void closePasswordGen();
void databaseStatusChanged(DatabaseWidget *dbWidget);
void databaseTabChanged(int tabIndex);
Expand Down
46 changes: 42 additions & 4 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,45 @@
<widget class="QWidget" name="pageWelcome">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="WelcomeWidget" name="welcomeWidget" native="true"/>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="WelcomeWidget" name="welcomeWidget" native="true">
<zorder>horizontalSpacer_2</zorder>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>50</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
Expand Down Expand Up @@ -277,9 +315,9 @@
</property>
</action>
<action name="actionDatabaseMerge">
<property name="text">
<string>Merge from KeePassX database</string>
</property>
<property name="text">
<string>Merge from KeePassX database</string>
</property>
</action>
<action name="actionEntryNew">
<property name="enabled">
Expand Down
38 changes: 38 additions & 0 deletions src/gui/WelcomeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,51 @@
#include "WelcomeWidget.h"
#include "ui_WelcomeWidget.h"

#include "config-keepassx.h"
#include "core/FilePath.h"
#include "core/Config.h"

WelcomeWidget::WelcomeWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::WelcomeWidget())
{
m_ui->setupUi(this);

m_ui->welcomeLabel->setText(m_ui->welcomeLabel->text() + " " + KEEPASSX_VERSION);
QFont welcomeLabelFont = m_ui->welcomeLabel->font();
welcomeLabelFont.setBold(true);
welcomeLabelFont.setPointSize(welcomeLabelFont.pointSize() + 4);
m_ui->welcomeLabel->setFont(welcomeLabelFont);

m_ui->iconLabel->setPixmap(filePath()->applicationIcon().pixmap(64));

m_ui->recentListWidget->clear();
const QStringList lastDatabases = config()->get("LastDatabases", QVariant()).toStringList();
for (const QString& database : lastDatabases) {
QListWidgetItem *itm = new QListWidgetItem;
itm->setText(database);
m_ui->recentListWidget->addItem(itm);
}
bool recent_visibility = (m_ui->recentListWidget->count() > 0);
m_ui->startLabel->setVisible(!recent_visibility);
m_ui->recentListWidget->setVisible(recent_visibility);
m_ui->recentLabel->setVisible(recent_visibility);

connect(m_ui->buttonNewDatabase, SIGNAL(clicked()), SIGNAL(newDatabase()));
connect(m_ui->buttonOpenDatabase, SIGNAL(clicked()), SIGNAL(openDatabase()));
connect(m_ui->buttonImportKeePass1, SIGNAL(clicked()), SIGNAL(importKeePass1Database()));
connect(m_ui->recentListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(openDatabaseFromFile(QListWidgetItem*)));
}

WelcomeWidget::~WelcomeWidget()
{
}

void WelcomeWidget::openDatabaseFromFile(QListWidgetItem* item)
{
if (item->text().isEmpty()) {
return;
}
Q_EMIT openDatabaseFile(item->text());
}
10 changes: 10 additions & 0 deletions src/gui/WelcomeWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define KEEPASSX_WELCOMEWIDGET_H

#include <QWidget>
#include <QListWidgetItem>

namespace Ui {
class WelcomeWidget;
Expand All @@ -32,6 +33,15 @@ class WelcomeWidget : public QWidget
explicit WelcomeWidget(QWidget* parent = nullptr);
~WelcomeWidget();

Q_SIGNALS:
void newDatabase();
void openDatabase();
void openDatabaseFile(QString);
void importKeePass1Database();

private Q_SLOTS:
void openDatabaseFromFile(QListWidgetItem* item);

private:
const QScopedPointer<Ui::WelcomeWidget> m_ui;
};
Expand Down
157 changes: 155 additions & 2 deletions src/gui/WelcomeWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,170 @@
<ui version="4.0">
<class>WelcomeWidget</class>
<widget class="QWidget" name="WelcomeWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>450</width>
<height>401</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>450</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="labelWelcome">
<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>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="iconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="welcomeLabel">
<property name="text">
<string>Welcome to KeePassXC</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="startLabel">
<property name="text">
<string>Welcome!</string>
<string>Start storing your passwords securely in a KeePassXC database</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="buttonNewDatabase">
<property name="text">
<string>Create new database</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonOpenDatabase">
<property name="text">
<string>Open existing database</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="buttonImportKeePass1">
<property name="text">
<string>Import from KeePass 1</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="recentLabel">
<property name="text">
<string>Recent databases</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="recentListWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down