本文整理汇总了C++中TrayIcon::enableShutdownMenu方法的典型用法代码示例。如果您正苦于以下问题:C++ TrayIcon::enableShutdownMenu方法的具体用法?C++ TrayIcon::enableShutdownMenu怎么用?C++ TrayIcon::enableShutdownMenu使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrayIcon
的用法示例。
在下文中一共展示了TrayIcon::enableShutdownMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
dlg->setApplicationPath(settings.value("ApplicationPath").toString());
dlg->setModal(true);
ok = dlg->exec();
QString browsercommand = dlg->getBrowserCommand();
QString pythonpath = dlg->getPythonPath();
QString applicationpath = dlg->getApplicationPath();
if (ok)
{
settings.setValue("BrowserCommand", browsercommand);
settings.setValue("PythonPath", pythonpath);
settings.setValue("ApplicationPath", applicationpath);
settings.sync();
}
else
{
exit(1);
}
delete server;
}
else
done = true;
}
// Ensure the server gets cleaned up later
QObject::connect(server, SIGNAL(finished()), server, SLOT(deleteLater()));
// Generate the app server URL
QString appServerUrl = QString("http://127.0.0.1:%1/?key=%2").arg(port).arg(key);
// Read the server connection timeout from the registry or set the default timeout.
int timeout = settings.value("ConnectionTimeout", 30).toInt();
// Now the server should be up, we'll attempt to connect and get a response.
// We'll retry in a loop a few time before aborting if necessary.
QTime endTime = QTime::currentTime().addSecs(timeout);
bool alive = false;
while(QTime::currentTime() <= endTime)
{
alive = PingServer(QUrl(appServerUrl));
if (alive)
{
break;
}
delay(200);
}
// Attempt to connect one more time in case of a long network timeout while looping
if (!alive && !PingServer(QUrl(appServerUrl)))
{
splash->finish(NULL);
QString error(QWidget::tr("The application server could not be contacted."));
QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
exit(1);
}
// Stash the URL for any duplicate processes to open
if (addrFile.open(QIODevice::WriteOnly))
{
addrFile.setPermissions(QFile::ReadOwner|QFile::WriteOwner);
QTextStream out(&addrFile);
out << appServerUrl << endl;
}
// Go!
trayicon->setAppServerUrl(appServerUrl);
// Enable the shutdown server menu as server started successfully.
trayicon->enableShutdownMenu();
QString cmd = settings.value("BrowserCommand").toString();
if (!cmd.isEmpty())
{
cmd.replace("%URL%", appServerUrl);
QProcess::startDetached(cmd);
}
else
{
if (!QDesktopServices::openUrl(appServerUrl))
{
QString error(QWidget::tr("Failed to open the system default web browser. Is one installed?."));
QMessageBox::critical(NULL, QString(QWidget::tr("Fatal Error")), error);
exit(1);
}
}
QObject::connect(trayicon, SIGNAL(shutdownSignal(QUrl)), server, SLOT(shutdown(QUrl)));
splash->finish(NULL);
return app.exec();
}