Skip to content

Commit

Permalink
#47, window minimize/maximize/fullscreen/restore
Browse files Browse the repository at this point in the history
  • Loading branch information
ffiirree committed Jul 8, 2023
1 parent a4676ae commit 06a8fe3
Show file tree
Hide file tree
Showing 31 changed files with 365 additions and 132 deletions.
36 changes: 18 additions & 18 deletions languages/capturer_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,79 +45,79 @@
<context>
<name>ImageWindow</name>
<message>
<location filename="../src/preview/image-window.cpp" line="137"/>
<location filename="../src/preview/image-window.cpp" line="139"/>
<source>Open Image</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="149"/>
<location filename="../src/preview/image-window.cpp" line="151"/>
<source>Save Image</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="166"/>
<location filename="../src/preview/image-window.cpp" line="168"/>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="167"/>
<location filename="../src/preview/image-window.cpp" line="169"/>
<source>Paste</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="171"/>
<location filename="../src/preview/image-window.cpp" line="173"/>
<source>Open Image...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="172"/>
<location filename="../src/preview/image-window.cpp" line="174"/>
<source>Save As...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="176"/>
<location filename="../src/preview/image-window.cpp" line="178"/>
<source>Grayscale</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="177"/>
<location filename="../src/preview/image-window.cpp" line="179"/>
<source>Rotate +90</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="178"/>
<location filename="../src/preview/image-window.cpp" line="180"/>
<source>Rotate -90</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="179"/>
<location filename="../src/preview/image-window.cpp" line="181"/>
<source>H Flip</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="180"/>
<location filename="../src/preview/image-window.cpp" line="182"/>
<source>V Flip</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="187"/>
<location filename="../src/preview/image-window.cpp" line="199"/>
<location filename="../src/preview/image-window.cpp" line="189"/>
<location filename="../src/preview/image-window.cpp" line="201"/>
<source>Zoom : </source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="188"/>
<location filename="../src/preview/image-window.cpp" line="200"/>
<location filename="../src/preview/image-window.cpp" line="190"/>
<location filename="../src/preview/image-window.cpp" line="202"/>
<source>Opacity : </source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="189"/>
<location filename="../src/preview/image-window.cpp" line="191"/>
<source>Recover</source>
<translation></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="193"/>
<location filename="../src/preview/image-window.cpp" line="195"/>
<source>Close</source>
<translation></translation>
</message>
Expand All @@ -141,7 +141,7 @@
<context>
<name>SettingWindow</name>
<message>
<location filename="../src/setting/settingdialog.cpp" line="43"/>
<location filename="../src/setting/settingdialog.cpp" line="42"/>
<source>Settings</source>
<translation></translation>
</message>
Expand Down
36 changes: 18 additions & 18 deletions languages/capturer_zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
<context>
<name>ImageWindow</name>
<message>
<location filename="../src/preview/image-window.cpp" line="137"/>
<location filename="../src/preview/image-window.cpp" line="139"/>
<source>Open Image</source>
<translation>打开图片</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="149"/>
<location filename="../src/preview/image-window.cpp" line="151"/>
<source>Save Image</source>
<translation>保存图片</translation>
</message>
Expand All @@ -71,47 +71,47 @@
<translation type="vanished">另存为...</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="166"/>
<location filename="../src/preview/image-window.cpp" line="168"/>
<source>Copy</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="167"/>
<location filename="../src/preview/image-window.cpp" line="169"/>
<source>Paste</source>
<translation type="unfinished">粘贴</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="171"/>
<location filename="../src/preview/image-window.cpp" line="173"/>
<source>Open Image...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="172"/>
<location filename="../src/preview/image-window.cpp" line="174"/>
<source>Save As...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="176"/>
<location filename="../src/preview/image-window.cpp" line="178"/>
<source>Grayscale</source>
<translation>灰度图</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="177"/>
<location filename="../src/preview/image-window.cpp" line="179"/>
<source>Rotate +90</source>
<translation>旋转 +90°</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="178"/>
<location filename="../src/preview/image-window.cpp" line="180"/>
<source>Rotate -90</source>
<translation>旋转 -90°</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="179"/>
<location filename="../src/preview/image-window.cpp" line="181"/>
<source>H Flip</source>
<translation>水平翻转</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="180"/>
<location filename="../src/preview/image-window.cpp" line="182"/>
<source>V Flip</source>
<translation>垂直翻转</translation>
</message>
Expand Down Expand Up @@ -144,24 +144,24 @@
<translation type="vanished">阴影</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="187"/>
<location filename="../src/preview/image-window.cpp" line="199"/>
<location filename="../src/preview/image-window.cpp" line="189"/>
<location filename="../src/preview/image-window.cpp" line="201"/>
<source>Zoom : </source>
<translation>缩放 :</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="188"/>
<location filename="../src/preview/image-window.cpp" line="200"/>
<location filename="../src/preview/image-window.cpp" line="190"/>
<location filename="../src/preview/image-window.cpp" line="202"/>
<source>Opacity : </source>
<translation>透明度 :</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="189"/>
<location filename="../src/preview/image-window.cpp" line="191"/>
<source>Recover</source>
<translation>复原</translation>
</message>
<message>
<location filename="../src/preview/image-window.cpp" line="193"/>
<location filename="../src/preview/image-window.cpp" line="195"/>
<source>Close</source>
<translation>关闭</translation>
</message>
Expand All @@ -185,7 +185,7 @@
<context>
<name>SettingWindow</name>
<message>
<location filename="../src/setting/settingdialog.cpp" line="43"/>
<location filename="../src/setting/settingdialog.cpp" line="42"/>
<source>Settings</source>
<translation>设置</translation>
</message>
Expand Down
2 changes: 1 addition & 1 deletion src/capturer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Capturer::Capturer(QWidget *parent)
connect(&Config::instance(), &Config::changed, this, &Capturer::updateConfig);

