Skip to content

Improve "add space" wizard - #10079

Merged
fmoc merged 1 commit into
masterfrom
work/new-spaces-browser
Sep 6, 2022
Merged

fmoc merged 1 commit into
masterfrom
work/new-spaces-browser

Conversation

@fmoc

@fmoc fmoc commented Sep 2, 2022 •

Copy link
Copy Markdown
Contributor

Follow-up for #9575 and a few other PRs.

screenshot_2022-09-02_19-51-14

This PR rewrites a lot of spaces-related code, and should be reviewed carefully. The "open in browser" buttons are not working at the moment due to a server limitation (it does not send us URLs we could open in the browser as of yet). The placeholder is temporary, I hope in the future the server will just send us one.

Closes #10047.

@fmoc fmoc added this to the 3.0 milestone Sep 2, 2022
@fmoc
fmoc requested review from a team, erikjv and tbsbdr September 2, 2022 17:49
@fmoc
fmoc force-pushed the work/new-spaces-browser branch from 6092644 to 9b81222 Compare September 5, 2022 11:55
@fmoc
fmoc marked this pull request as ready for review September 5, 2022 11:55
@fmoc
fmoc force-pushed the work/new-spaces-browser branch from 9b81222 to 8dcea2d Compare September 6, 2022 07:15
@fmoc
fmoc requested review from a team and erikjv September 6, 2022 07:18
@fmoc

fmoc commented Sep 6, 2022

Copy link
Copy Markdown
Contributor Author

Please re-review.

@fmoc

fmoc commented Sep 6, 2022

Copy link
Copy Markdown
Contributor Author

screenshot_2022-09-06_09-24-33

screenshot_2022-09-06_09-24-39

@fmoc
fmoc force-pushed the work/new-spaces-browser branch from 8dcea2d to cee5c07 Compare September 6, 2022 07:32
@fmoc
fmoc force-pushed the work/new-spaces-browser branch from cee5c07 to d4264cb Compare September 6, 2022 08:35
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2022

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@fmoc
fmoc merged commit 482ea66 into master Sep 6, 2022
@delete-merged-branch
delete-merged-branch Bot deleted the work/new-spaces-browser branch September 6, 2022 13:48

@TheOneRing TheOneRing left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that you removed the space model feel free to manually implement sorting, filtering and searhing.

auto drive = new OCC::GraphApi::DrivesJob(accountPtr);

connect(drive, &OCC::GraphApi::DrivesJob::finishedSignal, [drive, accountPtr, this] {
QList<Spaces::Space> spaces;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces.reserve

Comment thread src/gui/spaces/space.cpp

namespace OCC::Spaces {

Space::Space(const QString &name, const QString &subtitle, const QUrl &webUrl, const QUrl &webDavUrl, const QUrl &imageUrl)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason we need that constructor, can't we just own the Drive and operate on it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It gives us some flexibility with regards to (future) testing.

_ui->setupUi(this);

static const QSize ImageSizeC(128, 128);
static const auto PlaceholderImageC = OCC::Utility::getCoreIcon(QStringLiteral("th-large")).pixmap(ImageSizeC);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use a static if the value can be themed and it probably requires a dark and light theme

QPixmap pixmap;
qDebug() << "loading pixmap from space image:" << pixmap.loadFromData(job->reply()->readAll());
const auto scaledPixmap = pixmap.scaled(ImageSizeC, Qt::KeepAspectRatio);
_ui->imageLabel->setPixmap(scaledPixmap);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smooth scaling?

Comment thread src/gui/spaces/space.cpp
{
QUrl imageUrl = [special = drive.getSpecial()] {
const auto imageFolder = std::find_if(special.begin(), special.end(), [](const OpenAPI::OAIDriveItem &item) {
return item.getSpecialFolder().getName() == QStringLiteral("image");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment thiss lambda is the only value added by all those lines of code.

_ui->imageLabel->setPixmap(PlaceholderImageC);

if (!space.imageUrl().isEmpty()) {
auto job = new OCC::SimpleNetworkJob(accountPtr, space.imageUrl(), {}, "GET", {}, {}, nullptr);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we move that code also to the space class, and also cache it in that class?

@fmoc

fmoc commented Sep 6, 2022

Copy link
Copy Markdown
Contributor Author

Now that you removed the space model feel free to manually implement sorting, filtering and searching.

That's true, but I couldn't find a reasonable-effort way of rendering widgets with a delegate... Even when using rich text and falling back to some HTML links instead of buttons, some of the features provided by this PR would just not have worked without a custom delegate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spaces] Add a single Space

4 participants