diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ca9be92af..0c539b50d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -70,6 +70,7 @@ set(keepassx_SOURCES
format/KeePass2XmlWriter.cpp
gui/AboutDialog.cpp
gui/Application.cpp
+ gui/CategoryListWidget.cpp
gui/ChangeMasterKeyWidget.cpp
gui/Clipboard.cpp
gui/DatabaseOpenWidget.cpp
@@ -132,6 +133,7 @@ set(keepassx_FORMS
gui/ChangeMasterKeyWidget.ui
gui/DatabaseOpenWidget.ui
gui/DatabaseSettingsWidget.ui
+ gui/CategoryListWidget.ui
gui/EditWidget.ui
gui/EditWidgetIcons.ui
gui/EditWidgetProperties.ui
diff --git a/src/gui/CategoryListWidget.cpp b/src/gui/CategoryListWidget.cpp
new file mode 100644
index 000000000..758709c0b
--- /dev/null
+++ b/src/gui/CategoryListWidget.cpp
@@ -0,0 +1,173 @@
+/*
+ * Copyright (C) 2017 KeePassXC Team
+ *
+ * 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 "CategoryListWidget.h"
+#include "ui_CategoryListWidget.h"
+
+#include
+#include
+#include
+#include
+#include
+
+CategoryListWidget::CategoryListWidget(QWidget* parent)
+ : QWidget(parent),
+ m_ui(new Ui::CategoryListWidget())
+{
+ m_ui->setupUi(this);
+ m_ui->categoryList->setItemDelegate(new CategoryListWidgetDelegate(this));
+
+ connect(m_ui->categoryList, SIGNAL(currentRowChanged(int)), SLOT(emitCategoryChanged(int)));
+
+ connect(m_ui->scrollUp, SIGNAL(clicked()), SLOT(scrollCategoriesUp()));
+ connect(m_ui->scrollDown, SIGNAL(clicked()), SLOT(scrollCategoriesDown()));
+ connect(m_ui->categoryList->verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(updateCategoryScrollButtons()));
+ connect(m_ui->categoryList->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), SLOT(updateCategoryScrollButtons()));
+}
+
+CategoryListWidget::~CategoryListWidget()
+{
+}
+
+QSize CategoryListWidget::sizeHint() const
+{
+ QSize sizeHint = QWidget::sizeHint();
+
+ int width = m_ui->categoryList->sizeHintForColumn(0) + m_ui->categoryList->frameWidth() * 2;
+ if (m_ui->categoryList->verticalScrollBar()->isVisible()) {
+ width += m_ui->categoryList->verticalScrollBar()->width();
+ }
+ sizeHint.setWidth(width);
+
+ return sizeHint;
+}
+
+QSize CategoryListWidget::minimumSizeHint() const
+{
+ return QSize(sizeHint().width(), m_ui->categoryList->sizeHintForRow(0) * 2);
+}
+
+int CategoryListWidget::addCategory(const QString& labelText, const QIcon& icon)
+{
+ QListWidgetItem* item = new QListWidgetItem(m_ui->categoryList);
+ item->setText(labelText);
+ item->setIcon(icon);
+ m_ui->categoryList->addItem(item);
+ return m_ui->categoryList->count() - 1;
+}
+
+void CategoryListWidget::removeCategory(int index)
+{
+ m_ui->categoryList->removeItemWidget(m_ui->categoryList->item(index));
+}
+
+int CategoryListWidget::currentCategory()
+{
+ return m_ui->categoryList->currentRow();
+}
+
+void CategoryListWidget::setCurrentCategory(int index)
+{
+ m_ui->categoryList->setCurrentRow(index);
+}
+
+void CategoryListWidget::setCategoryHidden(int index, bool hidden)
+{
+ m_ui->categoryList->item(index)->setHidden(hidden);
+}
+
+bool CategoryListWidget::isCategoryHidden(int index)
+{
+ return m_ui->categoryList->item(index)->isHidden();
+}
+
+void CategoryListWidget::showEvent(QShowEvent* event)
+{
+ QWidget::showEvent(event);
+ updateCategoryScrollButtons();
+}
+
+void CategoryListWidget::updateCategoryScrollButtons()
+{
+ m_ui->scrollUp->setEnabled(m_ui->categoryList->verticalScrollBar()->value() != 0);
+ m_ui->scrollDown->setEnabled(m_ui->categoryList->verticalScrollBar()->value()
+ != m_ui->categoryList->verticalScrollBar()->maximum());
+
+ m_ui->scrollUp->setVisible(m_ui->categoryList->verticalScrollBar()->maximum() > 0);
+ m_ui->scrollDown->setVisible(m_ui->scrollUp->isVisible());
+}
+
+void CategoryListWidget::scrollCategoriesUp()
+{
+ m_ui->categoryList->verticalScrollBar()->setValue(
+ m_ui->categoryList->verticalScrollBar()->value() - m_ui->categoryList->verticalScrollBar()->pageStep()
+ );
+}
+
+void CategoryListWidget::scrollCategoriesDown()
+{
+ m_ui->categoryList->verticalScrollBar()->setValue(
+ m_ui->categoryList->verticalScrollBar()->value() + m_ui->categoryList->verticalScrollBar()->pageStep()
+ );
+}
+
+void CategoryListWidget::emitCategoryChanged(int index)
+{
+ emit categoryChanged(index);
+}
+
+
+/* =============================================================================================== */
+
+
+CategoryListWidgetDelegate::CategoryListWidgetDelegate(QWidget* parent)
+ : QStyledItemDelegate(parent),
+ m_size(96, 96)
+{}
+
+void CategoryListWidgetDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
+{
+ QStyleOptionViewItem opt = option;
+ initStyleOption(&opt, index);
+
+ painter->save();
+
+ QIcon icon = opt.icon;
+ QSize iconSize = opt.icon.actualSize(QSize(32, 32));
+ opt.icon = QIcon();
+ opt.decorationAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
+ opt.decorationPosition = QStyleOptionViewItem::Top;
+
+ QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
+ style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
+
+ QRect fontRect = painter->fontMetrics().boundingRect(
+ QRect(0, 0, m_size.width(), m_size.height()), Qt::AlignHCenter | Qt::AlignBottom | Qt::TextWordWrap, opt.text);
+
+ int paddingTop = fontRect.height() < 30 ? 15 : 10;
+ int left = opt.rect.left() + opt.rect.width() / 2 - iconSize.width() / 2;
+ painter->drawPixmap(left, opt.rect.top() + paddingTop, icon.pixmap(iconSize));
+
+ painter->restore();
+}
+
+QSize CategoryListWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ Q_UNUSED(option);
+ Q_UNUSED(index);
+ return m_size;
+}
diff --git a/src/gui/CategoryListWidget.h b/src/gui/CategoryListWidget.h
new file mode 100644
index 000000000..de910fdf3
--- /dev/null
+++ b/src/gui/CategoryListWidget.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2017 KeePassXC Team
+ *
+ * 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
+#include
+
+namespace Ui {
+ class CategoryListWidget;
+}
+
+class CategoryListWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ CategoryListWidget(QWidget* parent = 0);
+ ~CategoryListWidget();
+
+ int currentCategory();
+ void setCurrentCategory(int index);
+ int addCategory(const QString& labelText, const QIcon& icon);
+ void setCategoryHidden(int index, bool hidden);
+ bool isCategoryHidden(int index);
+ void removeCategory(int index);
+
+signals:
+ void categoryChanged(int index);
+
+protected:
+ void showEvent(QShowEvent* event) override;
+ QSize sizeHint() const override;
+ QSize minimumSizeHint() const override;
+
+protected slots:
+ void updateCategoryScrollButtons();
+ void scrollCategoriesDown();
+ void scrollCategoriesUp();
+ void emitCategoryChanged(int index);
+
+private:
+ const QScopedPointer m_ui;
+
+ Q_DISABLE_COPY(CategoryListWidget)
+};
+
+
+/* =============================================================================================== */
+
+
+class CategoryListWidgetDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ explicit CategoryListWidgetDelegate(QWidget* parent = nullptr);
+
+protected:
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
+ QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
+
+private:
+ QSize m_size;
+
+ Q_DISABLE_COPY(CategoryListWidgetDelegate)
+};
diff --git a/src/gui/CategoryListWidget.ui b/src/gui/CategoryListWidget.ui
new file mode 100644
index 000000000..307a039b6
--- /dev/null
+++ b/src/gui/CategoryListWidget.ui
@@ -0,0 +1,116 @@
+
+
+ CategoryListWidget
+
+
+
+ 0
+ 0
+ 182
+ 418
+
+
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
+ 0
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 15
+
+
+
+
+
+
+ Qt::UpArrow
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ Qt::ScrollBarAlwaysOff
+
+
+ QListView::Static
+
+
+ QListView::TopToBottom
+
+
+ false
+
+
+ QListView::IconMode
+
+
+ true
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 15
+
+
+
+
+
+
+ Qt::DownArrow
+
+
+
+
+
+
+ categoryList
+ scrollUp
+ scrollDown
+
+
+
+
diff --git a/src/gui/EditWidget.cpp b/src/gui/EditWidget.cpp
index 157848eb9..24cc64fec 100644
--- a/src/gui/EditWidget.cpp
+++ b/src/gui/EditWidget.cpp
@@ -34,41 +34,43 @@ EditWidget::EditWidget(QWidget* parent)
headerLabelFont.setPointSize(headerLabelFont.pointSize() + 2);
headlineLabel()->setFont(headerLabelFont);
- connect(m_ui->categoryList, SIGNAL(currentRowChanged(int)),
+ connect(m_ui->categoryList, SIGNAL(categoryChanged(int)),
m_ui->stackedWidget, SLOT(setCurrentIndex(int)));
connect(m_ui->buttonBox, SIGNAL(accepted()), SIGNAL(accepted()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SIGNAL(rejected()));
-
- connect(m_ui->scrollUp, SIGNAL(clicked()), SLOT(scrollCategoriesUp()));
- connect(m_ui->scrollDown, SIGNAL(clicked()), SLOT(scrollCategoriesDown()));
- connect(m_ui->categoryList->verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(updateCategoryScrollButtons()));
- connect(m_ui->categoryList->verticalScrollBar(), SIGNAL(rangeChanged(int, int)), SLOT(updateCategoryScrollButtons()));
}
EditWidget::~EditWidget()
{
}
-void EditWidget::add(const QString& labelText, QWidget* widget)
+void EditWidget::addPage(const QString& labelText, const QIcon& icon, QWidget* widget)
{
- m_ui->categoryList->addItem(labelText);
- QListWidgetItem* item = m_ui->categoryList->item(m_ui->categoryList->count() - 1);
- item->setIcon(FilePath::instance()->icon("apps", "keepassxc"));
m_ui->stackedWidget->addWidget(widget);
+ m_ui->categoryList->addCategory(labelText, icon);
}
-void EditWidget::setRowHidden(QWidget* widget, bool hide)
+void EditWidget::setPageHidden(QWidget* widget, bool hidden)
{
- int row = m_ui->stackedWidget->indexOf(widget);
- if (row != -1) {
- m_ui->categoryList->item(row)->setHidden(hide);
+ int index = m_ui->stackedWidget->indexOf(widget);
+ if (index != -1) {
+ m_ui->categoryList->setCategoryHidden(index, hidden);
+ }
+
+ if (index == m_ui->stackedWidget->currentIndex()) {
+ int newIndex = m_ui->stackedWidget->currentIndex() - 1;
+ if (newIndex < 0) {
+ newIndex = m_ui->stackedWidget->count() - 1;
+ }
+ m_ui->stackedWidget->setCurrentIndex(newIndex);
}
}
-void EditWidget::setCurrentRow(int index)
+void EditWidget::setCurrentPage(int index)
{
- m_ui->categoryList->setCurrentRow(index);
+ m_ui->categoryList->setCurrentCategory(index);
+ m_ui->stackedWidget->setCurrentIndex(index);
}
void EditWidget::setHeadline(const QString& text)
@@ -109,33 +111,3 @@ void EditWidget::hideMessage()
m_ui->messageWidget->animatedHide();
}
}
-
-void EditWidget::updateCategoryScrollButtons()
-{
- m_ui->scrollUp->setEnabled(m_ui->categoryList->verticalScrollBar()->value() != 0);
- m_ui->scrollDown->setEnabled(m_ui->categoryList->verticalScrollBar()->value()
- != m_ui->categoryList->verticalScrollBar()->maximum());
-
- m_ui->scrollUp->setVisible(m_ui->categoryList->verticalScrollBar()->maximum() > 0);
- m_ui->scrollDown->setVisible(m_ui->scrollUp->isVisible());
-}
-
-void EditWidget::showEvent(QShowEvent* event)
-{
- QWidget::showEvent(event);
- updateCategoryScrollButtons();
-}
-
-void EditWidget::scrollCategoriesUp()
-{
- m_ui->categoryList->verticalScrollBar()->setValue(
- m_ui->categoryList->verticalScrollBar()->value() - m_ui->categoryList->verticalScrollBar()->pageStep()
- );
-}
-
-void EditWidget::scrollCategoriesDown()
-{
- m_ui->categoryList->verticalScrollBar()->setValue(
- m_ui->categoryList->verticalScrollBar()->value() + m_ui->categoryList->verticalScrollBar()->pageStep()
- );
-}
diff --git a/src/gui/EditWidget.h b/src/gui/EditWidget.h
index 398a04600..46951de41 100644
--- a/src/gui/EditWidget.h
+++ b/src/gui/EditWidget.h
@@ -39,25 +39,19 @@ public:
explicit EditWidget(QWidget* parent = nullptr);
~EditWidget();
- void add(const QString& labelText, QWidget* widget);
- void setRowHidden(QWidget* widget, bool hide);
- void setCurrentRow(int index);
+ void addPage(const QString& labelText, const QIcon& icon, QWidget* widget);
+ void setPageHidden(QWidget* widget, bool hidden);
+ void setCurrentPage(int index);
void setHeadline(const QString& text);
QLabel* headlineLabel();
void setReadOnly(bool readOnly);
bool readOnly() const;
-protected:
- void showEvent(QShowEvent* event) override;
-
signals:
void accepted();
void rejected();
protected slots:
- void updateCategoryScrollButtons();
- void scrollCategoriesDown();
- void scrollCategoriesUp();
void showMessage(const QString& text, MessageWidget::MessageType type);
void hideMessage();
diff --git a/src/gui/EditWidget.ui b/src/gui/EditWidget.ui
index 7ab9b143f..239c3d9f8 100644
--- a/src/gui/EditWidget.ui
+++ b/src/gui/EditWidget.ui
@@ -40,58 +40,7 @@
-
-
-
-
- 0
-
-
-
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 15
-
-
-
-
-
-
- Qt::UpArrow
-
-
-
- -
-
-
- -
-
-
-
- 0
- 0
-
-
-
-
- 16777215
- 15
-
-
-
-
-
-
- Qt::DownArrow
-
-
-
-
+
-
@@ -128,14 +77,9 @@
CategoryListWidget
QListWidget
- gui/entry/EditEntryWidget_p.h
+
-
- categoryList
- scrollUp
- scrollDown
-
diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp
index 5696ff121..ef153c123 100644
--- a/src/gui/SettingsWidget.cpp
+++ b/src/gui/SettingsWidget.cpp
@@ -22,6 +22,7 @@
#include "autotype/AutoType.h"
#include "core/Config.h"
#include "core/Translator.h"
+#include "core/FilePath.h"
class SettingsWidget::ExtraPage
{
@@ -57,8 +58,8 @@ SettingsWidget::SettingsWidget(QWidget* parent)
m_secUi->setupUi(m_secWidget);
m_generalUi->setupUi(m_generalWidget);
- add(tr("General"), m_generalWidget);
- add(tr("Security"), m_secWidget);
+ addPage(tr("General"), FilePath::instance()->icon("apps", "keepassxc"), m_generalWidget);
+ addPage(tr("Security"), FilePath::instance()->icon("apps", "keepassxc"), m_secWidget);
m_generalUi->autoTypeShortcutWidget->setVisible(autoType()->isAvailable());
m_generalUi->autoTypeShortcutLabel->setVisible(autoType()->isAvailable());
@@ -92,7 +93,7 @@ void SettingsWidget::addSettingsPage(ISettingsPage *page)
QWidget * widget = page->createWidget();
widget->setParent(this);
m_extraPages.append(ExtraPage(page, widget));
- add(page->name(), widget);
+ addPage(page->name(), FilePath::instance()->icon("apps", "keepassxc"), widget);
}
void SettingsWidget::loadSettings()
@@ -146,7 +147,7 @@ void SettingsWidget::loadSettings()
Q_FOREACH (const ExtraPage& page, m_extraPages)
page.loadSettings();
- setCurrentRow(0);
+ setCurrentPage(0);
}
void SettingsWidget::saveSettings()
diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp
index 4acfd8765..ff75540af 100644
--- a/src/gui/entry/EditEntryWidget.cpp
+++ b/src/gui/entry/EditEntryWidget.cpp
@@ -90,7 +90,7 @@ EditEntryWidget::~EditEntryWidget()
void EditEntryWidget::setupMain()
{
m_mainUi->setupUi(m_mainWidget);
- add(tr("Entry"), m_mainWidget);
+ addPage(tr("Entry"), FilePath::instance()->icon("apps", "keepassxc"), m_mainWidget);
m_mainUi->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_mainUi->togglePasswordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator", false));
@@ -115,7 +115,7 @@ void EditEntryWidget::setupMain()
void EditEntryWidget::setupAdvanced()
{
m_advancedUi->setupUi(m_advancedWidget);
- add(tr("Advanced"), m_advancedWidget);
+ addPage(tr("Advanced"), FilePath::instance()->icon("apps", "keepassxc"), m_advancedWidget);
m_attachmentsModel->setEntryAttachments(m_entryAttachments);
m_advancedUi->attachmentsView->setModel(m_attachmentsModel);
@@ -139,13 +139,13 @@ void EditEntryWidget::setupAdvanced()
void EditEntryWidget::setupIcon()
{
- add(tr("Icon"), m_iconsWidget);
+ addPage(tr("Icon"), FilePath::instance()->icon("apps", "keepassxc"), m_iconsWidget);
}
void EditEntryWidget::setupAutoType()
{
m_autoTypeUi->setupUi(m_autoTypeWidget);
- add(tr("Auto-Type"), m_autoTypeWidget);
+ addPage(tr("Auto-Type"), FilePath::instance()->icon("apps", "keepassxc"), m_autoTypeWidget);
m_autoTypeDefaultSequenceGroup->addButton(m_autoTypeUi->inheritSequenceButton);
m_autoTypeDefaultSequenceGroup->addButton(m_autoTypeUi->customSequenceButton);
@@ -177,13 +177,13 @@ void EditEntryWidget::setupAutoType()
void EditEntryWidget::setupProperties()
{
- add(tr("Properties"), m_editWidgetProperties);
+ addPage(tr("Properties"), FilePath::instance()->icon("apps", "keepassxc"), m_editWidgetProperties);
}
void EditEntryWidget::setupHistory()
{
m_historyUi->setupUi(m_historyWidget);
- add(tr("History"), m_historyWidget);
+ addPage(tr("History"), FilePath::instance()->icon("apps", "keepassxc"), m_historyWidget);
m_sortModel->setSourceModel(m_historyModel);
m_sortModel->setDynamicSortFilter(true);
@@ -291,8 +291,8 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q
setForms(entry);
setReadOnly(m_history);
- setCurrentRow(0);
- setRowHidden(m_historyWidget, m_history);
+ setCurrentPage(0);
+ setPageHidden(m_historyWidget, m_history || m_entry->historyItems().count() < 1);
}
void EditEntryWidget::setForms(const Entry* entry, bool restore)
diff --git a/src/gui/entry/EditEntryWidget_p.h b/src/gui/entry/EditEntryWidget_p.h
index 34232d25e..0e37c1fe8 100644
--- a/src/gui/entry/EditEntryWidget_p.h
+++ b/src/gui/entry/EditEntryWidget_p.h
@@ -18,90 +18,8 @@
#ifndef KEEPASSX_EDITENTRYWIDGET_P_H
#define KEEPASSX_EDITENTRYWIDGET_P_H
-#include
+#include
#include
-#include
-#include
-#include
-
-class CategoryListViewDelegate : public QStyledItemDelegate
-{
-public:
- explicit CategoryListViewDelegate(QListView* parent = nullptr)
- : QStyledItemDelegate(parent), m_size(96, 96)
- {}
-
-protected:
- void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
- {
- QStyleOptionViewItem opt = option;
- initStyleOption(&opt, index);
-
- painter->save();
-
- QIcon icon = opt.icon;
- QSize iconSize = opt.icon.actualSize(QSize(32, 32));
- opt.icon = QIcon();
- opt.decorationAlignment = Qt::AlignHCenter | Qt::AlignVCenter;
- opt.decorationPosition = QStyleOptionViewItem::Top;
-
- QStyle* style = opt.widget ? opt.widget->style() : QApplication::style();
- style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
-
- QRect fontRect = painter->fontMetrics().boundingRect(
- QRect(0, 0, m_size.width(), m_size.height()), Qt::AlignHCenter | Qt::AlignBottom | Qt::TextWordWrap, opt.text);
-
- int paddingTop = fontRect.height() < 30 ? 15 : 10;
- int left = opt.rect.left() + opt.rect.width() / 2 - iconSize.width() / 2;
- painter->drawPixmap(left, opt.rect.top() + paddingTop, icon.pixmap(iconSize));
-
- painter->restore();
- }
-
- QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override
- {
- Q_UNUSED(option);
- Q_UNUSED(index);
- return m_size;
- }
-
-private:
- QSize m_size;
-};
-
-class CategoryListWidget : public QListWidget
-{
-public:
- explicit CategoryListWidget(QWidget* parent = 0)
- : QListWidget(parent)
- {
- setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
- setItemDelegate(new CategoryListViewDelegate(this));
- setMovement(QListView::Static);
- setViewMode(QListWidget::IconMode);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setWordWrap(true);
- }
-protected:
- QSize sizeHint() const override
- {
- QSize sizeHint = QListWidget::sizeHint();
-
- int width = sizeHintForColumn(0) + frameWidth() * 2;
- if (verticalScrollBar()->isVisible()) {
- width += verticalScrollBar()->width();
- }
- sizeHint.setWidth(width);
-
- return sizeHint;
- }
-
- QSize minimumSizeHint() const override
- {
- return QSize(sizeHint().width(), sizeHintForRow(0) * 2);
- }
-};
class AttributesListView : public QListView
{
diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp
index 5b9dfcbc8..23e2108b5 100644
--- a/src/gui/group/EditGroupWidget.cpp
+++ b/src/gui/group/EditGroupWidget.cpp
@@ -19,6 +19,7 @@
#include "ui_EditGroupWidgetMain.h"
#include "core/Metadata.h"
+#include "core/FilePath.h"
#include "gui/EditWidgetIcons.h"
#include "gui/EditWidgetProperties.h"
@@ -33,9 +34,9 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
{
m_mainUi->setupUi(m_editGroupWidgetMain);
- add(tr("Group"), m_editGroupWidgetMain);
- add(tr("Icon"), m_editGroupWidgetIcons);
- add(tr("Properties"), m_editWidgetProperties);
+ addPage(tr("Group"), FilePath::instance()->icon("apps", "keepassxc"), m_editGroupWidgetMain);
+ addPage(tr("Icon"), FilePath::instance()->icon("apps", "keepassxc"), m_editGroupWidgetIcons);
+ addPage(tr("Properties"), FilePath::instance()->icon("apps", "keepassxc"), m_editWidgetProperties);
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
connect(m_mainUi->autoTypeSequenceCustomRadio, SIGNAL(toggled(bool)),
@@ -94,7 +95,7 @@ void EditGroupWidget::loadGroup(Group* group, bool create, Database* database)
m_editWidgetProperties->setFields(group->timeInfo(), group->uuid());
- setCurrentRow(0);
+ setCurrentPage(0);
m_mainUi->editName->setFocus();
}