Create config file deprecation mechanism & rename Details->Preview (#2371)

Rename UI elements involved with the bottom preview panel to use the
terminology "entry preview panel" instead of "details view" or "preview
panel". Change all associated variables, widgets, and classes to
reference EntryPreviewPanel. Create Config::upgrade() function and
deprecation mapping to help rename/remove previous config settings in a
clean manner.

Fixes #2327
This commit is contained in:
Kyle Kneitinger 2018-10-08 18:11:44 -07:00 committed by Jonathan White
parent 4ff63c2bf5
commit 265325057a
13 changed files with 109 additions and 77 deletions

View File

@ -107,7 +107,7 @@ set(keepassx_SOURCES
gui/DatabaseTabWidget.cpp
gui/DatabaseWidget.cpp
gui/DatabaseWidgetStateSync.cpp
gui/DetailsWidget.cpp
gui/EntryPreviewWidget.cpp
gui/DialogyWidget.cpp
gui/DragTabBar.cpp
gui/EditWidget.cpp

View File

@ -24,6 +24,23 @@
#include <QStandardPaths>
#include <QTemporaryFile>
/*
* Map of configuration file settings that are either deprecated, or have
* had their name changed. Entries in the map are of the form
* {oldName, newName}
* Set newName to empty string to remove the setting from the file.
*/
static const QMap<QString, QString> deprecationMap = {
// >2.3.4
{"security/hidepassworddetails", "security/HidePasswordPreviewPanel"},
// >2.3.4
{"GUI/HideDetailsView", "GUI/HidePreviewPanel"},
// >2.3.4
{"GUI/DetailSplitterState", "GUI/PreviewSplitterState"},
// >2.3.4
{"security/IconDownloadFallbackToGoogle", "security/IconDownloadFallback"},
};
Config* Config::m_instance(nullptr);
QVariant Config::get(const QString& key)
@ -63,6 +80,19 @@ void Config::sync()
m_settings->sync();
}
void Config::upgrade()
{
for (const auto& setting : deprecationMap.keys()) {
if (m_settings->contains(setting)) {
if(!deprecationMap.value(setting).isEmpty()) {
// Add entry with new name and old entry's value
m_settings->setValue(deprecationMap.value(setting), m_settings->value(setting));
}
m_settings->remove(setting);
}
}
}
Config::Config(const QString& fileName, QObject* parent)
: QObject(parent)
{
@ -118,6 +148,7 @@ Config::~Config()
void Config::init(const QString& fileName)
{
m_settings.reset(new QSettings(fileName, QSettings::IniFormat));
upgrade();
connect(qApp, &QCoreApplication::aboutToQuit, this, &Config::sync);
m_defaults.insert("SingleInstance", true);
@ -147,7 +178,7 @@ void Config::init(const QString& fileName)
m_defaults.insert("security/passwordsrepeat", false);
m_defaults.insert("security/passwordscleartext", false);
m_defaults.insert("security/passwordemptynodots", true);
m_defaults.insert("security/hidepassworddetails", true);
m_defaults.insert("security/HidePasswordPreviewPanel", true);
m_defaults.insert("security/autotypeask", true);
m_defaults.insert("security/IconDownloadFallback", false);
m_defaults.insert("security/resettouchid", false);

View File

@ -47,6 +47,7 @@ private:
Config(const QString& fileName, QObject* parent);
explicit Config(QObject* parent);
void init(const QString& fileName);
void upgrade();
static Config* m_instance;

View File

@ -154,7 +154,7 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->languageComboBox->setCurrentIndex(defaultIndex);
}
m_generalUi->detailsHideCheckBox->setChecked(config()->get("GUI/HideDetailsView").toBool());
m_generalUi->previewHideCheckBox->setChecked(config()->get("GUI/HidePreviewPanel").toBool());
m_generalUi->toolbarHideCheckBox->setChecked(config()->get("GUI/HideToolbar").toBool());
m_generalUi->systrayShowCheckBox->setChecked(config()->get("GUI/ShowTrayIcon").toBool());
m_generalUi->systrayDarkIconCheckBox->setChecked(config()->get("GUI/DarkTrayIcon").toBool());
@ -187,7 +187,7 @@ void ApplicationSettingsWidget::loadSettings()
m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool());
m_secUi->passwordShowDotsCheckBox->setChecked(config()->get("security/passwordemptynodots").toBool());
m_secUi->passwordDetailsCleartextCheckBox->setChecked(config()->get("security/hidepassworddetails").toBool());
m_secUi->passwordPreviewCleartextCheckBox->setChecked(config()->get("security/HidePasswordPreviewPanel").toBool());
m_secUi->passwordRepeatCheckBox->setChecked(config()->get("security/passwordsrepeat").toBool());
m_secUi->hideNotesCheckBox->setChecked(config()->get("security/hidenotes").toBool());
@ -230,7 +230,7 @@ void ApplicationSettingsWidget::saveSettings()
config()->set("GUI/Language", m_generalUi->languageComboBox->itemData(currentLangIndex).toString());
config()->set("GUI/HideDetailsView", m_generalUi->detailsHideCheckBox->isChecked());
config()->set("GUI/HidePreviewPanel", m_generalUi->previewHideCheckBox->isChecked());
config()->set("GUI/HideToolbar", m_generalUi->toolbarHideCheckBox->isChecked());
config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked());
config()->set("GUI/DarkTrayIcon", m_generalUi->systrayDarkIconCheckBox->isChecked());
@ -259,7 +259,7 @@ void ApplicationSettingsWidget::saveSettings()
config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked());
config()->set("security/passwordemptynodots", m_secUi->passwordShowDotsCheckBox->isChecked());
config()->set("security/hidepassworddetails", m_secUi->passwordDetailsCleartextCheckBox->isChecked());
config()->set("security/HidePasswordPreviewPanel", m_secUi->passwordPreviewCleartextCheckBox->isChecked());
config()->set("security/passwordsrepeat", m_secUi->passwordRepeatCheckBox->isChecked());
config()->set("security/hidenotes", m_secUi->hideNotesCheckBox->isChecked());

