From d1ae9c451b613cf4597433ffe315e64dd8c0144d Mon Sep 17 00:00:00 2001 From: Alberto Villa Date: Wed, 12 May 2010 11:29:16 +0000 Subject: [PATCH] - mainwindow.cpp: possibly avoid a step when locating MLT environment in parseProfiles() - Start documenting code. - Reindent and cleanup. svn path=/trunk/kdenlive/; revision=4432 --- src/geometryval.cpp | 2 +- src/main.cpp | 2 +- src/mainwindow.cpp | 48 +++++++++++++++-------------------- src/mainwindow.h | 62 +++++++++++++++++++++++++++------------------ 4 files changed, 61 insertions(+), 53 deletions(-) diff --git a/src/geometryval.cpp b/src/geometryval.cpp index d7265480..b87c3a1c 100644 --- a/src/geometryval.cpp +++ b/src/geometryval.cpp @@ -363,7 +363,7 @@ void Geometryval::setupParam(const QDomElement par, int minFrame, int maxFrame) if (par.attribute("opacity") == "false") { label_opacity->setHidden(true); spinTransp->setHidden(true); - } else if(par.attribute("opacity") == "nonzero") { + } else if (par.attribute("opacity") == "nonzero") { spinTransp->setMinimum(1); } char *tmp = (char *) qstrdup(val.toUtf8().data()); diff --git a/src/main.cpp b/src/main.cpp index 282c6cbe..0a02c50e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) aboutData.addAuthor(ki18n("Ray Lehtiniemi"), ki18n("Bug fixing, etc."), "rayl@mail.com"); aboutData.addAuthor(ki18n("Dan Dennedy"), ki18n("Bug fixing, etc."), "dan@dennedy.org"); aboutData.addAuthor(ki18n("Simon A. Eugster"), ki18n("Bug fixing, etc."), "simon.eu@gmail.com"); - aboutData.addAuthor(ki18n("Alberto Villa"), ki18n("Bug fixing, logo, etc."), "avilla@FreeBSD.org"); + aboutData.addAuthor(ki18n("Alberto Villa"), ki18n("Bug fixing, logo, etc."), "avilla@FreeBSD.org"); aboutData.addAuthor(ki18n("Jason Wood"), ki18n("Original KDE 3 version author (not active anymore)"), "jasonwood@blueyonder.co.uk"); aboutData.setHomepage("http://kdenlive.org"); aboutData.setCustomAuthorText(ki18n("Please report bugs to http://kdenlive.org/mantis"), ki18n("Please report bugs to http://kdenlive.org/mantis")); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 38b4d515..7abcf534 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1738,11 +1738,8 @@ void MainWindow::recoverFiles(QList staleFiles) } } - void MainWindow::parseProfiles(const QString &mltPath) { - // kDebug()<<" + + YOUR MLT INSTALL WAS FOUND IN: "<< MLT_PREFIX <exec() == QDialog::Rejected) { + ::exit(0); + } + KUrl rendererPath = getUrl->selectedUrl(); + delete getUrl; + if (rendererPath.isEmpty()) ::exit(0); + KdenliveSettings::setRendererpath(rendererPath.path()); + } + QStringList profilesFilter; profilesFilter << "*"; QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); - if (profilesList.isEmpty()) { // Cannot find MLT path, try finding melt QString profilePath = KdenliveSettings::rendererpath(); if (!profilePath.isEmpty()) { profilePath = profilePath.section('/', 0, -3); KdenliveSettings::setMltpath(profilePath + "/share/mlt/profiles/"); - QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); + profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); } - if (profilesList.isEmpty()) { // Cannot find the MLT profiles, ask for location - KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your Mlt profiles, please give the path"), this); + KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(KdenliveSettings::mltpath(), i18n("Cannot find your MLT profiles, please give the path"), this); getUrl->fileDialog()->setMode(KFile::Directory); if (getUrl->exec() == QDialog::Rejected) { ::exit(0); @@ -1782,25 +1791,13 @@ void MainWindow::parseProfiles(const QString &mltPath) delete getUrl; if (mltPath.isEmpty()) ::exit(0); KdenliveSettings::setMltpath(mltPath.path(KUrl::AddTrailingSlash)); - QStringList profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); - } - } - - if (KdenliveSettings::rendererpath().isEmpty()) { - // Cannot find the MLT melt renderer, ask for location - KUrlRequesterDialog *getUrl = new KUrlRequesterDialog(QString(), i18n("Cannot find the melt program required for rendering (part of Mlt)"), this); - if (getUrl->exec() == QDialog::Rejected) { - ::exit(0); + profilesList = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files); } - KUrl rendererPath = getUrl->selectedUrl(); - delete getUrl; - if (rendererPath.isEmpty()) ::exit(0); - KdenliveSettings::setRendererpath(rendererPath.path()); } kDebug() << "RESULTING MLT PATH: " << KdenliveSettings::mltpath(); - // Parse MLT profiles to build a list of available video formats + // Parse again MLT profiles to build a list of available video formats if (profilesList.isEmpty()) parseProfiles(); } @@ -2947,12 +2944,9 @@ void MainWindow::keyPressEvent(QKeyEvent *ke) /** Gets called when the window gets hidden */ void MainWindow::hideEvent(QHideEvent */*event*/) { - // kDebug() << "I was hidden"; - // issue http://www.kdenlive.org/mantis/view.php?id=231 - if (isMinimized()) { - // kDebug() << "I am minimized"; - if (m_monitorManager) m_monitorManager->stopActiveMonitor(); - } + if (isMinimized()) + if (m_monitorManager) + m_monitorManager->stopActiveMonitor(); } bool MainWindow::eventFilter(QObject *obj, QEvent *event) diff --git a/src/mainwindow.h b/src/mainwindow.h index 285147c3..27fa7d88 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -68,15 +68,23 @@ class MainWindow : public KXmlGuiWindow Q_CLASSINFO("D-Bus Interface", "org.kdenlive.MainWindow") public: - /** Constructor - * \param MltPath path to MLT environment - * \param Url Url to open - * \param parent Std. widget parent + + /** @brief Initialises the main window. + * @param MltPath (optional) path to MLT environment + * @param Url (optional) file to open + * + * If Url is present, it will be opened, otherwhise, if openlastproject is + * set, latest project will be opened. If no file is open after trying this, + * a default new file will be created. */ + explicit MainWindow(const QString &MltPath = QString(), + const KUrl &Url = KUrl(), QWidget *parent = 0); + + /** @brief Locates the MLT environment. + * @param mltPath (optional) path to MLT environment * - * The constructor inits the main window. If Url is present, it will be opened. - * If Url is not present, and openLastproject is set, last project will be set - * If no file is open after trying this, a default "newfile" will be created. */ - explicit MainWindow(const QString &MltPath = QString(), const KUrl & Url = KUrl(), QWidget *parent = 0); + * It tries to set the paths of the MLT profiles and renderer, using + * mltPath, MLT_PREFIX, searching for the binary `melt`, or asking to the + * user. It doesn't fill any list of profiles, while its name suggests so. */ void parseProfiles(const QString &mltPath = QString()); static EffectsList videoEffects; @@ -84,23 +92,29 @@ public: static EffectsList customEffects; static EffectsList transitions; protected: + + /** @brief Closes the window. + * @return false if the user presses "Cancel" on a confirmation dialog or + * the operation requested (starting waiting jobs or saving file) fails, + * true otherwise */ virtual bool queryClose(); - virtual void customEvent(QEvent * e); + + /** @brief Reports a message in the status bar when an error occurs. */ + virtual void customEvent(QEvent *e); + + /** @brief Enables live search in the timeline. */ virtual void keyPressEvent(QKeyEvent *ke); - /** Override hideEvent to get events when the mainwindow gets hidden */ + + /** @brief Stops the active monitor when the window gets hidden. */ virtual void hideEvent(QHideEvent *e); + + /** @brief Filters key events to the live search. */ bool eventFilter(QObject *obj, QEvent *ev); - /** - * This function is called when it is time for the app to save its - * properties for session management purposes. - */ + + /** @brief Saves the file and the window properties when saving the session. */ virtual void saveProperties(KConfigGroup &config); - /** - * This function is called when this app is restored. The KConfig - * object points to the session management config file that was saved - * with @ref saveProperties - */ + /** @brief Restores the window and the file when a session is loaded. */ virtual void readProperties(const KConfigGroup &config); private: @@ -145,10 +159,10 @@ private: QMenu *m_timelineContextTransitionMenu; KUrl m_startUrl; - /** - * Shortcut to remove the focus of any element. Allows to get out - * of e.g. text input fields and to press another shortcut. - */ + /** @brief Shortcut to remove the focus from any element. + * + * It allows to get out of e.g. text input fields and to press another + * shortcut. */ QShortcut* m_shortcutRemoveFocus; RenderWidget *m_renderWidget; @@ -341,7 +355,7 @@ private slots: void slotRevert(); void slotShutdown(); void slotUpdateTrackInfo(); - /** \brief Change color scheme */ + /** @brief Changes the color scheme. */ void slotChangePalette(QAction *action, const QString &themename = QString()); void slotSwitchMonitors(); void slotCheckRenderStatus(); -- 2.39.2