Bundle icons using the Qt resource system.

Simplify resource loading logic and enable reproducible builds.
Fixes #2582
This commit is contained in:
Janek Bevendorff 2020-03-09 01:27:16 +01:00 committed by Jonathan White
parent 4ff781fa48
commit b045160e4f
56 changed files with 630 additions and 548 deletions

View File

@ -132,7 +132,7 @@ For **Qt-UI files** (*.ui*): 2 spaces
// Application includes
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
// Global includes
#include <QWidget>

View File

@ -19,10 +19,6 @@ add_subdirectory(translations)
file(GLOB wordlists_files "wordlists/*.wordlist")
install(FILES ${wordlists_files} DESTINATION ${DATA_INSTALL_DIR}/wordlists)
file(GLOB DATABASE_ICONS icons/database/*.png)
install(FILES ${DATABASE_ICONS} DESTINATION ${DATA_INSTALL_DIR}/icons/database)
if(UNIX AND NOT APPLE AND NOT HAIKU)
install(DIRECTORY icons/application/ DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor
FILES_MATCHING PATTERN "keepassx*.png" PATTERN "keepassx*.svg"
@ -39,13 +35,10 @@ if(APPLE)
install(FILES macosx/keepassxc.icns DESTINATION ${DATA_INSTALL_DIR})
endif()
install(FILES icons/application/256x256/apps/keepassxc.png DESTINATION ${DATA_INSTALL_DIR}/icons/application/256x256/apps)
install(DIRECTORY docs/ DESTINATION ${DATA_INSTALL_DIR}/docs FILES_MATCHING PATTERN "*.pdf")
install(DIRECTORY wizard/ DESTINATION ${DATA_INSTALL_DIR}/wizard FILES_MATCHING PATTERN "*.png")
install(DIRECTORY icons/application/ DESTINATION ${DATA_INSTALL_DIR}/icons/application
FILES_MATCHING PATTERN "*.png" PATTERN "*.svg")
add_custom_target(icons
# SVG to PNGs for KeePassXC
COMMAND inkscape -z -w 16 -h 16

View File

@ -0,0 +1,45 @@
[Icon Theme]
Name=application
Comment=KeePassXC Application Icon Theme
Directories=256x256/apps,scalable/actions,scalable/apps,scalable/categories,scalable/mimetypes,scalable/status
[scalable/actions]
Size=48
Type=Scalable
MinSize=1
MaxSize=256
Context=Actions
[scalable/apps]
Size=48
Type=Scalable
MinSize=1
MaxSize=256
Context=Applications
[scalable/categories]
Size=48
Type=Scalable
MinSize=1
MaxSize=256
Context=Categories
[scalable/mimetypes]
Size=48
Type=Scalable
MinSize=1
MaxSize=256
Context=MimeTypes
[scalable/status]
Size=48
Type=Scalable
MinSize=1
MaxSize=256
Context=Status
[256x256/apps]
Size=256
Type=Fixed
Context=Applications

View File

@ -1,92 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
width="108.7505"
height="91.166321"
viewBox="0 0 87.000389 72.933061"
id="svg2"
sodipodi:docname="freedesktop.svg"
inkscape:version="0.92.4 5da689c313, 2019-01-14">
<defs
id="defs14" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="2106"
id="namedview12"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="1.7980996"
inkscape:cx="-97.45169"
inkscape:cy="25.551539"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<metadata
id="metadata57">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(0.01402783,0.01402783)"
id="g37"
style="fill:#ffffff;fill-rule:nonzero;stroke:#000000;stroke-width:2.45880008;stroke-miterlimit:4">
<g
id="g39">
<path
d="M 85.277,40.796 C 87.335,48.68 82.61,56.738 74.726,58.795 L 27.143,71.21 C 19.259,73.267 11.2,68.543 9.143,60.658 L 1.695,32.108 C -0.362,24.224 4.362,16.166 12.246,14.109 L 59.83,1.695 c 7.884,-2.057 15.942,2.667 17.999,10.551 l 7.449,28.55 z"
id="path41"
style="stroke:#bababa"
inkscape:connector-curvature="0" />
<path
d="m 80.444,39.778 c 1.749,7.854 -1.816,13.621 -9.504,15.447 L 28.704,66.245 C 21.135,68.641 14.615,65.064 12.866,57.409 L 6.53,33.127 C 4.781,24.982 7.239,20.238 16.033,17.68 L 58.27,6.661 c 8.144,-1.826 14.089,1.363 15.838,8.835 z"
id="path43"
style="fill:#000000;stroke:none"
inkscape:connector-curvature="0" />
</g>
<path
d="M 45.542,51.793 24.104,31.102 62.204,26.709 Z"
id="path45"
style="opacity:0.5;fill:none;stroke:#ffffff"
inkscape:connector-curvature="0" />
<path
d="m 72.325,28.769 c 0.405,1.55 -0.525,3.136 -2.075,3.541 l -12.331,3.217 c -1.551,0.404 -3.137,-0.525 -3.542,-2.076 L 52.082,24.65 c -0.405,-1.551 0.524,-3.137 2.076,-3.542 l 12.33,-3.217 c 1.551,-0.405 3.137,0.525 3.542,2.076 l 2.295,8.801 z"
id="path47"
inkscape:connector-curvature="0" />
<path
d="m 36.51,33.625 c 0.496,1.9 -0.645,3.844 -2.545,4.34 l -15.112,3.943 c -1.901,0.496 -3.845,-0.644 -4.34,-2.544 L 11.699,28.578 c -0.496,-1.901 0.644,-3.844 2.544,-4.34 l 15.113,-3.942 c 1.901,-0.496 3.845,0.643 4.34,2.544 l 2.814,10.786 z"
id="path49"
inkscape:connector-curvature="0" />
<path
d="m 52.493,53.208 c 0.278,1.065 -0.36,2.154 -1.425,2.432 L 42.6,57.848 c -1.064,0.277 -2.153,-0.36 -2.431,-1.426 l -1.577,-6.043 c -0.277,-1.064 0.36,-2.153 1.425,-2.432 l 8.468,-2.209 c 1.064,-0.277 2.154,0.361 2.431,1.426 l 1.577,6.043 z"
id="path51"
inkscape:connector-curvature="0" />
</g>
</svg>
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>freedesktop.org icon</title><path d="M17.702 1.934a4.375 4.375 0 0 0-1.264.14L3.3 5.502a4.418 4.418 0 0 0-3.156 5.384L2.2 18.77a4.418 4.418 0 0 0 5.384 3.157l13.139-3.429c2.212-.577 3.573-2.745 3.222-4.958h.045l-.111-.425-2.057-7.884a4.421 4.421 0 0 0-4.12-3.296zm-.02.677a3.73 3.73 0 0 1 3.483 2.791l1.946 7.458.11.425c.523 2-.67 4.034-2.67 4.555L7.412 21.268a3.729 3.729 0 0 1-4.555-2.67L.8 10.715a3.729 3.729 0 0 1 2.671-4.556L16.61 2.731a3.77 3.77 0 0 1 1.072-.12zm-.392 1.024a5.386 5.386 0 0 0-1.197.139L4.431 6.817c-2.428.706-3.107 2.016-2.624 4.265l1.75 6.704c.482 2.114 2.282 3.102 4.372 2.44l11.662-3.043c2.123-.504 3.107-2.096 2.624-4.265l-1.749-6.704c-.392-1.677-1.55-2.572-3.176-2.579zm1.25 3.554a.46.46 0 0 1 .472.345l.623 2.388.01.042a.457.457 0 0 1-.33.564l-3.405.888a.457.457 0 0 1-.564-.33l-.633-2.43a.457.457 0 0 1 .33-.565l3.405-.888a.468.468 0 0 1 .093-.014zm-10.216.658a.64.64 0 0 1 .655.48l.777 2.978a.638.638 0 0 1-.46.784l-4.172 1.089a.638.638 0 0 1-.784-.46L3.563 9.74a.638.638 0 0 1 .46-.785l4.172-1.088a.646.646 0 0 1 .13-.02zm5.859 1.466l.173.663-4.12.476-.174-.663zm.898 2.542c.183.147.41.237.648.252l-1.57 2.362a.892.892 0 0 0-.642-.26zm-5.626.894l2.032 1.96-.52.136a.867.867 0 0 0-.22.095l-2.062-1.99zm4.064 2.137a.209.209 0 0 1 .215.157l.435 1.669a.206.206 0 0 1-.15.258l-2.338.61a.206.206 0 0 1-.257-.152l-.436-1.668a.206.206 0 0 1 .151-.258l2.338-.61a.207.207 0 0 1 .042-.006Z"/></svg>

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

152
share/icons/icons.qrc Normal file
View File

@ -0,0 +1,152 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/icons">
<file>application/index.theme</file>
<file>application/256x256/apps/keepassxc.png</file>
<file>application/scalable/actions/application-exit.svg</file>
<file>application/scalable/actions/auto-type.svg</file>
<file>application/scalable/actions/bugreport.svg</file>
<file>application/scalable/actions/chronometer.svg</file>
<file>application/scalable/actions/configure.svg</file>
<file>application/scalable/actions/database-change-key.svg</file>
<file>application/scalable/actions/database-lock.svg</file>
<file>application/scalable/actions/database-merge.svg</file>
<file>application/scalable/actions/dialog-close.svg</file>
<file>application/scalable/actions/dialog-ok.svg</file>
<file>application/scalable/actions/document-close.svg</file>
<file>application/scalable/actions/document-edit.svg</file>
<file>application/scalable/actions/document-new.svg</file>
<file>application/scalable/actions/document-open.svg</file>
<file>application/scalable/actions/document-properties.svg</file>
<file>application/scalable/actions/document-save.svg</file>
<file>application/scalable/actions/document-save-as.svg</file>
<file>application/scalable/actions/donate.svg</file>
<file>application/scalable/actions/edit-clear-locationbar-ltr.svg</file>
<file>application/scalable/actions/edit-clear-locationbar-rtl.svg</file>
<file>application/scalable/actions/entry-clone.svg</file>
<file>application/scalable/actions/entry-delete.svg</file>
<file>application/scalable/actions/entry-edit.svg</file>
<file>application/scalable/actions/entry-new.svg</file>
<file>application/scalable/actions/favicon-download.svg</file>
<file>application/scalable/actions/getting-started.svg</file>
<file>application/scalable/actions/group-delete.svg</file>
<file>application/scalable/actions/group-edit.svg</file>
<file>application/scalable/actions/group-empty-trash.svg</file>
<file>application/scalable/actions/group-new.svg</file>
<file>application/scalable/actions/health.svg</file>
<file>application/scalable/actions/help-about.svg</file>
<file>application/scalable/actions/key-enter.svg</file>
<file>application/scalable/actions/keyboard-shortcuts.svg</file>
<file>application/scalable/actions/message-close.svg</file>
<file>application/scalable/actions/object-locked.svg</file>
<file>application/scalable/actions/object-unlocked.svg</file>
<file>application/scalable/actions/paperclip.svg</file>
<file>application/scalable/actions/password-copy.svg</file>
<file>application/scalable/actions/password-generate.svg</file>
<file>application/scalable/actions/password-generator.svg</file>
<file>application/scalable/actions/password-show-off.svg</file>
<file>application/scalable/actions/password-show-on.svg</file>
<file>application/scalable/actions/sort-alphabetical-ascending.svg</file>
<file>application/scalable/actions/sort-alphabetical-descending.svg</file>
<file>application/scalable/actions/statistics.svg</file>
<file>application/scalable/actions/system-help.svg</file>
<file>application/scalable/actions/system-search.svg</file>
<file>application/scalable/actions/system-software-update.svg</file>
<file>application/scalable/actions/url-copy.svg</file>
<file>application/scalable/actions/user-guide.svg</file>
<file>application/scalable/actions/username-copy.svg</file>
<file>application/scalable/actions/view-history.svg</file>
<file>application/scalable/actions/web.svg</file>
<file>application/scalable/apps/freedesktop.svg</file>
<file>application/scalable/apps/internet-web-browser.svg</file>
<file>application/scalable/apps/keepassxc.svg</file>
<file>application/scalable/apps/keepassxc-dark.svg</file>
<file>application/scalable/apps/keepassxc-locked.svg</file>
<file>application/scalable/apps/keepassxc-unlocked.svg</file>
<file>application/scalable/apps/preferences-desktop-icons.svg</file>
<file>application/scalable/apps/preferences-system-network-sharing.svg</file>
<file>application/scalable/apps/utilities-terminal.svg</file>
<file>application/scalable/categories/preferences-other.svg</file>
<file>application/scalable/mimetypes/application-x-keepassxc.svg</file>
<file>application/scalable/status/dialog-error.svg</file>
<file>application/scalable/status/dialog-information.svg</file>
<file>application/scalable/status/dialog-warning.svg</file>
<file>application/scalable/status/security-high.svg</file>
<file>database/C00_Password.png</file>
<file>database/C01_Package_Network.png</file>
<file>database/C02_MessageBox_Warning.png</file>
<file>database/C03_Server.png</file>
<file>database/C04_Klipper.png</file>
<file>database/C05_Edu_Languages.png</file>
<file>database/C06_KCMDF.png</file>
<file>database/C07_Kate.png</file>
<file>database/C08_Socket.png</file>
<file>database/C09_Identity.png</file>
<file>database/C10_Kontact.png</file>
<file>database/C11_Camera.png</file>
<file>database/C12_IRKickFlash.png</file>
<file>database/C13_KGPG_Key3.png</file>
<file>database/C14_Laptop_Power.png</file>
<file>database/C15_Scanner.png</file>
<file>database/C16_Mozilla_Firebird.png</file>
<file>database/C17_CDROM_Unmount.png</file>
<file>database/C18_Display.png</file>
<file>database/C19_Mail_Generic.png</file>
<file>database/C20_Misc.png</file>
<file>database/C21_KOrganizer.png</file>
<file>database/C22_ASCII.png</file>
<file>database/C23_Icons.png</file>
<file>database/C24_Connect_Established.png</file>
<file>database/C25_Folder_Mail.png</file>
<file>database/C26_FileSave.png</file>
<file>database/C27_NFS_Unmount.png</file>
<file>database/C28_QuickTime.png</file>
<file>database/C29_KGPG_Term.png</file>
<file>database/C30_Konsole.png</file>
<file>database/C31_FilePrint.png</file>
<file>database/C32_FSView.png</file>
<file>database/C33_Run.png</file>
<file>database/C34_Configure.png</file>
<file>database/C35_KRFB.png</file>
<file>database/C36_Ark.png</file>
<file>database/C37_KPercentage.png</file>
<file>database/C38_Samba_Unmount.png</file>
<file>database/C39_History.png</file>
<file>database/C40_Mail_Find.png</file>
<file>database/C41_VectorGfx.png</file>
<file>database/C42_KCMMemory.png</file>
<file>database/C43_EditTrash.png</file>
<file>database/C44_KNotes.png</file>
<file>database/C45_Cancel.png</file>
<file>database/C46_Help.png</file>
<file>database/C47_KPackage.png</file>
<file>database/C48_Folder.png</file>
<file>database/C49_Folder_Blue_Open.png</file>
<file>database/C50_Folder_Tar.png</file>
<file>database/C51_Decrypted.png</file>
<file>database/C52_Encrypted.png</file>
<file>database/C53_Apply.png</file>
<file>database/C54_Signature.png</file>
<file>database/C55_Thumbnail.png</file>
<file>database/C56_KAddressBook.png</file>
<file>database/C57_View_Text.png</file>
<file>database/C58_KGPG.png</file>
<file>database/C59_Package_Development.png</file>
<file>database/C60_KFM_Home.png</file>
<file>database/C61_Services.png</file>
<file>database/C62_Tux.png</file>
<file>database/C63_Feather.png</file>
<file>database/C64_Apple.png</file>
<file>database/C65_W.png</file>
<file>database/C66_Money.png</file>
<file>database/C67_Certificate.png</file>
<file>database/C68_BlackBerry.png</file>
</qresource>
</RCC>

6
share/wizard/wizard.qrc Normal file
View File

@ -0,0 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/wizard">
<file>background-pixmap.png</file>
</qresource>
</RCC>

View File

@ -40,7 +40,6 @@ set(keepassx_SOURCES
core/EntryAttachments.cpp
core/EntryAttributes.cpp
core/EntrySearcher.cpp
core/FilePath.cpp
core/FileWatcher.cpp
core/Group.cpp
core/HibpOffline.cpp
@ -50,6 +49,7 @@ set(keepassx_SOURCES
core/PasswordGenerator.cpp
core/PasswordHealth.cpp
core/PassphraseGenerator.cpp
core/Resources.cpp
core/SignalMultiplexer.cpp
core/ScreenLockListener.cpp
core/ScreenLockListenerPrivate.cpp
@ -210,6 +210,10 @@ if(MINGW OR (UNIX AND NOT APPLE))
core/OSEventFilter.cpp)
endif()
set(keepassx_SOURCES ${keepassx_SOURCES}
../share/icons/icons.qrc
../share/wizard/wizard.qrc)
set(keepassx_SOURCES_MAINEXE main.cpp)
add_feature_info(Auto-Type WITH_XC_AUTOTYPE "Automatic password typing")

View File

@ -31,9 +31,9 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/ListDeleter.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "gui/MessageBox.h"
@ -63,7 +63,7 @@ AutoType::AutoType(QObject* parent, bool test)
pluginName += "test";
}
QString pluginPath = filePath()->pluginPath(pluginName);
QString pluginPath = resources()->pluginPath(pluginName);
if (!pluginPath.isEmpty()) {
#ifdef WITH_XC_AUTOTYPE

View File

@ -34,7 +34,7 @@
#include "autotype/AutoTypeSelectView.h"
#include "core/AutoTypeMatch.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/entry/AutoTypeMatchModel.h"
AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
@ -49,7 +49,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
setAttribute(Qt::WA_X11BypassTransientForHint);
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
setWindowTitle(tr("Auto-Type - KeePassXC"));
setWindowIcon(filePath()->applicationIcon());
setWindowIcon(resources()->applicationIcon());
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
QRect screenGeometry = QApplication::screenAt(QCursor::pos())->availableGeometry();

View File

@ -22,7 +22,7 @@
#include "BrowserSettings.h"
#include "config-keepassx.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include <QFileDialog>

View File

@ -70,6 +70,7 @@ namespace Bootstrap
#ifdef QT_NO_DEBUG
disableCoreDumps();
#endif
setupSearchPaths();
applyEarlyQNetworkAccessManagerWorkaround();
Translator::installTranslators();

View File

@ -17,7 +17,7 @@
#include "DatabaseIcons.h"
#include "core/FilePath.h"
#include "core/Resources.h"
DatabaseIcons* DatabaseIcons::m_instance(nullptr);
const int DatabaseIcons::IconCount(69);
@ -103,18 +103,15 @@ QImage DatabaseIcons::icon(int index)
{
if (index < 0 || index >= IconCount) {
qWarning("DatabaseIcons::icon: invalid icon index %d", index);
return QImage();
return {};
}
if (!m_iconCache[index].isNull()) {
return m_iconCache[index];
} else {
QString iconPath = QString("icons/database/").append(m_indexToName[index]);
QImage icon(filePath()->dataPath(iconPath));
m_iconCache[index] = icon;
return icon;
}
QImage icon(QStringLiteral(":/icons/database/").append(m_indexToName[index]));
m_iconCache[index] = icon;
return icon;
}
QPixmap DatabaseIcons::iconPixmap(int index)

View File

@ -1,259 +0,0 @@
/*
* Copyright (C) 2017 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "FilePath.h"
#include <QBitmap>
#include <QDir>
#include <QLibrary>
#include <QStyle>
#include "config-keepassx.h"
#include "core/Config.h"
#include "core/Global.h"
#include "gui/MainWindow.h"
FilePath* FilePath::m_instance(nullptr);
QString FilePath::dataPath(const QString& name)
{
if (name.isEmpty() || name.startsWith('/')) {
return m_dataPath + name;
} else {
return m_dataPath + "/" + name;
}
}
QString FilePath::pluginPath(const QString& name)
{
QStringList pluginPaths;
QDir buildDir(QCoreApplication::applicationDirPath() + "/autotype");
const QStringList buildDirEntryList = buildDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString& dir : buildDirEntryList) {
pluginPaths << QCoreApplication::applicationDirPath() + "/autotype/" + dir;
}
// for TestAutoType
pluginPaths << QCoreApplication::applicationDirPath() + "/../src/autotype/test";
#if defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE)
pluginPaths << QCoreApplication::applicationDirPath() + "/../PlugIns";
#endif
pluginPaths << QCoreApplication::applicationDirPath();
QString configuredPluginDir = KEEPASSX_PLUGIN_DIR;
if (configuredPluginDir != ".") {
if (QDir(configuredPluginDir).isAbsolute()) {
pluginPaths << configuredPluginDir;
} else {
QString relativePluginDir =
QString("%1/../%2").arg(QCoreApplication::applicationDirPath(), configuredPluginDir);
pluginPaths << QDir(relativePluginDir).canonicalPath();
QString absolutePluginDir = QString("%1/%2").arg(KEEPASSX_PREFIX_DIR, configuredPluginDir);
pluginPaths << QDir(absolutePluginDir).canonicalPath();
}
}
QStringList dirFilter;
dirFilter << QString("*%1*").arg(name);
for (const QString& path : asConst(pluginPaths)) {
const QStringList fileCandidates = QDir(path).entryList(dirFilter, QDir::Files);
for (const QString& file : fileCandidates) {
QString filePath = path + "/" + file;
if (QLibrary::isLibrary(filePath)) {
return filePath;
}
}
}
return QString();
}
QString FilePath::wordlistPath(const QString& name)
{
return dataPath("wordlists/" + name);
}
QIcon FilePath::applicationIcon()
{
return icon("apps", "keepassxc", false);
}
QIcon FilePath::trayIcon()
{
return useDarkIcon() ? icon("apps", "keepassxc-dark", false) : icon("apps", "keepassxc", false);
}
QIcon FilePath::trayIconLocked()
{
return icon("apps", "keepassxc-locked", false);
}
QIcon FilePath::trayIconUnlocked()
{
return useDarkIcon() ? icon("apps", "keepassxc-dark", false) : icon("apps", "keepassxc-unlocked", false);
}
QIcon FilePath::icon(const QString& category, const QString& name, bool recolor)
{
QString combinedName = category + "/" + name;
QIcon icon = m_iconCache.value(combinedName);
if (!icon.isNull()) {
return icon;
}
if (icon.isNull()) {
const QList<int> pngSizes = {16, 22, 24, 32, 48, 64, 128};
QString filename;
for (int size : pngSizes) {
filename =
QString("%1/icons/application/%2x%2/%3.png").arg(m_dataPath, QString::number(size), combinedName);
if (QFile::exists(filename)) {
icon.addFile(filename, QSize(size, size));
}
}
filename = QString("%1/icons/application/scalable/%2.svg").arg(m_dataPath, combinedName);
if (QFile::exists(filename) && getMainWindow() && recolor) {
QPalette palette = getMainWindow()->palette();
QFile f(filename);
QIcon scalable(filename);
QPixmap pixmap = scalable.pixmap({128, 128});
auto mask = QBitmap::fromImage(pixmap.toImage().createAlphaMask());
pixmap.fill(palette.color(QPalette::WindowText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Normal);
pixmap.fill(palette.color(QPalette::HighlightedText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Selected);
pixmap.fill(palette.color(QPalette::Disabled, QPalette::WindowText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Disabled);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
icon.setIsMask(true);
#endif
} else if (QFile::exists(filename)) {
icon.addFile(filename);
}
}
m_iconCache.insert(combinedName, icon);
return icon;
}
QIcon FilePath::onOffIcon(const QString& category, const QString& name, bool recolor)
{
QString combinedName = category + "/" + name;
QString cacheName = "onoff/" + combinedName;
QIcon icon = m_iconCache.value(cacheName);
if (!icon.isNull()) {
return icon;
}
QIcon on = FilePath::icon(category, name + "-on", recolor);
for (const auto& size : on.availableSizes()) {
icon.addPixmap(on.pixmap(size, QIcon::Mode::Normal), QIcon::Mode::Normal, QIcon::On);
icon.addPixmap(on.pixmap(size, QIcon::Mode::Selected), QIcon::Mode::Selected, QIcon::On);
icon.addPixmap(on.pixmap(size, QIcon::Mode::Disabled), QIcon::Mode::Disabled, QIcon::On);
}
QIcon off = FilePath::icon(category, name + "-off", recolor);
for (const auto& size : off.availableSizes()) {
icon.addPixmap(off.pixmap(size, QIcon::Mode::Normal), QIcon::Mode::Normal, QIcon::Off);
icon.addPixmap(off.pixmap(size, QIcon::Mode::Selected), QIcon::Mode::Selected, QIcon::Off);
icon.addPixmap(off.pixmap(size, QIcon::Mode::Disabled), QIcon::Mode::Disabled, QIcon::Off);
}
m_iconCache.insert(cacheName, icon);
return icon;
}
FilePath::FilePath()
{
const QString appDirPath = QCoreApplication::applicationDirPath();
bool isDataDirAbsolute = QDir::isAbsolutePath(KEEPASSX_DATA_DIR);
Q_UNUSED(isDataDirAbsolute);
if (false) {
}
#ifdef QT_DEBUG
else if (testSetDir(QString(KEEPASSX_SOURCE_DIR) + "/share")) {
}
#endif
#if defined(Q_OS_UNIX) && !(defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE))
else if (isDataDirAbsolute && testSetDir(KEEPASSX_DATA_DIR)) {
} else if (!isDataDirAbsolute && testSetDir(QString("%1/../%2").arg(appDirPath, KEEPASSX_DATA_DIR))) {
} else if (!isDataDirAbsolute && testSetDir(QString("%1/%2").arg(KEEPASSX_PREFIX_DIR, KEEPASSX_DATA_DIR))) {
}
#endif
#if defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE)
else if (testSetDir(appDirPath + "/../Resources")) {
}
#endif
#ifdef Q_OS_WIN
else if (testSetDir(appDirPath + "/share")) {
}
#endif
// Last ditch test when running in the build directory (mainly for travis tests)
else if (testSetDir(QString(KEEPASSX_SOURCE_DIR) + "/share")) {
}
if (m_dataPath.isEmpty()) {
qWarning("FilePath::DataPath: can't find data dir");
} else {
m_dataPath = QDir::cleanPath(m_dataPath);
}
}
bool FilePath::testSetDir(const QString& dir)
{
if (QFile::exists(dir + "/icons/database/C00_Password.png")) {
m_dataPath = dir;
return true;
} else {
return false;
}
}
bool FilePath::useDarkIcon()
{
return config()->get("GUI/DarkTrayIcon").toBool();
}
FilePath* FilePath::instance()
{
if (!m_instance) {
m_instance = new FilePath();
}
return m_instance;
}

View File

@ -21,7 +21,7 @@
#include <QTextStream>
#include <cmath>
#include "core/FilePath.h"
#include "core/Resources.h"
#include "crypto/Random.h"
const char* PassphraseGenerator::DefaultSeparator = " ";
@ -80,7 +80,7 @@ void PassphraseGenerator::setWordList(const QString& path)
void PassphraseGenerator::setDefaultWordList()
{
const QString path = filePath()->wordlistPath(PassphraseGenerator::DefaultWordList);
const QString path = resources()->wordlistPath(PassphraseGenerator::DefaultWordList);
setWordList(path);
}

232
src/core/Resources.cpp Normal file
View File

@ -0,0 +1,232 @@
/*
* Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include "Resources.h"
#include <QBitmap>
#include <QDir>
#include <QLibrary>
#include <QStyle>
#include "config-keepassx.h"
#include "core/Config.h"
#include "core/Global.h"
#include "gui/MainWindow.h"
Resources* Resources::m_instance(nullptr);
QString Resources::dataPath(const QString& name)
{
if (name.isEmpty() || name.startsWith('/')) {
return m_dataPath + name;
}
return m_dataPath + "/" + name;
}
QString Resources::pluginPath(const QString& name)
{
QStringList pluginPaths;
QDir buildDir(QCoreApplication::applicationDirPath() + "/autotype");
const QStringList buildDirEntryList = buildDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
for (const QString& dir : buildDirEntryList) {
pluginPaths << QCoreApplication::applicationDirPath() + "/autotype/" + dir;
}
// for TestAutoType
pluginPaths << QCoreApplication::applicationDirPath() + "/../src/autotype/test";
#if defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE)
pluginPaths << QCoreApplication::applicationDirPath() + "/../PlugIns";
#endif
pluginPaths << QCoreApplication::applicationDirPath();
QString configuredPluginDir = KEEPASSX_PLUGIN_DIR;
if (configuredPluginDir != ".") {
if (QDir(configuredPluginDir).isAbsolute()) {
pluginPaths << configuredPluginDir;
} else {
QString relativePluginDir =
QStringLiteral("%1/../%2").arg(QCoreApplication::applicationDirPath(), configuredPluginDir);
pluginPaths << QDir(relativePluginDir).canonicalPath();
QString absolutePluginDir = QStringLiteral("%1/%2").arg(KEEPASSX_PREFIX_DIR, configuredPluginDir);
pluginPaths << QDir(absolutePluginDir).canonicalPath();
}
}
QStringList dirFilter;
dirFilter << QStringLiteral("*%1*").arg(name);
for (const QString& path : asConst(pluginPaths)) {
const QStringList fileCandidates = QDir(path).entryList(dirFilter, QDir::Files);
for (const QString& file : fileCandidates) {
QString filePath = path + "/" + file;
if (QLibrary::isLibrary(filePath)) {
return filePath;
}
}
}
return {};
}
QString Resources::wordlistPath(const QString& name)
{
return dataPath(QStringLiteral("wordlists/%1").arg(name));
}
QIcon Resources::applicationIcon()
{
return icon("keepassxc", false);
}
QIcon Resources::trayIcon()
{
return useDarkIcon() ? icon("keepassxc-dark", false) : icon("keepassxc", false);
}
QIcon Resources::trayIconLocked()
{
return icon("keepassxc-locked", false);
}
QIcon Resources::trayIconUnlocked()
{
return useDarkIcon() ? icon("keepassxc-dark", false) : icon("keepassxc-unlocked", false);
}
QIcon Resources::icon(const QString& name, bool recolor)
{
QIcon icon = m_iconCache.value(name);
if (!icon.isNull()) {
return icon;
}
icon = QIcon::fromTheme(name);
if (getMainWindow() && recolor) {
QPixmap pixmap = icon.pixmap(128, 128);
icon = {};
QPalette palette = getMainWindow()->palette();
auto mask = QBitmap::fromImage(pixmap.toImage().createAlphaMask());
pixmap.fill(palette.color(QPalette::WindowText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Normal);
pixmap.fill(palette.color(QPalette::HighlightedText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Selected);
pixmap.fill(palette.color(QPalette::Disabled, QPalette::WindowText));
pixmap.setMask(mask);
icon.addPixmap(pixmap, QIcon::Mode::Disabled);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
icon.setIsMask(true);
#endif
}
m_iconCache.insert(name, icon);
return icon;
}
QIcon Resources::onOffIcon(const QString& name, bool recolor)
{
QString cacheName = "onoff/" + name;
QIcon icon = m_iconCache.value(cacheName);
if (!icon.isNull()) {
return icon;
}
QIcon on = Resources::icon(name + "-on", recolor);
for (const auto& size : on.availableSizes()) {
icon.addPixmap(on.pixmap(size, QIcon::Mode::Normal), QIcon::Mode::Normal, QIcon::On);
icon.addPixmap(on.pixmap(size, QIcon::Mode::Selected), QIcon::Mode::Selected, QIcon::On);
icon.addPixmap(on.pixmap(size, QIcon::Mode::Disabled), QIcon::Mode::Disabled, QIcon::On);
}
QIcon off = Resources::icon(name + "-off", recolor);
for (const auto& size : off.availableSizes()) {
icon.addPixmap(off.pixmap(size, QIcon::Mode::Normal), QIcon::Mode::Normal, QIcon::Off);
icon.addPixmap(off.pixmap(size, QIcon::Mode::Selected), QIcon::Mode::Selected, QIcon::Off);
icon.addPixmap(off.pixmap(size, QIcon::Mode::Disabled), QIcon::Mode::Disabled, QIcon::Off);
}
m_iconCache.insert(cacheName, icon);
return icon;
}
Resources::Resources()
{
const QString appDirPath = QCoreApplication::applicationDirPath();
#if defined(Q_OS_UNIX) && !(defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE))
testResourceDir(KEEPASSX_DATA_DIR) || testResourceDir(QStringLiteral("%1/../%2").arg(appDirPath, KEEPASSX_DATA_DIR))
|| testResourceDir(QStringLiteral("%1/%2").arg(KEEPASSX_PREFIX_DIR, KEEPASSX_DATA_DIR));
#elif defined(Q_OS_MACOS) && defined(WITH_APP_BUNDLE)
testResourceDir(appDirPath + QStringLiteral("/../Resources"));
#elif defined(Q_OS_WIN)
testResourceDir(appDirPath + QStringLiteral("/share"));
#endif
if (m_dataPath.isEmpty()) {
// Last ditch check if we are running from inside the src or test build directory
testResourceDir(appDirPath + QStringLiteral("/../../share"))
|| testResourceDir(appDirPath + QStringLiteral("/../share"))
|| testResourceDir(appDirPath + QStringLiteral("/../../../share"));
}
if (m_dataPath.isEmpty()) {
qWarning("Resources::DataPath: can't find data dir");
}
}
bool Resources::testResourceDir(const QString& dir)
{
if (QFile::exists(dir + QStringLiteral("/icons/application/256x256/apps/keepassxc.png"))) {
m_dataPath = QDir::cleanPath(dir);
return true;
}
return false;
}
bool Resources::useDarkIcon()
{
return config()->get("GUI/DarkTrayIcon").toBool();
}
Resources* Resources::instance()
{
if (!m_instance) {
m_instance = new Resources();
Q_INIT_RESOURCE(icons);
QIcon::setThemeSearchPaths({":/icons"});
QIcon::setThemeName("application");
}
return m_instance;
}

View File

@ -1,4 +1,5 @@
/*
* Copyright (C) 2020 KeePassXC Team <team@keepassxc.org>
* Copyright (C) 2011 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
@ -15,14 +16,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_FILEPATH_H
#define KEEPASSX_FILEPATH_H
#ifndef KEEPASSX_RESOURCES_H
#define KEEPASSX_RESOURCES_H
#include <QHash>
#include <QIcon>
#include <QString>
class FilePath
class Resources
{
public:
QString dataPath(const QString& name);
@ -32,27 +33,27 @@ public:
QIcon trayIcon();
QIcon trayIconLocked();
QIcon trayIconUnlocked();
QIcon icon(const QString& category, const QString& name, bool recolor = true);
QIcon onOffIcon(const QString& category, const QString& name, bool recolor = true);
QIcon icon(const QString& name, bool recolor = true);
QIcon onOffIcon(const QString& name, bool recolor = true);
static FilePath* instance();
static Resources* instance();
private:
FilePath();
bool testSetDir(const QString& dir);
Resources();
bool testResourceDir(const QString& dir);
bool useDarkIcon();
static FilePath* m_instance;
static Resources* m_instance;
QString m_dataPath;
QHash<QString, QIcon> m_iconCache;
Q_DISABLE_COPY(FilePath)
Q_DISABLE_COPY(Resources)
};
inline FilePath* filePath()
inline Resources* resources()
{
return FilePath::instance();
return Resources::instance();
}
#endif // KEEPASSX_FILEPATH_H
#endif // KEEPASSX_RESOURCES_H

View File

@ -27,7 +27,7 @@
#include "config-keepassx.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
/**
* Install all KeePassXC and Qt translators.
@ -53,7 +53,7 @@ void Translator::installTranslators()
#ifdef QT_DEBUG
QString("%1/share/translations").arg(KEEPASSX_BINARY_DIR),
#endif
filePath()->dataPath("translations")};
resources()->dataPath("translations")};
bool translationsLoaded = false;
for (const QString& path : paths) {
@ -121,7 +121,7 @@ QList<QPair<QString, QString>> Translator::availableLanguages()
#ifdef QT_DEBUG
QString("%1/share/translations").arg(KEEPASSX_BINARY_DIR),
#endif
filePath()->dataPath("translations")};
resources()->dataPath("translations")};
QList<QPair<QString, QString>> languages;
languages.append(QPair<QString, QString>("system", "System default"));

View File

@ -19,7 +19,7 @@
#include "fdosecrets/widgets/DatabaseSettingsWidgetFdoSecrets.h"
#include "core/FilePath.h"
#include "core/Resources.h"
QString DatabaseSettingsPageFdoSecrets::name()
{
@ -28,7 +28,7 @@ QString DatabaseSettingsPageFdoSecrets::name()
QIcon DatabaseSettingsPageFdoSecrets::icon()
{
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("freedesktop"));
return resources()->icon(QStringLiteral("freedesktop"));
}
QWidget* DatabaseSettingsPageFdoSecrets::createWidget()

View File

@ -18,7 +18,7 @@
#ifndef KEEPASSXC_FDOSECRETSPLUGIN_H
#define KEEPASSXC_FDOSECRETSPLUGIN_H
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/ApplicationSettingsWidget.h"
#include <QPointer>
@ -45,7 +45,7 @@ public:
QIcon icon() override
{
return FilePath::instance()->icon("apps", "freedesktop");
return Resources::instance()->icon("freedesktop");
}
QWidget* createWidget() override;

View File

@ -24,7 +24,7 @@
#include "core/Database.h"
#include "core/DatabaseIcons.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/DatabaseTabWidget.h"
#include "gui/DatabaseWidget.h"
@ -130,7 +130,7 @@ namespace FdoSecrets
case Qt::DisplayRole:
return tr("Unlock to show");
case Qt::DecorationRole:
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("object-locked"));
return resources()->icon(QStringLiteral("object-locked"));
case Qt::FontRole: {
QFont font;
font.setItalic(true);
@ -165,7 +165,7 @@ namespace FdoSecrets
case Qt::DisplayRole:
return tr("None");
case Qt::DecorationRole:
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("paint-none"));
return resources()->icon(QStringLiteral("paint-none"));
default:
return {};
}

View File

@ -23,7 +23,7 @@
#include "fdosecrets/objects/Session.h"
#include "fdosecrets/widgets/SettingsModels.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/DatabaseWidget.h"
#include <QAction>
@ -63,7 +63,7 @@ namespace
// db settings
m_dbSettingsAct = new QAction(tr("Database settings"), this);
m_dbSettingsAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("document-edit")));
m_dbSettingsAct->setIcon(resources()->icon(QStringLiteral("document-edit")));
m_dbSettingsAct->setToolTip(tr("Edit database settings"));
m_dbSettingsAct->setEnabled(false);
connect(m_dbSettingsAct, &QAction::triggered, this, [this]() {
@ -77,7 +77,7 @@ namespace
// unlock/lock
m_lockAct = new QAction(tr("Unlock database"), this);
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked")));
m_lockAct->setIcon(resources()->icon(QStringLiteral("object-locked")));
m_lockAct->setToolTip(tr("Unlock database to show more information"));
connect(m_lockAct, &QAction::triggered, this, [this]() {
if (!m_dbWidget) {
@ -135,13 +135,13 @@ namespace
}
connect(m_dbWidget, &DatabaseWidget::databaseLocked, this, [this]() {
m_lockAct->setText(tr("Unlock database"));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked")));
m_lockAct->setIcon(resources()->icon(QStringLiteral("object-locked")));
m_lockAct->setToolTip(tr("Unlock database to show more information"));
m_dbSettingsAct->setEnabled(false);
});
connect(m_dbWidget, &DatabaseWidget::databaseUnlocked, this, [this]() {
m_lockAct->setText(tr("Lock database"));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-unlocked")));
m_lockAct->setIcon(resources()->icon(QStringLiteral("object-unlocked")));
m_lockAct->setToolTip(tr("Lock database"));
m_dbSettingsAct->setEnabled(true);
});
@ -174,7 +174,7 @@ namespace
addWidget(spacer);
m_disconnectAct = new QAction(tr("Disconnect"), this);
m_disconnectAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("dialog-close")));
m_disconnectAct->setIcon(resources()->icon(QStringLiteral("dialog-close")));
m_disconnectAct->setToolTip(tr("Disconnect this application"));
connect(m_disconnectAct, &QAction::triggered, this, [this]() {
if (m_session) {

View File

@ -20,7 +20,7 @@
#include "ui_AboutDialog.h"
#include "config-keepassx.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "crypto/Crypto.h"
@ -207,7 +207,7 @@ AboutDialog::AboutDialog(QWidget* parent)
nameLabelFont.setPointSize(nameLabelFont.pointSize() + 4);
m_ui->nameLabel->setFont(nameLabelFont);
m_ui->iconLabel->setPixmap(filePath()->applicationIcon().pixmap(48));
m_ui->iconLabel->setPixmap(resources()->applicationIcon().pixmap(48));
QString debugInfo = Tools::debugInfo().append("\n").append(Crypto::debugInfo());
m_ui->debugInfo->setPlainText(debugInfo);

View File

@ -24,8 +24,8 @@
#include "autotype/AutoType.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Global.h"
#include "core/Resources.h"
#include "core/Translator.h"
#include "MessageBox.h"
@ -91,8 +91,8 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
m_secUi->setupUi(m_secWidget);
m_generalUi->setupUi(m_generalWidget);
addPage(tr("General"), FilePath::instance()->icon("categories", "preferences-other"), m_generalWidget);
addPage(tr("Security"), FilePath::instance()->icon("status", "security-high"), m_secWidget);
addPage(tr("General"), Resources::instance()->icon("preferences-other"), m_generalWidget);
addPage(tr("Security"), Resources::instance()->icon("security-high"), m_secWidget);
if (!autoType()->isAvailable()) {
m_generalUi->generalSettingsTabWidget->removeTab(1);

View File

@ -21,7 +21,7 @@
#include "config-keepassx.h"
#include "core/Database.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "crypto/Crypto.h"
#include "gui/DatabaseWidget.h"

View File

@ -21,7 +21,7 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "crypto/Random.h"
#include "format/KeePass2Reader.h"
#include "gui/FileDialog.h"
@ -61,14 +61,14 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_ui->hardwareKeyLabelHelp->setIcon(filePath()->icon("actions", "system-help").pixmap(QSize(12, 12)));
m_ui->hardwareKeyLabelHelp->setIcon(resources()->icon("system-help").pixmap(QSize(12, 12)));
connect(m_ui->hardwareKeyLabelHelp, SIGNAL(clicked(bool)), SLOT(openHardwareKeyHelp()));
m_ui->keyFileLabelHelp->setIcon(filePath()->icon("actions", "system-help").pixmap(QSize(12, 12)));
m_ui->keyFileLabelHelp->setIcon(resources()->icon("system-help").pixmap(QSize(12, 12)));
connect(m_ui->keyFileLabelHelp, SIGNAL(clicked(bool)), SLOT(openKeyFileHelp()));
connect(m_ui->comboKeyFile->lineEdit(), SIGNAL(textChanged(QString)), SLOT(handleKeyFileComboEdited()));
connect(m_ui->comboKeyFile, SIGNAL(currentIndexChanged(int)), SLOT(handleKeyFileComboChanged()));
m_ui->keyFileClearIcon->setIcon(filePath()->icon("actions", "edit-clear-locationbar-rtl"));
m_ui->keyFileClearIcon->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->keyFileClearIcon->setVisible(false);
connect(m_ui->keyFileClearIcon, SIGNAL(triggered(bool)), SLOT(clearKeyFileEdit()));

View File

@ -36,11 +36,11 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/EntrySearcher.h"
#include "core/FilePath.h"
#include "core/FileWatcher.h"
#include "core/Group.h"
#include "core/Merger.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "format/KeePass2Reader.h"
#include "gui/Clipboard.h"

View File

@ -22,7 +22,7 @@
#include <QPushButton>
#include <QScrollArea>
#include "core/FilePath.h"
#include "core/Resources.h"
EditWidget::EditWidget(QWidget* parent)
: DialogyWidget(parent)

View File

@ -24,7 +24,7 @@
#include <QDir>
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "entry/EntryAttachmentsModel.h"
#include "gui/Clipboard.h"
#if defined(WITH_XC_KEESHARE)
@ -48,12 +48,12 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
m_ui->setupUi(this);
// Entry
m_ui->entryTotpButton->setIcon(filePath()->icon("actions", "chronometer"));
m_ui->entryCloseButton->setIcon(filePath()->icon("actions", "dialog-close"));
m_ui->entryTotpButton->setIcon(resources()->icon("chronometer"));
m_ui->entryCloseButton->setIcon(resources()->icon("dialog-close"));
m_ui->entryPasswordLabel->setFont(Font::fixedFont());
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_ui->toggleEntryNotesButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_ui->toggleGroupNotesButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_ui->togglePasswordButton->setIcon(resources()->onOffIcon("password-show"));
m_ui->toggleEntryNotesButton->setIcon(resources()->onOffIcon("password-show"));
m_ui->toggleGroupNotesButton->setIcon(resources()->onOffIcon("password-show"));
m_ui->entryAttachmentsWidget->setReadOnly(true);
m_ui->entryAttachmentsWidget->setButtonsVisible(false);
@ -78,7 +78,7 @@ EntryPreviewWidget::EntryPreviewWidget(QWidget* parent)
connect(&m_totpTimer, SIGNAL(timeout()), SLOT(updateTotpLabel()));
// Group
m_ui->groupCloseButton->setIcon(filePath()->icon("actions", "dialog-close"));
m_ui->groupCloseButton->setIcon(resources()->icon("dialog-close"));
connect(m_ui->groupCloseButton, SIGNAL(clicked()), SLOT(hide()));
connect(m_ui->groupTabWidget, SIGNAL(tabBarClicked(int)), SLOT(updateTabIndexes()), Qt::QueuedConnection);

View File

@ -20,7 +20,7 @@
*/
#include "KMessageWidget.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "core/Global.h"
#include <QAction>
@ -94,7 +94,7 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
QAction *closeAction = new QAction(q);
closeAction->setText(KMessageWidget::tr("&Close"));
closeAction->setToolTip(KMessageWidget::tr("Close message"));
closeAction->setIcon(FilePath::instance()->icon("actions", "message-close"));
closeAction->setIcon(Resources::instance()->icon("message-close"));
QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide()));

