mirror of
https://github.com/mapmapteam/mapmap.git
synced 2026-06-16 12:33:19 +02:00
Camera implement improvements
This commit is contained in:
@@ -51,6 +51,10 @@ bool CameraImpl::loadMovie(const QString &path)
|
||||
if (_camera->state() == QCamera::ActiveState)
|
||||
return true;
|
||||
|
||||
if (_camera->error() != QCamera::NoError)
|
||||
QMessageBox(QMessageBox::Critical, "Camera Error",
|
||||
"Failed to start: " + _camera->errorString()).exec();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+16
-7
@@ -630,6 +630,9 @@ void MainWindow::importMedia()
|
||||
void MainWindow::openCameraDevice()
|
||||
{
|
||||
#if QT_VERSION >= 0x050300
|
||||
// Stop video playback, if it is playing, to avoid lags. XXX Hack
|
||||
pause(!pauseAction->isVisible());
|
||||
|
||||
QString device;
|
||||
QList<QCameraInfo> cameras = QCameraInfo::availableCameras();
|
||||
|
||||
@@ -653,18 +656,25 @@ void MainWindow::openCameraDevice()
|
||||
if (devices.contains(deviceName))
|
||||
device = devices.value(deviceName);
|
||||
}
|
||||
}
|
||||
|
||||
else if (QCameraInfo::defaultCamera().isNull())
|
||||
{
|
||||
QMessageBox::warning(this, tr("No camera available"), tr("You can not use this feature!\nNo camera available in your system"));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
device = QCameraInfo::defaultCamera().deviceName();
|
||||
if (QCameraInfo::defaultCamera().isNull())
|
||||
{
|
||||
QMessageBox::warning(this, tr("No camera available"), tr("You can not use this feature!\nNo camera available in your system"));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
device = QCameraInfo::defaultCamera().deviceName();
|
||||
}
|
||||
}
|
||||
|
||||
// Restart video playback if it was previously playing. XXX Hack
|
||||
play(!pauseAction->isVisible());
|
||||
|
||||
if (!device.isEmpty())
|
||||
importMediaFile(device, false, true);
|
||||
#else
|
||||
@@ -2714,12 +2724,11 @@ bool MainWindow::importMediaFile(const QString &fileName, bool isImage, bool isC
|
||||
if (!fileSupported(fileName, isImage))
|
||||
return false;
|
||||
|
||||
// if (fileName.contains(QString("/dev/video"))) {
|
||||
if (isCamera) {
|
||||
type = VIDEO_WEBCAM;
|
||||
}
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
if (!isCamera && !file.open(QIODevice::ReadOnly)) {
|
||||
if (file.isSequential()) {
|
||||
type = VIDEO_SHMSRC;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user