Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 271eb151b18e57b99c71644c240f618281056ebd
  • master par défaut protégée
  • rust-playlist-sync
  • rust
  • fix-qt-deprecated-qvariant-type
  • fix-mpris-qtwindow-race-condition
  • rust-appimage-wayland
  • windows-build-rebased
  • v2.5 protégée
  • v2.4 protégée
  • v2.3-1 protégée
  • v2.3 protégée
  • v2.2 protégée
  • v2.1 protégée
  • v2.0 protégée
  • v1.8-3 protégée
  • v1.8-2 protégée
  • v1.8-1 protégée
  • v1.8 protégée
  • v1.7 protégée
  • v1.6 protégée
  • v1.5 protégée
  • v1.4 protégée
  • v1.3 protégée
  • v1.2 protégée
  • v1.1 protégée
  • v1.0 protégée
27 résultats

module_sdl2.c

Blame
  • AbstractDocument.hh 3,53 Kio
    #ifndef VIVY_ABSTRACT_DOCUMENT_H
    #define VIVY_ABSTRACT_DOCUMENT_H
    
    #ifndef __cplusplus
    #error "This is a C++ header"
    #endif
    
    #include "Utils.hh"
    #include "Uuid.hh"
    #include <QFileInfo>
    #include <QDir>
    
    namespace Vivy
    {
    class AbstractDocument : public QObject {
        Q_OBJECT
        VIVY_UNMOVABLE_OBJECT(AbstractDocument)
    
    public:
        enum class Type : quint64 {
            Vivy   = Utils::toUnderlying(Utils::DocumentType::Vivy),
            Script = Utils::toUnderlying(Utils::DocumentType::VivyScript)
        };
    
    protected:
        AbstractDocument(Type childType, const QString &documentName)
            : type(childType)
            , name(documentName)
        {
        }
    
        // Automate a part of the rename process, just need to provide a "success"
        // callback and the new file info.
        void copyWith(const QFileInfo &newFile, auto success)
        {
            const QFileInfo oldFile(getName());
    
            // Create folder if needed
            QDir dirOp;
            const QString newAbsDirPath = newFile.dir().absolutePath();
            if (!dirOp.exists(newAbsDirPath)) {
                qInfo() << "Create folder " << newAbsDirPath;
                dirOp.mkpath(newAbsDirPath);
            }
    
            if (newFile.exists()) {
                qWarning() << "Deleting the already existing" << newFile;
                if (!dirOp.remove(newFile.absoluteFilePath()))
                    throw std::runtime_error("Failed to remove " +
                                             newFile.absoluteFilePath().toStdString());
            }
    
            if (QFile::copy(oldFile.absoluteFilePath(), newFile.absoluteFilePath())) {
                success();
                save();
            }
    
            else
                throw std::runtime_error("Failed to copy " + oldFile.absoluteFilePath().toStdString() +
                                         " to " + newFile.absoluteFilePath().toStdString());
        }
    
        // Automate a part of the rename process, just need to provide a "success"
        // callback and the new file info.
        void renameWith(const QFileInfo &newFile, auto success)
        {
            const QFileInfo oldFile(getName());
    
            // Create folder if needed
            QDir dirOp;