mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-06-29 17:07:32 -04:00
Introduce Compact Mode
* Added to the new view menu, show entry/group icons at 16px and reduce toolbar icons to 22px. * Fix search widget being too large vertically (removed padding)
This commit is contained in:
parent
4bf6d8d94d
commit
fd65a47d51
9 changed files with 58 additions and 25 deletions
|
@ -101,6 +101,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||||
{Config::GUI_AdvancedSettings, {QS("GUI/AdvancedSettings"), Roaming, false}},
|
{Config::GUI_AdvancedSettings, {QS("GUI/AdvancedSettings"), Roaming, false}},
|
||||||
{Config::GUI_MonospaceNotes, {QS("GUI/MonospaceNotes"), Roaming, false}},
|
{Config::GUI_MonospaceNotes, {QS("GUI/MonospaceNotes"), Roaming, false}},
|
||||||
{Config::GUI_ApplicationTheme, {QS("GUI/ApplicationTheme"), Roaming, QS("auto")}},
|
{Config::GUI_ApplicationTheme, {QS("GUI/ApplicationTheme"), Roaming, QS("auto")}},
|
||||||
|
{Config::GUI_CompactMode, {QS("GUI/CompactMode"), Roaming, false}},
|
||||||
{Config::GUI_CheckForUpdates, {QS("GUI/CheckForUpdates"), Roaming, true}},
|
{Config::GUI_CheckForUpdates, {QS("GUI/CheckForUpdates"), Roaming, true}},
|
||||||
{Config::GUI_CheckForUpdatesNextCheck, {QS("GUI/CheckForUpdatesNextCheck"), Local, 0}},
|
{Config::GUI_CheckForUpdatesNextCheck, {QS("GUI/CheckForUpdatesNextCheck"), Local, 0}},
|
||||||
{Config::GUI_CheckForUpdatesIncludeBetas, {QS("GUI/CheckForUpdatesIncludeBetas"), Roaming, false}},
|
{Config::GUI_CheckForUpdatesIncludeBetas, {QS("GUI/CheckForUpdatesIncludeBetas"), Roaming, false}},
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
GUI_AdvancedSettings,
|
GUI_AdvancedSettings,
|
||||||
GUI_MonospaceNotes,
|
GUI_MonospaceNotes,
|
||||||
GUI_ApplicationTheme,
|
GUI_ApplicationTheme,
|
||||||
|
GUI_CompactMode,
|
||||||
GUI_CheckForUpdates,
|
GUI_CheckForUpdates,
|
||||||
GUI_CheckForUpdatesIncludeBetas,
|
GUI_CheckForUpdatesIncludeBetas,
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "DatabaseIcons.h"
|
#include "DatabaseIcons.h"
|
||||||
|
|
||||||
|
#include "core/Config.h"
|
||||||
#include "core/Global.h"
|
#include "core/Global.h"
|
||||||
#include "core/Resources.h"
|
#include "core/Resources.h"
|
||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
|
@ -44,6 +45,9 @@ DatabaseIcons::DatabaseIcons()
|
||||||
|
|
||||||
iconList = QDir(iconDir).entryList(QDir::NoFilter, QDir::Name);
|
iconList = QDir(iconDir).entryList(QDir::NoFilter, QDir::Name);
|
||||||
badgeList = QDir(badgeDir).entryList(QDir::NoFilter, QDir::Name);
|
badgeList = QDir(badgeDir).entryList(QDir::NoFilter, QDir::Name);
|
||||||
|
|
||||||
|
// Set this early and once to ensure consistent icon size until app restart
|
||||||
|
m_compactMode = config()->get(Config::GUI_CompactMode).toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseIcons* DatabaseIcons::instance()
|
DatabaseIcons* DatabaseIcons::instance()
|
||||||
|
@ -66,13 +70,13 @@ QPixmap DatabaseIcons::icon(int index, IconSize size)
|
||||||
auto icon = m_iconCache.value(cacheKey);
|
auto icon = m_iconCache.value(cacheKey);
|
||||||
if (icon.isNull()) {
|
if (icon.isNull()) {
|
||||||
icon.addFile(iconDir + iconList[index]);
|
icon.addFile(iconDir + iconList[index]);
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Default));
|
icon.addPixmap(icon.pixmap(iconSize(IconSize::Default)));
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Medium));
|
icon.addPixmap(icon.pixmap(iconSize(IconSize::Medium)));
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Large));
|
icon.addPixmap(icon.pixmap(iconSize(IconSize::Large)));
|
||||||
m_iconCache.insert(cacheKey, icon);
|
m_iconCache.insert(cacheKey, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
return icon.pixmap(size);
|
return icon.pixmap(iconSize(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap DatabaseIcons::applyBadge(const QPixmap& basePixmap, Badges badgeIndex)
|
QPixmap DatabaseIcons::applyBadge(const QPixmap& basePixmap, Badges badgeIndex)
|
||||||
|
@ -83,7 +87,8 @@ QPixmap DatabaseIcons::applyBadge(const QPixmap& basePixmap, Badges badgeIndex)
|
||||||
qWarning("DatabaseIcons: Out-of-range badge index given to applyBadge: %d", badgeIndex);
|
qWarning("DatabaseIcons: Out-of-range badge index given to applyBadge: %d", badgeIndex);
|
||||||
} else if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
} else if (!QPixmapCache::find(cacheKey, &pixmap)) {
|
||||||
int baseSize = basePixmap.width();
|
int baseSize = basePixmap.width();
|
||||||
int badgeSize = baseSize <= IconSize::Default * basePixmap.devicePixelRatio() ? baseSize * 0.6 : baseSize * 0.5;
|
int badgeSize =
|
||||||
|
baseSize <= iconSize(IconSize::Default) * basePixmap.devicePixelRatio() ? baseSize * 0.6 : baseSize * 0.5;
|
||||||
QPoint badgePos(baseSize - badgeSize, baseSize - badgeSize);
|
QPoint badgePos(baseSize - badgeSize, baseSize - badgeSize);
|
||||||
badgePos /= basePixmap.devicePixelRatio();
|
badgePos /= basePixmap.devicePixelRatio();
|
||||||
|
|
||||||
|
@ -106,3 +111,15 @@ int DatabaseIcons::count()
|
||||||
{
|
{
|
||||||
return iconList.size();
|
return iconList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DatabaseIcons::iconSize(IconSize size)
|
||||||
|
{
|
||||||
|
switch (size) {
|
||||||
|
case Medium:
|
||||||
|
return m_compactMode ? 26 : 30;
|
||||||
|
case Large:
|
||||||
|
return m_compactMode ? 30 : 36;
|
||||||
|
default:
|
||||||
|
return m_compactMode ? 16 : 22;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -39,11 +39,14 @@ public:
|
||||||
QPixmap applyBadge(const QPixmap& basePixmap, Badges badgeIndex);
|
QPixmap applyBadge(const QPixmap& basePixmap, Badges badgeIndex);
|
||||||
int count();
|
int count();
|
||||||
|
|
||||||
|
int iconSize(IconSize size);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DatabaseIcons();
|
DatabaseIcons();
|
||||||
|
|
||||||
static DatabaseIcons* m_instance;
|
static DatabaseIcons* m_instance;
|
||||||
QHash<QString, QIcon> m_iconCache;
|
QHash<QString, QIcon> m_iconCache;
|
||||||
|
bool m_compactMode;
|
||||||
|
|
||||||
Q_DISABLE_COPY(DatabaseIcons)
|
Q_DISABLE_COPY(DatabaseIcons)
|
||||||
};
|
};
|
||||||
|
|
|
@ -48,9 +48,9 @@ static const auto FALSE_STR = QStringLiteral("false");
|
||||||
|
|
||||||
enum IconSize
|
enum IconSize
|
||||||
{
|
{
|
||||||
Default = 22,
|
Default,
|
||||||
Medium = 30,
|
Medium,
|
||||||
Large = 36
|
Large
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct AddConst
|
template <typename T> struct AddConst
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QtCore/QCryptographicHash>
|
#include <QtCore/QCryptographicHash>
|
||||||
|
|
||||||
#include "core/Clock.h"
|
#include "core/Clock.h"
|
||||||
|
#include "core/DatabaseIcons.h"
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
#include "core/Tools.h"
|
#include "core/Tools.h"
|
||||||
|
@ -186,7 +187,7 @@ QPixmap Metadata::customIconPixmap(const QUuid& uuid, IconSize size) const
|
||||||
if (!hasCustomIcon(uuid)) {
|
if (!hasCustomIcon(uuid)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return m_customIcons.value(uuid).pixmap(size);
|
return m_customIcons.value(uuid).pixmap(databaseIcons()->iconSize(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QUuid, QPixmap> Metadata::customIconsPixmaps(IconSize size) const
|
QHash<QUuid, QPixmap> Metadata::customIconsPixmaps(IconSize size) const
|
||||||
|
@ -380,9 +381,9 @@ void Metadata::addCustomIcon(const QUuid& uuid, const QImage& image)
|
||||||
// Generate QIcon with pre-baked resolutions
|
// Generate QIcon with pre-baked resolutions
|
||||||
auto basePixmap = QPixmap::fromImage(image).scaled(128, 128, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
auto basePixmap = QPixmap::fromImage(image).scaled(128, 128, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
QIcon icon(basePixmap);
|
QIcon icon(basePixmap);
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Default));
|
icon.addPixmap(icon.pixmap(databaseIcons()->iconSize(IconSize::Default)));
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Medium));
|
icon.addPixmap(icon.pixmap(databaseIcons()->iconSize(IconSize::Medium)));
|
||||||
icon.addPixmap(icon.pixmap(IconSize::Large));
|
icon.addPixmap(icon.pixmap(databaseIcons()->iconSize(IconSize::Large)));
|
||||||
m_customIcons.insert(uuid, icon);
|
m_customIcons.insert(uuid, icon);
|
||||||
} else {
|
} else {
|
||||||
m_customIcons.insert(uuid, QIcon());
|
m_customIcons.insert(uuid, QIcon());
|
||||||
|
|
|
@ -107,6 +107,10 @@ MainWindow::MainWindow()
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
if (config()->get(Config::GUI_CompactMode).toBool()) {
|
||||||
|
m_ui->toolBar->setIconSize({20, 20});
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the search widget in the toolbar
|
// Setup the search widget in the toolbar
|
||||||
m_searchWidget = new SearchWidget();
|
m_searchWidget = new SearchWidget();
|
||||||
m_searchWidget->connectSignals(m_actionMultiplexer);
|
m_searchWidget->connectSignals(m_actionMultiplexer);
|
||||||
|
@ -1684,6 +1688,12 @@ void MainWindow::initViewMenu()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_ui->actionCompactMode->setChecked(config()->get(Config::GUI_CompactMode).toBool());
|
||||||
|
connect(m_ui->actionCompactMode, &QAction::toggled, this, [this](bool checked) {
|
||||||
|
config()->set(Config::GUI_CompactMode, checked);
|
||||||
|
restartApp(tr("You must restart the application to apply this setting. Would you like to restart now?"));
|
||||||
|
});
|
||||||
|
|
||||||
m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());
|
m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());
|
||||||
connect(m_ui->actionShowToolbar, &QAction::toggled, this, [this](bool checked) {
|
connect(m_ui->actionShowToolbar, &QAction::toggled, this, [this](bool checked) {
|
||||||
config()->set(Config::GUI_HideToolbar, !checked);
|
config()->set(Config::GUI_HideToolbar, !checked);
|
||||||
|
|
|
@ -367,6 +367,7 @@
|
||||||
<addaction name="actionThemeClassic"/>
|
<addaction name="actionThemeClassic"/>
|
||||||
</widget>
|
</widget>
|
||||||
<addaction name="menuTheme"/>
|
<addaction name="menuTheme"/>
|
||||||
|
<addaction name="actionCompactMode"/>
|
||||||
<addaction name="actionShowPreviewPanel"/>
|
<addaction name="actionShowPreviewPanel"/>
|
||||||
<addaction name="actionShowToolbar"/>
|
<addaction name="actionShowToolbar"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -861,6 +862,14 @@
|
||||||
<string>Remove key from SSH Agent</string>
|
<string>Remove key from SSH Agent</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionCompactMode">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Compact Mode</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionThemeAuto">
|
<action name="actionThemeAuto">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
|
@ -6,17 +6,11 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>630</width>
|
<width>465</width>
|
||||||
<height>34</height>
|
<height>34</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="4">
|
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -32,20 +26,17 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="searchEdit">
|
<widget class="QLineEdit" name="searchEdit">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>0</width>
|
<width>150</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">padding:3px</string>
|
|
||||||
</property>
|
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue