Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/ui/integration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
#include "ui_integration_dialog.h"

IntegrationDialog::IntegrationDialog(QString pathToAppImage, QString integratedAppImagesDestinationPath,
QWidget* parent) :
bool integrateInPlace, QWidget* parent) :
QDialog(parent), ui(new Ui::IntegrationDialog),
pathToAppImage(std::move(pathToAppImage)),
integratedAppImagesDestinationPath(std::move(integratedAppImagesDestinationPath)) {
integratedAppImagesDestinationPath(std::move(integratedAppImagesDestinationPath)),
integrateInPlace(integrateInPlace) {
ui->setupUi(this);

setIcon();
Expand All @@ -29,6 +30,22 @@ IntegrationDialog::IntegrationDialog(QString pathToAppImage, QString integratedA
}

void IntegrationDialog::setMessage() {
// the message designed in the .ui file describes integrating and moving the AppImage into the integration
// destination directory; when the AppImage is going to be integrated in place, use an alternate message
// which does not mention the move
if (integrateInPlace) {
ui->message->setText(
tr("%1 has not been integrated into your system.\n"
"\n"
"Integrating it will include the AppImage in your application launcher, and leave the file in its "
"current location.\n"
"\n"
"To remove or update the AppImage, please use the context menu of the application icon in your "
"task bar or launcher.").arg(pathToAppImage)
);
return;
}

QString message = ui->message->text();
message = message.arg(pathToAppImage, integratedAppImagesDestinationPath);
ui->message->setText(message);
Expand Down
3 changes: 2 additions & 1 deletion src/ui/integration_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Q_OBJECT
};

explicit IntegrationDialog(QString pathToAppImage, QString integratedAppImagesDestinationPath,
QWidget* parent = nullptr);
bool integrateInPlace = false, QWidget* parent = nullptr);

~IntegrationDialog() override;

Expand All @@ -35,6 +35,7 @@ Q_OBJECT
Ui::IntegrationDialog* ui;
QString pathToAppImage;
QString integratedAppImagesDestinationPath;
bool integrateInPlace;

void setIcon();

Expand Down
23 changes: 16 additions & 7 deletions src/ui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,12 @@ int main(int argc, char** argv) {
displayError("Could not read config file");
}

// if the user opted out of the "ask move" thing, we can just run the AppImage
if (config->contains("AppImageLauncher/ask_to_move") && !config->value("AppImageLauncher/ask_to_move").toBool()) {
return runAppImage(pathToAppImage, appImageArgv.size(), appImageArgv.data());
}
// the "ask to move" option is presented in the settings and first run dialogs (a checkbox inside the
// "Launcher Dialog" section) as merely controlling whether AppImages are moved into the integration
// destination directory; opting out must not disable the launcher dialog altogether, therefore AppImages
// are integrated in place instead of not being integrated at all
const auto askToMove = !config->contains("AppImageLauncher/ask_to_move") ||
config->value("AppImageLauncher/ask_to_move").toBool();

// check for X-AppImage-Integrate=false
auto shallNotBeIntegrated = appimage_shall_not_be_integrated(pathToAppImage.toStdString().c_str());
Expand All @@ -312,7 +314,11 @@ int main(int argc, char** argv) {
if (pathToAppImage.startsWith("/tmp/.mount_"))
return runAppImage(pathToAppImage, appImageArgv.size(), appImageArgv.data());

const auto pathToIntegratedAppImage = buildPathToIntegratedAppImage(pathToAppImage);
// when the user opted out of moving AppImages into the integration destination directory, the AppImage
// is integrated in place by using its current path as the target; integrateAppImage() skips the move
// if both paths are identical
const auto pathToIntegratedAppImage =
askToMove ? buildPathToIntegratedAppImage(pathToAppImage) : QString(pathToAppImage);

auto integrateAndRunAppImage = [&pathToAppImage, &pathToIntegratedAppImage, &appImageArgv]() {
// check whether integration was successful
Expand Down Expand Up @@ -350,7 +356,9 @@ int main(int argc, char** argv) {

// assume we have to ask
// prove me wrong!
bool needToAskAboutMoving = true;
// if the user opted out of moving AppImages into the integration destination directory, there's no
// point in asking them about moving an already integrated AppImage, either
bool needToAskAboutMoving = askToMove;

// okay, I'll try to prove you wrong
{
Expand Down Expand Up @@ -420,7 +428,8 @@ int main(int argc, char** argv) {
}

QString integratedAppImagesDestinationPath = integratedAppImagesDestination().path();
auto integrationDialog = new IntegrationDialog(pathToAppImage, integratedAppImagesDestinationPath);
auto integrationDialog =
new IntegrationDialog(pathToAppImage, integratedAppImagesDestinationPath, !askToMove);
integrationDialog->show();

// As the integration dialog is the only window in our application we can safely use its exec method
Expand Down