Merge branch 'develop' into feature/yubikey

This commit is contained in:
Janek Bevendorff 2017-03-03 22:04:55 +01:00
commit 5df7b9aa85
No known key found for this signature in database
GPG key ID: CFEC2F6850BFFA53
14 changed files with 1606 additions and 641 deletions

View file

@ -28,10 +28,12 @@
#include "gui/IconModels.h"
#include "gui/MessageBox.h"
#ifdef WITH_XC_HTTP
#include "http/qhttp/qhttpclient.hpp"
#include "http/qhttp/qhttpclientresponse.hpp"
using namespace qhttp::client;
#endif
IconStruct::IconStruct()
: uuid(Uuid())
@ -45,7 +47,11 @@ EditWidgetIcons::EditWidgetIcons(QWidget* parent)
, m_database(nullptr)
, m_defaultIconModel(new DefaultIconModel(this))
, m_customIconModel(new CustomIconModel(this))
#ifdef WITH_XC_HTTP
, m_httpClient(nullptr)
, m_fallbackToGoogle(true)
, m_redirectCount(0)
#endif
{
m_ui->setupUi(this);
@ -138,18 +144,25 @@ void EditWidgetIcons::load(const Uuid& currentUuid, Database* database, const Ic
void EditWidgetIcons::setUrl(const QString& url)
{
#ifdef WITH_XC_HTTP
m_url = url;
m_ui->faviconButton->setVisible(!url.isEmpty());
resetFaviconDownload();
#else
m_ui->faviconButton->setVisible(false);
#endif
}
void EditWidgetIcons::downloadFavicon()
{
#ifdef WITH_XC_HTTP
QUrl url = QUrl(m_url);
url.setPath("/favicon.ico");
fetchFavicon(url);
#endif
}
#ifdef WITH_XC_HTTP
void EditWidgetIcons::fetchFavicon(const QUrl& url)
{
if (nullptr == m_httpClient) {
@ -241,6 +254,7 @@ void EditWidgetIcons::resetFaviconDownload(bool clearRedirect)
m_fallbackToGoogle = true;
m_ui->faviconButton->setDisabled(false);
}
#endif
void EditWidgetIcons::addCustomIcon()
{

View file

@ -22,6 +22,7 @@
#include <QSet>
#include <QUrl>
#include "config-keepassx.h"
#include "core/Global.h"
#include "core/Uuid.h"
#include "gui/MessageWidget.h"
@ -30,11 +31,14 @@ class Database;
class DefaultIconModel;
class CustomIconModel;
#ifdef WITH_XC_HTTP
namespace qhttp {
namespace client {
class QHttpClient;
}
}
#endif
namespace Ui {
class EditWidgetIcons;
}
@ -68,9 +72,11 @@ Q_SIGNALS:
private Q_SLOTS:
void downloadFavicon();
#ifdef WITH_XC_HTTP
void fetchFavicon(const QUrl& url);
void fetchFaviconFromGoogle(const QString& domain);
void resetFaviconDownload(bool clearRedirect = true);
#endif
void addCustomIcon();
void removeCustomIcon();
void updateWidgetsDefaultIcons(bool checked);
@ -83,12 +89,14 @@ private:
Database* m_database;
Uuid m_currentUuid;
QString m_url;
QUrl m_redirectUrl;
bool m_fallbackToGoogle = true;
unsigned short m_redirectCount = 0;
DefaultIconModel* const m_defaultIconModel;
CustomIconModel* const m_customIconModel;
#ifdef WITH_XC_HTTP
QUrl m_redirectUrl;
bool m_fallbackToGoogle;
unsigned short m_redirectCount;
qhttp::client::QHttpClient* m_httpClient;
#endif
Q_DISABLE_COPY(EditWidgetIcons)
};

View file

@ -301,7 +301,7 @@ MainWindow::MainWindow()
connect(m_ui->welcomeWidget, SIGNAL(importKeePass1Database()), SLOT(switchToKeePass1Database()));
connect(m_ui->actionAbout, SIGNAL(triggered()), SLOT(showAboutDialog()));
#ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac(true);
#endif
@ -612,7 +612,7 @@ void MainWindow::closeEvent(QCloseEvent* event)
if (minimizeOnClose && !appExitCalled)
{
event->ignore();
toggleWindow();
hideWindow();
if (config()->get("security/lockdatabaseminimize").toBool()) {
m_ui->tabWidget->lockDatabases();
@ -777,22 +777,27 @@ void MainWindow::trayIconTriggered(QSystemTrayIcon::ActivationReason reason)
}
}
void MainWindow::hideWindow()
{
setWindowState(windowState() | Qt::WindowMinimized);
QTimer::singleShot(0, this, SLOT(hide()));
if (config()->get("security/lockdatabaseminimize").toBool()) {
m_ui->tabWidget->lockDatabases();
}
}
void MainWindow::toggleWindow()
{
if ((QApplication::activeWindow() == this) && isVisible() && !isMinimized()) {
setWindowState(windowState() | Qt::WindowMinimized);
QTimer::singleShot(0, this, SLOT(hide()));
if (config()->get("security/lockdatabaseminimize").toBool()) {
m_ui->tabWidget->lockDatabases();
}
hideWindow();
} else {
ensurePolished();
setWindowState(windowState() & ~Qt::WindowMinimized);
show();
raise();
activateWindow();
#if defined(Q_OS_LINUX) && ! defined(QT_NO_DBUS)
// re-register global D-Bus menu (needed on Ubuntu with Unity)
// see https://github.com/keepassxreboot/keepassxc/issues/271
@ -832,7 +837,7 @@ void MainWindow::repairDatabase()
if (fileName.isEmpty()) {
return;
}
QScopedPointer<QDialog> dialog(new QDialog(this));
DatabaseRepairWidget* dbRepairWidget = new DatabaseRepairWidget(dialog.data());
connect(dbRepairWidget, SIGNAL(success()), dialog.data(), SLOT(accept()));

View file

@ -78,6 +78,7 @@ private Q_SLOTS:
void rememberOpenDatabases(const QString& filePath);
void applySettingsChanges();
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
void hideWindow();
void toggleWindow();
void lockDatabasesAfterInactivity();
void repairDatabase();