File indexing completed on 2024-04-21 05:48:31

0001 /***********************************************************************
0002  * SPDX-FileCopyrightText: 2003-2004 Max Howell <max.howell@methylblue.com>
0003  * SPDX-FileCopyrightText: 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
0004  * SPDX-FileCopyrightText: 2017-2022 Harald Sitter <sitter@kde.org>
0005  *
0006  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0007  ***********************************************************************/
0008 
0009 #pragma once
0010 
0011 #include <QUrl>
0012 
0013 #include "Config.h"
0014 
0015 class QLabel;
0016 class QQmlApplicationEngine;
0017 
0018 namespace RadialMap
0019 {
0020 class Item;
0021 } // namespace RadialMap
0022 class Folder;
0023 class HistoryCollection;
0024 
0025 namespace Filelight
0026 {
0027 
0028 class ScanManager;
0029 
0030 class MainContext : public QObject
0031 {
0032     Q_OBJECT
0033 public:
0034     Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
0035     Q_SIGNAL void urlChanged();
0036     QUrl url() const;
0037 
0038     Q_PROPERTY(QList<QObject *> historyActions MEMBER m_historyActions NOTIFY historyActionsChanged)
0039     Q_SIGNAL void historyActionsChanged();
0040 
0041     explicit MainContext(QObject *parent = nullptr);
0042 
0043 Q_SIGNALS:
0044     void canceled(const QString &);
0045     void canvasIsDirty(Filelight::Dirty filth);
0046 
0047 public Q_SLOTS:
0048     void scan(const QUrl &u);
0049 
0050     void slotUp();
0051     void slotScanFolder();
0052     void slotScanHomeFolder();
0053     void slotScanRootFolder();
0054     bool slotScanUrl(const QUrl &);
0055     bool slotScanPath(const QString &);
0056 
0057     bool openUrl(const QUrl &);
0058 
0059     void updateURL(const QUrl &);
0060     void rescanSingleDir(const QUrl &) const;
0061 
0062 private:
0063     void setupActions(QQmlApplicationEngine *engine);
0064 
0065     void addHistoryAction(QObject *action);
0066 
0067     /// For internal use only -- call openUrl() instead
0068     void setUrl(const QUrl &url);
0069 
0070     QUrl m_url;
0071     HistoryCollection *m_histories;
0072     ScanManager *m_manager;
0073     QList<QObject *> m_historyActions;
0074 
0075 public:
0076     Q_INVOKABLE QString prettyUrl(const QUrl &url) const;
0077     Q_INVOKABLE bool start(const QUrl &) const;
0078 };
0079 
0080 } // namespace Filelight