本文整理汇总了C++中QProcess::setProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ QProcess::setProperty方法的具体用法?C++ QProcess::setProperty怎么用?C++ QProcess::setProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProcess
的用法示例。
在下文中一共展示了QProcess::setProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleComponentFinished
void RepoInfoFetcher::handleComponentFinished (int id)
{
if (!PendingComponents_.contains (id))
return;
PendingComponent pc = PendingComponents_.take (id);
QProcess *unarch = new QProcess (this);
unarch->setProperty ("Component", pc.Component_);
unarch->setProperty ("Filename", pc.Location_);
unarch->setProperty ("URL", pc.URL_);
unarch->setProperty ("RepoID", pc.RepoID_);
connect (unarch,
SIGNAL (finished (int, QProcess::ExitStatus)),
this,
SLOT (handleComponentUnarchFinished (int, QProcess::ExitStatus)));
connect (unarch,
SIGNAL (error (QProcess::ProcessError)),
this,
SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
unarch->start ("7za", QStringList ("e") << "-so" << pc.Location_);
#else
unarch->start ("gunzip", QStringList ("-c") << pc.Location_);
#endif
}
示例2: handlePackageFinished
void RepoInfoFetcher::handlePackageFinished (int id)
{
if (!PendingPackages_.contains (id))
return;
PendingPackage pp = PendingPackages_ [id];
QProcess *unarch = new QProcess (this);
unarch->setProperty ("Filename", pp.Location_);
unarch->setProperty ("URL", pp.URL_);
unarch->setProperty ("TaskID", id);
connect (unarch,
SIGNAL (finished (int, QProcess::ExitStatus)),
this,
SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
connect (unarch,
SIGNAL (error (QProcess::ProcessError)),
this,
SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
unarch->start ("7za", QStringList ("e") << "-so" << pp.Location_);
#else
unarch->start ("gunzip", QStringList ("-c") << pp.Location_);
#endif
}
示例3: handleRIFinished
void RepoInfoFetcher::handleRIFinished (int id)
{
if (!PendingRIs_.contains (id))
return;
PendingRI pri = PendingRIs_.take (id);
QString name = pri.Location_;
QProcess *unarch = new QProcess (this);
unarch->setProperty ("URL", pri.URL_);
unarch->setProperty ("Filename", name);
connect (unarch,
SIGNAL (finished (int, QProcess::ExitStatus)),
this,
SLOT (handleRepoUnarchFinished (int, QProcess::ExitStatus)));
connect (unarch,
SIGNAL (error (QProcess::ProcessError)),
this,
SLOT (handleUnarchError (QProcess::ProcessError)));
#ifdef Q_OS_WIN32
unarch->start ("7za", QStringList ("e") << "-so" << name);
#else
unarch->start ("gunzip", QStringList ("-c") << name);
#endif
}
示例4: HandleFile
void PackageProcessor::HandleFile (int packageId,
const QUrl& url, PackageProcessor::Mode mode)
{
QString path = Core::Instance ()
.GetExtResourceManager ()->GetResourcePath (url);
QProcess *unarch = new QProcess (this);
connect (unarch,
SIGNAL (finished (int, QProcess::ExitStatus)),
this,
SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
connect (unarch,
SIGNAL (error (QProcess::ProcessError)),
this,
SLOT (handleUnarchError (QProcess::ProcessError)));
QString dirname = Util::GetTemporaryName ("lackman_stagingarea");
QStringList args;
#ifdef Q_WS_WIN
args << "x";
#else
args << "xzf";
#endif
args << path;
#ifdef Q_WS_WIN
args << "-o";
#else
args << "-C";
#endif
args << dirname;
unarch->setProperty ("PackageID", packageId);
unarch->setProperty ("StagingDirectory", dirname);
unarch->setProperty ("Path", path);
unarch->setProperty ("Mode", mode);
QFileInfo sdInfo (dirname);
QDir stagingParentDir (sdInfo.path ());
if (!stagingParentDir.exists (sdInfo.fileName ()) &&
!stagingParentDir.mkdir (sdInfo.fileName ()))
{
qWarning () << Q_FUNC_INFO
<< "unable to create staging directory"
<< sdInfo.fileName ()
<< "in"
<< sdInfo.path ();
QString errorString = tr ("Unable to create staging directory %1.")
.arg (sdInfo.fileName ());
emit packageInstallError (packageId, errorString);
return;
}
#ifdef Q_WS_WIN
QString command = "7za";
#else
QString command = "tar";
#endif
unarch->start (command, args);
}
示例5: scanWifi
void QNetCtlTool::scanWifi(QString device)
{
if (device.isNull() && sender())
device = sender()->property("QNetCtlScanDevice").toString();
if (myScanningDevices.contains(device))
return;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
QProcess *proc = new QProcess(this);
proc->setProcessEnvironment(env);
bool isDown = false;
proc->start(TOOL(ip) + " link show " + device, QIODevice::ReadOnly);
proc->waitForFinished();
if (proc->exitStatus() == QProcess::NormalExit && !proc->exitCode())
isDown = !QString::fromLocal8Bit(proc->readAllStandardOutput()).section('>', 0, 0).contains("UP");
bool waitsForUp = myUplinkingDevices.contains(device);
if (isDown) {
if (!waitsForUp) {
waitsForUp = true;
myUplinkingDevices << device;
proc->start(TOOL(ip) + " link set " + device + " up", QIODevice::ReadOnly);
proc->waitForFinished();
}
// we're waiting for the device to come up
delete proc;
QTimer *t = new QTimer(this);
t->setProperty("QNetCtlScanDevice", device);
t->setSingleShot(true);
connect(t, SIGNAL(timeout()), this, SLOT(scanWifi()));
connect(t, SIGNAL(timeout()), t, SLOT(deleteLater()));
t->start(500);
return;
}
myScanningDevices << device;
proc->setProperty("QNetCtlTag", "scan_wifi");
proc->setProperty("QNetCtlInfo", device);
// if we set it up, we've to set it back down through the chain slot
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), waitsForUp ? SLOT(chain()) : SLOT(reply()));
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
proc->start(TOOL(iw) + " dev " + device + " scan");
}
示例6: slotNotify
void SnoreToast::slotNotify(Notification notification)
{
QProcess *p = new QProcess(this);
p->setReadChannelMode(QProcess::MergedChannels);
connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill()));
QStringList arguements;
arguements << "-t"
<< Snore::toPlainText(notification.title())
<< "-m"
<< Snore::toPlainText(notification.text());
if(notification.icon().isValid())
{
arguements << "-p"
<< QDir::toNativeSeparators(notification.icon().localUrl());
}
arguements << "-w"
<< "-appID"
<< appId(notification.application())
<< "-id"
<< QString::number(notification.id());
if(notification.hints().value("silent",true).toBool())
{
arguements << "-silent";
}
snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements;
p->start("SnoreToast", arguements);
p->setProperty("SNORE_NOTIFICATION_ID",notification.id());
}
示例7: startDetailsProcess
// I decided to do this direct here to avoid "Handstände" with signals and stuff
// if we would do this in libwinpopup. GF
void WPUserInfo::startDetailsProcess(const QString &host)
{
QProcess *ipProcess = new QProcess;
connect(ipProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotDetailsProcess(int,QProcess::ExitStatus)));
connect(ipProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(slotDetailsProcess()));
ipProcess->setProperty("host", host);
ipProcess->setProcessChannelMode(QProcess::MergedChannels);
ipProcess->start("nmblookup", QStringList() << host);
}
示例8: request
void QNetCtlTool::request(const QString tag, const QString information)
{
QString cmd;
bool chain = false;
// debug(tag + information);
if (tag == "switch_to_profile") {
cmd = TOOL(netctl) + " switch-to " + information;
} else if (tag == "stop_profile") {
cmd = TOOL(netctl) + " stop " + information;
} else if (tag == "scan_wifi") {
scanWifi(information);
return;
} else if (tag == "enable_profile") {
cmd = TOOL(netctl) + " enable " + information;
} else if (tag == "enable_service") {
if (information.startsWith("netctl-"))
cmd = TOOL(systemctl) + " enable " + information;
}
else if (tag == "disable_profile") {
cmd = TOOL(netctl) + " disable " + information;
} else if (tag == "disable_service") {
if (information.startsWith("netctl-"))
cmd = TOOL(systemctl) + " disable " + information;
} else if (tag == "remove_profile") {
chain = true;
cmd = TOOL(netctl) + " disable " + information;
} else if (tag.startsWith("write_profile")) {
QString name = tag.section(' ', 1);
QFile file(gs_profilePath + name);
if (file.open(QIODevice::WriteOnly|QIODevice::Text)) {
file.write(information.toLocal8Bit());
file.close();
myClient->call(QDBus::NoBlock, "reply", tag, "SUCCESS");
} else {
myClient->call(QDBus::NoBlock, "reply", tag, "ERROR");
}
return; // no process to run
} else if (tag == "reparse_config") {
return;
} else if (tag == "quit") {
quit();
return;
}
if (cmd.isNull()) {
myClient->call(QDBus::NoBlock, "reply", tag, "ERROR: unsupported command / request:" + information);
return;
}
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.remove("LC_ALL");
env.remove("LANG");
QProcess *proc = new QProcess(this);
proc->setProcessEnvironment(env);
proc->setProperty("QNetCtlTag", tag);
if (chain) {
proc->setProperty("QNetCtlInfo", information);
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(chain()));
} else {
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(reply()));
}
connect (proc, SIGNAL(finished(int, QProcess::ExitStatus)), proc, SLOT(deleteLater()));
// debug(cmd);
proc->start(cmd, QIODevice::ReadOnly);
}
示例9: HandleFile
void PackageProcessor::HandleFile (int packageId,
const QUrl& url, PackageProcessor::Mode mode)
{
QString path = Core::Instance ().GetExtResourceManager ()->GetResourcePath (url);
PackageShortInfo info;
try
{
info = Core::Instance ().GetStorage ()->GetPackage (packageId);
}
catch (const std::exception& e)
{
qWarning () << Q_FUNC_INFO
<< "unable to get package info for"
<< packageId
<< e.what ();
return;
}
const QString& archiver = info.VersionArchivers_
.value (info.Versions_.value (0), "gz");
QProcess *unarch = new QProcess (this);
connect (unarch,
SIGNAL (finished (int, QProcess::ExitStatus)),
this,
SLOT (handlePackageUnarchFinished (int, QProcess::ExitStatus)));
connect (unarch,
SIGNAL (error (QProcess::ProcessError)),
this,
SLOT (handleUnarchError (QProcess::ProcessError)));
QString dirname = Util::GetTemporaryName ("lackman_stagingarea");
QStringList args;
#ifdef Q_OS_WIN32
args << "x"
<< "-ttar"
<< "-y"
<< "-si";
QString outDirArg ("-o");
outDirArg.append (dirname);
args << outDirArg;
QProcess *firstStep = new QProcess (unarch);
firstStep->setStandardOutputProcess (unarch);
QStringList firstStepArgs;
firstStepArgs << "x"
<< "-y"
<< "-so"
<< path;
#else
if (archiver == "lzma")
args << "--lzma";
args << "-xf";
args << path;
args << "-C";
args << dirname;
#endif
unarch->setProperty ("PackageID", packageId);
unarch->setProperty ("StagingDirectory", dirname);
unarch->setProperty ("Path", path);
unarch->setProperty ("Mode", mode);
QFileInfo sdInfo (dirname);
QDir stagingParentDir (sdInfo.path ());
if (!stagingParentDir.exists (sdInfo.fileName ()) &&
!stagingParentDir.mkdir (sdInfo.fileName ()))
{
qWarning () << Q_FUNC_INFO
<< "unable to create staging directory"
<< sdInfo.fileName ()
<< "in"
<< sdInfo.path ();
QString errorString = tr ("Unable to create staging directory %1.")
.arg (sdInfo.fileName ());
emit packageInstallError (packageId, errorString);
return;
}
#ifdef Q_OS_WIN32
QString command = "7za";
firstStep->start (command, firstStepArgs);
#else
QString command = "tar";
#endif
unarch->start (command, args);
}