File indexing completed on 2025-01-05 04:26:49

0001 /*
0002  * Replacement fot QT Bindings that were removed from QT5
0003  * Copyright (C) 2020  Pedro de Carvalho Gomes <pedrogomes81@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 
0019 #include "UiToolsUiLoader.h"
0020 
0021 #include "CoreDir.h"
0022 #include <QWidget>
0023 
0024 using namespace QtBindings::UiTools;
0025 
0026 UiLoader::UiLoader(QObject *parent) : QUiLoader(parent)
0027 {
0028 }
0029 
0030 UiLoader::UiLoader(const UiLoader &other) : QUiLoader(other.parent())
0031 {
0032     *this=other;
0033 }
0034 
0035 UiLoader::UiLoader(const QJSValue &other) : QUiLoader(nullptr)
0036 {
0037     Q_UNUSED(other);
0038 }
0039 
0040 UiLoader::~UiLoader()
0041 {
0042 }
0043 
0044 void UiLoader::addPluginPath(const QString &path)
0045 {
0046     QUiLoader::addPluginPath(path);
0047 }
0048 
0049 QStringList UiLoader::availableLayouts() const
0050 {
0051     return QUiLoader::availableLayouts();
0052 }
0053 
0054 QStringList UiLoader::availableWidgets() const
0055 {
0056     return QUiLoader::availableWidgets();
0057 }
0058 
0059 void UiLoader::clearPluginPaths()
0060 {
0061     QUiLoader::clearPluginPaths();
0062 }
0063 
0064 QAction *UiLoader::createAction(QObject *parent, const QString &name)
0065 {
0066     return QUiLoader::createAction(parent, name);
0067 }
0068 
0069 QActionGroup *
0070 UiLoader::createActionGroup(QObject *parent, const QString &name)
0071 {
0072     return QUiLoader::createActionGroup(parent, name);
0073 }
0074 
0075 QLayout *
0076 UiLoader::createLayout(const QString &className, QObject *parent,
0077                                             const QString &name)
0078 {
0079     return QUiLoader::createLayout(className, parent, name);
0080 }
0081 
0082 QWidget *
0083 UiLoader::createWidget(const QString &className, QWidget *parent,
0084                                             const QString &name)
0085 {
0086     return QUiLoader::createWidget(className, parent, name);
0087 }
0088 
0089 QString UiLoader::errorString() const
0090 {
0091     return QUiLoader::errorString();
0092 }
0093 
0094 bool UiLoader::isLanguageChangeEnabled() const
0095 {
0096     return QUiLoader::isLanguageChangeEnabled();
0097 }
0098 
0099 QJSValue UiLoader::load(QFile *device, QJSValue parentWidget)
0100 {
0101     QWidget *rootWidget = ( parentWidget.isQObject() ) ?
0102         QUiLoader::load(device, qobject_cast<QWidget*>( parentWidget.toQObject()) ) :
0103         QUiLoader::load(device);
0104 
0105     return this->mirrorObjectTree( rootWidget, qjsEngine( this ) );
0106 }
0107 
0108 QStringList UiLoader::pluginPaths() const
0109 {
0110     return QUiLoader::pluginPaths();
0111 }
0112 
0113 void UiLoader::setLanguageChangeEnabled(bool enabled)
0114 {
0115     QUiLoader::setLanguageChangeEnabled(enabled);
0116 }
0117 
0118 void UiLoader::setWorkingDirectory(const QDir &dir)
0119 {
0120     QUiLoader::setWorkingDirectory(dir);
0121 }
0122 
0123 QDir UiLoader::workingDirectory() const
0124 {
0125     return QtBindings::Core::Dir(QUiLoader::workingDirectory());
0126 }
0127 
0128 UiLoader &UiLoader::operator=(const UiLoader &other)
0129 {
0130     if (this != &other) {
0131         this->setLanguageChangeEnabled( other.isLanguageChangeEnabled() );
0132         this->setWorkingDirectory( other.workingDirectory() );
0133     }
0134     return *this;
0135 }
0136