- version 0.9.6 - fixes desktop file creation + settings file location

This commit is contained in:
Dmytro Bogovych 2022-09-20 10:25:59 +03:00
parent 81765e136f
commit d99d8f7f84
6 changed files with 33 additions and 8 deletions

View File

@ -39,7 +39,7 @@
#define APP_VERSION_MAJOR 0
#define APP_VERSION_MINOR 9
#define APP_VERSION_SUFFIX 5
#define APP_VERSION_SUFFIX 6
//#ifdef TARGET_OSX
#define ICONS ":/assets/images"

View File

@ -10,9 +10,8 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
helper::theme::applyCurrent(Settings::instance());
app.setApplicationName(APPNAME);
helper::theme::applyCurrent(Settings::instance());
auto& settings = Settings::instance();
QFont f;
if (settings.data().count(KEY_APP_FONT) > 0)

View File

@ -1556,7 +1556,13 @@ void MainWindow::showMainWindow()
void MainWindow::setupAppMenu()
{
#if defined(TARGET_LINUX)
appmenu::install(QCoreApplication::applicationFilePath().toStdString());
auto exe_path = QFileInfo(QCoreApplication::arguments().front()).absoluteFilePath();
const char* appimage = std::getenv("APPIMAGE");
if (appimage != nullptr)
exe_path = appimage;
qDebug() << "Found exe path: " << exe_path;
appmenu::install(exe_path.toStdString());
#endif
}

View File

@ -98,8 +98,21 @@ static fs::path appmenu_install_dir()
void appmenu::install(const std::string& path_to_me)
{
auto path_to_desktop = appmenu_install_dir() / NOO_DESKTOP_NAME;
// Check if app is installed already.
// The code below checks for path to app; as this app is distributed as .AppImage with version numbers - every new version will trigger desktop file rewriting
std::ifstream ifs(path_to_desktop);
std::string content((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
if (content.find(path_to_me) != std::string::npos)
return;
// Remove old one
std::string uninstall_cmd = "/usr/bin/xdg-desktop-menu uninstall --novendor " + (appmenu_install_dir() / NOO_DESKTOP_NAME).string();
system(uninstall_cmd.c_str());
// Put .desktop file to ~/.config/autostart
std::ofstream ofs(appmenu_install_dir() / NOO_DESKTOP_NAME);
std::ofstream ofs(path_to_desktop);
if (ofs.is_open())
{
ofs << fixup_desktop_file(read_desktop_file(), path_to_me);
@ -126,6 +139,9 @@ void appmenu::install(const std::string& path_to_me)
}
}
}
std::string install_cmd = "/usr/bin/xdg-desktop-menu install --novendor " + (appmenu_install_dir() / NOO_DESKTOP_NAME).string();
system(install_cmd.c_str());
}
void appmenu::uninstall()

View File

@ -6,6 +6,7 @@
#include <QFileInfo>
#include <QDir>
#include <QRect>
#include <QDebug>
Settings::Settings()
{
@ -27,7 +28,8 @@ void Settings::save()
auto path = helper::path::pathToSettings();
QSettings settings(path, QSettings::IniFormat);
settings.clear();
for (const QString& e: data().keys())
for (const QString& e: mData.keys())
{
settings.setValue(e, data().value(e));
}
@ -42,6 +44,8 @@ void Settings::load()
// Path to settings file
QString path = helper::path::pathToSettings();
qDebug() << "Settings file path: " << path;
// Check if directory exists at all
QString dir = QFileInfo(path).absoluteDir().path();

View File

@ -2,9 +2,9 @@
# I use this script on two different hosts so there are logic to find proper Qt installation
export QT_HOME=/home/$USER/qt/5.12.10/gcc_64
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
if [ ! -d "$QT_HOME" ] ; then
export QT_HOME=/home/$USER/qt5/5.12.12/gcc_64
export QT_HOME=/home/$USER/qt5.15/5.15.2/gcc_64
fi
# Build .appimage