Skip to content

Commit 8181ac0

Browse files
committed
wip qml
1 parent 3d1c295 commit 8181ac0

16 files changed

+297
-460
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2020

2121
find_package(QT 6.2 NAMES Qt6 COMPONENTS Core REQUIRED)
2222

23-
find_package(Qt6 COMPONENTS Core Concurrent Network Widgets Xml REQUIRED)
23+
find_package(Qt6 COMPONENTS Core Concurrent Network Widgets Xml Quick QuickWidgets REQUIRED)
2424
find_package(Qt6LinguistTools REQUIRED)
2525
get_target_property (QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
2626
message(STATUS "Using Qt ${QT_VERSION} (${QT_QMAKE_EXECUTABLE})")

src/gui/CMakeLists.txt

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(ECMAddAppIcon)
2+
include(ECMQmlModule)
23

34
find_package(KDSingleApplication-qt6 1.0.0 REQUIRED)
45

@@ -37,7 +38,6 @@ set(client_SRCS
3738
folder.cpp
3839
folderman.cpp
3940
folderstatusmodel.cpp
40-
folderstatusdelegate.cpp
4141
folderwatcher.cpp
4242
generalsettings.cpp
4343
ignorelisteditor.cpp
@@ -102,15 +102,25 @@ add_subdirectory(loginrequireddialog)
102102

103103
add_library(owncloudCore STATIC ${final_src})
104104
set_target_properties(owncloudCore PROPERTIES AUTOUIC ON AUTORCC ON)
105+
# for the generated qml module
106+
target_include_directories(owncloudCore PRIVATE models)
105107
target_link_libraries(owncloudCore
106108
PUBLIC
107-
Qt::Widgets Qt::Network Qt::Xml
109+
Qt::Widgets Qt::Network Qt::Xml Qt::Quick Qt::QuickWidgets
108110
newwizard folderwizard spaces loginrequireddialog
109111
libsync
110112
Qt6Keychain::Qt6Keychain
111113
)
112114

113115
apply_common_target_settings(owncloudCore)
116+
ecm_add_qml_module (owncloudCore
117+
URI org.ownCloud.qmlcomponents
118+
VERSION 1.0
119+
NAMESPACE OCC
120+
# TODO: main.cpp: qml_register_types_org_ownCloud_qmlcomponents
121+
QT_NO_PLUGIN
122+
QML_FILES qml/tree.qml
123+
)
114124

115125

116126
add_subdirectory(spaces)
@@ -159,7 +169,7 @@ set_target_properties(owncloud PROPERTIES
159169
AUTORCC ON
160170
)
161171
apply_common_target_settings(owncloud)
162-
target_link_libraries(owncloud owncloudCore owncloudResources KDAB::kdsingleapplication )
172+
target_link_libraries(owncloud PUBLIC owncloudCore owncloudResources KDAB::kdsingleapplication )
163173

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

src/gui/accountsettings.cpp

+47-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@
5454
#include <QToolTip>
5555
#include <QTreeView>
5656

57+
#include <QtQuickWidgets/QtQuickWidgets>
58+
5759

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

6668

69+
class NetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
70+
{
71+
public:
72+
NetworkAccessManagerFactory(Account *acc)
73+
: _acc(acc)
74+
{
75+
}
76+
77+
inline QNetworkAccessManager *create(QObject *parent) override { return _acc->accessManager(); }
78+
79+
Account *_acc;
80+
};
81+
6782
AccountSettings::AccountSettings(const AccountStatePtr &accountState, QWidget *parent)
6883
: QWidget(parent)
6984
, ui(new Ui::AccountSettings)
@@ -84,14 +99,31 @@ AccountSettings::AccountSettings(const AccountStatePtr &accountState, QWidget *p
8499

85100
_sortModel = weightedModel;
86101

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

89-
ui->_folderList->setItemDelegate(_delegate);
112+
connect(ui->reload, &QPushButton::clicked, this, [src, this] {
113+
ui->quickWidget->setSource(QUrl());
114+
ui->quickWidget->engine()->clearComponentCache();
115+
ui->quickWidget->setSource(src);
116+
for (const auto &e : ui->quickWidget->errors()) {
117+
qDebug() << "aaaaaaaaaaa" << e;
118+
}
119+
});
90120

91121
createAccountToolbox();
122+
#if 0
92123
connect(ui->_folderList, &QWidget::customContextMenuRequested,
93124
this, &AccountSettings::slotCustomContextMenuRequested);
94125
connect(ui->_folderList, &QAbstractItemView::clicked, this, &AccountSettings::slotFolderListClicked);
126+
#endif
95127
QAction *syncNowAction = new QAction(this);
96128
connect(syncNowAction, &QAction::triggered, this, &AccountSettings::slotScheduleCurrentFolder);
97129
addAction(syncNowAction);
@@ -157,8 +189,11 @@ void AccountSettings::createAccountToolbox()
157189

158190
Folder *AccountSettings::selectedFolder() const
159191
{
192+
return {};
193+
#if 0
160194
const QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
161195
return _model->folder(_sortModel->mapToSource(selected));
196+
#endif
162197
}
163198

164199
void AccountSettings::slotToggleSignInState()
@@ -172,6 +207,7 @@ void AccountSettings::slotToggleSignInState()
172207

173208
void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
174209
{
210+
#if 0
175211
auto *tv = ui->_folderList;
176212
QModelIndex index = tv->indexAt(pos);
177213
if (!index.isValid()) {
@@ -278,10 +314,12 @@ void AccountSettings::slotCustomContextMenuRequested(const QPoint &pos)
278314
} else {
279315
menu->deleteLater();
280316
}
317+
#endif
281318
}
282319

283320
void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
284321
{
322+
#if 0
285323
// tries to find if we clicked on the '...' button.
286324
auto *tv = ui->_folderList;
287325
const auto pos = tv->mapFromGlobal(QCursor::pos());
@@ -294,6 +332,7 @@ void AccountSettings::slotFolderListClicked(const QModelIndex &indx)
294332
emit showIssuesList();
295333
return;
296334
}
335+
#endif
297336
}
298337

299338
void AccountSettings::showSelectiveSyncDialog(Folder *folder)
@@ -352,6 +391,7 @@ void AccountSettings::slotFolderWizardAccepted()
352391

353392
void AccountSettings::slotRemoveCurrentFolder()
354393
{
394+
#if 0
355395
auto folder = selectedFolder();
356396
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
357397
if (selected.isValid() && folder) {
@@ -382,10 +422,12 @@ void AccountSettings::slotRemoveCurrentFolder()
382422
});
383423
messageBox->open();
384424
}
425+
#endif
385426
}
386427

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

