Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a UI for uploaded images #4995

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft

Add a UI for uploaded images #4995

wants to merge 24 commits into from

Conversation

Mm2PL
Copy link
Collaborator

@Mm2PL Mm2PL commented Dec 2, 2023

Description

This includes migrations which shouldn't be but might turn out being buggy, use at your own risk.

Ensure that have a backup of your Logs/ImageUploader.json file.

This PR adds a UI that lists all logged images. It also adds a button that forgets an image from the log.

Preview as of 6223e34:
image

Known issues:

  • Needs manual repaint to show images after they've been loaded.

Ill be using ic_fluent_image_prohibited_24_regular.svg from Fluenticons

@Mm2PL Mm2PL requested a review from pajlada December 2, 2023 00:25
@jupjohn
Copy link
Contributor

jupjohn commented Dec 2, 2023

Found 2 issues while testing on 097eb7b:

  1. After the file migration, when opening the log most images appear empty. These only fill out when the window is resized:
Chatterino2_4995_097eb7b_WindowResizeRepaintingImages.mp4
  1. After closing that newly migrated instance & reopening, the logs table appears empty while the backing ImageUploader2.json file still has content (screenshot below is right after reopening the instance from the recording above):

image

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

// image, path, delete url

UploadedImage UploadedImageModel::getItemFromRow(
std::vector<QStandardItem *> &row, const UploadedImage &original)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'row' is unused [misc-unused-parameters]

Suggested change
std::vector<QStandardItem *> &row, const UploadedImage &original)
std::vector<QStandardItem *> & /*row*/, const UploadedImage &original)


img->pixmapOrLoad();
// You cannot stop me, clang-tidy
auto *bleh = const_cast<ImagePtrItemDelegate *>(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: do not use const_cast [cppcoreguidelines-pro-type-const-cast]

        auto *bleh = const_cast<ImagePtrItemDelegate *>(this);
                     ^

auto *bleh = const_cast<ImagePtrItemDelegate *>(this);
bleh->ownedImages_[url] = img;
}
QSize sizeHint(const QStyleOptionViewItem &option,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'option' is unused [misc-unused-parameters]

Suggested change
QSize sizeHint(const QStyleOptionViewItem &option,
QSize sizeHint(const QStyleOptionViewItem & /*option*/,

bleh->ownedImages_[url] = img;
}
QSize sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const override
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: parameter 'index' is unused [misc-unused-parameters]

Suggested change
const QModelIndex &index) const override
const QModelIndex & /*index*/) const override

@Infinitay
Copy link
Contributor

Infinitay commented Dec 2, 2023

Would it be possible to add the ability to bring up a on-hover pop-up when hovering over the image preview for a better view? Similar to when hovering over emotes and links in chat.

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Dec 2, 2023

Would it be possible to add the ability to bring up a on-hover pop-up when hovering over the image preview for a better view? Similar to when hovering over emotes and links in chat.

I'm not sure I like this solution. It requires interaction to just look at an image, where there is no other good 'index' to go by.

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Dec 2, 2023

Found 2 issues while testing on 097eb7b:

@jupjohn I fixed lazy loading causing issues and migrations.

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented Dec 2, 2023

TODO

  • add channel which the image was intended to be sent to
  • stop using pajlada::Settings
  • Consider using a different layout than a table, like a file view
  • remove a bunch of complexity
  • remove migration
  • add right click menu
  • display upload date somehow
  • add search bar

@Mm2PL Mm2PL marked this pull request as draft March 13, 2024 02:05
Mm2PL added 3 commits May 14, 2024 14:51
This is ic_fluent_image_prohibited_24_regular from Fluenticons
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

//forget->setText("Remove image from log");
buttons->addStretch();

auto *view = layout.emplace<QListView>().getElement();
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'QListView' [clang-diagnostic-error]

        auto *view = layout.emplace<QListView>().getElement();
                                    ^

buttons->addStretch();

auto *view = layout.emplace<QListView>().getElement();
view->setViewMode(QListView::IconMode);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'QListView' [clang-diagnostic-error]

        view->setViewMode(QListView::IconMode);
                          ^

view->setViewMode(QListView::IconMode);
view->setModel(model);
view->setIconSize(QSize(96, 96));
view->setLayoutMode(QListView::Batched);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'QListView' [clang-diagnostic-error]

        view->setLayoutMode(QListView::Batched);
                            ^

view->setModel(model);
view->setIconSize(QSize(96, 96));
view->setLayoutMode(QListView::Batched);
view->setMovement(QListView::Static);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'QListView' [clang-diagnostic-error]

        view->setMovement(QListView::Static);
                          ^

view->setUniformItemSizes(true);

// without this prop qt throws everything into a single line
view->setResizeMode(QListView::Adjust);
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: use of undeclared identifier 'QListView' [clang-diagnostic-error]

        view->setResizeMode(QListView::Adjust);
                            ^

@Mm2PL
Copy link
Collaborator Author

Mm2PL commented May 17, 2024

There were complexity complaints related to this PR. They mostly included removing the image preview. However UI-wise an implementation that doesn't load previews might as well just be your text editor. Searching for any image in upload history (for example to repost or delete) is already tedious enough, especially if it's older than a couple of days. IMO this idea is not worth doing without the preview. I'd like to hear feedback on continuing development of this.
@pajlada

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

Successfully merging this pull request may close these issues.

3 participants