Skip to content

Commit

Permalink
feat: add icons for image preview context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ffiirree committed Nov 3, 2024
1 parent f3c5d76 commit 82ad07f
Show file tree
Hide file tree
Showing 21 changed files with 55 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ void Capturer::SetTheme(const QString& theme)

theme_ = theme;

QIcon::setThemeName(theme);

std::vector<QString> files{
":/stylesheets/capturer", ":/stylesheets/capturer-" + theme,
":/stylesheets/menu", ":/stylesheets/menu-" + theme,
Expand Down
22 changes: 21 additions & 1 deletion src/capturer.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<RCC version="1.0">
<qresource prefix="/icons">
<file alias="dark/index.theme">resources/icons/dark-index.theme</file>
<file alias="light/index.theme">resources/icons/light-index.theme</file>

<file alias="dark/png/flip-v.png">resources/icons/flip-v-light.png</file>
<file alias="light/png/flip-v.png">resources/icons/flip-v-dark.png</file>
<file alias="dark/png/flip-h.png">resources/icons/flip-h-light.png</file>
<file alias="light/png/flip-h.png">resources/icons/flip-h-dark.png</file>
<file alias="dark/png/copy.png">resources/icons/copy-light.png</file>
<file alias="light/png/copy.png">resources/icons/copy-dark.png</file>
<file alias="dark/png/paste.png">resources/icons/paste-light.png</file>
<file alias="light/png/paste.png">resources/icons/paste-dark.png</file>
<file alias="dark/png/rotate-left.png">resources/icons/rotate-left-light.png</file>
<file alias="light/png/rotate-left.png">resources/icons/rotate-left-dark.png</file>
<file alias="dark/png/rotate-right.png">resources/icons/rotate-right-light.png</file>
<file alias="light/png/rotate-right.png">resources/icons/rotate-right-dark.png</file>
<file alias="dark/png/close-m.png">resources/icons/close-m-light.png</file>
<file alias="light/png/close-m.png">resources/icons/close-m-dark.png</file>
<file alias="dark/png/recover.png">resources/icons/recover-light.png</file>
<file alias="light/png/recover.png">resources/icons/recover-dark.png</file>

<file alias="save">resources/icons/save.png</file>
<file alias="save-light">resources/icons/save-light.png</file>
<file alias="save-dark">resources/icons/save-dark.png</file>
Expand Down
16 changes: 8 additions & 8 deletions src/preview/image-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ void ImageWindow::initContextMenu()
{
context_menu_ = new Menu(this);

addAction(context_menu_->addAction(tr("Copy"), QKeySequence::Copy, [this] { clipboard::push(data_); }));
addAction(context_menu_->addAction(tr("Paste"), QKeySequence::Paste, [this] { paste(); }));
addAction(context_menu_->addAction(QIcon::fromTheme("copy"), tr("Copy"), QKeySequence::Copy, [this] { clipboard::push(data_); }));
addAction(context_menu_->addAction(QIcon::fromTheme("paste"), tr("Paste"), QKeySequence::Paste, [this] { paste(); }));

context_menu_->addSeparator();

Expand All @@ -202,10 +202,10 @@ void ImageWindow::initContextMenu()

addAction(context_menu_->addAction(tr("Grayscale"), QKeySequence(Qt::Key_G), [this] { present(grayscale(pixmap_)); }));
addAction(context_menu_->addAction(tr("Inverse"), QKeySequence(Qt::Key_I), [this] { present(inverse(pixmap_)); }));
addAction(context_menu_->addAction(tr("Rotate +90"), QKeySequence(Qt::Key_R), [this] { present(pixmap_.transformed(QTransform().rotate(+1 * 90.0))); }));
addAction(context_menu_->addAction(tr("Rotate -90"), QKeySequence(Qt::CTRL | Qt::Key_R), [this] { present(pixmap_.transformed(QTransform().rotate(-1 * 90.0))); }));
addAction(context_menu_->addAction(tr("H Flip"), QKeySequence(Qt::Key_H), [this] { present(pixmap_.transformed(QTransform().scale(-1, +1))); }));
addAction(context_menu_->addAction(tr("V Flip"), QKeySequence(Qt::Key_V), [this] { present(pixmap_.transformed(QTransform().scale(+1, -1))); }));
addAction(context_menu_->addAction(QIcon::fromTheme("rotate-right"), tr("Rotate +90"), QKeySequence(Qt::Key_R), [this] { present(pixmap_.transformed(QTransform().rotate(+1 * 90.0))); }));
addAction(context_menu_->addAction(QIcon::fromTheme("rotate-left"), tr("Rotate -90"), QKeySequence(Qt::CTRL | Qt::Key_R), [this] { present(pixmap_.transformed(QTransform().rotate(-1 * 90.0))); }));
addAction(context_menu_->addAction(QIcon::fromTheme("flip-h"), tr("H Flip"), QKeySequence(Qt::Key_H), [this] { present(pixmap_.transformed(QTransform().scale(-1, +1))); }));
addAction(context_menu_->addAction(QIcon::fromTheme("flip-v"), tr("V Flip"), QKeySequence(Qt::Key_V), [this] { present(pixmap_.transformed(QTransform().scale(+1, -1))); }));

context_menu_->addSeparator();

Expand All @@ -224,8 +224,8 @@ void ImageWindow::initContextMenu()

context_menu_->addSeparator();

context_menu_->addAction(tr("Recover"), [this] { preview(data_); });
context_menu_->addAction(tr("Close"), QKeySequence(Qt::Key_Escape), this, &ImageWindow::close);
context_menu_->addAction(QIcon::fromTheme("recover"), tr("Recover"), [this] { preview(data_); });
context_menu_->addAction(QIcon::fromTheme("close-m"), tr("Close"), QKeySequence(Qt::Key_Escape), this, &ImageWindow::close);
}
// clang-format on

Expand Down
Binary file added src/resources/icons/close-m-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/close-m-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/copy-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/copy-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/resources/icons/dark-index.theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Icon Theme]
Name=dark
Comment=dark theme icons

Directories=png

[png]
Size=24
Context=Applications
MinSize=16
MaxSize=512
Type=Fixed
Binary file added src/resources/icons/flip-h-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/resources/icons/flip-h-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/flip-v-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/resources/icons/flip-v-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions src/resources/icons/light-index.theme
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Icon Theme]
Name=light
Comment=light theme icons

Directories=png

[png]
Size=24
Context=Applications
MinSize=16
MaxSize=512
Type=Fixed
Binary file added src/resources/icons/paste-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/paste-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/recover-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/recover-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/rotate-left-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/rotate-left-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/rotate-right-dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/resources/icons/rotate-right-light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 82ad07f

Please sign in to comment.