Skip to content

Commit

Permalink
wip qml
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOneRing committed Feb 20, 2024
1 parent 3d1c295 commit 8181ac0
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 460 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(QT 6.2 NAMES Qt6 COMPONENTS Core REQUIRED)

find_package(Qt6 COMPONENTS Core Concurrent Network Widgets Xml REQUIRED)
find_package(Qt6 COMPONENTS Core Concurrent Network Widgets Xml Quick QuickWidgets REQUIRED)
find_package(Qt6LinguistTools REQUIRED)
get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
message(STATUS "Using Qt ${QT_VERSION} (${QT_QMAKE_EXECUTABLE})")
Expand Down
16 changes: 13 additions & 3 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
include(ECMAddAppIcon)
include(ECMQmlModule)

find_package(KDSingleApplication-qt6 1.0.0 REQUIRED)

Expand Down Expand Up @@ -37,7 +38,6 @@ set(client_SRCS
folder.cpp
folderman.cpp
folderstatusmodel.cpp
folderstatusdelegate.cpp
folderwatcher.cpp
generalsettings.cpp
ignorelisteditor.cpp
Expand Down Expand Up @@ -102,15 +102,25 @@ add_subdirectory(loginrequireddialog)

add_library(owncloudCore STATIC ${final_src})
set_target_properties(owncloudCore PROPERTIES AUTOUIC ON AUTORCC ON)
# for the generated qml module
target_include_directories(owncloudCore PRIVATE models)
target_link_libraries(owncloudCore
PUBLIC
Qt::Widgets Qt::Network Qt::Xml
Qt::Widgets Qt::Network Qt::Xml Qt::Quick Qt::QuickWidgets
newwizard folderwizard spaces loginrequireddialog
libsync
Qt6Keychain::Qt6Keychain
)

apply_common_target_settings(owncloudCore)
ecm_add_qml_module (owncloudCore
URI org.ownCloud.qmlcomponents
VERSION 1.0
NAMESPACE OCC
# TODO: main.cpp: qml_register_types_org_ownCloud_qmlcomponents
QT_NO_PLUGIN
QML_FILES qml/tree.qml
)


add_subdirectory(spaces)
Expand Down Expand Up @@ -159,7 +169,7 @@ set_target_properties(owncloud PROPERTIES
AUTORCC ON
)
apply_common_target_settings(owncloud)
target_link_libraries(owncloud owncloudCore owncloudResources KDAB::kdsingleapplication )
target_link_libraries(owncloud PUBLIC owncloudCore owncloudResources KDAB::kdsingleapplication )

MESSAGE(STATUS "OWNCLOUD_SIDEBAR_ICONS: ${APPLICATION_ICON_NAME}: ${OWNCLOUD_SIDEBAR_ICONS}")

Expand Down
49 changes: 47 additions & 2 deletions src/gui/accountsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include <QToolTip>
#include <QTreeView>

#include <QtQuickWidgets/QtQuickWidgets>


namespace {
constexpr auto modalWidgetStretchedMarginC = 50;
Expand All @@ -64,6 +66,19 @@ namespace OCC {
Q_LOGGING_CATEGORY(lcAccountSettings, "gui.account.settings", QtInfoMsg)


class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
public:
NetworkAccessManagerFactory(Account *acc)
: _acc(acc)
{
}

inline QNetworkAccessManager *create(QObject *parent) override { return _acc->accessManager(); }

Account *_acc;
};

AccountSettings::AccountSettings(const AccountStatePtr &accountState, QWidget *parent)
: QWidget(parent)
, ui(new Ui::AccountSettings)
Expand All @@ -84,14 +99,31 @@ AccountSettings::AccountSettings(const AccountStatePtr &accountState, QWidget *p

_sortModel = weightedModel;

ui->_folderList->setModel(_sortModel);
const QUrl src = QUrl::fromLocalFile(QStringLiteral("C:\\CraftRoot\\download\\git\\owncloud\\owncloud-client\\src\\gui\\qml\\tree.qml"));
// const QUrl src = QUrl::fromLocalFile(QStringLiteral(":/qt/qml/org/ownCloud/qmlcomponents/qml/tree.qml"));
ui->quickWidget->rootContext()->setContextProperty(QStringLiteral("ctx"), this);
ui->quickWidget->setSource(src);
ui->quickWidget->engine()->setNetworkAccessManagerFactory(new NetworkAccessManagerFactory(_accountState->account().get()));
ui->quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
for (const auto &e : ui->quickWidget->errors()) {
qDebug() << "aaaaaaaaaaa" << e;
}

ui->_folderList->setItemDelegate(_delegate);
connect(ui->reload, &QPushButton::clicked, this, [src, this] {
ui->quickWidget->setSource(QUrl());
ui->quickWidget->engine()->clearComponentCache();
ui->quickWidget->setSource(src);
for (const auto &e : ui->quickWidget->errors()) {
qDebug() << "aaaaaaaaaaa" << e;
}
});

createAccountToolbox();
#if 0
connect(ui->_folderList, &QWidget::customContextMenuRequested,
this, &AccountSettings::slotCustomContextMenuRequested);
connect(ui->_folderList, &QAbstractItemView::clicked, this, &AccountSettings::slotFolderListClicked);
#endif
QAction *syncNowAction = new QAction(this);
connect(syncNowAction, &QAction::triggered, this, &AccountSettings::slotScheduleCurrentFolder);
addAction(syncNowAction);
Expand Down Expand Up @@ -157,8 +189,11 @@ void AccountSettings::createAccountToolbox()

Folder *AccountSettings::selectedFolder() const
{
return {};
#if 0
const QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
return _model->folder(_sortModel->mapToSource(selected));
#endif
}

void AccountSettings::slotToggleSignInState()
Expand All @@ -172,6 +207,7 @@ void AccountSettings::slotToggleSignInState()

void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
{
#if 0
auto *tv = ui->_folderList;
QModelIndex index = tv->indexAt(pos);
if (!index.isValid()) {
Expand Down Expand Up @@ -278,10 +314,12 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
} else {
menu->deleteLater();
}
#endif
}

void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
{
#if 0
// tries to find if we clicked on the '...' button.
auto *tv = ui->_folderList;
const auto pos = tv->mapFromGlobal(QCursor::pos());
Expand All @@ -294,6 +332,7 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
emit showIssuesList();
return;
}
#endif
}

void AccountSettings::showSelectiveSyncDialog(Folder *folder)
Expand Down Expand Up @@ -352,6 +391,7 @@ void AccountSettings::slotFolderWizardAccepted()

void AccountSettings::slotRemoveCurrentFolder()
{
#if 0
auto folder = selectedFolder();
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
if (selected.isValid() && folder) {
Expand Down Expand Up @@ -382,10 +422,12 @@ void AccountSettings::slotRemoveCurrentFolder()
});
messageBox->open();
}
#endif
}

