Skip to content

Commit

Permalink
Ensure QR code remains square & code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
droidmonkey committed Aug 27, 2018
1 parent 0156e3c commit cdd26c3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/gui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ MainWindow::MainWindow()
m_actionMultiplexer.connect(m_ui->actionEntrySetupTotp, SIGNAL(triggered()), SLOT(setupTotp()));

m_actionMultiplexer.connect(m_ui->actionEntryCopyTotp, SIGNAL(triggered()), SLOT(copyTotp()));
m_actionMultiplexer.connect(m_ui->actionEntryTotpDisplayKey, SIGNAL(triggered()), SLOT(showTotpKeyQrCode()));
m_actionMultiplexer.connect(m_ui->actionEntryTotpQRCode, SIGNAL(triggered()), SLOT(showTotpKeyQrCode()));
m_actionMultiplexer.connect(m_ui->actionEntryCopyTitle, SIGNAL(triggered()), SLOT(copyTitle()));
m_actionMultiplexer.connect(m_ui->actionEntryCopyUsername, SIGNAL(triggered()), SLOT(copyUsername()));
m_actionMultiplexer.connect(m_ui->actionEntryCopyPassword, SIGNAL(triggered()), SLOT(copyPassword()));
Expand Down Expand Up @@ -479,7 +479,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
m_ui->actionEntryTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntryCopyTotp->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntrySetupTotp->setEnabled(singleEntrySelected);
m_ui->actionEntryTotpDisplayKey->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionEntryTotpQRCode->setEnabled(singleEntrySelected && dbWidget->currentEntryHasTotp());
m_ui->actionGroupNew->setEnabled(groupSelected);
m_ui->actionGroupEdit->setEnabled(groupSelected);
m_ui->actionGroupDelete->setEnabled(groupSelected && dbWidget->canDeleteCurrentGroup());
Expand Down
8 changes: 4 additions & 4 deletions src/gui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
</property>
<addaction name="actionEntryCopyTotp"/>
<addaction name="actionEntryTotp"/>
<addaction name="actionEntryTotpDisplayKey"/>
<addaction name="actionEntryTotpQRCode"/>
<addaction name="actionEntrySetupTotp"/>
</widget>
<addaction name="actionEntryCopyUsername"/>
Expand Down Expand Up @@ -584,12 +584,12 @@
</action>
<action name="actionEntryTotp">
<property name="text">
<string>Show TOTP</string>
<string>Show TOTP...</string>
</property>
</action>
<action name="actionEntryTotpDisplayKey">
<action name="actionEntryTotpQRCode">
<property name="text">
<string>Export TOTP settings</string>
<string>Show TOTP QR Code...</string>
</property>
</action>
<action name="actionEntrySetupTotp">
Expand Down
3 changes: 0 additions & 3 deletions src/gui/SquareSvgWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#include "SquareSvgWidget.h"

SquareSvgWidget::SquareSvgWidget() = default;
SquareSvgWidget::~SquareSvgWidget() = default;

bool SquareSvgWidget::hasHeightForWidth() const
{
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/SquareSvgWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#ifndef KEEPASSX_SquareSvgWidget_H
#define KEEPASSX_SquareSvgWidget_H

#include <QSvgWidget>
#include <QtSvg/QSvgWidget>

class SquareSvgWidget : public QSvgWidget
{
public:
SquareSvgWidget();
~SquareSvgWidget();
SquareSvgWidget() = default;
~SquareSvgWidget() override = default;

bool hasHeightForWidth() const override;
int heightForWidth(int width) const override;
Expand Down
25 changes: 6 additions & 19 deletions src/gui/TotpExportSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <QMessageBox>
#include <QPushButton>
#include <QSizePolicy>
//#include <QSvgWidget>
#include <QVBoxLayout>

TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry* entry)
Expand All @@ -44,14 +43,9 @@ TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry
{
m_verticalLayout->addItem(new QSpacerItem(0, 0));

auto horizontalLayout = new QHBoxLayout();
horizontalLayout->addItem(new QSpacerItem(0, 0));
horizontalLayout->addWidget(m_totpSvgWidget);
horizontalLayout->addItem(new QSpacerItem(0, 0));

m_verticalLayout->addItem(horizontalLayout);
m_verticalLayout->addItem(new QSpacerItem(0, 0));

m_verticalLayout->addStretch(0);
m_verticalLayout->addWidget(m_totpSvgWidget);
m_verticalLayout->addStretch(0);
m_verticalLayout->addWidget(m_countDown);
m_verticalLayout->addWidget(m_buttonBox);

Expand Down Expand Up @@ -79,17 +73,10 @@ TotpExportSettingsDialog::TotpExportSettingsDialog(DatabaseWidget* parent, Entry

if (qrc.isValid()) {
QBuffer buffer;
qrc.writeSvg(&buffer, this->logicalDpiX());
qrc.writeSvg(&buffer, logicalDpiX());
m_totpSvgWidget->load(buffer.data());

const int threeInches = this->logicalDpiX() * 3;
const int fourInches = this->logicalDpiX() * 4;
const QSizePolicy sizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);

m_totpSvgWidget->resize(QSize(threeInches, threeInches));
m_totpSvgWidget->setSizePolicy(sizePolicy);
setMinimumSize(QSize(threeInches, fourInches));
setSizePolicy(sizePolicy);
const int minsize = static_cast<int>(logicalDpiX() * 2.5);
m_totpSvgWidget->setMinimumSize(minsize, minsize);
} else {
auto errorBox = new QMessageBox(parent);
errorBox->setAttribute(Qt::WA_DeleteOnClose);
Expand Down

0 comments on commit cdd26c3

Please sign in to comment.