LCOV - code coverage report
Current view: top level - muse/framework/extensions/api/v1 - filedialog.h Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 1 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2024 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #pragma once
      24              : 
      25              : #include <QObject>
      26              : #include <QString>
      27              : #include <QUrl>
      28              : 
      29              : #include "global/modularity/ioc.h"
      30              : #include "interactive/iinteractive.h"
      31              : 
      32              : namespace muse::extensions::apiv1 {
      33              : class FileDialog : public QObject, public Contextable
      34              : {
      35              :     Q_OBJECT
      36              :     Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged FINAL)
      37              :     Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged FINAL)
      38              :     Q_PROPERTY(bool visible READ visible WRITE setVisible NOTIFY visibleChanged FINAL)
      39              :     Q_PROPERTY(QString folder READ folder WRITE setFolder NOTIFY folderChanged FINAL)
      40              :     Q_PROPERTY(QString filePath READ filePath WRITE setFilePath NOTIFY filePathChanged FINAL)
      41              :     Q_PROPERTY(QUrl fileUrl READ fileUrl WRITE setFileUrl FINAL)
      42              :     Q_PROPERTY(QList<QUrl> fileUrls READ fileUrls WRITE setFileUrls FINAL)
      43              : 
      44              :     ContextInject<IInteractive> interactive = { this };
      45              : 
      46              : public:
      47              :     FileDialog(QObject* parent = nullptr);
      48              : 
      49              :     enum Type {
      50              :         Load = 0,
      51              :         Save
      52              :     };
      53            0 :     Q_ENUM(Type)
      54              : 
      55              :     Type type() const;
      56              :     void setType(Type newType);
      57              : 
      58              :     QString title() const;
      59              :     void setTitle(const QString& newTitle);
      60              :     bool visible() const;
      61              :     void setVisible(bool newVisible);
      62              : 
      63              :     Q_INVOKABLE void open();
      64              :     Q_INVOKABLE void close();
      65              : 
      66              :     QString folder() const;
      67              :     void setFolder(const QString& newFolder);
      68              : 
      69              :     QString filePath() const;
      70              :     void setFilePath(const QString& newFilePath);
      71              : 
      72              :     QUrl fileUrl() const;
      73              :     void setFileUrl(const QUrl& newFileUrl);
      74              : 
      75              :     QList<QUrl> fileUrls() const;
      76              :     void setFileUrls(const QList<QUrl>& newFileUrls);
      77              : 
      78              : signals:
      79              :     void accepted();
      80              :     void rejected();
      81              : 
      82              :     void typeChanged();
      83              :     void titleChanged();
      84              :     void visibleChanged();
      85              :     void folderChanged();
      86              :     void filePathChanged();
      87              : 
      88              : private:
      89              : 
      90              :     QString doOpen(const QString& title, const QString& path);
      91              : 
      92              :     QString m_title;
      93              :     bool m_visible = false;
      94              :     QString m_folder;
      95              :     QString m_filePath;
      96              :     Type m_type = Type::Load;
      97              : };
      98              : }
        

Generated by: LCOV version 2.0-1