Skip to content

Commit

Permalink
[w&l] high dpi scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
ffiirree committed Mar 27, 2023
1 parent 5ddbba7 commit 8451c3e
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 86 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.12)

project(capturer VERSION 1.4.0 LANGUAGES C CXX)
project(capturer VERSION 1.4.1 LANGUAGES C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

![image](/capturer.png)


`Capturer`是使用`Qt`开发的一款**截图****录屏****录制GIF**软件,支持`Windows``Linux`系统。
> `录屏``录制GIF`依赖于`FFmpeg`,请[安装FFmpeg](#安装FFmpeg).
`Capturer`是使用`Qt`开发的一款**截图****贴图****录屏****录制GIF**软件,支持`Windows``Linux`系统。
配合快捷键可以快速选择`桌面区域``窗口`进行快速截图/录制。

## 快捷键

Expand Down Expand Up @@ -90,7 +89,7 @@ git clone https://github.com/ffiirree/Capturer.git --recursive
git submodule update --init --recursive
```

> 本项目开发使用的`Qt`版本为`Qt 5.12.12`, `FFmpeg`版本为4.4.1
> 本项目开发使用的`Qt`版本为`Qt 5.12.x / 5.15.x`, `FFmpeg`版本为`4.4.x` / `5.1.2`
### Windows

Expand Down
2 changes: 2 additions & 0 deletions src/capturer.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<RCC>
<qresource prefix="/icon">
<file>res/close.png</file>
<file>res/close-light.png</file>
<file>res/close-dark.png</file>
<file>res/save.png</file>
<file>res/save-light.png</file>
<file>res/save-dark.png</file>
Expand Down
4 changes: 2 additions & 2 deletions src/capturer.qss
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ QSpinBox::down-arrow {

QMenu {
border-radius: 5px;
padding: 0.5em;
padding: 0.35em;
}

QMenu::icon {
Expand Down Expand Up @@ -179,7 +179,7 @@ QMenu#tray-menu::item {
/*///////////////////////////////////////////////////////////////*/

QLabel#size_info {
background-color: rgba(0, 0, 0, 200);;
background-color: rgba(0, 0, 0, 200);
color: white;
font-size: 9pt;
font-family: "Microsoft YaHei";
Expand Down
2 changes: 1 addition & 1 deletion src/menu/editmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <QWidget>
#include <QPen>
#include "iconbutton.h"
#include "custombutton.h"

class EditMenu : public QWidget
{
Expand Down
1 change: 0 additions & 1 deletion src/menu/imageeditmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <QCheckBox>
#include "utils.h"
#include "stylemenu.h"
#include "iconbutton.h"
#include "buttongroup.h"

class ImageEditMenu : public EditMenu
Expand Down
4 changes: 0 additions & 4 deletions src/menu/menu-dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ EditMenu {
background-color: #232323;
}

ImageEditMenu QPushButton {
background-color: #232323;
}

ImageEditMenu QCheckBox::indicator:unchecked:hover {
background-color: #323232;
}
Expand Down
29 changes: 15 additions & 14 deletions src/menu/menu.qss
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ RecordMenu QCheckBox {
}

RecordMenu QCheckBox::indicator {
height: 1.5em;
width: 1.5em;
padding: 0.75em;
font-size: 9pt;

height: 1.35em;
width: 1.35em;
padding: 0.6em;
border-radius: 5px;
}

Expand All @@ -29,19 +31,15 @@ RecordMenu QCheckBox#stop-btn::indicator {

/*///////////////////////////////// Edit Menu //////////////////////////////*/

ImageEditMenu QPushButton {
width: 35px;
height: 35px;
border: none;
}

ImageEditMenu QCheckBox {
spacing: 0px;
}

ImageEditMenu QCheckBox::indicator {
height: 1.75em;
width: 1.75em;
font-size: 9pt;

height: 1.5em;
width: 1.5em;
padding: 0.5em;
}

Expand Down Expand Up @@ -102,8 +100,10 @@ StyleMenu QCheckBox {
}

StyleMenu QCheckBox::indicator {
height: 1.75em;
width: 1.75em;
font-size: 9pt;

height: 1.5em;
width: 1.5em;
padding: 0.5em;
}

Expand All @@ -112,5 +112,6 @@ StyleMenu QCheckBox#fill-btn::indicator:checked {
}

StyleMenu ColorPanel {
min-height: 2.75em;
font-size: 9pt;
min-height: 2.45em;
}
2 changes: 1 addition & 1 deletion src/menu/stylemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ StyleMenu::StyleMenu(int buttons, QWidget* parent)
if (buttons & FILL_BTN) {
fill_btn_ = new QCheckBox(this);
fill_btn_->setObjectName("fill-btn");
connect(fill_btn_, &IconButton::toggled, [this](bool checked) { fill_ = checked; emit changed(); });
connect(fill_btn_, &QCheckBox::toggled, [this](bool checked) { fill_ = checked; emit changed(); });

addWidget(fill_btn_);
group->addButton(fill_btn_);
Expand Down
3 changes: 1 addition & 2 deletions src/menu/stylemenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#include <QCheckBox>
#include "editmenu.h"
#include "colorpanel.h"
#include "linewidthwidget.h"
#include "iconbutton.h"
#include "linewidthbutton.h"
#include "buttongroup.h"

class StyleMenu : public EditMenu
Expand Down
Binary file added src/res/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 added src/res/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/res/close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/setting/settingswindow-dark.qss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ QLabel#title {
background-color: #202021;
}

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

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

QTabWidget#firstmenu::pane {
background: #272728;
}
Expand Down
4 changes: 4 additions & 0 deletions src/setting/settingswindow-light.qss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ QLabel#title {
background-color: #f5f7fa;
}

TitleBar QCheckBox#close-btn::indicator {
image: url(:/icon/res/close-dark)
}

/*///////////////////////////////////////////////////////////////*/
QTabWidget#firstmenu::pane {
background: #fcfdfe;
Expand Down
19 changes: 19 additions & 0 deletions src/setting/settingswindow.qss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ QLabel#title {
font-family: "华文新魏";
}

TitleBar QCheckBox {
spacing: 0px;
}

TitleBar QCheckBox#close-btn::indicator {
font-size: 9pt;

height: 1.25em;
width: 1.25em;

padding: 0.75em 1.25em 0.75em 1.25em;
}

TitleBar QCheckBox#close-btn::indicator:hover {
background-color: #e81123;
image: url(:/icon/res/close-light)
}

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

QTabWidget#firstmenu::pane {
border: none;
}
Expand Down
24 changes: 0 additions & 24 deletions src/widgets/iconbutton.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions src/widgets/iconbutton.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "linewidthwidget.h"
#include <QPainter>
#include <QWheelEvent>
#include "linewidthbutton.h"

void WidthButton::wheelEvent(QWheelEvent *event)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LINE_WIDTH_WIDGET_H
#define LINE_WIDTH_WIDGET_H
#ifndef LINE_WIDTH_BUTTON_H
#define LINE_WIDTH_BUTTON_H

#include "custombutton.h"

Expand Down Expand Up @@ -46,4 +46,4 @@ public slots:
int min_{ 1 };
};

#endif // LINE_WIDTH_WIDGET_H
#endif // !LINE_WIDTH_BUTTON_H
17 changes: 9 additions & 8 deletions src/widgets/titlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QHBoxLayout>
#include <QMouseEvent>
#include <QStyle>
#include <QCheckBox>
#include <QPushButton>

TitleBar::TitleBar(QWidget *parent)
Expand All @@ -20,12 +21,12 @@ TitleBar::TitleBar(QWidget *parent)
icon_label->setObjectName("logo");
auto logo = QPixmap(":/icon/res/icon");
icon_label->setPixmap(logo);
icon_label->setFixedSize(50, 50);
icon_label->setContentsMargins({10, 10, 10, 10});
icon_label->setFixedSize(60, 50);
icon_label->setContentsMargins({ 20, 10, 10, 10 });
icon_label->setScaledContents(true);

title_label_ = new QLabel("", this);
title_label_->setFixedWidth(150);
title_label_->setFixedWidth(140);
title_label_->setObjectName("title");

layout->addWidget(icon_label);
Expand All @@ -35,12 +36,12 @@ TitleBar::TitleBar(QWidget *parent)
layout->addSpacerItem(new QSpacerItem(20, 50, QSizePolicy::Expanding, QSizePolicy::Minimum));

// close button
auto close_btn = new IconButton(QPixmap(":/icon/res/close"), { 50, 50 }, { 24, 24 }, false, this);
close_btn->normal(QColor("#afafaf"));
close_btn->hover(QColor("#409eff"));
connect(close_btn, &QPushButton::clicked, this, &TitleBar::close);
auto close_btn = new QCheckBox(this);
close_btn->setObjectName("close-btn");
close_btn->setCheckable(false);
connect(close_btn, &QCheckBox::clicked, this, &TitleBar::close);

layout->addWidget(close_btn);
layout->addWidget(close_btn, 0, Qt::AlignTop);
}

void TitleBar::mousePressEvent(QMouseEvent * event)
Expand Down
1 change: 0 additions & 1 deletion src/widgets/titlebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <QWidget>
#include <QLabel>
#include "iconbutton.h"

class TitleBar : public QWidget {
Q_OBJECT
Expand Down

0 comments on commit 8451c3e

Please sign in to comment.