Feature #3172 - Add stop service feature to GUI
This commit is contained in:
parent
49c1a5e9a1
commit
ede57b0c81
|
@ -27,14 +27,7 @@
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QGridLayout">
|
<layout class="QGridLayout">
|
||||||
<item row="6" column="7">
|
<item row="1" column="0" colspan="12">
|
||||||
<widget class="QPushButton" name="m_pButtonToggleStart">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Start</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0" colspan="8">
|
|
||||||
<widget class="QGroupBox" name="m_pGroupServer">
|
<widget class="QGroupBox" name="m_pGroupServer">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
@ -127,7 +120,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="8">
|
<item row="2" column="0" colspan="12">
|
||||||
<widget class="QGroupBox" name="m_pGroupClient">
|
<widget class="QGroupBox" name="m_pGroupClient">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
@ -168,7 +161,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="8">
|
<item row="3" column="0" colspan="12">
|
||||||
<widget class="QGroupBox" name="m_pGroupLog">
|
<widget class="QGroupBox" name="m_pGroupLog">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Log</string>
|
<string>Log</string>
|
||||||
|
@ -223,7 +216,7 @@
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="pixmap">
|
<property name="pixmap">
|
||||||
<pixmap>:/res/icons/16x16/warning.png</pixmap>
|
<pixmap resource="Synergy.qrc">:/res/icons/16x16/warning.png</pixmap>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -237,7 +230,21 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="6">
|
<item row="6" column="11">
|
||||||
|
<widget class="QPushButton" name="m_pButtonToggleStart">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="10">
|
||||||
|
<widget class="QPushButton" name="m_pButtonApply">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Apply</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="9">
|
||||||
<widget class="QCheckBox" name="m_pElevateCheckBox">
|
<widget class="QCheckBox" name="m_pElevateCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Elevate</string>
|
<string>&Elevate</string>
|
||||||
|
@ -330,7 +337,9 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="Synergy.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>m_pButtonToggleStart</sender>
|
<sender>m_pButtonToggleStart</sender>
|
||||||
|
|
|
@ -119,7 +119,7 @@ void MainWindow::wizardFinished()
|
||||||
|
|
||||||
void MainWindow::onModeChanged(bool firstRun, bool forceServiceApply)
|
void MainWindow::onModeChanged(bool firstRun, bool forceServiceApply)
|
||||||
{
|
{
|
||||||
refreshStartButton();
|
refreshApplyButton();
|
||||||
|
|
||||||
stopSynergy();
|
stopSynergy();
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ void MainWindow::onModeChanged(bool firstRun, bool forceServiceApply)
|
||||||
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
disconnect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
||||||
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
connect(m_pButtonToggleStart, SIGNAL(clicked()), m_pActionStartSynergy, SLOT(trigger()));
|
||||||
|
|
||||||
if (firstRun || forceServiceApply)
|
if (forceServiceApply)
|
||||||
{
|
{
|
||||||
startSynergy();
|
startSynergy();
|
||||||
}
|
}
|
||||||
|
@ -149,16 +149,9 @@ void MainWindow::onModeChanged(bool firstRun, bool forceServiceApply)
|
||||||
m_pElevateCheckBox->setEnabled(appConfig().processMode() == Service);
|
m_pElevateCheckBox->setEnabled(appConfig().processMode() == Service);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::refreshStartButton()
|
void MainWindow::refreshApplyButton()
|
||||||
{
|
{
|
||||||
if (appConfig().processMode() == Service)
|
m_pButtonApply->setEnabled(appConfig().processMode() == Service);
|
||||||
{
|
|
||||||
m_pButtonToggleStart->setText(tr("&Apply"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pButtonToggleStart->setText(tr("&Start"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setStatus(const QString &status)
|
void MainWindow::setStatus(const QString &status)
|
||||||
|
@ -294,22 +287,7 @@ void MainWindow::logOutput()
|
||||||
{
|
{
|
||||||
if (!line.isEmpty())
|
if (!line.isEmpty())
|
||||||
{
|
{
|
||||||
appendLogRaw(line);
|
appendLogRaw(line);
|
||||||
if (line.contains("has connected") ||
|
|
||||||
line.contains("connected to server"))
|
|
||||||
{
|
|
||||||
// only set connected state and hide, if we get
|
|
||||||
// "has connected" message. this is a little bit
|
|
||||||
// hacky, but it works for now (until we have IPC).
|
|
||||||
setSynergyState(synergyConnected);
|
|
||||||
|
|
||||||
// only hide once after each new connection.
|
|
||||||
if (!m_alreadyHidden && appConfig().autoHide())
|
|
||||||
{
|
|
||||||
hide();
|
|
||||||
m_alreadyHidden = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -344,9 +322,29 @@ void MainWindow::appendLogError(const QString& text)
|
||||||
|
|
||||||
void MainWindow::appendLogRaw(const QString& text)
|
void MainWindow::appendLogRaw(const QString& text)
|
||||||
{
|
{
|
||||||
foreach(QString line, text.split(QRegExp("\r|\n|\r\n")))
|
foreach(QString line, text.split(QRegExp("\r|\n|\r\n"))) {
|
||||||
if (!line.isEmpty())
|
if (!line.isEmpty()) {
|
||||||
m_pLogOutput->append(line);
|
m_pLogOutput->append(line);
|
||||||
|
updateStateFromLogLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::updateStateFromLogLine(const QString &line)
|
||||||
|
{
|
||||||
|
// TODO: implement ipc connection state messages to replace this hack.
|
||||||
|
if (line.contains("started server") ||
|
||||||
|
line.contains("connected to server"))
|
||||||
|
{
|
||||||
|
setSynergyState(synergyConnected);
|
||||||
|
|
||||||
|
// only hide once after each new connection.
|
||||||
|
if (!m_alreadyHidden && appConfig().autoHide())
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
m_alreadyHidden = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::clearLog()
|
void MainWindow::clearLog()
|
||||||
|
@ -435,15 +433,7 @@ void MainWindow::startSynergy()
|
||||||
if (!m_pLogOutput->toPlainText().isEmpty())
|
if (!m_pLogOutput->toPlainText().isEmpty())
|
||||||
appendLogRaw("");
|
appendLogRaw("");
|
||||||
|
|
||||||
if (desktopMode)
|
appendLogNote("starting " + QString(synergyType() == synergyServer ? "server" : "client"));
|
||||||
{
|
|
||||||
appendLogNote("starting " + QString(synergyType() == synergyServer ? "server" : "client"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (serviceMode)
|
|
||||||
{
|
|
||||||
appendLogNote("applying service mode: " + QString(synergyType() == synergyServer ? "server" : "client"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// show command if debug log level...
|
// show command if debug log level...
|
||||||
if (appConfig().logLevel() >= 4) {
|
if (appConfig().logLevel() >= 4) {
|
||||||
|
@ -575,7 +565,11 @@ bool MainWindow::serverArgs(QStringList& args, QString& app)
|
||||||
|
|
||||||
void MainWindow::stopSynergy()
|
void MainWindow::stopSynergy()
|
||||||
{
|
{
|
||||||
if (synergyProcess())
|
if (appConfig().processMode() == Service) {
|
||||||
|
// send empty command to stop service from laucning anything.
|
||||||
|
m_IpcClient.sendCommand("", m_ElevateProcess);
|
||||||
|
}
|
||||||
|
else if (synergyProcess())
|
||||||
{
|
{
|
||||||
appendLogNote("stopping synergy");
|
appendLogNote("stopping synergy");
|
||||||
|
|
||||||
|
@ -583,10 +577,10 @@ void MainWindow::stopSynergy()
|
||||||
synergyProcess()->close();
|
synergyProcess()->close();
|
||||||
delete synergyProcess();
|
delete synergyProcess();
|
||||||
setSynergyProcess(NULL);
|
setSynergyProcess(NULL);
|
||||||
|
|
||||||
setSynergyState(synergyDisconnected);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSynergyState(synergyDisconnected);
|
||||||
|
|
||||||
// HACK: deleting the object deletes the physical file, which is
|
// HACK: deleting the object deletes the physical file, which is
|
||||||
// bad, since it could be in use by the Windows service!
|
// bad, since it could be in use by the Windows service!
|
||||||
//delete m_pTempConfigFile;
|
//delete m_pTempConfigFile;
|
||||||
|
@ -617,10 +611,6 @@ void MainWindow::synergyFinished(int exitCode, QProcess::ExitStatus)
|
||||||
|
|
||||||
void MainWindow::setSynergyState(qSynergyState state)
|
void MainWindow::setSynergyState(qSynergyState state)
|
||||||
{
|
{
|
||||||
// ignore state stuff when in service mode (for now anyway).
|
|
||||||
if (appConfig().processMode() == Service)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (synergyState() == state)
|
if (synergyState() == state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -747,3 +737,8 @@ void MainWindow::on_m_pElevateCheckBox_toggled(bool checked)
|
||||||
settings().setValue("elevateChecked", checked);
|
settings().setValue("elevateChecked", checked);
|
||||||
settings().sync();
|
settings().sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_m_pButtonApply_clicked()
|
||||||
|
{
|
||||||
|
startSynergy();
|
||||||
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
void logOutput();
|
void logOutput();
|
||||||
void logError();
|
void logError();
|
||||||
void updateFound(const QString& version);
|
void updateFound(const QString& version);
|
||||||
void refreshStartButton();
|
void refreshApplyButton();
|
||||||
void wizardFinished();
|
void wizardFinished();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -135,6 +135,7 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
void setStatus(const QString& status);
|
void setStatus(const QString& status);
|
||||||
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
void sendIpcMessage(qIpcMessageType type, const char* buffer, bool showErrors);
|
||||||
void onModeChanged(bool firstRun, bool forceServiceApply);
|
void onModeChanged(bool firstRun, bool forceServiceApply);
|
||||||
|
void updateStateFromLogLine(const QString& line);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSettings& m_Settings;
|
QSettings& m_Settings;
|
||||||
|
@ -151,6 +152,9 @@ class MainWindow : public QMainWindow, public Ui::MainWindowBase
|
||||||
IpcClient m_IpcClient;
|
IpcClient m_IpcClient;
|
||||||
bool m_ElevateProcess;
|
bool m_ElevateProcess;
|
||||||
bool m_SuppressElevateWarning;
|
bool m_SuppressElevateWarning;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_m_pButtonApply_clicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue