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
2 changes: 1 addition & 1 deletion src/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if(NOT BUILD_LITE)
# main AppImageLauncher application
add_executable(AppImageLauncher main.cpp resources.qrc first-run.cpp first-run.h first-run.ui integration_dialog.cpp integration_dialog.h integration_dialog.ui)
target_link_libraries(AppImageLauncher shared PkgConfig::glib libappimage shared)
target_link_libraries(AppImageLauncher shared PkgConfig::glib libappimage shared XdgUtils::DesktopEntry)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this dependency loaded? I presume you forgot to commit a line in some other file...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It comes as a dependency of libappimage


# set binary runtime rpath to make sure the libappimage.so built and installed by this project is going to be used
# by the installed binaries (be it the .deb, the AppImage, or whatever)
Expand Down
72 changes: 54 additions & 18 deletions src/ui/integration_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
// library includes
#include <QStyle>

#include <XdgUtils/DesktopEntry/DesktopEntry.h>
#include <appimage/utils/ResourcesExtractor.h>


// local headers
#include "integration_dialog.h"
#include "ui_integration_dialog.h"
Expand All @@ -16,25 +20,12 @@ IntegrationDialog::IntegrationDialog(QString pathToAppImage, QString integratedA
integratedAppImagesDestinationPath(std::move(integratedAppImagesDestinationPath)) {
ui->setupUi(this);

setIcon();
setMessage();
loadAppImageInfo();

QObject::connect(ui->pushButtonIntegrateAndRun, &QPushButton::released, this,
&IntegrationDialog::onPushButtonIntegrateAndRunReleased);
QObject::connect(ui->pushButtonRunOnce, &QPushButton::released, this,
&IntegrationDialog::onPushButtonRunOnceReleased);
}

void IntegrationDialog::setMessage() {
QString message = ui->message->text();
message = message.arg(pathToAppImage, integratedAppImagesDestinationPath);
ui->message->setText(message);
}

void IntegrationDialog::setIcon() {
QIcon icon = QIcon(":/AppImageLauncher.svg");
QPixmap pixmap = icon.pixmap(QSize(64, 64));
ui->icon->setPixmap(pixmap);
QObject::connect(ui->pushButtonIntegrateAndRun, &QPushButton::released,
this, &IntegrationDialog::onPushButtonIntegrateAndRunReleased);
QObject::connect(ui->pushButtonRunOnce, &QPushButton::released,
this, &IntegrationDialog::onPushButtonRunOnceReleased);
}

IntegrationDialog::~IntegrationDialog() {
Expand All @@ -54,3 +45,48 @@ void IntegrationDialog::onPushButtonRunOnceReleased() {
IntegrationDialog::ResultingAction IntegrationDialog::getResultAction() const {
return resultAction;
}

void IntegrationDialog::loadAppImageInfo() {
try {
appimage::core::AppImage appImage(pathToAppImage.toStdString());
appimage::utils::ResourcesExtractor extractor(appImage);

auto desktopEntryPath = extractor.getDesktopEntryPath();
auto desktopEntryData = extractor.extractText(desktopEntryPath);

XdgUtils::DesktopEntry::DesktopEntry desktopEntry(desktopEntryData);
auto appName = QString::fromStdString(desktopEntry.get("Desktop Entry/Name", ""));
auto appDescription = QString::fromStdString(desktopEntry.get("Desktop Entry/Comment", ""));

ui->labelName->setText(appName);
ui->labelDescription->setText(appDescription);

// to keep the text aligned in the center with the icon
if (appDescription.isEmpty()) {
ui->labelDescription->setVisible(false);
ui->labelName->setAlignment(Qt::AlignVCenter);
}

// Read icon data from ".DirIcon"
std::vector<char> iconData = extractor.extract(".DirIcon");

// Load into a pixmap
QPixmap pixmap;
pixmap.loadFromData(reinterpret_cast<const uchar*>(iconData.data()), iconData.size());

// Fallback to the AppImageLauncher icon in case of error
if (pixmap.isNull())
pixmap = QPixmap(":/AppImageLauncher.svg");

// scale icon to 64x64
pixmap = pixmap.scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->icon->setPixmap(pixmap);

// Replace Integrated AppImages Destination Path in the message label
QString message = ui->message->text();
message = message.arg(integratedAppImagesDestinationPath);
ui->message->setText(message);
} catch (appimage::core::AppImageError& error) {
// TODO: Properly handle errors
Copy link
Collaborator Author

@azubieta azubieta Apr 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideas are welcome here!

}
}
4 changes: 1 addition & 3 deletions src/ui/integration_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ Q_OBJECT
QString pathToAppImage;
QString integratedAppImagesDestinationPath;

void setIcon();

void setMessage();
void loadAppImageInfo();
};

#endif //APPIMAGELAUNCHER_INTEGRATION_DIALOG_H
170 changes: 135 additions & 35 deletions src/ui/integration_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>460</width>
<width>380</width>
<height>300</height>
</rect>
</property>
Expand All @@ -23,69 +23,169 @@
<string>Desktop Integration</string>
</property>
<property name="sizeGripEnabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>1</width>
<height>0</height>
</size>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string>Icon</string>
<string/>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="margin">
<number>12</number>
<number>6</number>
</property>
<property name="indent">
<number>0</number>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="message">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="labelName">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>10</pointsize>
<italic>false</italic>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="message">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>2</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;%1 has not been integrated into your system.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt; &lt;br /&gt;Integrating it will move the AppImage into a predefined location, and include it in your application launcher.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Integrating this AppImage will cause it to be moved into '&lt;a href=&quot;file://%2&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#2980b9;&quot;&gt;%2&lt;/span&gt;&lt;/a&gt;', and to be included in your application launcher.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To remove or update the AppImage, please use the context menu of the application icon in your task bar or launcher. &lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;The directory where the integrated AppImages are stored in is currently set to: %2&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;To remove or update the AppImage, please use the context menu of the application icon in your task bar or launcher. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="margin">
<number>6</number>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down