mirror of
https://github.com/Llewellynvdm/Tomb.git
synced 2024-12-23 10:38:59 +00:00
commit
0a14747ccf
BIN
extras/qt-tray/i18n/tomb-qt-tray_it.qm
Normal file
BIN
extras/qt-tray/i18n/tomb-qt-tray_it.qm
Normal file
Binary file not shown.
75
extras/qt-tray/i18n/tomb-qt-tray_it.ts
Normal file
75
extras/qt-tray/i18n/tomb-qt-tray_it.ts
Normal file
@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="it_IT">
|
||||
<context>
|
||||
<name>Dialog</name>
|
||||
<message>
|
||||
<source>Explore</source>
|
||||
<translation type="vanished">Esplora</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation type="vanished">Chiudi</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Tomb</name>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="72"/>
|
||||
<source>Explore</source>
|
||||
<translation>Esplora</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="77"/>
|
||||
<source>Close</source>
|
||||
<translation>Chiudi</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="80"/>
|
||||
<source>Slam</source>
|
||||
<translation>Slam</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="22"/>
|
||||
<location filename="../tomb.cpp" line="120"/>
|
||||
<location filename="../tomb.cpp" line="123"/>
|
||||
<location filename="../tomb.cpp" line="144"/>
|
||||
<source>tomb-qt-tray</source>
|
||||
<translation>tomb-qt-tray</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="22"/>
|
||||
<source>You need to specify a Tomb File.
|
||||
Exiting</source>
|
||||
<translation>Devi specificare un file Tomb.
|
||||
Uscita</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="38"/>
|
||||
<source>Tomb encrypted undertaker</source>
|
||||
<translation>Tomb encrypted undertaker</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="38"/>
|
||||
<source>We started digging out bones</source>
|
||||
<translation>Abbiamo cominciato a tirare fuori gli scheletri</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="120"/>
|
||||
<source>polkit is not installed</source>
|
||||
<translation>polkit non è installato</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="123"/>
|
||||
<source>The program crashed
|
||||
Try to run 'tomb close' in a console</source>
|
||||
<translation>Il programma è crashato
|
||||
Prova ad eseguire "tomb close" in una console</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../tomb.cpp" line="135"/>
|
||||
<source>The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.</source>
|
||||
<translation>Il programma non è stato avviato. O il programma chiamato non è installato o non hai sufficienti diritti per eseguirlo.</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
41
extras/qt-tray/main.cpp
Normal file
41
extras/qt-tray/main.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/* Tomb - encrypted storage undertaker
|
||||
*
|
||||
* (c) Copyright 2015 Gianluca Montecchi <gian@grys.it>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
|
||||
#include "tomb.h"
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QTranslator translator(0);
|
||||
|
||||
|
||||
translator.load( QString("./i18n/tomb-qt-tray_") + QLocale::system().name() );
|
||||
|
||||
a.installTranslator( &translator );
|
||||
//w.show();
|
||||
Tomb w;
|
||||
|
||||
|
||||
return a.exec();
|
||||
}
|
BIN
extras/qt-tray/pixmaps/tomb_icon.png
Normal file
BIN
extras/qt-tray/pixmaps/tomb_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.7 KiB |
47
extras/qt-tray/qt-tray.pro
Normal file
47
extras/qt-tray/qt-tray.pro
Normal file
@ -0,0 +1,47 @@
|
||||
# Tomb - encrypted storage undertaker
|
||||
#
|
||||
# (c) Copyright 2015 Gianluca Montecchi <gian@grys.it>
|
||||
#
|
||||
# This source code is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Public License as published
|
||||
# by the Free Software Foundation; either version 3 of the License,
|
||||
# or (at your option) any later version.
|
||||
#
|
||||
# This source code is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# Please refer to the GNU Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Public License along with
|
||||
# this source code; if not, write to:
|
||||
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#/
|
||||
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-07-30T22:53:13
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui quick
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = tomb-qt-tray
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
tomb.cpp
|
||||
|
||||
HEADERS += tomb.h
|
||||
|
||||
TRANSLATIONS = i18n/tomb-qt-tray_it.ts
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
FORMS +=
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
171
extras/qt-tray/tomb.cpp
Normal file
171
extras/qt-tray/tomb.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/* Tomb - encrypted storage undertaker
|
||||
*
|
||||
* (c) Copyright 2015 Gianluca Montecchi <gian@grys.it>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "tomb.h"
|
||||
#include <QDir>
|
||||
#include <QStorageInfo>
|
||||
#include <QMessageBox>
|
||||
#include <QQuickView>
|
||||
|
||||
#include <mntent.h>
|
||||
|
||||
Tomb::Tomb(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
struct mntent *ent;
|
||||
FILE *aFile;
|
||||
|
||||
|
||||
if (QApplication::arguments().length() > 1) {
|
||||
this->info = QFileInfo(QApplication::arguments().takeAt(1));
|
||||
this->tombName = QString(info.baseName());
|
||||
this->tombPath = info.path();
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("tomb-qt-tray"), tr("You need to specify a Tomb File.\nExiting"), QMessageBox::Ok);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
// Build the menù
|
||||
this->icon = QIcon( QCoreApplication::applicationDirPath() + QDir::separator()+QString("pixmaps/tomb_icon.png"));
|
||||
this->trayIcon = new QSystemTrayIcon(this->icon);
|
||||
this->trayIconMenu = new QMenu();
|
||||
|
||||
this->tombBuildMenu();
|
||||
|
||||
this->trayIcon->setContextMenu(this->trayIconMenu);
|
||||
|
||||
this->trayIcon->setToolTip(QString(info.baseName()));
|
||||
this->trayIcon->show();
|
||||
this->trayIcon->showMessage(tr("Tomb encrypted undertaker"),tr("We started digging out bones"), QSystemTrayIcon::Information);
|
||||
if (QT_VERSION >= 0x050400) {
|
||||
for (auto volume : QStorageInfo::mountedVolumes()) {
|
||||
if (QString(volume.device()).contains(this->tombName) == true) {
|
||||
this->tombMountPoint = QString(volume.rootPath());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
aFile = setmntent("/proc/mounts", "r");
|
||||
if (aFile == NULL) {
|
||||
perror("setmntent");
|
||||
exit(1);
|
||||
}
|
||||
while (NULL != (ent = getmntent(aFile))) {
|
||||
if (QString( ent->mnt_fsname).contains(this->tombName) == true) {
|
||||
this->tombMountPoint = QString(ent->mnt_dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
endmntent(aFile);
|
||||
}
|
||||
}
|
||||
|
||||
void Tomb::closeEvent(QCloseEvent *event) {
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void Tomb::tombBuildMenu() {
|
||||
|
||||
// Create the menu items
|
||||
// this->tombOpen = new QAction(tr("Open"), this);
|
||||
//this->trayIconMenu->addAction(tombOpen);
|
||||
|
||||
this->menu_tombExplore = new QAction(tr("Explore"), this);
|
||||
this->trayIconMenu->addAction(menu_tombExplore);
|
||||
|
||||
this->trayIconMenu->addSeparator();
|
||||
|
||||
this->menu_tombClose = new QAction(tr("Close"), this);
|
||||
this->trayIconMenu->addAction(menu_tombClose);
|
||||
|
||||
this->menu_tombSlam = new QAction(tr("Slam"), this);
|
||||
this->trayIconMenu->addAction(menu_tombSlam);
|
||||
|
||||
connect(this->menu_tombExplore, SIGNAL(triggered()), this, SLOT(tombExplore()));
|
||||
connect(this->menu_tombClose, SIGNAL(triggered()), this, SLOT(tombClose()));
|
||||
connect(this->menu_tombSlam, SIGNAL(triggered()), this, SLOT(tombSlam()));
|
||||
|
||||
}
|
||||
|
||||
void Tomb::tombExplore() {
|
||||
|
||||
QDesktopServices::openUrl(QUrl(QUrl::fromLocalFile(this->tombMountPoint)));
|
||||
|
||||
}
|
||||
|
||||
void Tomb::tombClose() {
|
||||
|
||||
QProcess *tomb;
|
||||
tomb = new QProcess(this);
|
||||
tomb->start("pkexec", QStringList() << "tomb" << "close");
|
||||
connect(tomb, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(tombCheckCmdRet(int , QProcess::ExitStatus )));
|
||||
connect(tomb, SIGNAL(error(QProcess::ProcessError)), this, SLOT(tombStartError(QProcess::ProcessError)));
|
||||
tomb->waitForFinished(30000);
|
||||
|
||||
}
|
||||
|
||||
void Tomb::tombSlam() {
|
||||
|
||||
QProcess *tomb;
|
||||
tomb = new QProcess(this);
|
||||
tomb->start("pkexec", QStringList() << "tomb" << "slam");
|
||||
connect(tomb, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(tombCheckCmdRet(int , QProcess::ExitStatus )));
|
||||
connect(tomb, SIGNAL(error(QProcess::ProcessError)), this, SLOT(tombStartError(QProcess::ProcessError)));
|
||||
tomb->waitForFinished(30000);
|
||||
|
||||
}
|
||||
|
||||
void Tomb::tombCheckCmdRet(int exitCode, QProcess::ExitStatus exitStatus) {
|
||||
|
||||
if (exitStatus == QProcess::CrashExit) {
|
||||
QMessageBox::critical(this, tr("tomb-qt-tray"), tr("polkit is not installed"),QMessageBox::Ok);
|
||||
} else {
|
||||
if (exitCode != QProcess::NormalExit) {
|
||||
QMessageBox::critical(this, tr("tomb-qt-tray"), tr("The program crashed\nTry to run 'tomb close' in a console"),QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Tomb::tombStartError(QProcess::ProcessError err) {
|
||||
|
||||
QString msg = QString();
|
||||
|
||||
switch (err) {
|
||||
case QProcess::FailedToStart :
|
||||
msg = tr("The process failed to start. Either the invoked program is missing, or you may have insufficient permissions to invoke the program.");
|
||||
break;
|
||||
case QProcess::Crashed:
|
||||
case QProcess::Timedout:
|
||||
case QProcess::ReadError:
|
||||
case QProcess::WriteError:
|
||||
case QProcess::UnknownError:
|
||||
break;
|
||||
}
|
||||
QMessageBox::critical(this, tr("tomb-qt-tray"), msg, QMessageBox::Ok);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Tomb::~Tomb() {
|
||||
|
||||
}
|
||||
|
72
extras/qt-tray/tomb.h
Normal file
72
extras/qt-tray/tomb.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* Tomb - encrypted storage undertaker
|
||||
*
|
||||
* (c) Copyright 2015 Gianluca Montecchi <gian@grys.it>
|
||||
*
|
||||
* This source code is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Public License as published
|
||||
* by the Free Software Foundation; either version 3 of the License,
|
||||
* or (at your option) any later version.
|
||||
*
|
||||
* This source code is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* Please refer to the GNU Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Public License along with
|
||||
* this source code; if not, write to:
|
||||
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QProcess>
|
||||
|
||||
class Tomb : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Tomb(QWidget *parent = 0);
|
||||
~Tomb();
|
||||
|
||||
|
||||
QIcon icon;
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QMenu *trayIconMenu;
|
||||
QAction *menu_tombExplore;
|
||||
QAction *menu_tombClose;
|
||||
QAction *menu_tombSlam;
|
||||
|
||||
private:
|
||||
void tombBuildMenu();
|
||||
|
||||
QString tombPath;
|
||||
QString tombName;
|
||||
QFileInfo info;
|
||||
QString tombMountPoint;
|
||||
|
||||
private slots:
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
||||
public slots:
|
||||
void tombExplore();
|
||||
void tombClose();
|
||||
void tombSlam();
|
||||
void tombCheckCmdRet(int exitCode, QProcess::ExitStatus);
|
||||
void tombStartError(QProcess::ProcessError err);
|
||||
};
|
||||
|
||||
#endif // DIALOG_H
|
Loading…
Reference in New Issue
Block a user