Changeset View
Changeset View
Standalone View
Standalone View
src/SpectacleCore.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
82 | } | 82 | } | ||
83 | 83 | | |||
84 | // set up the export manager | 84 | // set up the export manager | ||
85 | auto lExportManager = ExportManager::instance(); | 85 | auto lExportManager = ExportManager::instance(); | ||
86 | lExportManager->setCaptureMode(theCaptureMode); | 86 | lExportManager->setCaptureMode(theCaptureMode); | ||
87 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | 87 | connect(lExportManager, &ExportManager::errorMessage, this, &SpectacleCore::showErrorMessage); | ||
88 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | 88 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doCopyPath); | ||
89 | connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | 89 | connect(lExportManager, &ExportManager::forceNotify, this, &SpectacleCore::doNotify); | ||
90 | connect(lExportManager, &ExportManager::imageSaved, this, &SpectacleCore::doTask); | ||||
91 | connect(lExportManager, &ExportManager::imageSavedAndCopied, this, &SpectacleCore::doTask); | ||||
90 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | 92 | connect(mPlatform.get(), &Platform::windowTitleChanged, lExportManager, &ExportManager::setWindowTitle); | ||
91 | 93 | | |||
92 | switch (theStartMode) { | 94 | switch (theStartMode) { | ||
93 | case StartMode::DBus: | 95 | case StartMode::DBus: | ||
94 | break; | 96 | break; | ||
95 | case StartMode::Background: { | 97 | case StartMode::Background: { | ||
96 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | 98 | auto lMsec = (KWindowSystem::compositingActive() ? 200 : 50) + theDelayMsec; | ||
97 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | 99 | auto lShutterMode = lImmediateAvailable ? Platform::ShutterMode::Immediate : Platform::ShutterMode::OnClick; | ||
▲ Show 20 Lines • Show All 264 Lines • ▼ Show 20 Line(s) | |||||
362 | 364 | | |||
363 | void SpectacleCore::doCopyPath(const QUrl &savedAt) | 365 | void SpectacleCore::doCopyPath(const QUrl &savedAt) | ||
364 | { | 366 | { | ||
365 | if (SpectacleConfig::instance()->copySaveLocationToClipboard()) { | 367 | if (SpectacleConfig::instance()->copySaveLocationToClipboard()) { | ||
366 | qApp->clipboard()->setText(savedAt.toLocalFile()); | 368 | qApp->clipboard()->setText(savedAt.toLocalFile()); | ||
367 | } | 369 | } | ||
368 | } | 370 | } | ||
369 | 371 | | |||
372 | void SpectacleCore::doTask(const QUrl &savedAt) | ||||
373 | { | ||||
374 | if (SpectacleConfig::instance()->runTask()) { | ||||
375 | QUrl taskLocationUrl = SpectacleConfig::instance()->taskLocation(); | ||||
376 | QString taskLocationString = taskLocationUrl.toString(); | ||||
377 | QProcess taskProcess; | ||||
378 | taskProcess.setArguments(QStringList() << taskLocationUrl.path(QUrl::FullyEncoded) << savedAt.toString()); | ||||
379 | taskProcess.setWorkingDirectory(savedAt.path(QUrl::FullyEncoded | QUrl::RemoveFilename)); | ||||
380 | | ||||
381 | if (taskLocationString.endsWith(QStringLiteral(".sh"))) { | ||||
382 | QString userShell = QString::fromUtf8(qgetenv("SHELL")); | ||||
383 | taskProcess.setProgram(userShell); | ||||
384 | } else if (taskLocationString.endsWith(QStringLiteral(".py"))) { | ||||
385 | taskProcess.setProgram(QStringLiteral("python")); | ||||
386 | } else { | ||||
387 | taskProcess.setProgram(taskLocationString); | ||||
388 | } | ||||
389 | | ||||
390 | taskProcess.startDetached(); | ||||
391 | } | ||||
392 | } | ||||
393 | | ||||
370 | void SpectacleCore::doStartDragAndDrop() | 394 | void SpectacleCore::doStartDragAndDrop() | ||
371 | { | 395 | { | ||
372 | auto lExportManager = ExportManager::instance(); | 396 | auto lExportManager = ExportManager::instance(); | ||
373 | QUrl lTempFile = lExportManager->tempSave(); | 397 | QUrl lTempFile = lExportManager->tempSave(); | ||
374 | if (!lTempFile.isValid()) { | 398 | if (!lTempFile.isValid()) { | ||
375 | return; | 399 | return; | ||
376 | } | 400 | } | ||
377 | 401 | | |||
▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines |