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

pr is features #1

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

pr is features #1

wants to merge 18 commits into from

Conversation

Gigas002
Copy link
Owner

@Gigas002 Gigas002 commented Mar 29, 2024

Rework based on (currently) unmerged iced prs. When a new iced version with this stuff releases will merge this branch

Summary by CodeRabbit

  • New Features

    • Introduced a new image viewer module with functionalities for switching and rotating images.
    • Added support for native Wayland on Linux and cross-platform compatibility.
  • Documentation

    • Updated the README with new features, usage instructions, configuration details, and guidance on common issues.
  • Refactor

    • Restructured configuration and image viewer code for improved maintainability and error handling.
    • Reorganized the main function and module imports for better clarity.
  • Chores

    • Updated project dependencies and metadata in the configuration files, including authorship and licensing details.

Copy link

coderabbitai bot commented Mar 29, 2024

Walkthrough

The recent changes enhance the imgvwr project significantly. Key updates include improvements in the .gitignore and Cargo.toml files, facilitating better dependency management and providing detailed project metadata. The README.md is now more informative with expanded usage instructions and common issues. Code refactoring across various Rust source files has improved overall structure, introduced new functionalities, and enhanced error handling, particularly for the image viewing experience.

Changes

File/Group Change Summary
.gitignore Added *.png to ignore list.
Cargo.toml Introduced authors' details, project metadata, updates to dependencies, lint configurations, and improved features.
README.md Expanded sections on features, usage instructions, configuration setup, and common issues. Updated TODO list and recommended tools.
config.toml Updated properties for window, image viewer settings, UI theme, and keyboard bindings.
src/args.rs Refactored Args struct, made config field public, and removed get_config method.
src/config.rs Restructured configuration fields, enhanced error handling, renamed fields, introduced ContentFit enum, and updated default values.
src/imgvwr.rs Added Imgvwr module with functionalities for image viewing, switching, and rotating images. Introduced new enums and message handling.
src/main.rs Reorganized imports, refactored main function, centralized program settings, improved error handling, and streamlined initialization for the image viewer app.
src/strings/keybindings.rs Defined constants for key bindings (quit, rotate left, rotate right).
src/strings/messages.rs Added constants for error messages related to file handling and image processing.
src/strings/mod.rs Introduced new modules for keybindings and messages. Defined constants for application name, configuration file name, and supported extensions.
src/util.rs Enhanced file support checks, updated the return type of get_files, adjusted get_file_id, and improved sorting logic for files.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant ImgVwr
    participant Config
    participant Main
    User->>CLI: Run imgvwr command
    CLI->>Config: Load configuration
    Config-->>CLI: Configuration data
    CLI->>Main: Initialize image viewer with config
    Main->>ImgVwr: Create Imgvwr instance
    User->>ImgVwr: View image
    ImgVwr->>ImgVwr: switch_image / rotate_image
    ImgVwr-->>User: Display updated image
Loading

Poem

In code we stride, a viewer we made,
With images bright, no bugs invade.
New settings abound, key bindings refined,
Rotate and switch, with ease you'll find.
Git ignore's neat, configs so sweet,
Our imgvwr now is mighty complete. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c85c033 and da96a68.
Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (12)
  • .gitignore (1 hunks)
  • Cargo.toml (1 hunks)
  • README.md (1 hunks)
  • config.toml (1 hunks)
  • src/args.rs (2 hunks)
  • src/config.rs (4 hunks)
  • src/imgvwr.rs (1 hunks)
  • src/main.rs (1 hunks)
  • src/strings/keybindings.rs (1 hunks)
  • src/strings/messages.rs (1 hunks)
  • src/strings/mod.rs (1 hunks)
  • src/util.rs (1 hunks)
Files skipped from review due to trivial changes (3)
  • .gitignore
  • src/strings/keybindings.rs
  • src/strings/messages.rs
Additional Context Used
Additional comments not posted (15)
src/strings/mod.rs (1)

1-6: The constants and module declarations are well-structured and follow Rust's conventions. The use of constants for application-wide strings like APPLICATION_NAME and CONFIG_FILENAME enhances maintainability and consistency across the codebase.

src/args.rs (2)

1-6: The reordering of imports and structuring of the use statements improve the readability and maintainability of the code. Grouping related imports together is a good practice.


18-29: The error handling in get_config method is enhanced by using expect with descriptive error messages. This makes the code more robust and user-friendly by providing clear error messages when the configuration path is not found or cannot be canonicalized. However, consider handling these errors more gracefully in a production environment to avoid panics.

Consider implementing error propagation to handle these scenarios more gracefully, allowing the application to continue running or exit cleanly with an error message.

config.toml (1)

1-33: The updates to config.toml introduce several new configurations that enhance the application's flexibility and user experience. The inclusion of decorations, antialiasing, theme, min_scale, max_scale, scale_step, filter_method, content_fit, and keyboard bindings are well-structured and follow TOML conventions. Ensure that the application correctly handles these configurations and provides defaults where necessary.

src/util.rs (2)

1-11: The refactoring of is_file_supported to use a match statement improves readability and makes the function more idiomatic Rust. This change also simplifies the logic for checking file support based on extensions.


15-24: The update to get_files to return a Vec<PathBuf> instead of a HashMap<usize, PathBuf> simplifies the data structure used for storing file paths. This change likely improves the performance and usability of the function. Ensure that all usages of get_files have been updated accordingly.

Cargo.toml (1)

4-24: The enhancements to the Cargo.toml file, including the addition of authors' information, project metadata, lint configuration for unsafe code, and dependency updates, significantly improve the project's metadata and code quality. The removal of the image dependency and updates to clap, iced, and toml dependencies are notable. Ensure that the removal of the image dependency does not affect the project's functionality and that all dependencies are correctly updated in the codebase.

src/main.rs (1)

3-41: The addition of new modules and the reorganization of imports in src/main.rs enhance the code structure and readability. The refactoring of the main function to handle errors and configuration settings more effectively is commendable. The simplification of the Imgvwr struct and related methods, along with the updates to program settings and initialization, are well-executed. Ensure that error handling is robust and that the application gracefully handles any potential errors during initialization.

README.md (1)

5-49: The updates to the README.md file significantly enhance the documentation, providing users with a comprehensive overview of the application's features, limitations, usage instructions, and configuration setup. The guidance on requesting new features and troubleshooting common issues is helpful and encourages community engagement. The updated TODO section clearly outlines future development directions. Ensure that all links are valid and that the documentation accurately reflects the current state of the project.

src/imgvwr.rs (1)

16-165: The introduction of the Imgvwr struct and its methods in src/imgvwr.rs significantly enhances the application's image viewing capabilities. The struct fields and methods are well-defined, and the implementation of image switching, rotation, and viewer configuration is robust. The use of enums for Direction, Rotation, and Message improves code readability and maintainability. Ensure that all new functionalities are thoroughly tested, especially the image rotation and switching logic, to ensure correctness and performance.

src/config.rs (5)

8-8: The Config struct now includes a window, viewer, and keybindings field. Ensure that all parts of the application that instantiate Config are updated to handle these optional fields appropriately, especially since they are now Option types which may require unwrapping or default handling.


34-35: The Window struct includes a new decorations field. This is a good use of an Option<bool> to allow for optional configuration. However, consider documenting the default behavior when this field is None to improve clarity for users of the Config struct.


116-116: The addition of the content_fit field in the Viewer struct is a significant enhancement, allowing for more flexible image viewing options. Ensure that the application's UI correctly interprets and applies these settings.


153-161: The ContentFit enum provides various options for how content is fitted within the viewer. This is a valuable addition for user customization. Ensure that all enum variants are handled in the application logic, particularly in the image rendering code, to respect user preferences.


184-185: The Keybindings struct now includes options for rotate_left and rotate_right. It's important to ensure that these keybindings are configurable and correctly hooked up to the application's event handling system. Additionally, consider validating the keybinding strings to prevent conflicts or unsupported keys.

src/util.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

src/main.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 100f9b6 and 379bc9e.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • src/imgvwr.rs (1 hunks)
Additional comments not posted (4)
Cargo.toml (2)

4-11: Metadata enhancements are well-defined and improve project documentation and package management.


14-14: Enforcing the forbid rule on unsafe_code is a commendable practice to ensure code safety.

src/imgvwr.rs (2)

16-26: The Imgvwr struct is well-structured and encapsulates the necessary fields for image handling effectively.


148-164: Enums Direction, Rotation, and Message are appropriately defined and enhance the clarity of action types in the code.

