| 166 | } |
| 167 | |
| 168 | void Screenshot::optimize() |
| 169 | { |
| 170 | QProcess *process = new QProcess(this); |
| 171 | |
| 172 | // Delete the QProcess once it's done. |
| 173 | connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this , SLOT(optimizationDone())); |
| 174 | connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), process, SLOT(deleteLater())); |
| 175 | |
| 176 | QString optiPNG; |
| 177 | |
| 178 | #ifdef Q_OS_UNIX |
| 179 | optiPNG = "optipng"; |
| 180 | #else |
| 181 | optiPNG = qApp->applicationDirPath() % QDir::separator() % "optipng.exe"; |
| 182 | #endif |
| 183 | |
| 184 | if (!QFile::exists(optiPNG)) { |
| 185 | emit optimizationDone(); |
| 186 | } |
| 187 | |
| 188 | process->start(optiPNG, QStringList() << mOptions.fileName); |
| 189 | |
| 190 | if (process->state() == QProcess::NotRunning) { |
| 191 | emit optimizationDone(); |
| 192 | process->deleteLater(); |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void Screenshot::optimizationDone() |
| 197 | { |
nothing calls this directly
no outgoing calls
no test coverage detected