Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "Settings" option in integration screen #549

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
7 changes: 7 additions & 0 deletions src/ui/integration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ IntegrationDialog::IntegrationDialog(QString pathToAppImage, QString integratedA
&IntegrationDialog::onPushButtonIntegrateAndRunReleased);
QObject::connect(ui->pushButtonRunOnce, &QPushButton::released, this,
&IntegrationDialog::onPushButtonRunOnceReleased);
QObject::connect(ui->pushButtonSettings, &QPushButton::released, this,
&IntegrationDialog::onPushButtonSettingsReleased);

// make translation fit by adjusting the minimum size of the message label to the size calculated by Qt
ui->message->setMinimumSize(ui->message->sizeHint());
Expand Down Expand Up @@ -54,6 +56,11 @@ void IntegrationDialog::onPushButtonRunOnceReleased() {
this->accept();
}

void IntegrationDialog::onPushButtonSettingsReleased() {
this->resultAction = ResultingAction::Settings;
this->accept();
}

IntegrationDialog::ResultingAction IntegrationDialog::getResultAction() const {
return resultAction;
}
5 changes: 4 additions & 1 deletion src/ui/integration_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Q_OBJECT
public:
enum ResultingAction {
IntegrateAndRun,
RunOnce
RunOnce,
Settings
};

explicit IntegrationDialog(QString pathToAppImage, QString integratedAppImagesDestinationPath,
Expand All @@ -29,6 +30,8 @@ Q_OBJECT

Q_SLOT void onPushButtonRunOnceReleased();

Q_SLOT void onPushButtonSettingsReleased();

ResultingAction resultAction;

private:
Expand Down
24 changes: 24 additions & 0 deletions src/ui/integration_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
Expand Down Expand Up @@ -89,6 +106,13 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pushButtonSettings">
<property name="text">
<string>Settings</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down
15 changes: 15 additions & 0 deletions src/ui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,21 @@ int main(int argc, char** argv) {
return integrateAndRunAppImage();
case IntegrationDialog::RunOnce:
return runAppImage(pathToAppImage, appImageArgv.size(), appImageArgv.data());
case IntegrationDialog::Settings:{

auto makeVectorBuffer = [](const std::string& str) {
std::vector<char> strBuffer(str.size() + 1, '\0');
strncpy(strBuffer.data(), str.c_str(), str.size());
return strBuffer;
};

const QString ownBinaryDirPath = QFileInfo(getOwnBinaryPath().get()).dir().absolutePath();
auto settingsBinBuffer = makeVectorBuffer((ownBinaryDirPath+"/AppImageLauncherSettings").toStdString());
char* settingsBin = settingsBinBuffer.data();

char* settingsArgs[] = {settingsBin, nullptr};
return execv(settingsBin, settingsArgs);
}
default:
displayError(QObject::tr("Unexpected result from the integration dialog."));
return 1;
Expand Down