View File

@ -164,9 +164,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="detailsHideCheckBox">
<widget class="QCheckBox" name="previewHideCheckBox">
<property name="text">
<string>Hide the Details view</string>
<string>Hide the entry preview panel</string>
</property>
</widget>
</item>

View File

@ -187,9 +187,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="passwordDetailsCleartextCheckBox">
<widget class="QCheckBox" name="passwordPreviewCleartextCheckBox">
<property name="text">
<string>Hide passwords in the preview panel</string>
<string>Hide passwords in the entry preview panel</string>
</property>
</widget>
</item>

View File

@ -44,7 +44,7 @@
#include "gui/CloneDialog.h"
#include "gui/DatabaseOpenWidget.h"
#include "gui/dbsettings/DatabaseSettingsDialog.h"
#include "gui/DetailsWidget.h"
#include "gui/EntryPreviewWidget.h"
#include "gui/KeePass1OpenWidget.h"
#include "gui/MessageBox.h"
#include "gui/TotpSetupDialog.h"
@ -85,9 +85,9 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
mainLayout->addLayout(layout);
m_mainSplitter = new QSplitter(m_mainWidget);
m_mainSplitter->setChildrenCollapsible(false);
m_detailSplitter = new QSplitter(m_mainWidget);
m_detailSplitter->setOrientation(Qt::Vertical);
m_detailSplitter->setChildrenCollapsible(true);
m_previewSplitter = new QSplitter(m_mainWidget);
m_previewSplitter->setOrientation(Qt::Vertical);
m_previewSplitter->setChildrenCollapsible(true);
QWidget* rightHandSideWidget = new QWidget(m_mainSplitter);
@ -111,27 +111,27 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
"border: 2px solid rgb(190, 190, 190);"
"border-radius: 5px;");
m_detailsView = new DetailsWidget(this);
m_detailsView->hide();
connect(this, SIGNAL(pressedEntry(Entry*)), m_detailsView, SLOT(setEntry(Entry*)));
connect(this, SIGNAL(pressedGroup(Group*)), m_detailsView, SLOT(setGroup(Group*)));
m_previewView = new EntryPreviewWidget(this);
m_previewView->hide();
connect(this, SIGNAL(pressedEntry(Entry*)), m_previewView, SLOT(setEntry(Entry*)));
connect(this, SIGNAL(pressedGroup(Group*)), m_previewView, SLOT(setGroup(Group*)));
connect(this,
SIGNAL(currentModeChanged(DatabaseWidget::Mode)),
m_detailsView,
m_previewView,
SLOT(setDatabaseMode(DatabaseWidget::Mode)));
connect(m_detailsView, SIGNAL(errorOccurred(QString)), this, SLOT(showErrorMessage(QString)));
connect(m_previewView, SIGNAL(errorOccurred(QString)), this, SLOT(showErrorMessage(QString)));
auto* vLayout = new QVBoxLayout(rightHandSideWidget);
vLayout->setMargin(0);
vLayout->addWidget(m_searchingLabel);
vLayout->addWidget(m_detailSplitter);
vLayout->addWidget(m_previewSplitter);
m_detailSplitter->addWidget(m_entryView);
m_detailSplitter->addWidget(m_detailsView);
m_previewSplitter->addWidget(m_entryView);
m_previewSplitter->addWidget(m_previewView);
m_detailSplitter->setStretchFactor(0, 100);
m_detailSplitter->setStretchFactor(1, 0);
m_detailSplitter->setSizes({1, 1});
m_previewSplitter->setStretchFactor(0, 100);
m_previewSplitter->setStretchFactor(1, 0);
m_previewSplitter->setSizes({1, 1});
m_searchingLabel->setVisible(false);
@ -179,7 +179,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
addWidget(m_unlockDatabaseWidget);
connect(m_mainSplitter, SIGNAL(splitterMoved(int, int)), SIGNAL(mainSplitterSizesChanged()));
connect(m_detailSplitter, SIGNAL(splitterMoved(int, int)), SIGNAL(detailSplitterSizesChanged()));
connect(m_previewSplitter, SIGNAL(splitterMoved(int, int)), SIGNAL(previewSplitterSizesChanged()));
connect(m_entryView, SIGNAL(viewStateChanged()), SIGNAL(entryViewStateChanged()));
connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(onGroupChanged(Group*)));
connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
@ -276,14 +276,14 @@ void DatabaseWidget::setMainSplitterSizes(const QList<int>& sizes)
m_mainSplitter->setSizes(sizes);
}
QList<int> DatabaseWidget::detailSplitterSizes() const
QList<int> DatabaseWidget::previewSplitterSizes() const
{
return m_detailSplitter->sizes();
return m_previewSplitter->sizes();
}
void DatabaseWidget::setDetailSplitterSizes(const QList<int>& sizes)
void DatabaseWidget::setPreviewSplitterSizes(const QList<int>& sizes)
{
m_detailSplitter->setSizes(sizes);
m_previewSplitter->setSizes(sizes);
}
/**

View File

@ -46,7 +46,7 @@ class QSplitter;
class QLabel;
class UnlockDatabaseWidget;
class MessageWidget;
class DetailsWidget;
class EntryPreviewWidget;
class UnlockDatabaseDialog;
class QFileSystemWatcher;
@ -90,8 +90,8 @@ public:
bool isEditWidgetModified() const;
QList<int> mainSplitterSizes() const;
void setMainSplitterSizes(const QList<int>& sizes);
QList<int> detailSplitterSizes() const;
void setDetailSplitterSizes(const QList<int>& sizes);
QList<int> previewSplitterSizes() const;
void setPreviewSplitterSizes(const QList<int>& sizes);
bool isUsernamesHidden() const;
void setUsernamesHidden(const bool hide);
bool isPasswordsHidden() const;
@ -130,7 +130,7 @@ signals:
void searchModeAboutToActivate();
void searchModeActivated();
void mainSplitterSizesChanged();
void detailSplitterSizesChanged();
void previewSplitterSizesChanged();
void entryViewStateChanged();
void updateSearch(QString text);
@ -224,7 +224,7 @@ private:
UnlockDatabaseWidget* m_unlockDatabaseWidget;
UnlockDatabaseDialog* m_unlockDatabaseDialog;
QSplitter* m_mainSplitter;
QSplitter* m_detailSplitter;
QSplitter* m_previewSplitter;
GroupView* m_groupView;
EntryView* m_entryView;
QLabel* m_searchingLabel;
@ -235,7 +235,7 @@ private:
QUuid m_groupBeforeLock;
QUuid m_entryBeforeLock;
MessageWidget* m_messageWidget;
DetailsWidget* m_detailsView;
EntryPreviewWidget* m_previewView;
// Search state
QString m_lastSearchText;

View File

@ -28,7 +28,7 @@ DatabaseWidgetStateSync::DatabaseWidgetStateSync(QObject* parent)
, m_blockUpdates(false)
{
m_mainSplitterSizes = variantToIntList(config()->get("GUI/SplitterState"));
m_detailSplitterSizes = variantToIntList(config()->get("GUI/DetailSplitterState"));
m_previewSplitterSizes = variantToIntList(config()->get("GUI/PreviewSplitterState"));
m_hideUsernames = config()->get("GUI/HideUsernames").toBool();
m_hidePasswords = config()->get("GUI/HidePasswords").toBool();
m_listViewState = config()->get("GUI/ListViewState").toByteArray();
@ -47,7 +47,7 @@ DatabaseWidgetStateSync::~DatabaseWidgetStateSync()
void DatabaseWidgetStateSync::sync()
{
config()->set("GUI/SplitterState", intListToVariant(m_mainSplitterSizes));
config()->set("GUI/DetailSplitterState", intListToVariant(m_detailSplitterSizes));
config()->set("GUI/PreviewSplitterState", intListToVariant(m_previewSplitterSizes));
config()->set("GUI/HideUsernames", m_hideUsernames);
config()->set("GUI/HidePasswords", m_hidePasswords);
config()->set("GUI/ListViewState", m_listViewState);
@ -70,8 +70,8 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget)
m_activeDbWidget->setMainSplitterSizes(m_mainSplitterSizes);
}
if (!m_detailSplitterSizes.isEmpty()) {
m_activeDbWidget->setDetailSplitterSizes(m_detailSplitterSizes);
if (!m_previewSplitterSizes.isEmpty()) {
m_activeDbWidget->setPreviewSplitterSizes(m_previewSplitterSizes);
}
if (m_activeDbWidget->isInSearchMode()) {
@ -83,7 +83,7 @@ void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget)
m_blockUpdates = false;
connect(m_activeDbWidget, SIGNAL(mainSplitterSizesChanged()), SLOT(updateSplitterSizes()));
connect(m_activeDbWidget, SIGNAL(detailSplitterSizesChanged()), SLOT(updateSplitterSizes()));
connect(m_activeDbWidget, SIGNAL(previewSplitterSizesChanged()), SLOT(updateSplitterSizes()));
connect(m_activeDbWidget, SIGNAL(entryViewStateChanged()), SLOT(updateViewState()));
connect(m_activeDbWidget, SIGNAL(listModeActivated()), SLOT(restoreListView()));
connect(m_activeDbWidget, SIGNAL(searchModeActivated()), SLOT(restoreSearchView()));
@ -158,7 +158,7 @@ void DatabaseWidgetStateSync::updateSplitterSizes()
}
m_mainSplitterSizes = m_activeDbWidget->mainSplitterSizes();
m_detailSplitterSizes = m_activeDbWidget->detailSplitterSizes();
m_previewSplitterSizes = m_activeDbWidget->previewSplitterSizes();
}
/**

View File

@ -49,7 +49,7 @@ private:
bool m_blockUpdates;
QList<int> m_mainSplitterSizes;
QList<int> m_detailSplitterSizes;
QList<int> m_previewSplitterSizes;
bool m_hideUsernames;
bool m_hidePasswords;

View File

@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DetailsWidget.h"
#include "ui_DetailsWidget.h"
#include "EntryPreviewWidget.h"
#include "ui_EntryPreviewWidget.h"
#include <QDebug>
#include <QDesktopServices>
@ -33,9 +33,9 @@ namespace
constexpr int GeneralTabIndex = 0;
}
DetailsWidget::DetailsWidget(QWidget* parent)
EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::DetailsWidget())
, m_ui(new Ui::EntryPreviewWidget())
, m_locked(false)
, m_currentEntry(nullptr)
, m_currentGroup(nullptr)
@ -62,11 +62,11 @@ DetailsWidget::DetailsWidget(QWidget* parent)
connect(m_ui->groupTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection);
}
DetailsWidget::~DetailsWidget()
EntryPreviewWidget::~EntryPreviewWidget()
{
}
void DetailsWidget::setEntry(Entry* selectedEntry)
void EntryPreviewWidget::setEntry(Entry* selectedEntry)
{
if (!selectedEntry) {
hide();
@ -83,7 +83,7 @@ void DetailsWidget::setEntry(Entry* selectedEntry)
updateEntryAttachmentsTab();
updateEntryAutotypeTab();
setVisible(!config()->get("GUI/HideDetailsView").toBool());
setVisible(!config()->get("GUI/HidePreviewPanel").toBool());
m_ui->stackedWidget->setCurrentWidget(m_ui->pageEntry);
const int tabIndex = m_ui->entryTabWidget->isTabEnabled(m_selectedTabEntry) ? m_selectedTabEntry : GeneralTabIndex;
@ -91,7 +91,7 @@ void DetailsWidget::setEntry(Entry* selectedEntry)
m_ui->entryTabWidget->setCurrentIndex(tabIndex);
}
void DetailsWidget::setGroup(Group* selectedGroup)
void EntryPreviewWidget::setGroup(Group* selectedGroup)
{
if (!selectedGroup) {
hide();
@ -103,7 +103,7 @@ void DetailsWidget::setGroup(Group* selectedGroup)
updateGroupGeneralTab();
updateGroupNotesTab();
setVisible(!config()->get("GUI/HideDetailsView").toBool());
setVisible(!config()->get("GUI/HidePreviewPanel").toBool());
m_ui->stackedWidget->setCurrentWidget(m_ui->pageGroup);
const int tabIndex = m_ui->groupTabWidget->isTabEnabled(m_selectedTabGroup) ? m_selectedTabGroup : GeneralTabIndex;
@ -111,7 +111,7 @@ void DetailsWidget::setGroup(Group* selectedGroup)
m_ui->groupTabWidget->setCurrentIndex(tabIndex);
}
void DetailsWidget::setDatabaseMode(DatabaseWidget::Mode mode)
void EntryPreviewWidget::setDatabaseMode(DatabaseWidget::Mode mode)
{
m_locked = mode == DatabaseWidget::LockedMode;
if (m_locked) {
@ -127,7 +127,7 @@ void DetailsWidget::setDatabaseMode(DatabaseWidget::Mode mode)
}
}
void DetailsWidget::updateEntryHeaderLine()
void EntryPreviewWidget::updateEntryHeaderLine()
{
Q_ASSERT(m_currentEntry);
const QString title = m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->title());
@ -135,7 +135,7 @@ void DetailsWidget::updateEntryHeaderLine()
m_ui->entryIcon->setPixmap(preparePixmap(m_currentEntry->iconPixmap(), 16));
}
void DetailsWidget::updateEntryTotp()
void EntryPreviewWidget::updateEntryTotp()
{
Q_ASSERT(m_currentEntry);
const bool hasTotp = m_currentEntry->hasTotp();
@ -152,12 +152,12 @@ void DetailsWidget::updateEntryTotp()
}
}
void DetailsWidget::updateEntryGeneralTab()
void EntryPreviewWidget::updateEntryGeneralTab()
{
Q_ASSERT(m_currentEntry);
m_ui->entryUsernameLabel->setText(m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->username()));
if (!config()->get("security/hidepassworddetails").toBool()) {
if (!config()->get("security/HidePasswordPreviewPanel").toBool()) {
const QString password = m_currentEntry->resolveMultiplePlaceholders(m_currentEntry->password());
m_ui->entryPasswordLabel->setRawText(password);
m_ui->entryPasswordLabel->setToolTip(password);
@ -183,7 +183,7 @@ void DetailsWidget::updateEntryGeneralTab()
m_ui->entryExpirationLabel->setText(expires);
}
void DetailsWidget::updateEntryNotesTab()
void EntryPreviewWidget::updateEntryNotesTab()
{
Q_ASSERT(m_currentEntry);
const QString notes = m_currentEntry->notes();
@ -191,7 +191,7 @@ void DetailsWidget::updateEntryNotesTab()
m_ui->entryNotesEdit->setText(notes);
}
void DetailsWidget::updateEntryAttributesTab()
void EntryPreviewWidget::updateEntryAttributesTab()
{
Q_ASSERT(m_currentEntry);
m_ui->entryAttributesEdit->clear();
@ -212,7 +212,7 @@ void DetailsWidget::updateEntryAttributesTab()
}
}
void DetailsWidget::updateEntryAttachmentsTab()
void EntryPreviewWidget::updateEntryAttachmentsTab()
{
Q_ASSERT(m_currentEntry);
const bool hasAttachments = !m_currentEntry->attachments()->isEmpty();
@ -220,7 +220,7 @@ void DetailsWidget::updateEntryAttachmentsTab()
m_ui->entryAttachmentsWidget->setEntryAttachments(m_currentEntry->attachments());
}
void DetailsWidget::updateEntryAutotypeTab()
void EntryPreviewWidget::updateEntryAutotypeTab()
{
Q_ASSERT(m_currentEntry);
m_ui->entryAutotypeTree->clear();
@ -237,14 +237,14 @@ void DetailsWidget::updateEntryAutotypeTab()
setTabEnabled(m_ui->entryTabWidget, m_ui->entryAutotypeTab, !items.isEmpty());
}
void DetailsWidget::updateGroupHeaderLine()
void EntryPreviewWidget::updateGroupHeaderLine()
{
Q_ASSERT(m_currentGroup);
m_ui->groupTitleLabel->setRawText(hierarchy(m_currentGroup, {}));
m_ui->groupIcon->setPixmap(preparePixmap(m_currentGroup->iconPixmap(), 32));
}
void DetailsWidget::updateGroupGeneralTab()
void EntryPreviewWidget::updateGroupGeneralTab()
{
Q_ASSERT(m_currentGroup);
const QString searchingText = m_currentGroup->resolveSearchingEnabled() ? tr("Enabled") : tr("Disabled");
@ -259,7 +259,7 @@ void DetailsWidget::updateGroupGeneralTab()
m_ui->groupExpirationLabel->setText(expiresText);
}
void DetailsWidget::updateGroupNotesTab()
void EntryPreviewWidget::updateGroupNotesTab()
{
Q_ASSERT(m_currentGroup);
const QString notes = m_currentGroup->notes();
@ -267,7 +267,7 @@ void DetailsWidget::updateGroupNotesTab()
m_ui->groupNotesEdit->setText(notes);
}
void DetailsWidget::updateTotpLabel()
void EntryPreviewWidget::updateTotpLabel()
{
if (!m_locked && m_currentEntry && m_currentEntry->hasTotp()) {
const QString totpCode = m_currentEntry->totp();
@ -280,20 +280,20 @@ void DetailsWidget::updateTotpLabel()
}
}
void DetailsWidget::updateTabIndexes()
void EntryPreviewWidget::updateTabIndexes()
{
m_selectedTabEntry = m_ui->entryTabWidget->currentIndex();
m_selectedTabGroup = m_ui->groupTabWidget->currentIndex();
}
void DetailsWidget::setTabEnabled(QTabWidget* tabWidget, QWidget* widget, bool enabled)
void EntryPreviewWidget::setTabEnabled(QTabWidget* tabWidget, QWidget* widget, bool enabled)
{
const int tabIndex = tabWidget->indexOf(widget);
Q_ASSERT(tabIndex != -1);
tabWidget->setTabEnabled(tabIndex, enabled);
}
QPixmap DetailsWidget::preparePixmap(const QPixmap& pixmap, int size)
QPixmap EntryPreviewWidget::preparePixmap(const QPixmap& pixmap, int size)
{
if (pixmap.width() > size || pixmap.height() > size) {
return pixmap.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
@ -301,7 +301,7 @@ QPixmap DetailsWidget::preparePixmap(const QPixmap& pixmap, int size)
return pixmap;
}
QString DetailsWidget::hierarchy(const Group* group, const QString& title)
QString EntryPreviewWidget::hierarchy(const Group* group, const QString& title)
{
const QString separator(" / ");
QStringList hierarchy = group->hierarchy();

View File

@ -24,16 +24,16 @@
namespace Ui
{
class DetailsWidget;
class EntryPreviewWidget;
}
class DetailsWidget : public QWidget
class EntryPreviewWidget : public QWidget
{
Q_OBJECT
public:
explicit DetailsWidget(QWidget* parent = nullptr);
~DetailsWidget() override;
explicit EntryPreviewWidget(QWidget* parent = nullptr);
~EntryPreviewWidget() override;
public slots:
void setEntry(Entry* selectedEntry);
@ -65,7 +65,7 @@ private:
static QPixmap preparePixmap(const QPixmap& pixmap, int size);
static QString hierarchy(const Group* group, const QString& title);
const QScopedPointer<Ui::DetailsWidget> m_ui;
const QScopedPointer<Ui::EntryPreviewWidget> m_ui;
bool m_locked;
Entry* m_currentEntry;
Group* m_currentGroup;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DetailsWidget</class>
<widget class="QWidget" name="DetailsWidget">
<class>EntryPreviewWidget</class>
<widget class="QWidget" name="EntryPreviewWidget">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>