Compare commits

..

No commits in common. "master" and "license" have entirely different histories.

14 changed files with 79 additions and 140 deletions

View File

@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.5)
project(squawk VERSION 0.2.3 LANGUAGES CXX) project(squawk VERSION 0.2.3 LANGUAGES CXX)
cmake_policy(SET CMP0076 NEW) cmake_policy(SET CMP0076 NEW)
cmake_policy(SET CMP0077 NEW) cmake_policy(SET CMP0077 NEW)
cmake_policy(SET CMP0079 NEW) cmake_policy(SET CMP0079 NEW)
cmake_policy(SET CMP0167 NEW)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(QT_VERSION_MAJOR 5) set(QT_VERSION_MAJOR 5)
@ -34,8 +33,7 @@ option(SYSTEM_LMDBAL "Use system lmdbal lib" ON)
option(WITH_KWALLET "Build KWallet support module" ON) option(WITH_KWALLET "Build KWallet support module" ON)
option(WITH_KIO "Build KIO support module" ON) option(WITH_KIO "Build KIO support module" ON)
option(WITH_KCONFIG "Build KConfig support module" ON) option(WITH_KCONFIG "Build KConfig support module" ON)
option(WITH_OMEMO "Build OMEMO support module" OFF) #it should be off by default untill I sort the problems out option(WITH_OMEMO "Build OMEMO support module" OFF) #it should be off by default untill I sourt the problems out
option(WITH_SIMPLE_CRYPT "Builds with SimpleCrypt to obfuscate password" ON)
# Dependencies # Dependencies
## Qt ## Qt
@ -177,18 +175,13 @@ target_link_libraries(squawk
Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Xml
LMDBAL::LMDBAL LMDBAL::LMDBAL
QXmpp::QXmpp QXmpp::QXmpp
simpleCrypt
) )
if (WITH_OMEMO) if (WITH_OMEMO)
target_link_libraries(squawk PRIVATE QXmpp::Omemo) target_link_libraries(squawk PRIVATE QXmpp::Omemo)
endif () endif ()
if (WITH_SIMPLE_CRYPT)
target_compile_definitions(squawk PRIVATE WITH_SIMPLE_CRYPT)
add_subdirectory(external/simpleCrypt)
target_link_libraries(squawk PRIVATE simpleCrypt)
endif ()
## Link thread libraries on Linux ## Link thread libraries on Linux
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
@ -218,13 +211,9 @@ if(CMAKE_COMPILER_IS_GNUCXX)
target_compile_options(squawk PRIVATE ${COMPILE_OPTIONS}) target_compile_options(squawk PRIVATE ${COMPILE_OPTIONS})
endif(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX)
# I am not really sure about this solution
# This should enable plugins to be found in path like /usr/lib/squawk instead of just /usr/lib
set(PLUGIN_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/squawk")
add_compile_definitions(PLUGIN_PATH="${PLUGIN_PATH}")
add_subdirectory(main) add_subdirectory(main)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(external/simpleCrypt)
add_subdirectory(packaging) add_subdirectory(packaging)
add_subdirectory(plugins) add_subdirectory(plugins)
add_subdirectory(resources) add_subdirectory(resources)

View File

@ -4,7 +4,7 @@
[![AUR version](https://img.shields.io/aur/version/squawk?style=flat-square)](https://aur.archlinux.org/packages/squawk/) [![AUR version](https://img.shields.io/aur/version/squawk?style=flat-square)](https://aur.archlinux.org/packages/squawk/)
[![Liberapay patrons](https://img.shields.io/liberapay/patrons/macaw.me?logo=liberapay&style=flat-square)](https://liberapay.com/macaw.me) [![Liberapay patrons](https://img.shields.io/liberapay/patrons/macaw.me?logo=liberapay&style=flat-square)](https://liberapay.com/macaw.me)
![Squawk screenshot](https://macaw.me/projects/squawk/0.2.2.png) ![Squawk screenshot](https://macaw.me/images/squawk/0.2.2.png)
### Prerequisites ### Prerequisites

View File

@ -28,8 +28,7 @@ Core::PSE::KWallet::CreateFolder Core::PSE::KWallet::createFolder = 0;
Core::PSE::KWallet::SetFolder Core::PSE::KWallet::setFolder = 0; Core::PSE::KWallet::SetFolder Core::PSE::KWallet::setFolder = 0;
Core::PSE::KWallet::SupportState Core::PSE::KWallet::sState = Core::PSE::KWallet::initial; Core::PSE::KWallet::SupportState Core::PSE::KWallet::sState = Core::PSE::KWallet::initial;
QLibrary Core::PSE::KWallet::lib("kwalletWrapper");
QLibrary Core::PSE::KWallet::lib(QString("%1/kwalletWrapper").arg(PLUGIN_PATH));
Core::PSE::KWallet::KWallet(): Core::PSE::KWallet::KWallet():
QObject(), QObject(),

View File

@ -1,4 +1,4 @@
add_library(kwalletWrapper SHARED kwallet.cpp) add_library(kwalletWrapper SHARED kwallet.cpp)
target_link_libraries(kwalletWrapper PRIVATE KF5::Wallet) target_link_libraries(kwalletWrapper PRIVATE KF5::Wallet)
install(TARGETS kwalletWrapper LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/squawk) install(TARGETS kwalletWrapper LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@ -22,10 +22,6 @@
#include <QDir> #include <QDir>
#include <QStandardPaths> #include <QStandardPaths>
#ifdef WITH_SIMPLE_CRYPT
#include "external/simpleCrypt/simplecrypt.h"
#endif
Core::Squawk::Squawk(QObject* parent): Core::Squawk::Squawk(QObject* parent):
QObject(parent), QObject(parent),
accounts(), accounts(),
@ -75,6 +71,7 @@ void Core::Squawk::stop() {
QSettings settings; QSettings settings;
settings.beginGroup("core"); settings.beginGroup("core");
settings.beginWriteArray("accounts"); settings.beginWriteArray("accounts");
SimpleCrypt crypto(passwordHash);
for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) { for (std::deque<Account*>::size_type i = 0; i < accounts.size(); ++i) {
settings.setArrayIndex(i); settings.setArrayIndex(i);
Account* acc = accounts[i]; Account* acc = accounts[i];
@ -87,13 +84,7 @@ void Core::Squawk::stop() {
password = acc->getPassword(); password = acc->getPassword();
break; break;
case Shared::AccountPassword::jammed: case Shared::AccountPassword::jammed:
#ifdef WITH_SIMPLE_CRYPT2 password = crypto.encryptToString(acc->getPassword());
password = SimpleCrypt(passwordHash).encryptToString(acc->getPassword());
#else
qDebug() << "The password for account" << acc->getName() << "is set to be jammed, but Squawk was compiled without SimpleCrypt support";
qDebug("Can not encode password, setting this account to always ask password mode");
ap = Shared::AccountPassword::alwaysAsk;
#endif
break; break;
default: default:
break; break;
@ -706,24 +697,17 @@ void Core::Squawk::readSettings() {
settings.value("passwordType", static_cast<int>(Shared::AccountPassword::plain)).toInt() settings.value("passwordType", static_cast<int>(Shared::AccountPassword::plain)).toInt()
); );
QString name = settings.value("name").toString();
QString password = settings.value("password", "").toString(); QString password = settings.value("password", "").toString();
if (passwordType == Shared::AccountPassword::jammed) { if (passwordType == Shared::AccountPassword::jammed) {
#ifdef WITH_SIMPLE_CRYPT
SimpleCrypt crypto(passwordHash); SimpleCrypt crypto(passwordHash);
password = crypto.decryptToString(password); password = crypto.decryptToString(password);
#else
qDebug() << "The password for account" << name << "is jammed, but Squawk was compiled without SimpleCrypt support";
qDebug("Can not decode password, setting this account to always ask password mode");
passwordType = Shared::AccountPassword::alwaysAsk;
#endif
} }
addAccount( addAccount(
settings.value("login").toString(), settings.value("login").toString(),
settings.value("server").toString(), settings.value("server").toString(),
password, password,
name, settings.value("name").toString(),
settings.value("resource").toString(), settings.value("resource").toString(),
settings.value("active").toBool(), settings.value("active").toBool(),
passwordType passwordType

View File

@ -33,6 +33,7 @@
#include "shared/global.h" #include "shared/global.h"
#include "shared/info.h" #include "shared/info.h"
#include "shared/clientinfo.h" #include "shared/clientinfo.h"
#include "external/simpleCrypt/simplecrypt.h"
#include <core/components/clientcache.h> #include <core/components/clientcache.h>
#include <core/components/networkaccess.h> #include <core/components/networkaccess.h>
@ -41,8 +42,10 @@
#include "passwordStorageEngines/kwallet.h" #include "passwordStorageEngines/kwallet.h"
#endif #endif
namespace Core { namespace Core
class Squawk : public QObject { {
class Squawk : public QObject
{
Q_OBJECT Q_OBJECT
public: public:

View File

@ -58,7 +58,6 @@ Root::~Root() {
delete gui; delete gui;
if (core != nullptr) if (core != nullptr)
delete core; delete core;
delete coreThread; delete coreThread;
} }
delete global; delete global;
@ -73,13 +72,13 @@ void Root::initializeTranslation() {
bool found = false; bool found = false;
for (QString share : shares) { for (QString share : shares) {
found = currentTranslator.load(QLocale(), QLatin1String("squawk"), ".", share + "/l10n"); found = currentTranslator.load(QLocale(), QLatin1String("squawk"), ".", share + "/l10n");
if (found) if (found) {
break; break;
} }
}
if (!found) if (!found) {
currentTranslator.load(QLocale(), QLatin1String("squawk"), ".", QCoreApplication::applicationDirPath()); currentTranslator.load(QLocale(), QLatin1String("squawk"), ".", QCoreApplication::applicationDirPath());
}
installTranslator(&currentTranslator); installTranslator(&currentTranslator);
} }
@ -95,18 +94,20 @@ bool Root::initializeSettings() {
QVariant vs = settings.value("style"); QVariant vs = settings.value("style");
if (vs.isValid()) { if (vs.isValid()) {
QString style = vs.toString().toLower(); QString style = vs.toString().toLower();
if (style != "system") if (style != "system") {
Shared::Global::setStyle(style); Shared::Global::setStyle(style);
} }
}
if (Shared::Global::supported("colorSchemeTools")) { if (Shared::Global::supported("colorSchemeTools")) {
QVariant vt = settings.value("theme"); QVariant vt = settings.value("theme");
if (vt.isValid()) { if (vt.isValid()) {
QString theme = vt.toString(); QString theme = vt.toString();
if (theme.toLower() != "system") if (theme.toLower() != "system") {
Shared::Global::setTheme(theme); Shared::Global::setTheme(theme);
} }
} }
}
QString path = Shared::downloadsPathCheck(); QString path = Shared::downloadsPathCheck();
if (path.size() > 0) { if (path.size() > 0) {

View File

@ -1,7 +1,3 @@
configure_file(squawk.desktop squawk.desktop COPYONLY) configure_file(squawk.desktop squawk.desktop COPYONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/squawk.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
configure_file(macaw.me.squawk.appdata.xml macaw.me.squawk.appdata.xml COPYONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/macaw.me.squawk.appdata.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:its="http://www.w3.org/2005/11/its" xmlns="https://specifications.freedesktop.org/metainfo/1.0" type="desktop-application">
<id>macaw.me.squawk</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license>
<name>Squawk</name>
<summary>Desktop Qt based XMPP messenger</summary>
<description>
<p>
Squawk is a lightweight XMPP desktop messenger.
The primary objective of this project is to offer
you a fast and user-friendly messaging experience
that closely aligns with your systems style, while
also minimizing resource consumption.
</p>
<p>
Squawk is still at a very early stage and might not suit
everyone but you are welcome to try it out.
</p>
</description>
<launchable type="desktop-id">macaw.me.squawk.desktop</launchable>
<screenshots>
<screenshot type="default">
<image>https://macaw.me/projects/squawk/0.2.2.png</image>
<caption>View XMPP contacts and conversations</caption>
</screenshot>
</screenshots>
<url type="homepage">https://macaw.me/projects/squawk/</url>
<provides>
<binary>squawk</binary>
</provides>
<update_contact>blue@macaw.me</update_contact>
</component>

View File

@ -2,7 +2,7 @@ if (WITH_KIO)
add_library(openFileManagerWindowJob SHARED openfilemanagerwindowjob.cpp) add_library(openFileManagerWindowJob SHARED openfilemanagerwindowjob.cpp)
target_link_libraries(openFileManagerWindowJob PRIVATE KF5::KIOWidgets) target_link_libraries(openFileManagerWindowJob PRIVATE KF5::KIOWidgets)
install(TARGETS openFileManagerWindowJob LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/squawk) install(TARGETS openFileManagerWindowJob LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif () endif ()
if (WITH_KCONFIG) if (WITH_KCONFIG)
@ -10,5 +10,5 @@ if (WITH_KCONFIG)
target_link_libraries(colorSchemeTools PRIVATE KF5::ConfigCore) target_link_libraries(colorSchemeTools PRIVATE KF5::ConfigCore)
target_link_libraries(colorSchemeTools PRIVATE KF5::ConfigWidgets) target_link_libraries(colorSchemeTools PRIVATE KF5::ConfigWidgets)
install(TARGETS colorSchemeTools LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/squawk) install(TARGETS colorSchemeTools LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif() endif()

View File

@ -3,8 +3,11 @@ target_sources(squawk PRIVATE resources.qrc)
configure_file(images/logo.svg squawk.svg COPYONLY) configure_file(images/logo.svg squawk.svg COPYONLY)
configure_file(squawk.rc squawk.rc COPYONLY) configure_file(squawk.rc squawk.rc COPYONLY)
set(CONVERT_BIN magick) if(WIN32)
set(CONVERT_BIN magick convert)
else(WIN32)
set(CONVERT_BIN convert)
endif(WIN32)
execute_process(COMMAND ${CONVERT_BIN} -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND ${CONVERT_BIN} -background none -size 48x48 squawk.svg squawk48.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND ${CONVERT_BIN} -background none -size 64x64 squawk.svg squawk64.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND ${CONVERT_BIN} -background none -size 128x128 squawk.svg squawk128.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
@ -19,16 +22,16 @@ endif (WIN32)
if (APPLE) if (APPLE)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/icns.iconset")
execute_process(COMMAND ${CONVERT_BIN} -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -size 16x16 squawk.svg icns.iconset/icon_16x16.png WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_16x16@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !32x32 squawk.svg "icns.iconset/icon_32x32.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !64x64 squawk.svg "icns.iconset/icon_32x32@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !128x128 squawk.svg "icns.iconset/icon_128x128.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !128x128 squawk.svg "icns.iconset/icon_128x128.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !256x256 squawk.svg "icns.iconset/icon_128x128@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_128x128@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !256x256 squawk.svg "icns.iconset/icon_256x256.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !256x256 squawk.svg "icns.iconset/icon_256x256.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !512x512 squawk.svg "icns.iconset/icon_256x256@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_256x256@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !512x512 squawk.svg "icns.iconset/icon_512x512.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CONVERT_BIN} -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND convert -background none -resize !1024x1024 squawk.svg "icns.iconset/icon_512x512@2x.png" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) execute_process(COMMAND iconutil -c icns "icns.iconset" -o "squawk.icns" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(MACOSX_BUNDLE_ICON_FILE squawk.icns) set(MACOSX_BUNDLE_ICON_FILE squawk.icns)
set(MACOSX_BUNDLE_ICON_FILE ${MACOSX_BUNDLE_ICON_FILE} PARENT_SCOPE) set(MACOSX_BUNDLE_ICON_FILE ${MACOSX_BUNDLE_ICON_FILE} PARENT_SCOPE)

View File

@ -21,13 +21,6 @@
#include "enums.h" #include "enums.h"
#include "ui/models/roster.h" #include "ui/models/roster.h"
#ifdef WITH_SIMPLE_CRYPT
#define SIMPLE_CRYPT_ENABLED true
#else
#define SIMPLE_CRYPT_ENABLED false
#endif
#ifdef WITH_OMEMO #ifdef WITH_OMEMO
constexpr bool OMEMO_SUPPORT = true; constexpr bool OMEMO_SUPPORT = true;
#else #else
@ -43,11 +36,12 @@ QFont getFont (QFontDatabase::SystemFont type, bool bold = false, bool italic =
if (factor != 1.0) { if (factor != 1.0) {
float ps = font.pointSizeF(); float ps = font.pointSizeF();
if (ps != -1) if (ps != -1) {
font.setPointSizeF(ps * factor); font.setPointSizeF(ps * factor);
else } else {
font.setPointSize(font.pointSize() * factor); font.setPointSize(font.pointSize() * factor);
} }
}
return font; return font;
} }
@ -56,12 +50,12 @@ Shared::Global* Shared::Global::instance = 0;
const std::set<QString> Shared::Global::supportedImagesExts = {"png", "jpg", "webp", "jpeg", "gif", "svg"}; const std::set<QString> Shared::Global::supportedImagesExts = {"png", "jpg", "webp", "jpeg", "gif", "svg"};
#ifdef WITH_KIO #ifdef WITH_KIO
QLibrary Shared::Global::openFileManagerWindowJob(QString("%1/openFileManagerWindowJob").arg(PLUGIN_PATH)); QLibrary Shared::Global::openFileManagerWindowJob("openFileManagerWindowJob");
Shared::Global::HighlightInFileManager Shared::Global::hfm = 0; Shared::Global::HighlightInFileManager Shared::Global::hfm = 0;
#endif #endif
#ifdef WITH_KCONFIG #ifdef WITH_KCONFIG
QLibrary Shared::Global::colorSchemeTools(QString("%1/colorSchemeTools").arg(PLUGIN_PATH)); QLibrary Shared::Global::colorSchemeTools("colorSchemeTools");
Shared::Global::CreatePreview Shared::Global::createPreview = 0; Shared::Global::CreatePreview Shared::Global::createPreview = 0;
Shared::Global::DeletePreview Shared::Global::deletePreview = 0; Shared::Global::DeletePreview Shared::Global::deletePreview = 0;
Shared::Global::ColorSchemeName Shared::Global::colorSchemeName = 0; Shared::Global::ColorSchemeName Shared::Global::colorSchemeName = 0;
@ -154,11 +148,10 @@ Shared::Global::Global():
smallFontMetrics(smallFont), smallFontMetrics(smallFont),
headerFontMetrics(headerFont), headerFontMetrics(headerFont),
titleFontMetrics(titleFont), titleFontMetrics(titleFont),
optionalFeatures({ pluginSupport({
{"KWallet", false}, {"KWallet", false},
{"openFileManagerWindowJob", false}, {"openFileManagerWindowJob", false},
{"colorSchemeTools", false}, {"colorSchemeTools", false}
{"simpleCryptJammedPassword", SIMPLE_CRYPT_ENABLED}
}), }),
fileCache() fileCache()
{ {
@ -204,7 +197,8 @@ Shared::Global::Global():
static const QSize defaultIconFileInfoHeight(50, 50); static const QSize defaultIconFileInfoHeight(50, 50);
Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path) { Shared::Global::FileInfo Shared::Global::getFileInfo(const QString& path)
{
std::map<QString, FileInfo>::const_iterator itr = instance->fileCache.find(path); std::map<QString, FileInfo>::const_iterator itr = instance->fileCache.find(path);
if (itr == instance->fileCache.end()) { if (itr == instance->fileCache.end()) {
QMimeDatabase db; QMimeDatabase db;
@ -281,17 +275,17 @@ QString Shared::Global::getName(EncryptionProtocol ep) {
} }
void Shared::Global::setSupported(const QString& pluginName, bool support) { void Shared::Global::setSupported(const QString& pluginName, bool support) {
std::map<QString, bool>::iterator itr = instance->optionalFeatures.find(pluginName); std::map<QString, bool>::iterator itr = instance->pluginSupport.find(pluginName);
if (itr != instance->optionalFeatures.end()) { if (itr != instance->pluginSupport.end()) {
itr->second = support; itr->second = support;
} }
} }
bool Shared::Global::supported(const QString& pluginName) { bool Shared::Global::supported(const QString& pluginName) {
std::map<QString, bool>::iterator itr = instance->optionalFeatures.find(pluginName); std::map<QString, bool>::iterator itr = instance->pluginSupport.find(pluginName);
if (itr != instance->optionalFeatures.end()) if (itr != instance->pluginSupport.end()) {
return itr->second; return itr->second;
}
return false; return false;
} }
@ -331,10 +325,11 @@ void Shared::Global::highlightInFileManager(const QString& path)
QString output = proc.readLine().simplified(); QString output = proc.readLine().simplified();
QString folder; QString folder;
if (info.isDir()) if (info.isDir()) {
folder = info.canonicalFilePath(); folder = info.canonicalFilePath();
else } else {
folder = info.canonicalPath(); folder = info.canonicalPath();
}
if (output.contains(dolphinReg)) { if (output.contains(dolphinReg)) {
//there is a bug on current (21.04.0) dolphin, it works correct only if you already have dolphin launched //there is a bug on current (21.04.0) dolphin, it works correct only if you already have dolphin launched
@ -394,19 +389,20 @@ void Shared::Global::setTheme(const QString& path) {
} }
void Shared::Global::setStyle(const QString& style) { void Shared::Global::setStyle(const QString& style) {
if (style.toLower() == "system") if (style.toLower() == "system") {
QApplication::setStyle(getInstance()->defaultSystemStyle); QApplication::setStyle(getInstance()->defaultSystemStyle);
else } else {
QApplication::setStyle(style); QApplication::setStyle(style);
} }
}
#define FROM_INT_INPL(Enum) \ #define FROM_INT_INPL(Enum) \
template<> \ template<> \
Enum Shared::Global::fromInt(int src) \ Enum Shared::Global::fromInt(int src) \
{ \ { \
if (src < static_cast<int>(Enum##Lowest) || src > static_cast<int>(Enum##Highest)) \ if (src < static_cast<int>(Enum##Lowest) || src > static_cast<int>(Enum##Highest)) { \
throw EnumOutOfRange(#Enum); \ throw EnumOutOfRange(#Enum); \
\ } \
return static_cast<Enum>(src); \ return static_cast<Enum>(src); \
} \ } \
template<> \ template<> \

View File

@ -135,7 +135,7 @@ namespace Shared {
private: private:
static Global* instance; static Global* instance;
std::map<QString, bool> optionalFeatures; std::map<QString, bool> pluginSupport;
std::map<QString, FileInfo> fileCache; std::map<QString, FileInfo> fileCache;
#ifdef WITH_KIO #ifdef WITH_KIO

View File

@ -26,7 +26,6 @@ Account::Account():
m_ui->setupUi(this); m_ui->setupUi(this);
connect(m_ui->passwordType, qOverload<int>(&QComboBox::currentIndexChanged), this, &Account::onComboboxChange); connect(m_ui->passwordType, qOverload<int>(&QComboBox::currentIndexChanged), this, &Account::onComboboxChange);
QStandardItemModel *model = static_cast<QStandardItemModel*>(m_ui->passwordType->model());
for (int i = static_cast<int>(Shared::AccountPasswordLowest); i < static_cast<int>(Shared::AccountPasswordHighest) + 1; ++i) { for (int i = static_cast<int>(Shared::AccountPasswordLowest); i < static_cast<int>(Shared::AccountPasswordHighest) + 1; ++i) {
Shared::AccountPassword ap = static_cast<Shared::AccountPassword>(i); Shared::AccountPassword ap = static_cast<Shared::AccountPassword>(i);
@ -35,19 +34,18 @@ Account::Account():
m_ui->passwordType->setCurrentIndex(static_cast<int>(Shared::AccountPassword::plain)); m_ui->passwordType->setCurrentIndex(static_cast<int>(Shared::AccountPassword::plain));
if (!Shared::Global::supported("KWallet")) { if (!Shared::Global::supported("KWallet")) {
QStandardItemModel *model = static_cast<QStandardItemModel*>(m_ui->passwordType->model());
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet)); QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::kwallet));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled); item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
} }
if (!Shared::Global::supported("simpleCryptJammedPassword")) {
QStandardItem *item = model->item(static_cast<int>(Shared::AccountPassword::jammed));
item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
}
} }
Account::~Account() {} Account::~Account()
{
}
QMap<QString, QVariant> Account::value() const { QMap<QString, QVariant> Account::value() const
{
QMap<QString, QVariant> map; QMap<QString, QVariant> map;
map["login"] = m_ui->login->text(); map["login"] = m_ui->login->text();
map["password"] = m_ui->password->text(); map["password"] = m_ui->password->text();
@ -60,11 +58,13 @@ QMap<QString, QVariant> Account::value() const {
return map; return map;
} }
void Account::lockId() { void Account::lockId()
{
m_ui->name->setReadOnly(true);; m_ui->name->setReadOnly(true);;
} }
void Account::setData(const QMap<QString, QVariant>& data) { void Account::setData(const QMap<QString, QVariant>& data)
{
m_ui->login->setText(data.value("login").toString()); m_ui->login->setText(data.value("login").toString());
m_ui->password->setText(data.value("password").toString()); m_ui->password->setText(data.value("password").toString());
m_ui->server->setText(data.value("server").toString()); m_ui->server->setText(data.value("server").toString());
@ -73,7 +73,8 @@ void Account::setData(const QMap<QString, QVariant>& data) {
m_ui->passwordType->setCurrentIndex(data.value("passwordType").toInt()); m_ui->passwordType->setCurrentIndex(data.value("passwordType").toInt());
} }
void Account::onComboboxChange(int index) { void Account::onComboboxChange(int index)
{
QString description = Shared::Global::getDescription(Shared::Global::fromInt<Shared::AccountPassword>(index)); QString description = Shared::Global::getDescription(Shared::Global::fromInt<Shared::AccountPassword>(index));
m_ui->comment->setText(description); m_ui->comment->setText(description);
} }