mirror of
https://github.com/Ximi1970/systray-x.git
synced 2025-10-26 07:46:09 +01:00
Add options tab for restart
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#/bin/sh
|
||||
|
||||
#/bin/sh
|
||||
|
||||
#sleep 30
|
||||
$2 &
|
||||
|
||||
@@ -255,6 +255,15 @@ void Preferences::setPlatformOs( const QString os )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the platform arch
|
||||
*/
|
||||
const QString& Preferences::getPlatformArch() const
|
||||
{
|
||||
return m_platform_arch;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the platform arch
|
||||
*/
|
||||
|
||||
@@ -155,6 +155,13 @@ class Preferences : public QObject
|
||||
*/
|
||||
void setPlatformOs( const QString os );
|
||||
|
||||
/**
|
||||
* @brief getPlatformArch. Get the platform architecture.
|
||||
*
|
||||
* @param arch The architecture.
|
||||
*/
|
||||
const QString& getPlatformArch() const;
|
||||
|
||||
/**
|
||||
* @brief setPlatformArch. Set the platform architecture.
|
||||
*
|
||||
|
||||
@@ -1149,6 +1149,109 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Restart</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>19</x>
|
||||
<y>19</y>
|
||||
<width>601</width>
|
||||
<height>401</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_10">
|
||||
<property name="title">
|
||||
<string>Restart Thunderbird</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_16">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_25">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Export: </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="exportLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>Environment:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="environmentLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_19">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="thunderbirdLineEdit">
|
||||
<property name="text">
|
||||
<string>thunderbird</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="startBrowseButton_2">
|
||||
<property name="text">
|
||||
<string>Browse...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_20">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="text">
|
||||
<string>Arguments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="thunderbirdArgsLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_12">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabMail">
|
||||
<attribute name="title">
|
||||
<string>Mail</string>
|
||||
@@ -1358,14 +1461,14 @@
|
||||
</resources>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="startupTypeGroup"/>
|
||||
<buttongroup name="positionGroup"/>
|
||||
<buttongroup name="minimizeIconTypeGroup"/>
|
||||
<buttongroup name="iconTypeGroup"/>
|
||||
<buttongroup name="defaultIconTypeGroup"/>
|
||||
<buttongroup name="countTypeGroup"/>
|
||||
<buttongroup name="newIndicatorTypeGroup"/>
|
||||
<buttongroup name="minimizeTypeGroup"/>
|
||||
<buttongroup name="countTypeGroup"/>
|
||||
<buttongroup name="defaultIconTypeGroup"/>
|
||||
<buttongroup name="closeTypeGroup"/>
|
||||
<buttongroup name="minimizeTypeGroup"/>
|
||||
<buttongroup name="minimizeIconTypeGroup"/>
|
||||
<buttongroup name="positionGroup"/>
|
||||
<buttongroup name="startupTypeGroup"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include <QMenu>
|
||||
#include <QIcon>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QTemporaryFile>
|
||||
|
||||
/*
|
||||
* Constants
|
||||
@@ -742,42 +742,104 @@ void SysTrayX::slotRestart()
|
||||
{
|
||||
QString platform = QGuiApplication::platformName();
|
||||
QString os = m_preferences->getPlatformOs();
|
||||
QString arch = m_preferences->getPlatformArch();
|
||||
|
||||
emit signalConsole( QString( "Platform: %1").arg(platform));
|
||||
emit signalConsole( QString( "OS: %1").arg(os));
|
||||
|
||||
qint64 ppid = m_win_ctrl->getPpid();
|
||||
emit signalConsole( QString( "TB pid: %1").arg(ppid));
|
||||
|
||||
const QList< quint64 > list = m_win_ctrl->getWinIds();
|
||||
emit signalConsole( QString( "TB windows: %1").arg(list.count()));
|
||||
|
||||
if( os == "linux" )
|
||||
{
|
||||
// Start linux shell
|
||||
|
||||
// Get session type
|
||||
QString session = qgetenv( "XDG_SESSION_TYPE" );
|
||||
emit signalConsole( QString( "Session: %1").arg(session));
|
||||
|
||||
// Get start directory
|
||||
QProcess processPath;
|
||||
QString argsPath = QString( "-e /proc/%1/exe" ).arg( ppid );
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList argsPathList = argsPath.split( ' ', Qt::SkipEmptyParts );
|
||||
#else
|
||||
QStringList argsPathList = argsPath.split( ' ', QString::SkipEmptyParts );
|
||||
#endif
|
||||
processPath.start( "readlink", argsPathList );
|
||||
processPath.waitForFinished( -1 );
|
||||
QString path = processPath.readAllStandardOutput();
|
||||
path = path.left( path.lastIndexOf( "/" ) );
|
||||
|
||||
emit signalConsole( QString( "Path: %1" ).arg( path ) );
|
||||
|
||||
// Get cmd and arguments
|
||||
QProcess processCmd;
|
||||
QString argsCmd = QString( "-p %1 -o args --no-headers" ).arg( ppid );
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList argsCmdList = argsCmd.split( ' ', Qt::SkipEmptyParts );
|
||||
#else
|
||||
QStringList argsCmdList = argsCmd.split( ' ', QString::SkipEmptyParts );
|
||||
#endif
|
||||
processCmd.start( "ps", argsCmdList );
|
||||
processCmd.waitForFinished( -1 );
|
||||
QString cmdline = processCmd.readAllStandardOutput();
|
||||
cmdline = cmdline.mid( cmdline.indexOf( "/" ) + 1 );
|
||||
|
||||
emit signalConsole( QString( "Cmdline: %1" ).arg( cmdline ) );
|
||||
|
||||
// Create restart command
|
||||
QString restartCmd = path + "/" + cmdline;
|
||||
|
||||
|
||||
emit signalConsole( QString( "Start: %1").arg(":/files/restart.sh"));
|
||||
|
||||
|
||||
|
||||
// Start shell
|
||||
QTemporaryFile* file = QTemporaryFile::createNativeFile(":/files/restart.sh");
|
||||
QString filename = file->fileName();
|
||||
|
||||
QFileDevice::Permissions permissions = file->permissions();
|
||||
file->setPermissions( permissions | QFileDevice::ExeOwner );
|
||||
file->rename( filename + ".sh" );
|
||||
|
||||
QString app = "bash";
|
||||
QString args = QString( "-c %1.sh %2" ).arg( filename, restartCmd );
|
||||
|
||||
emit signalConsole( QString( "Args: %1").arg(args));
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList args_list = args.split( ' ', Qt::SkipEmptyParts );
|
||||
#else
|
||||
QStringList args_list = args.split( ' ', QString::SkipEmptyParts );
|
||||
#endif
|
||||
|
||||
if( !app.isEmpty() )
|
||||
{
|
||||
bool status = QProcess::startDetached( app, args_list );
|
||||
|
||||
emit signalConsole( QString( "Started: %1").arg(status));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start windows batch
|
||||
|
||||
if( arch == "x86-64" )
|
||||
{
|
||||
emit signalConsole( QString( "Path: %1").arg("C:\\Program Files"));
|
||||
}
|
||||
else
|
||||
{
|
||||
emit signalConsole( QString( "Path: %1").arg("C:\\Program Files (x86)"));
|
||||
}
|
||||
|
||||
emit signalConsole( QString( "Start: %1").arg(":/files/restart.bat"));
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
QString app = m_preferences->getCloseApp();
|
||||
QString args = m_preferences->getCloseAppArgs();
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList args_list = args.split( ' ', Qt::SkipEmptyParts );
|
||||
#else
|
||||
QStringList args_list = args.split( ' ', QString::SkipEmptyParts );
|
||||
#endif
|
||||
|
||||
if( !app.isEmpty() )
|
||||
{
|
||||
QProcess::startDetached( app, args_list );
|
||||
}
|
||||
// slotShutdown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user