View File

@ -22,7 +22,7 @@
#include <QStyle>
#include <QToolButton>
#include "core/FilePath.h"
#include "core/Resources.h"
LineEdit::LineEdit(QWidget* parent)
: QLineEdit(parent)
@ -33,7 +33,7 @@ LineEdit::LineEdit(QWidget* parent)
QString iconNameDirected =
QString("edit-clear-locationbar-").append((layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr");
const auto icon = filePath()->icon("actions", iconNameDirected);
const auto icon = resources()->icon(iconNameDirected);
m_clearButton->setIcon(icon);
m_clearButton->setCursor(Qt::ArrowCursor);

View File

@ -31,9 +31,9 @@
#include "autotype/AutoType.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/InactivityTimer.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "gui/AboutDialog.h"
#include "gui/DatabaseWidget.h"
@ -103,7 +103,7 @@ public:
QIcon icon() override
{
return FilePath::instance()->icon("apps", "internet-web-browser");
return Resources::instance()->icon("internet-web-browser");
}
QWidget* createWidget() override
@ -210,7 +210,7 @@ MainWindow::MainWindow()
m_ui->settingsWidget->addSettingsPage(fdoSS);
#endif
setWindowIcon(filePath()->applicationIcon());
setWindowIcon(resources()->applicationIcon());
m_ui->globalMessageWidget->setHidden(true);
// clang-format off
connect(m_ui->globalMessageWidget, &MessageWidget::linkActivated, &MessageWidget::openHttpUrl);
@ -334,48 +334,48 @@ MainWindow::MainWindow()
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_C, this, SLOT(togglePasswordsHidden()));
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_B, this, SLOT(toggleUsernamesHidden()));
m_ui->actionDatabaseNew->setIcon(filePath()->icon("actions", "document-new"));
m_ui->actionDatabaseOpen->setIcon(filePath()->icon("actions", "document-open"));
m_ui->actionDatabaseSave->setIcon(filePath()->icon("actions", "document-save"));
m_ui->actionDatabaseSaveAs->setIcon(filePath()->icon("actions", "document-save-as"));
m_ui->actionDatabaseClose->setIcon(filePath()->icon("actions", "document-close"));
m_ui->actionReports->setIcon(filePath()->icon("actions", "help-about"));
m_ui->actionChangeDatabaseSettings->setIcon(filePath()->icon("actions", "document-edit"));
m_ui->actionChangeMasterKey->setIcon(filePath()->icon("actions", "database-change-key"));
m_ui->actionLockDatabases->setIcon(filePath()->icon("actions", "database-lock"));
m_ui->actionQuit->setIcon(filePath()->icon("actions", "application-exit"));
m_ui->actionDatabaseMerge->setIcon(filePath()->icon("actions", "database-merge"));
m_ui->actionDatabaseNew->setIcon(resources()->icon("document-new"));
m_ui->actionDatabaseOpen->setIcon(resources()->icon("document-open"));
m_ui->actionDatabaseSave->setIcon(resources()->icon("document-save"));
m_ui->actionDatabaseSaveAs->setIcon(resources()->icon("document-save-as"));
m_ui->actionDatabaseClose->setIcon(resources()->icon("document-close"));
m_ui->actionReports->setIcon(resources()->icon("help-about"));
m_ui->actionChangeDatabaseSettings->setIcon(resources()->icon("document-edit"));
m_ui->actionChangeMasterKey->setIcon(resources()->icon("database-change-key"));
m_ui->actionLockDatabases->setIcon(resources()->icon("database-lock"));
m_ui->actionQuit->setIcon(resources()->icon("application-exit"));
m_ui->actionDatabaseMerge->setIcon(resources()->icon("database-merge"));
m_ui->actionEntryNew->setIcon(filePath()->icon("actions", "entry-new"));
m_ui->actionEntryClone->setIcon(filePath()->icon("actions", "entry-clone"));
m_ui->actionEntryEdit->setIcon(filePath()->icon("actions", "entry-edit"));
m_ui->actionEntryDelete->setIcon(filePath()->icon("actions", "entry-delete"));
m_ui->actionEntryAutoType->setIcon(filePath()->icon("actions", "auto-type"));
m_ui->actionEntryCopyUsername->setIcon(filePath()->icon("actions", "username-copy"));
m_ui->actionEntryCopyPassword->setIcon(filePath()->icon("actions", "password-copy"));
m_ui->actionEntryCopyURL->setIcon(filePath()->icon("actions", "url-copy"));
m_ui->actionEntryDownloadIcon->setIcon(filePath()->icon("actions", "favicon-download"));
m_ui->actionGroupSortAsc->setIcon(filePath()->icon("actions", "sort-alphabetical-ascending"));
m_ui->actionGroupSortDesc->setIcon(filePath()->icon("actions", "sort-alphabetical-descending"));
m_ui->actionEntryNew->setIcon(resources()->icon("entry-new"));
m_ui->actionEntryClone->setIcon(resources()->icon("entry-clone"));
m_ui->actionEntryEdit->setIcon(resources()->icon("entry-edit"));
m_ui->actionEntryDelete->setIcon(resources()->icon("entry-delete"));
m_ui->actionEntryAutoType->setIcon(resources()->icon("auto-type"));
m_ui->actionEntryCopyUsername->setIcon(resources()->icon("username-copy"));
m_ui->actionEntryCopyPassword->setIcon(resources()->icon("password-copy"));
m_ui->actionEntryCopyURL->setIcon(resources()->icon("url-copy"));
m_ui->actionEntryDownloadIcon->setIcon(resources()->icon("favicon-download"));
m_ui->actionGroupSortAsc->setIcon(resources()->icon("sort-alphabetical-ascending"));
m_ui->actionGroupSortDesc->setIcon(resources()->icon("sort-alphabetical-descending"));
m_ui->actionGroupNew->setIcon(filePath()->icon("actions", "group-new"));
m_ui->actionGroupEdit->setIcon(filePath()->icon("actions", "group-edit"));
m_ui->actionGroupDelete->setIcon(filePath()->icon("actions", "group-delete"));
m_ui->actionGroupEmptyRecycleBin->setIcon(filePath()->icon("actions", "group-empty-trash"));
m_ui->actionEntryOpenUrl->setIcon(filePath()->icon("actions", "web"));
m_ui->actionGroupDownloadFavicons->setIcon(filePath()->icon("actions", "favicon-download"));
m_ui->actionGroupNew->setIcon(resources()->icon("group-new"));
m_ui->actionGroupEdit->setIcon(resources()->icon("group-edit"));
m_ui->actionGroupDelete->setIcon(resources()->icon("group-delete"));
m_ui->actionGroupEmptyRecycleBin->setIcon(resources()->icon("group-empty-trash"));
m_ui->actionEntryOpenUrl->setIcon(resources()->icon("web"));
m_ui->actionGroupDownloadFavicons->setIcon(resources()->icon("favicon-download"));
m_ui->actionSettings->setIcon(filePath()->icon("actions", "configure"));
m_ui->actionPasswordGenerator->setIcon(filePath()->icon("actions", "password-generator"));
m_ui->actionSettings->setIcon(resources()->icon("configure"));
m_ui->actionPasswordGenerator->setIcon(resources()->icon("password-generator"));
m_ui->actionAbout->setIcon(filePath()->icon("actions", "help-about"));
m_ui->actionDonate->setIcon(filePath()->icon("actions", "donate"));
m_ui->actionBugReport->setIcon(filePath()->icon("actions", "bugreport"));
m_ui->actionGettingStarted->setIcon(filePath()->icon("actions", "getting-started"));
m_ui->actionUserGuide->setIcon(filePath()->icon("actions", "user-guide"));
m_ui->actionOnlineHelp->setIcon(filePath()->icon("actions", "system-help"));
m_ui->actionKeyboardShortcuts->setIcon(filePath()->icon("actions", "keyboard-shortcuts"));
m_ui->actionCheckForUpdates->setIcon(filePath()->icon("actions", "system-software-update"));
m_ui->actionAbout->setIcon(resources()->icon("help-about"));
m_ui->actionDonate->setIcon(resources()->icon("donate"));
m_ui->actionBugReport->setIcon(resources()->icon("bugreport"));
m_ui->actionGettingStarted->setIcon(resources()->icon("getting-started"));
m_ui->actionUserGuide->setIcon(resources()->icon("user-guide"));
m_ui->actionOnlineHelp->setIcon(resources()->icon("system-help"));
m_ui->actionKeyboardShortcuts->setIcon(resources()->icon("keyboard-shortcuts"));
m_ui->actionCheckForUpdates->setIcon(resources()->icon("system-software-update"));
m_actionMultiplexer.connect(
SIGNAL(currentModeChanged(DatabaseWidget::Mode)), this, SLOT(setMenuActionState(DatabaseWidget::Mode)));
@ -894,12 +894,12 @@ void MainWindow::openBugReportUrl()
void MainWindow::openGettingStartedGuide()
{
customOpenUrl(QString("file:///%1").arg(filePath()->dataPath("docs/KeePassXC_GettingStarted.pdf")));
customOpenUrl(QString("file:///%1").arg(resources()->dataPath("docs/KeePassXC_GettingStarted.pdf")));
}
void MainWindow::openUserGuide()
{
customOpenUrl(QString("file:///%1").arg(filePath()->dataPath("docs/KeePassXC_UserGuide.pdf")));
customOpenUrl(QString("file:///%1").arg(resources()->dataPath("docs/KeePassXC_UserGuide.pdf")));
}
void MainWindow::openOnlineHelp()
@ -1138,7 +1138,7 @@ void MainWindow::updateTrayIcon()
QAction* actionToggle = new QAction(tr("Toggle window"), menu);
menu->addAction(actionToggle);
actionToggle->setIcon(filePath()->icon("apps", "keepassxc-dark", false));
actionToggle->setIcon(resources()->icon("keepassxc-dark", false));
menu->addAction(m_ui->actionLockDatabases);
@ -1158,13 +1158,13 @@ void MainWindow::updateTrayIcon()
m_trayIcon->setContextMenu(menu);
m_trayIcon->setIcon(filePath()->trayIcon());
m_trayIcon->setIcon(resources()->trayIcon());
m_trayIcon->show();
}
if (m_ui->tabWidget->hasLockableDatabases()) {
m_trayIcon->setIcon(filePath()->trayIconUnlocked());
m_trayIcon->setIcon(resources()->trayIconUnlocked());
} else {
m_trayIcon->setIcon(filePath()->trayIconLocked());
m_trayIcon->setIcon(resources()->trayIconLocked());
}
} else {
if (m_trayIcon) {
@ -1525,7 +1525,7 @@ void MainWindow::displayDesktopNotification(const QString& msg, QString title, i
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
m_trayIcon->showMessage(title, msg, filePath()->applicationIcon(), msTimeoutHint);
m_trayIcon->showMessage(title, msg, resources()->applicationIcon(), msTimeoutHint);
#else
m_trayIcon->showMessage(title, msg, QSystemTrayIcon::Information, msTimeoutHint);
#endif

View File

@ -19,7 +19,7 @@
#include "PasswordEdit.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/Application.h"
#include "gui/Font.h"
#include "gui/PasswordGeneratorWidget.h"
@ -39,12 +39,12 @@ namespace
PasswordEdit::PasswordEdit(QWidget* parent)
: QLineEdit(parent)
{
const QIcon errorIcon = filePath()->icon("status", "dialog-error");
const QIcon errorIcon = resources()->icon("dialog-error");
m_errorAction = addAction(errorIcon, QLineEdit::TrailingPosition);
m_errorAction->setVisible(false);
m_errorAction->setToolTip(tr("Passwords do not match"));
const QIcon correctIcon = filePath()->icon("actions", "dialog-ok");
const QIcon correctIcon = resources()->icon("dialog-ok");
m_correctAction = addAction(correctIcon, QLineEdit::TrailingPosition);
m_correctAction->setVisible(false);
m_correctAction->setToolTip(tr("Passwords match so far"));
@ -57,7 +57,7 @@ PasswordEdit::PasswordEdit(QWidget* parent)
setFont(passwordFont);
m_toggleVisibleAction = new QAction(
filePath()->icon("actions", "password-show-off"),
resources()->icon("password-show"),
tr("Toggle Password (%1)").arg(QKeySequence(Qt::CTRL + Qt::Key_H).toString(QKeySequence::NativeText)),
nullptr);
m_toggleVisibleAction->setCheckable(true);
@ -67,7 +67,7 @@ PasswordEdit::PasswordEdit(QWidget* parent)
connect(m_toggleVisibleAction, &QAction::triggered, this, &PasswordEdit::setShowPassword);
m_passwordGeneratorAction = new QAction(
filePath()->icon("actions", "password-generator"),
resources()->icon("password-generator"),
tr("Generate Password (%1)").arg(QKeySequence(Qt::CTRL + Qt::Key_G).toString(QKeySequence::NativeText)),
nullptr);
m_passwordGeneratorAction->setShortcut(Qt::CTRL + Qt::Key_G);
@ -105,7 +105,7 @@ void PasswordEdit::enablePasswordGenerator()
void PasswordEdit::setShowPassword(bool show)
{
setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password);
m_toggleVisibleAction->setIcon(filePath()->icon("actions", show ? "password-show-on" : "password-show-off"));
m_toggleVisibleAction->setIcon(resources()->icon(show ? "password-show-on" : "password-show-off"));
m_toggleVisibleAction->setChecked(show);
if (m_repeatPasswordEdit) {

View File

@ -24,9 +24,9 @@
#include <QLineEdit>
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/PasswordGenerator.h"
#include "core/PasswordHealth.h"
#include "core/Resources.h"
#include "gui/Application.h"
#include "gui/Clipboard.h"
@ -38,10 +38,10 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
{
m_ui->setupUi(this);
m_ui->buttonGenerate->setIcon(filePath()->icon("actions", "refresh"));
m_ui->buttonGenerate->setIcon(resources()->icon("refresh"));
m_ui->buttonGenerate->setToolTip(
tr("Regenerate password (%1)").arg(m_ui->buttonGenerate->shortcut().toString(QKeySequence::NativeText)));
m_ui->buttonCopy->setIcon(filePath()->icon("actions", "clipboard-text"));
m_ui->buttonCopy->setIcon(resources()->icon("clipboard-text"));
m_ui->buttonClose->setShortcut(Qt::Key_Escape);
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateButtonsEnabled(QString)));
@ -85,7 +85,7 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
m_ui->wordCaseComboBox->addItem(tr("UPPER CASE"), PassphraseGenerator::UPPERCASE);
m_ui->wordCaseComboBox->addItem(tr("Title Case"), PassphraseGenerator::TITLECASE);
QDir path(filePath()->wordlistPath(""));
QDir path(resources()->wordlistPath(""));
QStringList files = path.entryList(QDir::Files);
m_ui->comboBoxWordList->addItems(files);
if (files.size() > 1) {
@ -538,7 +538,7 @@ void PasswordGeneratorWidget::updateGenerator()
m_dicewareGenerator->setWordCount(m_ui->spinBoxWordCount->value());
if (!m_ui->comboBoxWordList->currentText().isEmpty()) {
QString path = filePath()->wordlistPath(m_ui->comboBoxWordList->currentText());
QString path = resources()->wordlistPath(m_ui->comboBoxWordList->currentText());
m_dicewareGenerator->setWordList(path);
}
m_dicewareGenerator->setWordSeparator(m_ui->editWordSeparator->text());

View File

@ -25,7 +25,7 @@
#include <QToolButton>
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/widgets/PopupHelpWidget.h"
SearchWidget::SearchWidget(QWidget* parent)
@ -69,13 +69,13 @@ SearchWidget::SearchWidget(QWidget* parent)
m_actionLimitGroup->setCheckable(true);
m_actionLimitGroup->setChecked(config()->get("SearchLimitGroup", false).toBool());
m_ui->searchIcon->setIcon(filePath()->icon("actions", "system-search"));
m_ui->searchIcon->setIcon(resources()->icon("system-search"));
m_ui->searchEdit->addAction(m_ui->searchIcon, QLineEdit::LeadingPosition);
m_ui->helpIcon->setIcon(filePath()->icon("actions", "system-help"));
m_ui->helpIcon->setIcon(resources()->icon("system-help"));
m_ui->searchEdit->addAction(m_ui->helpIcon, QLineEdit::TrailingPosition);
m_ui->clearIcon->setIcon(filePath()->icon("actions", "edit-clear-locationbar-rtl"));
m_ui->clearIcon->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->clearIcon->setVisible(false);
m_ui->searchEdit->addAction(m_ui->clearIcon, QLineEdit::TrailingPosition);

View File

@ -21,7 +21,7 @@
#include <QRegularExpression>
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include "gui/Font.h"
@ -30,7 +30,7 @@ const QColor URLEdit::ErrorColor = QColor(255, 125, 125);
URLEdit::URLEdit(QWidget* parent)
: QLineEdit(parent)
{
const QIcon errorIcon = filePath()->icon("status", "dialog-error");
const QIcon errorIcon = resources()->icon("dialog-error");
m_errorAction = addAction(errorIcon, QLineEdit::TrailingPosition);
m_errorAction->setVisible(false);
m_errorAction->setToolTip(tr("Invalid URL"));

View File

@ -16,7 +16,7 @@
*/
#include "UpdateCheckDialog.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "ui_UpdateCheckDialog.h"
#include "updatecheck/UpdateChecker.h"
@ -28,7 +28,7 @@ UpdateCheckDialog::UpdateCheckDialog(QWidget* parent)
setWindowFlags(Qt::Window);
setAttribute(Qt::WA_DeleteOnClose);
m_ui->iconLabel->setPixmap(filePath()->applicationIcon().pixmap(48));
m_ui->iconLabel->setPixmap(resources()->applicationIcon().pixmap(48));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
connect(UpdateChecker::instance(),

View File

@ -22,7 +22,7 @@
#include "config-keepassx.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
WelcomeWidget::WelcomeWidget(QWidget* parent)
: QWidget(parent)
@ -36,7 +36,7 @@ WelcomeWidget::WelcomeWidget(QWidget* parent)
welcomeLabelFont.setPointSize(welcomeLabelFont.pointSize() + 4);
m_ui->welcomeLabel->setFont(welcomeLabelFont);
m_ui->iconLabel->setPixmap(filePath()->applicationIcon().pixmap(64));
m_ui->iconLabel->setPixmap(resources()->applicationIcon().pixmap(64));
refreshLastDatabases();

View File

@ -34,8 +34,8 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Global.h"
#include "core/Resources.h"
#include "touchid/TouchID.h"
class DatabaseSettingsDialog::ExtraPage
@ -76,8 +76,8 @@ DatabaseSettingsDialog::DatabaseSettingsDialog(QWidget* parent)
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(save()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_ui->categoryList->addCategory(tr("General"), FilePath::instance()->icon("categories", "preferences-other"));
m_ui->categoryList->addCategory(tr("Security"), FilePath::instance()->icon("status", "security-high"));
m_ui->categoryList->addCategory(tr("General"), Resources::instance()->icon("preferences-other"));
m_ui->categoryList->addCategory(tr("Security"), Resources::instance()->icon("security-high"));
m_ui->stackedWidget->addWidget(m_generalWidget);
m_ui->stackedWidget->addWidget(m_securityTabWidget);
@ -100,8 +100,7 @@ DatabaseSettingsDialog::DatabaseSettingsDialog(QWidget* parent)
connect(m_ui->advancedSettingsToggle, SIGNAL(toggled(bool)), SLOT(toggleAdvancedMode(bool)));
#ifdef WITH_XC_BROWSER
m_ui->categoryList->addCategory(tr("Browser Integration"),
FilePath::instance()->icon("apps", "internet-web-browser"));
m_ui->categoryList->addCategory(tr("Browser Integration"), Resources::instance()->icon("internet-web-browser"));
m_ui->stackedWidget->addWidget(m_browserWidget);
#endif

View File

@ -41,8 +41,8 @@
#include "core/Config.h"
#include "core/Database.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#include "core/TimeDelta.h"
#include "core/Tools.h"
#ifdef WITH_XC_SSHAGENT
@ -138,7 +138,7 @@ EditEntryWidget::~EditEntryWidget()
void EditEntryWidget::setupMain()
{
m_mainUi->setupUi(m_mainWidget);
addPage(tr("Entry"), FilePath::instance()->icon("actions", "document-edit"), m_mainWidget);
addPage(tr("Entry"), Resources::instance()->icon("document-edit"), m_mainWidget);
m_mainUi->usernameComboBox->setEditable(true);
m_usernameCompleter->setCompletionMode(QCompleter::InlineCompletion);
@ -147,7 +147,7 @@ void EditEntryWidget::setupMain()
m_mainUi->usernameComboBox->setCompleter(m_usernameCompleter);
#ifdef WITH_XC_NETWORKING
m_mainUi->fetchFaviconButton->setIcon(filePath()->icon("actions", "favicon-download"));
m_mainUi->fetchFaviconButton->setIcon(resources()->icon("favicon-download"));
m_mainUi->fetchFaviconButton->setDisabled(true);
#else
m_mainUi->fetchFaviconButton->setVisible(false);
@ -168,7 +168,7 @@ void EditEntryWidget::setupMain()
void EditEntryWidget::setupAdvanced()
{
m_advancedUi->setupUi(m_advancedWidget);
addPage(tr("Advanced"), FilePath::instance()->icon("categories", "preferences-other"), m_advancedWidget);
addPage(tr("Advanced"), Resources::instance()->icon("preferences-other"), m_advancedWidget);
m_advancedUi->attachmentsWidget->setReadOnly(false);
m_advancedUi->attachmentsWidget->setButtonsVisible(true);
@ -198,7 +198,7 @@ void EditEntryWidget::setupAdvanced()
void EditEntryWidget::setupIcon()
{
m_iconsWidget->setShowApplyIconToButton(false);
addPage(tr("Icon"), FilePath::instance()->icon("apps", "preferences-desktop-icons"), m_iconsWidget);
addPage(tr("Icon"), Resources::instance()->icon("preferences-desktop-icons"), m_iconsWidget);
connect(this, SIGNAL(accepted()), m_iconsWidget, SLOT(abortRequests()));
connect(this, SIGNAL(rejected()), m_iconsWidget, SLOT(abortRequests()));
}
@ -211,9 +211,9 @@ void EditEntryWidget::openAutotypeHelp()
void EditEntryWidget::setupAutoType()
{
m_autoTypeUi->setupUi(m_autoTypeWidget);
addPage(tr("Auto-Type"), FilePath::instance()->icon("actions", "key-enter"), m_autoTypeWidget);
addPage(tr("Auto-Type"), Resources::instance()->icon("key-enter"), m_autoTypeWidget);
m_autoTypeUi->openHelpButton->setIcon(filePath()->icon("actions", "system-help"));
m_autoTypeUi->openHelpButton->setIcon(resources()->icon("system-help"));
m_autoTypeDefaultSequenceGroup->addButton(m_autoTypeUi->inheritSequenceButton);
m_autoTypeDefaultSequenceGroup->addButton(m_autoTypeUi->customSequenceButton);
@ -252,7 +252,7 @@ void EditEntryWidget::setupBrowser()
m_browserUi->setupUi(m_browserWidget);
if (config()->get("Browser/Enabled", false).toBool()) {
addPage(tr("Browser Integration"), FilePath::instance()->icon("apps", "internet-web-browser"), m_browserWidget);
addPage(tr("Browser Integration"), Resources::instance()->icon("internet-web-browser"), m_browserWidget);
m_additionalURLsDataModel->setEntryAttributes(m_entryAttributes);
m_browserUi->additionalURLsView->setModel(m_additionalURLsDataModel);
@ -370,13 +370,13 @@ void EditEntryWidget::updateCurrentURL()
void EditEntryWidget::setupProperties()
{
addPage(tr("Properties"), FilePath::instance()->icon("actions", "document-properties"), m_editWidgetProperties);
addPage(tr("Properties"), Resources::instance()->icon("document-properties"), m_editWidgetProperties);
}
void EditEntryWidget::setupHistory()
{
m_historyUi->setupUi(m_historyWidget);
addPage(tr("History"), FilePath::instance()->icon("actions", "view-history"), m_historyWidget);
addPage(tr("History"), Resources::instance()->icon("view-history"), m_historyWidget);
m_sortModel->setSourceModel(m_historyModel);
m_sortModel->setDynamicSortFilter(true);
@ -521,7 +521,7 @@ void EditEntryWidget::setupSSHAgent()
SIGNAL(entryAttachmentsModified()),
SLOT(updateSSHAgentAttachments()));
addPage(tr("SSH Agent"), FilePath::instance()->icon("apps", "utilities-terminal"), m_sshAgentWidget);
addPage(tr("SSH Agent"), Resources::instance()->icon("utilities-terminal"), m_sshAgentWidget);
}
void EditEntryWidget::updateSSHAgent()

View File

@ -26,10 +26,10 @@
#include "core/Config.h"
#include "core/DatabaseIcons.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "core/Global.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#ifdef Q_OS_MACOS
#include "gui/osutils/macutils/MacUtils.h"
#endif
@ -259,12 +259,12 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
return entry->iconScaledPixmap();
case Paperclip:
if (!entry->attachments()->isEmpty()) {
return filePath()->icon("actions", "paperclip");
return resources()->icon("paperclip");
}
break;
case Totp:
if (entry->hasTotp()) {
return filePath()->icon("actions", "chronometer");
return resources()->icon("chronometer");
}
break;
}
@ -336,9 +336,9 @@ QVariant EntryModel::headerData(int section, Qt::Orientation orientation, int ro
} else if (role == Qt::DecorationRole) {
switch (section) {
case Paperclip:
return filePath()->icon("actions", "paperclip");
return resources()->icon("paperclip");
case Totp:
return filePath()->icon("actions", "chronometer");
return resources()->icon("chronometer");
}
} else if (role == Qt::ToolTipRole) {
switch (section) {

View File

@ -19,7 +19,7 @@
#include "EntryURLModel.h"
#include "core/Entry.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "core/Tools.h"
#include <algorithm>
@ -27,7 +27,7 @@
EntryURLModel::EntryURLModel(QObject* parent)
: QStandardItemModel(parent)
, m_entryAttributes(nullptr)
, m_errorIcon(filePath()->icon("status", "dialog-error"))
, m_errorIcon(resources()->icon("dialog-error"))
{
}

View File

@ -20,8 +20,8 @@
#include "ui_EditGroupWidgetMain.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#include "gui/EditWidgetIcons.h"
#include "gui/EditWidgetProperties.h"
#include "gui/MessageBox.h"
@ -69,12 +69,12 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
{
m_mainUi->setupUi(m_editGroupWidgetMain);
addPage(tr("Group"), FilePath::instance()->icon("actions", "document-edit"), m_editGroupWidgetMain);
addPage(tr("Icon"), FilePath::instance()->icon("apps", "preferences-desktop-icons"), m_editGroupWidgetIcons);
addPage(tr("Group"), Resources::instance()->icon("document-edit"), m_editGroupWidgetMain);
addPage(tr("Icon"), Resources::instance()->icon("preferences-desktop-icons"), m_editGroupWidgetIcons);
#if defined(WITH_XC_KEESHARE)
addEditPage(new EditGroupPageKeeShare(this));
#endif
addPage(tr("Properties"), FilePath::instance()->icon("actions", "document-properties"), m_editWidgetProperties);
addPage(tr("Properties"), Resources::instance()->icon("document-properties"), m_editWidgetProperties);
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
connect(m_mainUi->autoTypeSequenceCustomRadio,

View File

@ -18,7 +18,7 @@
#include "PasswordEditWidget.h"
#include "ui_PasswordEditWidget.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "gui/PasswordGeneratorWidget.h"
#include "keys/CompositeKey.h"
#include "keys/PasswordKey.h"

View File

@ -18,7 +18,7 @@
#include "ReportsPageHealthcheck.h"
#include "ReportsWidgetHealthcheck.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include <QApplication>
@ -34,7 +34,7 @@ QString ReportsPageHealthcheck::name()
QIcon ReportsPageHealthcheck::icon()
{
return FilePath::instance()->icon("actions", "health");
return Resources::instance()->icon("health");
}
QWidget* ReportsPageHealthcheck::createWidget()

View File

@ -18,7 +18,7 @@
#include "ReportsPageStatistics.h"
#include "ReportsWidgetStatistics.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include <QApplication>
@ -29,7 +29,7 @@ QString ReportsPageStatistics::name()
QIcon ReportsPageStatistics::icon()
{
return FilePath::instance()->icon("actions", "statistics");
return Resources::instance()->icon("statistics");
}
QWidget* ReportsPageStatistics::createWidget()

View File

@ -20,9 +20,9 @@
#include "core/AsyncTask.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/PasswordHealth.h"
#include "core/Resources.h"
#include <QSharedPointer>
#include <QStandardItemModel>
@ -102,7 +102,7 @@ Health::Health(QSharedPointer<Database> db)
ReportsWidgetHealthcheck::ReportsWidgetHealthcheck(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::ReportsWidgetHealthcheck())
, m_errorIcon(FilePath::instance()->icon("status", "dialog-error"))
, m_errorIcon(Resources::instance()->icon("dialog-error"))
{
m_ui->setupUi(this);

View File

@ -20,10 +20,10 @@
#include "core/AsyncTask.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "core/PasswordHealth.h"
#include "core/Resources.h"
#include <QFileInfo>
#include <QHash>
@ -150,7 +150,7 @@ namespace
ReportsWidgetStatistics::ReportsWidgetStatistics(QWidget* parent)
: QWidget(parent)
, m_ui(new Ui::ReportsWidgetStatistics())
, m_errIcon(FilePath::instance()->icon("status", "dialog-error"))
, m_errIcon(Resources::instance()->icon("dialog-error"))
{
m_ui->setupUi(this);

View File

@ -4160,8 +4160,8 @@ void BaseStyle::polish(QApplication* app)
}
Q_INIT_RESOURCE(styles);
QString stylesheet;
QString stylesheet;
QFile baseStylesheetFile(":/styles/base/basestyle.qss");
if (baseStylesheetFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
stylesheet = baseStylesheetFile.readAll();

View File

@ -21,9 +21,9 @@
#include "NewDatabaseWizardPageMetaData.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Global.h"
#include "core/Group.h"
#include "core/Resources.h"
#include "format/KeePass2.h"
#include <QVBoxLayout>
@ -48,7 +48,8 @@ NewDatabaseWizard::NewDatabaseWizard(QWidget* parent)
setWindowTitle(tr("Create a new KeePassXC database..."));
setPixmap(QWizard::BackgroundPixmap, QPixmap(filePath()->dataPath("wizard/background-pixmap.png")));
Q_INIT_RESOURCE(wizard);
setPixmap(QWizard::BackgroundPixmap, QPixmap(":/wizard/background-pixmap.png"));
}
NewDatabaseWizard::~NewDatabaseWizard()

View File

@ -18,8 +18,8 @@
#include "DatabaseSettingsPageKeeShare.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/Resources.h"
#include "keeshare/DatabaseSettingsWidgetKeeShare.h"
#include "keeshare/KeeShare.h"
@ -32,7 +32,7 @@ QString DatabaseSettingsPageKeeShare::name()
QIcon DatabaseSettingsPageKeeShare::icon()
{
return FilePath::instance()->icon("apps", "preferences-system-network-sharing");
return Resources::instance()->icon("preferences-system-network-sharing");
}
QWidget* DatabaseSettingsPageKeeShare::createWidget()

View File

@ -18,8 +18,8 @@
#include "SettingsPageKeeShare.h"
#include "core/Database.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/Resources.h"
#include "gui/DatabaseTabWidget.h"
#include "gui/MessageWidget.h"
#include "keeshare/KeeShare.h"
@ -39,7 +39,7 @@ QString SettingsPageKeeShare::name()
QIcon SettingsPageKeeShare::icon()
{
return FilePath::instance()->icon("apps", "preferences-system-network-sharing");
return Resources::instance()->icon("preferences-system-network-sharing");
}
QWidget* SettingsPageKeeShare::createWidget()

View File

@ -17,7 +17,7 @@
#include "EditGroupPageKeeShare.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "keeshare/group/EditGroupWidgetKeeShare.h"
#include <QApplication>
@ -34,7 +34,7 @@ QString EditGroupPageKeeShare::name()
QIcon EditGroupPageKeeShare::icon()
{
return FilePath::instance()->icon("apps", "preferences-system-network-sharing");
return Resources::instance()->icon("preferences-system-network-sharing");
}
QWidget* EditGroupPageKeeShare::createWidget()

View File

@ -20,9 +20,9 @@
#include "core/Config.h"
#include "core/CustomData.h"
#include "core/FilePath.h"
#include "core/Group.h"
#include "core/Metadata.h"
#include "core/Resources.h"
#include "crypto/ssh/OpenSSHKey.h"
#include "gui/FileDialog.h"
#include "keeshare/KeeShare.h"

View File

@ -18,7 +18,7 @@
#include "AgentSettingsPage.h"
#include "AgentSettingsWidget.h"
#include "core/FilePath.h"
#include "core/Resources.h"
AgentSettingsPage::AgentSettingsPage(DatabaseTabWidget* tabWidget)
{
@ -36,7 +36,7 @@ QString AgentSettingsPage::name()
QIcon AgentSettingsPage::icon()
{
return FilePath::instance()->icon("apps", "utilities-terminal");
return Resources::instance()->icon("utilities-terminal");
}
QWidget* AgentSettingsPage::createWidget()

View File

@ -25,7 +25,7 @@
#include "autotype/AutoTypePlatformPlugin.h"
#include "autotype/test/AutoTypeTestInterface.h"
#include "core/Config.h"
#include "core/FilePath.h"
#include "core/Resources.h"
#include "crypto/Crypto.h"
#include "gui/MessageBox.h"
@ -39,7 +39,7 @@ void TestAutoType::initTestCase()
config()->set("security/autotypeask", false);
AutoType::createTestInstance();
QPluginLoader loader(filePath()->pluginPath("keepassx-autotype-test"));
QPluginLoader loader(resources()->pluginPath("keepassx-autotype-test"));
loader.setLoadHints(QLibrary::ResolveAllSymbolsHint);
QVERIFY(loader.instance());

View File

@ -94,6 +94,7 @@ map() {
entry-edit) echo comment-edit-outline ;;
entry-new) echo comment-plus-outline ;;
favicon-download) echo download ;;
freedesktop) echo freedesktop-dot-org ;;
getting-started) echo lightbulb-on-outline ;;
group-delete) echo folder-remove-outline ;;
group-edit) echo folder-edit-outline ;;