示例#1
0
void MainWindow::startSynergy()
{
	stopSynergy();

	QString app;
	QStringList args;

	args << "-f" << "--debug" << appConfig().logLevelText();

	if (!appConfig().screenName().isEmpty())
		args << "--name" << appConfig().screenName();

	if (appConfig().gameDevice())
	{
		args << "--game-device";
	}

	setSynergyProcess(new QProcess(this));

	if ((synergyType() == synergyClient && !clientArgs(args, app))
		|| (synergyType() == synergyServer && !serverArgs(args, app)))
	{
		stopSynergy();
		return;
	}

	connect(synergyProcess(), SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(synergyFinished(int, QProcess::ExitStatus)));
	connect(synergyProcess(), SIGNAL(readyReadStandardOutput()), m_pLogDialog, SLOT(readSynergyOutput()));
	connect(synergyProcess(), SIGNAL(readyReadStandardError()), m_pLogDialog, SLOT(readSynergyOutput()));

	m_pLogDialog->append(tr("\n\nRunning synergy: %1 %2\n\n").arg(app).arg(args.join(" ")));

	synergyProcess()->start(app, args);
	if (!synergyProcess()->waitForStarted())
	{
		stopSynergy();
		QMessageBox::warning(this, tr("Program can not be started"), QString(tr("The executable<br><br>%1<br><br>could not be successfully started, although it does exist. Please check if you have sufficient permissions to run this program.").arg(app)));
		return;
	}

	setSynergyState(synergyConnected);
}
示例#2
0
void MainWindow::initConnections()
{
    connect(m_pActionMinimize, SIGNAL(triggered()), this, SLOT(hide()));
    connect(m_pActionRestore, SIGNAL(triggered()), this, SLOT(showNormal()));
    connect(m_pActionStartSynergy, SIGNAL(triggered()), this, SLOT(startSynergy()));
    connect(m_pActionStopSynergy, SIGNAL(triggered()), this, SLOT(stopSynergy()));
    connect(m_pActionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));

    if (m_pTrayIcon)
        connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
}
示例#3
0
void MainWindow::synergyFinished(int exitCode, QProcess::ExitStatus)
{
    // on Windows, we always seem to have an exit code != 0.
#if !defined(Q_OS_WIN)
    if (exitCode != 0)
    {
        QMessageBox::critical(this, tr("Synergy terminated with an error"), QString(tr("Synergy terminated unexpectedly with an exit code of %1.<br><br>Please see the log output for details.")).arg(exitCode));
        stopSynergy();
    }
#else
    Q_UNUSED(exitCode);
#endif

    setSynergyState(synergyDisconnected);

    // do not call stopSynergy() in case of clean synergy shutdown, because this must have (well, should have...)
    // come from our own delete synergyProcess() in stopSynergy(), so we would do a double-delete...
}
示例#4
0
MainWindow::~MainWindow()
{
    stopSynergy();
    saveSettings();
}