406448
ui->_folderList->doItemsLayout();
407449
}
450+
#endif
408451
}
409452

410453
void AccountSettings::slotDisableVfsCurrentFolder()
411454
{
455+
#if 0
412456
QPointer<Folder> folder = selectedFolder();
413457
QModelIndex selected = ui->_folderList->selectionModel()->currentIndex();
414458
if (!selected.isValid() || !folder)
@@ -440,6 +484,7 @@ void AccountSettings::slotDisableVfsCurrentFolder()
440484
ui->_folderList->doItemsLayout();
441485
});
442486
msgBox->open();
487+
#endif
443488
}
444489

445490
void AccountSettings::showConnectionLabel(const QString &message, QStringList errors)

src/gui/accountsettings.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
#ifndef ACCOUNTSETTINGS_H
1616
#define ACCOUNTSETTINGS_H
1717

18-
#include <QWidget>
1918

2019
#include "folder.h"
2120
#include "loginrequireddialog.h"
2221
#include "owncloudgui.h"
2322
#include "progressdispatcher.h"
2423

24+
25+
#include <QSortFilterProxyModel>
26+
#include <QWidget>
27+
2528
class QModelIndex;
2629
class QNetworkReply;
2730
class QLabel;
28-
class QSortFilterProxyModel;
2931

3032
namespace OCC {
3133
class AccountModalWidget;
@@ -49,6 +51,7 @@ class AccountSettings : public QWidget
4951
{
5052
Q_OBJECT
5153
Q_PROPERTY(AccountStatePtr accountState MEMBER _accountState)
54+
Q_PROPERTY(QSortFilterProxyModel *model MEMBER _sortModel)
5255

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

68+
auto model() { return _sortModel; }
69+
6570
signals:
6671
void folderChanged();
6772
void showIssuesList();

src/gui/accountsettings.ui

+13-14
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,7 @@
147147
<widget class="QWidget" name="folderListPage">
148148
<layout class="QVBoxLayout" name="verticalLayout_6">
149149
<item>
150-
<widget class="QListView" name="_folderList">
151-
<property name="sizePolicy">
152-
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
153-
<horstretch>0</horstretch>
154-
<verstretch>5</verstretch>
155-
</sizepolicy>
156-
</property>
157-
<property name="contextMenuPolicy">
158-
<enum>Qt::CustomContextMenu</enum>
159-
</property>
160-
<property name="editTriggers">
161-
<set>QAbstractItemView::NoEditTriggers</set>
162-
</property>
163-
</widget>
150+
<widget class="QQuickWidget" name="quickWidget"/>
164151
</item>
165152
<item>
166153
<layout class="QHBoxLayout" name="horizontalLayout_5">
@@ -190,9 +177,21 @@
190177
</widget>
191178
</widget>
192179
</item>
180+
<item>
181+
<widget class="QPushButton" name="reload">
182+
<property name="text">
183+
<string>PushButton</string>
184+
</property>
185+
</widget>
186+
</item>
193187
</layout>
194188
</widget>
195189
<customwidgets>
190+
<customwidget>
191+
<class>QQuickWidget</class>
192+
<extends>QWidget</extends>
193+
<header location="global">QtQuickWidgets/QQuickWidget</header>
194+
</customwidget>
196195
<customwidget>
197196
<class>QProgressIndicator</class>
198197
<extends>QWidget</extends>

0 commit comments

Comments
 (0)