Changeset View
Changeset View
Standalone View
Standalone View
kmymoney/kmymoney.cpp
Show First 20 Lines • Show All 1154 Lines • ▼ Show 20 Line(s) | 1145 | #endif | |||
---|---|---|---|---|---|
1155 | QFrame* frame = new QFrame; | 1155 | QFrame* frame = new QFrame; | ||
1156 | frame->setFrameStyle(QFrame::NoFrame); | 1156 | frame->setFrameStyle(QFrame::NoFrame); | ||
1157 | // values for margin (11) and spacing(6) taken from KDialog implementation | 1157 | // values for margin (11) and spacing(6) taken from KDialog implementation | ||
1158 | QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, frame); | 1158 | QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom, frame); | ||
1159 | layout->setContentsMargins(2, 2, 2, 2); | 1159 | layout->setContentsMargins(2, 2, 2, 2); | ||
1160 | layout->setSpacing(6); | 1160 | layout->setSpacing(6); | ||
1161 | 1161 | | |||
1162 | { | 1162 | { | ||
1163 | #ifndef IS_APPIMAGE | ||||
1163 | // find where our custom icons were installed based on an custom icon that we know should exist after installation | 1164 | // find where our custom icons were installed based on an custom icon that we know should exist after installation | ||
1164 | const auto customIconRelativePath = QString(QStringLiteral("icons/hicolor/16x16/actions/account-add.png")); | 1165 | const auto customIconRelativePath = QString(QStringLiteral("icons/hicolor/16x16/actions/account-add.png")); | ||
1165 | auto customIconAbsolutePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, customIconRelativePath); | 1166 | auto customIconAbsolutePath = QStandardPaths::locate(QStandardPaths::AppDataLocation, customIconRelativePath); | ||
1167 | if (customIconAbsolutePath.isEmpty()) { | ||||
1168 | qWarning("Custom icons were not found in any of the following QStandardPaths::AppDataLocation:"); | ||||
1169 | for (const auto &standardPath : QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)) | ||||
1170 | qWarning() << standardPath; | ||||
1171 | } | ||||
1172 | #else | ||||
1173 | // according to https://docs.appimage.org/packaging-guide/ingredients.html#open-source-applications | ||||
1174 | // QStandardPaths::AppDataLocation is unreliable on AppImages, so apply workaround here in case we fail to find icons | ||||
1175 | const auto appImageAppDataLocation = QCoreApplication::applicationDirPath() + QLatin1String("/../share/kmymoney/") + customIconRelativePath; | ||||
1176 | if (QFile::exists(appImageAppDataLocation )) { | ||||
1177 | customIconAbsolutePath = appImageAppDataLocation ; | ||||
1178 | } else { | ||||
1179 | qWarning("Custom icons were not found in the following location:"); | ||||
1180 | qWarning() << appImageAppDataLocation ; | ||||
1181 | } | ||||
1182 | #endif | ||||
1166 | 1183 | | |||
1167 | // add our custom icons path to icons search path | 1184 | // add our custom icons path to icons search path | ||
1168 | if (!customIconAbsolutePath.isEmpty()) { | 1185 | if (!customIconAbsolutePath.isEmpty()) { | ||
1169 | customIconAbsolutePath.chop(customIconRelativePath.length()); | 1186 | customIconAbsolutePath.chop(customIconRelativePath.length()); | ||
1170 | customIconAbsolutePath.append(QLatin1String("icons")); | 1187 | customIconAbsolutePath.append(QLatin1String("icons")); | ||
1171 | auto paths = QIcon::themeSearchPaths(); | 1188 | auto paths = QIcon::themeSearchPaths(); | ||
1172 | paths.append(customIconAbsolutePath); | 1189 | paths.append(customIconAbsolutePath); | ||
1173 | QIcon::setThemeSearchPaths(paths); | 1190 | QIcon::setThemeSearchPaths(paths); | ||
1174 | } else { | | |||
1175 | qWarning("Custom icons were not found in any of the following QStandardPaths::AppDataLocation:"); | | |||
1176 | for (const auto &standardPath : QStandardPaths::standardLocations(QStandardPaths::AppDataLocation)) | | |||
1177 | qWarning() << standardPath; | | |||
1178 | } | 1191 | } | ||
1179 | 1192 | | |||
1180 | #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) | 1193 | #if defined(Q_OS_WIN) || defined(Q_OS_MACOS) | ||
1181 | QString themeName = QLatin1Literal("system"); // using QIcon::setThemeName on Craft build system causes icons to disappear | 1194 | QString themeName = QLatin1Literal("system"); // using QIcon::setThemeName on Craft build system causes icons to disappear | ||
1182 | #else | 1195 | #else | ||
1183 | QString themeName = KMyMoneySettings::iconsTheme(); // get theme user wants | 1196 | QString themeName = KMyMoneySettings::iconsTheme(); // get theme user wants | ||
1184 | #endif | 1197 | #endif | ||
1185 | if (!themeName.isEmpty() && themeName != QLatin1Literal("system")) // if it isn't default theme then set it | 1198 | if (!themeName.isEmpty() && themeName != QLatin1Literal("system")) // if it isn't default theme then set it | ||
▲ Show 20 Lines • Show All 1730 Lines • ▼ Show 20 Line(s) | 2926 | if (file.open(QFile::WriteOnly | QFile::Append | QFile::Text)) { | |||
2916 | file.close(); | 2929 | file.close(); | ||
2917 | } | 2930 | } | ||
2918 | } | 2931 | } | ||
2919 | } | 2932 | } | ||
2920 | 2933 | | |||
2921 | void KMyMoneyApp::Private::setThemedCSS() | 2934 | void KMyMoneyApp::Private::setThemedCSS() | ||
2922 | { | 2935 | { | ||
2923 | const QStringList CSSnames {QStringLiteral("kmymoney.css"), QStringLiteral("welcome.css")}; | 2936 | const QStringList CSSnames {QStringLiteral("kmymoney.css"), QStringLiteral("welcome.css")}; | ||
2924 | | ||||
2925 | const QString rcDir("/html/"); | 2937 | const QString rcDir("/html/"); | ||
2926 | const QStringList defaultCSSDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, rcDir, QStandardPaths::LocateDirectory); | 2938 | QStringList defaultCSSDirs; | ||
2939 | #ifndef IS_APPIMAGE | ||||
2940 | defaultCSSDirs = QStandardPaths::locateAll(QStandardPaths::AppDataLocation, rcDir, QStandardPaths::LocateDirectory); | ||||
2941 | #else | ||||
2942 | // according to https://docs.appimage.org/packaging-guide/ingredients.html#open-source-applications | ||||
2943 | // QStandardPaths::AppDataLocation is unreliable on AppImages, so apply workaround here in case we fail to find icons | ||||
2944 | const auto appImageAppDataLocation = QCoreApplication::applicationDirPath() + QLatin1String("/../share/kmymoney") + rcDir; | ||||
2945 | if (QFile::exists(appImageAppDataLocation + CSSnames.first())) { | ||||
2946 | defaultCSSDirs.append(appImageAppDataLocation); | ||||
2947 | } else { | ||||
2948 | qWarning("CSS file was not found in the following location:"); | ||||
2949 | qWarning() << appImageAppDataLocation; | ||||
2950 | } | ||||
2951 | #endif | ||||
2927 | 2952 | | |||
2928 | // scan the list of directories to find the ones that really | 2953 | // scan the list of directories to find the ones that really | ||
2929 | // contains all files we look for | 2954 | // contains all files we look for | ||
2930 | QString defaultCSSDir; | 2955 | QString defaultCSSDir; | ||
2931 | foreach (const auto dir, defaultCSSDirs) { | 2956 | foreach (const auto dir, defaultCSSDirs) { | ||
2932 | defaultCSSDir = dir; | 2957 | defaultCSSDir = dir; | ||
2933 | foreach (const auto CSSname, CSSnames) { | 2958 | foreach (const auto CSSname, CSSnames) { | ||
2934 | QFileInfo fileInfo(defaultCSSDir + CSSname); | 2959 | QFileInfo fileInfo(defaultCSSDir + CSSname); | ||
▲ Show 20 Lines • Show All 768 Lines • Show Last 20 Lines |