void AccountSettings::slotEnableVfsCurrentFolder()
{
#if 0
QPointer<Folder> folder = selectedFolder();
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
if (!selected.isValid() || !folder) {
Expand All @@ -405,10 +447,12 @@ void AccountSettings::slotEnableVfsCurrentFolder()

ui->_folderList->doItemsLayout();
}
#endif
}

void AccountSettings::slotDisableVfsCurrentFolder()
{
#if 0
QPointer<Folder> folder = selectedFolder();
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
if (!selected.isValid() || !folder)
Expand Down Expand Up @@ -440,6 +484,7 @@ void AccountSettings::slotDisableVfsCurrentFolder()
ui->_folderList->doItemsLayout();
});
msgBox->open();
#endif
}

void AccountSettings::showConnectionLabel(const QString &message, QStringList errors)
Expand Down
9 changes: 7 additions & 2 deletions src/gui/accountsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
#ifndef ACCOUNTSETTINGS_H
#define ACCOUNTSETTINGS_H

#include <QWidget>

#include "folder.h"
#include "loginrequireddialog.h"
#include "owncloudgui.h"
#include "progressdispatcher.h"


#include <QSortFilterProxyModel>
#include <QWidget>

class QModelIndex;
class QNetworkReply;
class QLabel;
class QSortFilterProxyModel;

namespace OCC {
class AccountModalWidget;
Expand All @@ -49,6 +51,7 @@ class AccountSettings : public QWidget
{
Q_OBJECT
Q_PROPERTY(AccountStatePtr accountState MEMBER _accountState)
Q_PROPERTY(QSortFilterProxyModel *model MEMBER _sortModel)

public:
enum class ModalWidgetSizePolicy { Minimum = QSizePolicy::Minimum, Expanding = QSizePolicy::Expanding };
Expand All @@ -62,6 +65,8 @@ class AccountSettings : public QWidget
void addModalLegacyDialog(QWidget *widget, ModalWidgetSizePolicy sizePolicy);
void addModalWidget(AccountModalWidget *widget);

auto model() { return _sortModel; }

signals:
void folderChanged();
void showIssuesList();
Expand Down
27 changes: 13 additions & 14 deletions src/gui/accountsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,7 @@
<widget class="QWidget" name="folderListPage">
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QListView" name="_folderList">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>5</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
<widget class="QQuickWidget" name="quickWidget"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
Expand Down Expand Up @@ -190,9 +177,21 @@
</widget>
</widget>
</item>
<item>
<widget class="QPushButton" name="reload">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QQuickWidget</class>
<extends>QWidget</extends>
<header location="global">QtQuickWidgets/QQuickWidget</header>
</customwidget>
<customwidget>
<class>QProgressIndicator</class>
<extends>QWidget</extends>
Expand Down
Loading

0 comments on commit 8181ac0

Please sign in to comment.