Cargo.toml Outdated Show resolved Hide resolved
src/imgvwr.rs Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 379bc9e and 2de29d4.

Files selected for processing (1)
  • README.md (1 hunks)
Additional context used
LanguageTool
README.md

[grammar] ~5-~5: A noun may be missing here. (DT_JJ_NO_NOUN)
Context: ...ced). You can actually think of this as an iced's viewer widget with config and very ...


[typographical] ~23-~23: Consider adding a comma after ‘Personally’ for more clarity. (RB_LY_COMMA)
Context: ...e's some stuff I don't like, of course. Personally I'd recommend to use these amazing tool...


[grammar] ~23-~23: The verb ‘recommend’ is used with the gerund form. (ADMIT_ENJOY_VB)
Context: ...I don't like, of course. Personally I'd recommend to use these amazing tools: - [imageglass](ht...


[style] ~23-~23: Consider using a more formal and expressive alternative to ‘amazing’. (AWESOME)
Context: .... Personally I'd recommend to use these amazing tools: - [imageglass](https://github.c...


[uncategorized] ~26-~26: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ...st upscaling filter I've encountered in open source image viewers so far and handles a lot ...


[style] ~26-~26: The phrase ‘a lot of’ might be wordy and overused. Consider using an alternative. (A_LOT_OF)
Context: ...source image viewers so far and handles a lot of formats. I also absolutely love how `gi...


[uncategorized] ~27-~27: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ...ns available, e.g. it lacks configuring floating point scaling value (only integer values are ...


[uncategorized] ~28-~28: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...r cons, there's no binary package for it and it's build time is VERY slow and resour...


[grammar] ~28-~28: Make sure that the noun ‘build’ is correct. Did you mean the past participle “built”? (BE_VB_OR_NN)
Context: ...ere's no binary package for it and it's build time is VERY slow and resource-consumin...


[grammar] ~30-~30: The plural noun “reasons” cannot be used with the article “a”. Did you mean “a different reason” or “different reasons”? (A_NNS)
Context: ... and there, but I didn't like those for a different reasons, so didn't use them for quite enough ti...


[grammar] ~32-~32: Did you mean “was”, “is”, or “was it”? (WAS_IS)
Context: ...ime to remember For me, the motivation was is that I wanted an oculante, which woul...


[grammar] ~32-~32: Did you mean to use the possessive pronoun “its”? (IT_S_ITS)
Context: ...ts I need, it handles wayland natively, it's performance is not bad and it has confi...


[uncategorized] ~32-~32: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...nd natively, it's performance is not bad and it has config file with all the options...


[style] ~46-~46: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...pstream projects and provide a PR there in order to keep this project's code as simple as p...


[style] ~46-~46: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...probably realted to something upstream. I also don't want to add any more externa...


[style] ~46-~46: The phrase ‘feel free to’ is used quite frequently. Consider using a less frequent alternative to set your writing apart from others and make it sound more professional. (FEEL_FREE_TO_STYLE_ME)
Context: ... least for now, so keep it in mind. But feel free to ask anything in issues here too, I'm no...


[typographical] ~50-~50: It appears that there’s a comma missing after this introductory phrase. (AS_FAR_AS_I_UNDERSTAND)
Context: ...rt (which relies on image crate), but AFAIK we may have an opportunity to load byte...


[uncategorized] ~52-~52: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ... not in imgvwr - file an issue/PR here and I'll add the support for it. If it's no...


[style] ~54-~54: In American English, abbreviations like “etc.” require a period. (ETC_PERIOD)
Context: ...ed to image modifications (paint, crop, etc) or a directory view then it's not plan...

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2de29d4 and fd05e6b.

Files selected for processing (1)
  • README.md (1 hunks)
Additional context used
LanguageTool
README.md

[grammar] ~23-~23: The verb ‘recommend’ is used with the gerund form. (ADMIT_ENJOY_VB)
Context: ... don't like, of course. Personally, I'd recommend to use these exceptional tools: - [imageglass...


[uncategorized] ~25-~25: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...it's windows-only I haven't used it for last several years, so I don't know what's c...


[uncategorized] ~26-~26: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...it that it's not developed actively for last two years. For pros, it has the best up...


[uncategorized] ~27-~27: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ...ns available, e.g. it lacks configuring floating point scaling value (only integer values are ...


[uncategorized] ~28-~28: You might be missing the article “an” here. (AI_EN_LECTOR_MISSING_DETERMINER_AN)
Context: ...ub.com/woelper/oculante) -- viewer with extremely friendly and passionate maintainer. Sup...


[uncategorized] ~28-~28: Possible missing article found. (AI_HYDRA_LEO_MISSING_A)
Context: ... slow and resource-consuming because of heavy dependency tree. The supported format l...


[uncategorized] ~28-~28: A period might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)
Context: ...so a bit smaller than the qimgv's for example Of course there are more tools for thi...


[uncategorized] ~30-~30: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ...ller than the qimgv's for example Of course there are more tools for this purpose h...


[grammar] ~30-~30: The plural noun “reasons” cannot be used with the article “a”. Did you mean “a different reason” or “different reasons”? (A_NNS)
Context: ... and there, but I didn't like those for a different reasons, so didn't use them for quite enough ti...


[uncategorized] ~32-~32: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...fix it right away or file a pr/issue in appropriate place. That's it. It handles formats I ...


[uncategorized] ~32-~32: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ...and natively, its performance is not bad and it has a config file with all the optio...


[style] ~46-~46: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...probably realted to something upstream. I also don't want to add any more externa...


[style] ~46-~46: The phrase ‘feel free to’ is used quite frequently. Consider using a less frequent alternative to set your writing apart from others and make it sound more professional. (FEEL_FREE_TO_STYLE_ME)
Context: ... least for now, so keep it in mind. But feel free to ask anything in issues here too, I'm no...


[uncategorized] ~46-~46: A period might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_PERIOD)
Context: ...ues here too, I'm not against it in any way As for common issues: - if it's relat...


[uncategorized] ~50-~50: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...d` may be important too though, since current implementation relies on their format s...


[typographical] ~50-~50: It appears that there’s a comma missing after this introductory phrase. (AS_FAR_AS_I_UNDERSTAND)
Context: ...rt (which relies on image crate), but AFAIK we may have an opportunity to load byte...


[uncategorized] ~52-~52: Use a comma before ‘and’ if it connects two independent clauses (unless they are closely connected and short). (COMMA_COMPOUND_SENTENCE)
Context: ... not in imgvwr - file an issue/PR here and I'll add the support for it. If it's no...


[style] ~54-~54: In American English, abbreviations like “etc.” require a period. (ETC_PERIOD)
Context: ...ed to image modifications (paint, crop, etc) or a directory view then it's not plan...

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fd05e6b and 7448a75.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • src/imgvwr.rs (1 hunks)
  • src/main.rs (1 hunks)
Additional comments not posted (14)
Cargo.toml (2)

4-11: Metadata additions look good.

The metadata fields such as authors, description, repository, license, keywords, categories, and exclude are correctly formatted and relevant to the project.


17-23: Dependency configurations look good.

The dependency configurations for clap, iced, and toml are correctly specified. Disabling default features and enabling specific features is a good practice for optimizing dependencies.

src/main.rs (4)

3-3: New module import looks good.

The import of the new module imgvwr is correctly added.


12-18: Improved error handling in main function.

The restructuring of the main function to return an iced::Result and the improved error handling for unsupported input files are good practices.


20-27: Simplified configuration loading.

The configuration loading and initialization process is simplified and correctly implemented.


32-41: Streamlined application setup.

The application setup using iced::application is streamlined and correctly implemented.

src/imgvwr.rs (8)

16-26: Struct fields look good.

The fields in the Imgvwr struct are correctly defined and relevant to managing the image viewer's state.


28-47: Method logic looks good.

The logic for switching images based on the direction is correctly implemented.


49-59: Method logic looks good.

The logic for rotating images based on the rotation direction is correctly implemented.


62-89: Initialization logic looks good.

The initialization logic for the Imgvwr struct is correctly implemented with the provided configuration and keybindings.


91-101: Method logic looks good.

The logic for generating the window title based on the current image and application name is correctly implemented.


103-119: Method logic looks good.

The logic for handling key presses and image navigation is correctly implemented.


121-136: Method logic looks good.

The logic for generating the UI for the image viewer is correctly implemented.


138-152: Method logic looks good.

The logic for handling key press subscriptions is correctly implemented.

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.

None yet

1 participant