// setting
setting_dialog_ = new SettingWindow(this);
setting_dialog_ = std::make_shared<SettingWindow>();

// System tray icon
// @attention Must after setting.
Expand Down
4 changes: 2 additions & 2 deletions src/capturer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "screenshoter.h"
#include "settingdialog.h"

#include <memory>
#include <QSystemTrayIcon>

class Capturer : public QWidget
Expand All @@ -15,7 +16,6 @@ class Capturer : public QWidget

public:
explicit Capturer(QWidget *parent = nullptr);
~Capturer() override = default;

private slots:
void pin();
Expand All @@ -36,7 +36,7 @@ private slots:

QSystemTrayIcon *sys_tray_icon_{ nullptr };

SettingWindow *setting_dialog_{ nullptr };
std::shared_ptr<SettingWindow> setting_dialog_{};

// hotkey
QHotkey *snip_sc_{ nullptr };
Expand Down
15 changes: 12 additions & 3 deletions src/capturer.qrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/icons">
<file alias="close">resources/icons/close.png</file>
<file alias="close-light">resources/icons/close-light.png</file>
<file alias="close-dark">resources/icons/close-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 Expand Up @@ -115,6 +112,18 @@
<file alias="scroll">resources/icons/scroll.png</file>
<file alias="scroll-dark">resources/icons/scroll-dark.png</file>
<file alias="scroll-light">resources/icons/scroll-light.png</file>
<file alias="minimize">resources/icons/minimize.png</file>
<file alias="minimize-light">resources/icons/minimize-light.png</file>
<file alias="minimize-dark">resources/icons/minimize-dark.png</file>
<file alias="maximize">resources/icons/maximize.png</file>
<file alias="maximize-light">resources/icons/maximize-light.png</file>
<file alias="maximize-dark">resources/icons/maximize-dark.png</file>
<file alias="normal">resources/icons/normal.png</file>
<file alias="normal-light">resources/icons/normal-light.png</file>
<file alias="normal-dark">resources/icons/normal-dark.png</file>
<file alias="close">resources/icons/close.png</file>
<file alias="close-light">resources/icons/close-light.png</file>
<file alias="close-dark">resources/icons/close-dark.png</file>
</qresource>
<qresource prefix="/stylesheets">
<file alias="capturer">resources/stylesheets/capturer.qss</file>
Expand Down
10 changes: 9 additions & 1 deletion src/common/clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Clipboard : public QObject
explicit Clipboard(QObject *parent = nullptr)
: QObject(parent)
{
connect(QApplication::clipboard(), &QClipboard::changed, [=](auto) {
connect(QApplication::clipboard(), &QClipboard::dataChanged, [=]() {
if (auto clipboard_data = QApplication::clipboard()->mimeData();
!clipboard_data->hasFormat(clipboard::MIME_TYPE_STATUS)) {
auto cloned = std::shared_ptr<QMimeData>(clipboard::clone(clipboard_data));
Expand All @@ -41,11 +41,19 @@ namespace clipboard
{
void init() { Clipboard::instance(); }

// TODO : crush while copying these types
static const QVector<QString> blacklist = {
R"(application/x-qt-windows-mime;value="HyperlinkWordBkmk")",
R"(application/x-qt-windows-mime;value="EnterpriseDataProtectionId")",
};

QMimeData *clone(const QMimeData *other)
{
auto mimedata = new QMimeData();

foreach(const auto& format, other->formats()) {
if (blacklist.contains(format)) continue;

if (format == MIME_TYPE_IMAGE) {
mimedata->setImageData(other->imageData());
continue;
Expand Down
5 changes: 5 additions & 0 deletions src/preview/color-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ ColorWindow::ColorWindow(QWidget *parent)
ColorWindow::ColorWindow(const std::shared_ptr<QMimeData>& data, QWidget *parent)
: FramelessWindow(parent)
{
setWindowTitle("Color Window");

if (data && data->hasColor()) {
data_ = data;
data_->setData(clipboard::MIME_TYPE_STATUS, "P");
Expand All @@ -84,6 +86,9 @@ ColorWindow::ColorWindow(const std::shared_ptr<QMimeData>& data, QWidget *parent
hl->addStretch();

connect(nbar, &NavigationBar::toggled, [this](int id) { refresh(static_cast<number_t>(id)); });

//
layout->addStretch();

auto gl = new QGridLayout();
layout->addLayout(gl);
Expand Down
2 changes: 2 additions & 0 deletions src/preview/image-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ImageWindow::ImageWindow(const std::shared_ptr<QMimeData>& data, QWidget *parent
setWindowFlags((windowFlags() & ~Qt::Window) | Qt::Tool | Qt::WindowStaysOnTopHint);
setAttribute(Qt::WA_DeleteOnClose);

setWindowTitle("Image Window");

setAcceptDrops(true);

preview_ = new TextureWidget(this);
Expand Down
Binary file modified src/resources/icons/close-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/close-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 modified src/resources/icons/close.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/maximize-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/maximize-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/maximize.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/minimize-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/minimize-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/minimize.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/normal-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/normal-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/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 26 additions & 1 deletion src/resources/stylesheets/capturer-dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ QLabel {
}

/*///////////////////////////////////////////////////////////////*/

ColorWindow {
background-color: #272728;
}
Expand All @@ -161,4 +160,30 @@ NavigationBar {
NavigationBar QCheckBox {
background-color: #2a292d;
border: 1px solid #444445;
}

/*///////////////////////////////////////////////////////////////*/
TitleBar {
background-color: #272728;
}

TitleBar QCheckBox#min-btn::indicator {
image: url(:/icons/minimize-light);
}

TitleBar QCheckBox#max-btn::indicator:unchecked {
image: url(:/icons/maximize-light);
}

TitleBar QCheckBox#max-btn::indicator:checked {
image: url(:/icons/normal-light);
}

TitleBar QCheckBox#close-btn::indicator {
image: url(:/icons/close-light);
}

TitleBar QCheckBox#min-btn:hover,
TitleBar QCheckBox#max-btn:hover {
background: #323232;
}
Loading

0 comments on commit 06a8fe3

Please sign in to comment.