122 lines
3.6 KiB
C++
Executable File
122 lines
3.6 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* User Menu on active sessions (logout, etc.)
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*
|
|
* Created by Mike Wille, SLSE, 2016-08-17
|
|
*/
|
|
|
|
#include "lts_operator_menu.h"
|
|
#include "ui_lts_operator_menu.h"
|
|
#include "lts_info_dialog.h"
|
|
#include <ngltranslator/ngltranslator.h>
|
|
|
|
#include <QPushButton>
|
|
#include <QProcess>
|
|
#include <QHostInfo>
|
|
|
|
|
|
namespace LtsWidgets
|
|
{
|
|
LtsOperatorMenu::LtsOperatorMenu(const QString &operatorName, const QString &workspaceId, bool debug, int screenCount, QWidget *parent)
|
|
: LtsFramelessDialog(parent)
|
|
, m_ui(new Ui::LtsOperatorMenu)
|
|
{
|
|
m_ui->setupUi(this);
|
|
m_ui->lbOperatorName->setText(operatorName);
|
|
m_ui->lbHostName->setText(QHostInfo::localHostName());
|
|
|
|
if (screenCount < 2)
|
|
m_ui->pbSwap->hide(); // swaps only possible if more than 1 screen is available
|
|
|
|
if (debug)
|
|
m_ui->lbWorkspaceId->setText(tr("Workspace: >>>%1<<<").arg(workspaceId));
|
|
else
|
|
m_ui->lbWorkspaceId->hide();
|
|
|
|
connect(m_ui->pbOperatorSettings, &QPushButton::clicked, this, &LtsOperatorMenu::signalShowOperatorSettings);
|
|
connect(m_ui->pbOperatorSettings, &QPushButton::clicked, this, &LtsOperatorMenu::close);
|
|
connect(m_ui->pbWindow, &QPushButton::clicked, this, &LtsOperatorMenu::onTerminalButtonClicked);
|
|
connect(m_ui->pbWindow, &QPushButton::clicked, this, &LtsOperatorMenu::close);
|
|
connect(m_ui->pbLogout, &QPushButton::clicked, this, &LtsOperatorMenu::signalLogout);
|
|
connect(m_ui->pbExit, &QPushButton::clicked, this, &LtsOperatorMenu::signalExit);
|
|
connect(m_ui->pbCancel, &QPushButton::clicked, this, &LtsOperatorMenu::close);
|
|
connect(m_ui->pbSwap, &QPushButton::clicked, this, &LtsOperatorMenu::signalSwap);
|
|
connect(m_ui->pbSwap, &QPushButton::clicked, this, &LtsOperatorMenu::close);
|
|
connect(m_ui->pbAbout, &QPushButton::clicked, this, &LtsOperatorMenu::slotShowInfoDialog);
|
|
connect(m_ui->pbAbout, &QPushButton::clicked, this, &LtsOperatorMenu::close);
|
|
|
|
|
|
if (NGL::translationLocale() == "de_DE")
|
|
m_ui->pbGer->setChecked(true);
|
|
else
|
|
m_ui->pbInt->setChecked(true);
|
|
|
|
connect(m_ui->pbGer, &QPushButton::clicked,
|
|
this, &LtsOperatorMenu::onLanguageChange);
|
|
connect(m_ui->pbInt, &QPushButton::clicked,
|
|
this, &LtsOperatorMenu::onLanguageChange);
|
|
|
|
#ifndef LTS_DEBUG
|
|
m_ui->debugWidget->hide();
|
|
#endif
|
|
}
|
|
|
|
|
|
LtsOperatorMenu::~LtsOperatorMenu()
|
|
{
|
|
delete m_ui;
|
|
}
|
|
|
|
|
|
void LtsOperatorMenu::slotShowInfoDialog()
|
|
{
|
|
LtsInfoDialog *infoDialog = new LtsInfoDialog();
|
|
infoDialog->setAttribute(Qt::WA_DeleteOnClose);
|
|
infoDialog->show();
|
|
}
|
|
|
|
|
|
void LtsOperatorMenu::onTerminalButtonClicked()
|
|
{
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
QString lang = QString::fromLatin1(NGL::translationLocale());
|
|
lang.append(QStringLiteral(".UTF-8"));
|
|
env.insert(QStringLiteral("LANG"), lang);
|
|
|
|
QProcess process;
|
|
process.setProcessEnvironment(env); //Da startDetached static ist wird hier drauf nicht zugegriffen
|
|
QStringList args;
|
|
args << QStringLiteral("--geometry") << QStringLiteral("800x800+200+100");
|
|
|
|
if (QApplication::queryKeyboardModifiers() == Qt::ControlModifier)
|
|
process.startDetached(QStringLiteral("xterm"), args);
|
|
else
|
|
process.startDetached(QStringLiteral("konsole"), args);
|
|
}
|
|
|
|
|
|
void LtsOperatorMenu::setTerminalButton(bool bVisible)
|
|
{
|
|
m_ui->pbWindow->setVisible(bVisible);
|
|
}
|
|
|
|
void LtsOperatorMenu::setOperatorSettingsButton(bool bVisible)
|
|
{
|
|
m_ui->pbOperatorSettings->setVisible(bVisible);
|
|
}
|
|
|
|
|
|
void LtsOperatorMenu::onLanguageChange()
|
|
{
|
|
if (m_ui->pbGer->isChecked())
|
|
NGL::setTranslationLocale(QByteArray("de_DE"));
|
|
|
|
if (m_ui->pbInt->isChecked())
|
|
NGL::setTranslationLocale(QByteArray("en_GB"));
|
|
}
|
|
} // namespace LtsWidgets
|