-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmainwindow.cpp
53 lines (47 loc) · 1.45 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QDebug>
#include <QMessageBox>
#include <QList>
#include <QAction>
#include <QActionGroup>
#include <QMenu>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qDebug() << "$APPIMAGE:" << qgetenv("APPIMAGE");
QProcess process;
process.start("which AppImageUpdate");
process.waitForFinished(500);
QString appImageUpdatePath = process.readAllStandardOutput();
/* Enable the 'Update' menu only if AppImageUpdate is on the $PATH
* and the $APPIMAGE environvent variable is set */
qDebug() << "which AppImageUpdate:" << appImageUpdatePath;
if((appImageUpdatePath != "") && (qgetenv("APPIMAGE") != NULL)) {
qDebug() << "Enable 'Update' menu";
QList<QMenu*> lst;
lst = ui->menuBar->findChildren<QMenu*>();
lst[1]->actions()[0]->setEnabled(1);
}
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_actionQuit_triggered()
{
QApplication::quit();
}
void MainWindow::on_actionUpdate_triggered()
{
QProcess process;
process.start("AppImageUpdate", QStringList() << qgetenv("APPIMAGE"));
process.waitForFinished(-1);
}
void MainWindow::on_actionAbout_AppImageUpdateExample_triggered()
{
QMessageBox::about(this, trUtf8("QtAppImageUpdateExample"), trUtf8("An example that shows\nhow to call AppImageUpdate\nfrom a Qt application"));
}