File indexing completed on 2024-12-22 04:41:15
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #pragma once 0019 0020 #include <QObject> 0021 #include "qmlwindow.h" 0022 0023 /** 0024 * @brief The class exposing Windows API to QML 0025 */ 0026 class QmlWindows : public QObject 0027 { 0028 Q_OBJECT 0029 public: 0030 QmlWindows(QObject *parent = nullptr); 0031 /** 0032 * @brief Gets a browser window 0033 * @param Integer representing the browser window 0034 * @return Object of type [QmlWindow](@ref QmlWindow) 0035 */ 0036 Q_INVOKABLE QmlWindow *get(int id) const; 0037 /** 0038 * @brief Gets the current browser window 0039 * @return Object of type [QmlWindow](@ref QmlWindow) 0040 */ 0041 Q_INVOKABLE QmlWindow *getCurrent() const; 0042 /** 0043 * @brief Get all the browser window 0044 * @return List of windows of type [QmlWindow](@ref QmlWindow) 0045 */ 0046 Q_INVOKABLE QList<QObject*> getAll() const; 0047 /** 0048 * @brief Creates a browser window 0049 * @param A JavaScript object containing 0050 * - url: 0051 * The url of the first tab of the window 0052 * - type: 0053 * The window [type](@ref QmlEnums::WindowType) 0054 * @return 0055 */ 0056 Q_INVOKABLE QmlWindow *create(const QVariantMap &map) const; 0057 /** 0058 * @brief Removes a browser window 0059 * @param Integer representing the window id 0060 */ 0061 Q_INVOKABLE void remove(int windowId) const; 0062 Q_SIGNALS: 0063 /** 0064 * @brief The signal emitted when a window is created 0065 * @param Object of type [QmlWindow](@ref QmlWindow) 0066 */ 0067 void created(QmlWindow *window); 0068 0069 /** 0070 * @brief The signal emitted when a window is removed 0071 * @param Object of type [QmlWindow](@ref QmlWindow) 0072 */ 0073 void removed(QmlWindow *window); 0074 private: 0075 BrowserWindow *getBrowserWindow(int windowId) const; 0076 };