add_subdirectory(onmonitoritems)
add_subdirectory(rotoscoping)
add_subdirectory(widgets)
+add_subdirectory(databackup)
macro_optional_find_package(Nepomuk)
macro_optional_find_package(QJSON)
--- /dev/null
+set(kdenlive_SRCS
+ ${kdenlive_SRCS}
+ databackup/backupwidget.cpp
+ PARENT_SCOPE
+)
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#include "backupwidget.h"
+#include "kdenlivesettings.h"
+
+#include <KUrl>
+
+
+BackupWidget::BackupWidget(KUrl projectUrl, KUrl projectFolder, QWidget * parent) :
+ QDialog(parent),
+ m_url(projectUrl)
+{
+ setupUi(this);
+ setWindowTitle(i18n("Restore Backup File"));
+
+ KUrl backupFile;
+ m_projectWildcard = projectUrl.fileName().section('.', 0, -2);
+ project_url->setUrl(projectFolder);
+
+ m_projectWildcard.append("-??");
+ m_projectWildcard.append("??");
+ m_projectWildcard.append("-??");
+ m_projectWildcard.append("-??");
+ m_projectWildcard.append("-??");
+ m_projectWildcard.append("-??.kdenlive");
+
+ slotParseBackupFiles();
+ connect(backup_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotDisplayBackupPreview()));
+ connect(project_url, SIGNAL(textChanged(const QString &)), this, SLOT(slotParseBackupFiles()));
+ backup_list->setCurrentRow(0);
+ backup_list->setMinimumHeight(QFontMetrics(font()).lineSpacing() * 12);
+
+}
+
+
+
+BackupWidget::~BackupWidget()
+{
+
+}
+
+void BackupWidget::slotParseBackupFiles()
+{
+ QStringList filter;
+ KUrl backupFile = project_url->url();
+ backupFile.addPath(".backup/");
+ QDir dir(backupFile.path());
+
+ filter << m_projectWildcard;
+ dir.setNameFilters(filter);
+ QFileInfoList resultList = dir.entryInfoList(QDir::Files, QDir::Time);
+ QStringList results;
+ QListWidgetItem *item;
+ for (int i = 0; i < resultList.count(); i++) {
+ item = new QListWidgetItem(resultList.at(i).lastModified().toString(Qt::DefaultLocaleLongDate), backup_list);
+ item->setData(Qt::UserRole, resultList.at(i).absoluteFilePath());
+ }
+}
+
+void BackupWidget::slotDisplayBackupPreview()
+{
+ QString path = backup_list->currentItem()->data(Qt::UserRole).toString();
+ QPixmap pix(path + ".png");
+ backup_preview->setPixmap(pix);
+}
+
+QString BackupWidget::selectedFile()
+{
+ if (!backup_list->currentItem()) return QString();
+ return backup_list->currentItem()->data(Qt::UserRole).toString();
+}
\ No newline at end of file
--- /dev/null
+/***************************************************************************
+ * Copyright (C) 2011 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+
+#ifndef BACKUPWIDGET_H
+#define BACKUPWIDGET_H
+
+
+#include "ui_backupdialog_ui.h"
+
+
+
+/**
+ * @class BackupWidget
+ * @brief A widget allowing to parse backup project files
+ * @author Jean-Baptiste Mardelle
+ */
+
+class BackupWidget : public QDialog, public Ui::BackupDialog_UI
+{
+ Q_OBJECT
+
+public:
+ BackupWidget(KUrl projectUrl, KUrl projectFolder, QWidget * parent = 0);
+ // Constructor for extracting widget
+ ~BackupWidget();
+ /** @brief Return the path for selected backup file. */
+ QString selectedFile();
+
+private slots:
+ /** @brief Parse the backup files in project folder. */
+ void slotParseBackupFiles();
+ /** @brief Display a thumbnail preview of selected backup. */
+ void slotDisplayBackupPreview();
+
+private:
+ KUrl m_url;
+ QString m_projectWildcard;
+
+signals:
+};
+
+
+#endif
+
const double DOCUMENTVERSION = 0.86;
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent, KProgressDialog *progressDialog) :
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
QObject(parent),
m_autosave(NULL),
m_url(url),
i.next();
m_documentProperties[i.key()] = i.value();
}
+
+ *openBackup = false;
if (!url.isEmpty()) {
QString tmpFile;
success = KIO::NetAccess::download(url.path(), tmpFile, parent);
- if (!success) // The file cannot be opened
- KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
+ if (!success) {
+ // The file cannot be opened
+ if (KMessageBox::warningContinueCancel(parent, i18n("Cannot open the project file, error is:\n%1\nDo you want to open a backup file?", KIO::NetAccess::lastErrorString()), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
+ *openBackup = true;
+ }
+ //KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
+ }
else {
QFile file(tmpFile);
QString errorMsg;
file.close();
KIO::NetAccess::removeTempFile(tmpFile);
- if (!success) // It is corrupted
- KMessageBox::error(parent, errorMsg);
+ if (!success) {
+ // It is corrupted
+ if (KMessageBox::warningContinueCancel(parent, i18n("Cannot open the project file, error is:\n%1\nDo you want to open a backup file?", errorMsg), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
+ *openBackup = true;
+ }
+ //KMessageBox::error(parent, errorMsg);
+ }
else {
parent->slotGotProgressInfo(i18n("Validating"), 0);
qApp->processEvents();
if (!success) {
// It is not a project file
parent->slotGotProgressInfo(i18n("File %1 is not a Kdenlive project file", m_url.path()), 100);
+ if (KMessageBox::warningContinueCancel(parent, i18n("File %1 is not a valid project file.\nDo you want to open a backup file?", m_url.path()), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
+ *openBackup = true;
+ }
} else {
/*
* Validate the file against the current version (upgrade
// Something went wrong, or a new file was requested: create a new project
if (!success) {
- m_url = KUrl();
+ m_url.clear();
setProfilePath(profileName);
m_document = createEmptyDocument(tracks.x(), tracks.y());
}
{
Q_OBJECT public:
- KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent = 0, KProgressDialog *progressDialog = 0);
+ KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent = 0, KProgressDialog *progressDialog = 0);
~KdenliveDoc();
QDomNodeList producersList();
double fps() const;
#include "audiospectrum.h"
#include "spectrogram.h"
#include "archivewidget.h"
+#include "databackup/backupwidget.h"
#include <KApplication>
#include <KAction>
m_jogShuttle(NULL),
#endif /* NO_JOGSHUTTLE */
m_findActivated(false),
- m_stopmotion(NULL),
- m_backup_ui(NULL)
+ m_stopmotion(NULL)
{
qRegisterMetaType<QVector<int16_t> > ();
// Create DBus interface
}
m_timelineArea->setEnabled(true);
m_projectList->setEnabled(true);
-
- KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, this);
+ bool openBackup;
+ KdenliveDoc *doc = new KdenliveDoc(KUrl(), projectFolder, m_commandStack, profileName, documentProperties, projectTracks, m_projectMonitor->render, m_notesWidget, &openBackup, this);
doc->m_autosave = new KAutoSaveFile(KUrl(), doc);
bool ok;
TrackView *trackView = new TrackView(doc, &ok, this);
progressDialog.progressBar()->setValue(0);
qApp->processEvents();
- KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, this, &progressDialog);
+ bool openBackup;
+ KdenliveDoc *doc = new KdenliveDoc(url, KdenliveSettings::defaultprojectfolder(), m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), m_projectMonitor->render, m_notesWidget, &openBackup, this, &progressDialog);
progressDialog.progressBar()->setValue(1);
progressDialog.progressBar()->setMaximum(4);
m_clipMonitor->refreshMonitor(true);
progressDialog.progressBar()->setValue(4);
+ if (openBackup) slotOpenBackupDialog(url);
}
void MainWindow::recoverFiles(QList<KAutoSaveFile *> staleFiles)
connect(doc, SIGNAL(docModified(bool)), this, SLOT(slotUpdateDocumentState(bool)));
connect(doc, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated()));
connect(doc, SIGNAL(saveTimelinePreview(const QString)), trackView->projectView(), SLOT(saveTimelinePreview(const QString)));
+
connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
}
-void MainWindow::slotOpenBackupDialog()
-{
- QDialog *dia = new QDialog(this);
- m_backup_ui = new Ui::BackupDialog_UI;
- m_backup_ui->setupUi(dia);
- dia->setWindowTitle(i18n("Backup Files"));
- KUrl backupFile = m_activeDocument->projectFolder();
- backupFile.addPath(".backup/");
- QDir dir(backupFile.path());
- QString projectFile = m_activeDocument->url().fileName().section('.', 0, -2);
- projectFile.append("-??");
- projectFile.append("??");
- projectFile.append("-??");
- projectFile.append("-??");
- projectFile.append("-??");
- projectFile.append("-??.kdenlive");
-
- QStringList filter;
- backupFile.addPath(projectFile);
- filter << projectFile;
- dir.setNameFilters(filter);
- QFileInfoList resultList = dir.entryInfoList(QDir::Files, QDir::Time);
- QStringList results;
- QListWidgetItem *item;
- for (int i = 0; i < resultList.count(); i++) {
- item = new QListWidgetItem(resultList.at(i).lastModified().toString(Qt::DefaultLocaleLongDate), m_backup_ui->backup_list);
- item->setData(Qt::UserRole, resultList.at(i).absoluteFilePath());
+void MainWindow::slotOpenBackupDialog(const KUrl url)
+{
+ KUrl projectFile;
+ KUrl projectFolder;
+ kDebug()<<"// BACKUP URL: "<<url.path();
+ if (!url.isEmpty()) {
+ // we could not open the project file, guess where the backups are
+ projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
+ projectFile = url;
}
- connect(m_backup_ui->backup_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotDisplayBackupPreview()));
- m_backup_ui->backup_list->setCurrentRow(0);
- m_backup_ui->backup_list->setMinimumHeight(QFontMetrics(font()).lineSpacing() * 12);
+ else {
+ projectFolder = m_activeDocument->projectFolder();
+ projectFile = m_activeDocument->url();
+ }
+
+ BackupWidget *dia = new BackupWidget(projectFile, projectFolder, this);
if (dia->exec() == QDialog::Accepted) {
- QString requestedBackup = m_backup_ui->backup_list->currentItem()->data(Qt::UserRole).toString();
- KUrl currentUrl = m_activeDocument->url();
- m_activeDocument->backupLastSavedVersion(currentUrl.path());
+ QString requestedBackup = dia->selectedFile();
+ m_activeDocument->backupLastSavedVersion(projectFile.path());
closeCurrentDocument(false);
doOpenFile(KUrl(requestedBackup), NULL);
- m_activeDocument->setUrl(currentUrl);
+ m_activeDocument->setUrl(projectFile);
setCaption(m_activeDocument->description());
}
delete dia;
- delete m_backup_ui;
- m_backup_ui = NULL;
}
-void MainWindow::slotDisplayBackupPreview()
-{
- QString path = m_backup_ui->backup_list->currentItem()->data(Qt::UserRole).toString();
- QPixmap pix(path + ".png");
- m_backup_ui->backup_preview->setPixmap(pix);
-}
+
+
#include "mainwindow.moc"
StopmotionWidget *m_stopmotion;
- /** @brief UI for backup dialog. */
- Ui::BackupDialog_UI *m_backup_ui;
-
public slots:
/** @brief Prepares opening @param url.
*
/** @brief Insert current project's timecode into the notes widget. */
void slotInsertNotesTimecode();
/** @brief Open the project's backupdialog. */
- void slotOpenBackupDialog();
- /** @brief Display chosen backup thumbnail. */
- void slotDisplayBackupPreview();
+ void slotOpenBackupDialog(const KUrl url = KUrl());
+
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
};
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="2" column="0">
+ <item row="3" column="1">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
- <item row="0" column="0">
+ <item row="1" column="0" colspan="2">
<widget class="KListWidget" name="backup_list">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0" colspan="2">
<widget class="QLabel" name="backup_preview">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
</widget>
</item>
+ <item row="0" column="1">
+ <widget class="KUrlRequester" name="project_url">
+ <property name="mode">
+ <set>KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Project Folder</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<customwidgets>
+ <customwidget>
+ <class>KUrlRequester</class>
+ <extends>QFrame</extends>
+ <header>kurlrequester.h</header>
+ </customwidget>
<customwidget>
<class>KListWidget</class>
<extends>QListWidget</extends>