Skip to content

Commit 37cfbf4

Browse files
authored
Merge pull request #18 from entire-orp/master
修复bug
2 parents b1dbac8 + 2b58080 commit 37cfbf4

File tree

7 files changed

+1162
-466
lines changed

7 files changed

+1162
-466
lines changed

ScreenSniper.pro

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,50 @@ unix:!macx {
5757
# LIBS += -lXrender
5858
# LIBS += -lXrandr
5959
}
60-
win32 {
61-
# Windows 配置
62-
# OpenCV 配置
63-
# 明确移除 NO_OPENCV 定义(如果之前有定义)
64-
DEFINES -= NO_OPENCV
60+
# win32 {
61+
# # Windows 配置
62+
# # OpenCV 配置
63+
# # 明确移除 NO_OPENCV 定义(如果之前有定义)
64+
# DEFINES -= NO_OPENCV
6565

66-
# OpenCV头文件路径
67-
INCLUDEPATH += D:/rr/opencv/opencv/opencv_bulid/install/include
66+
# # OpenCV头文件路径
67+
# INCLUDEPATH += D:/rr/opencv/opencv/opencv_bulid/install/include
6868

69-
# OpenCV库文件路径 + 链接库
70-
LIBS += -LD:/rr/opencv/opencv/opencv_bulid/lib
71-
LIBS += -lopencv_calib3d4120 -lopencv_core4120 -lopencv_dnn4120 -lopencv_features2d4120 \
72-
-lopencv_flann4120 -lopencv_highgui4120 -lopencv_imgcodecs4120 -lopencv_imgproc4120 \
73-
-lopencv_ml4120 -lopencv_objdetect4120 -lopencv_photo4120 -lopencv_stitching4120 \
74-
-lopencv_ts4120 -lopencv_video4120 -lopencv_videoio4120
75-
76-
# Tesseract configuration for Windows
77-
# 请根据实际安装路径修改
78-
# DEFINES += USE_TESSERACT
79-
# INCLUDEPATH += "C:/Program Files/Tesseract-OCR/include"
80-
# LIBS += -L"C:/Program Files/Tesseract-OCR/lib" -ltesseract51
69+
# # OpenCV库文件路径 + 链接库
70+
# LIBS += -LD:/rr/opencv/opencv/opencv_bulid/lib
71+
# LIBS += -lopencv_calib3d4120 -lopencv_core4120 -lopencv_dnn4120 -lopencv_features2d4120 \
72+
# -lopencv_flann4120 -lopencv_highgui4120 -lopencv_imgcodecs4120 -lopencv_imgproc4120 \
73+
# -lopencv_ml4120 -lopencv_objdetect4120 -lopencv_photo4120 -lopencv_stitching4120 \
74+
# -lopencv_ts4120 -lopencv_video4120 -lopencv_videoio4120
75+
76+
# # Tesseract configuration for Windows
77+
# # 请根据实际安装路径修改
78+
# # DEFINES += USE_TESSERACT
79+
# # INCLUDEPATH += "C:/Program Files/Tesseract-OCR/include"
80+
# # LIBS += -L"C:/Program Files/Tesseract-OCR/lib" -ltesseract51
81+
82+
# LIBS += -lPsapi -lDwmapi
83+
# }
8184

82-
LIBS += -lPsapi -lDwmapi
83-
}
85+
win32 {
86+
# Windows 配置
87+
INCLUDEPATH += "D:/C++/opencv/build/include"
88+
DEPENDPATH += "D:/C++/opencv/build/include"
8489

90+
# 显式添加 opencv2 子目录
91+
INCLUDEPATH += "D:/C++/opencv/build/include/opencv2"
92+
DEPENDPATH += "D:/C++/opencv/build/include/opencv2"
8593

94+
LIBS += -lPsapi -lDwmapi
95+
LIBS += -L"D:/C++/opencv/build/x64/vc16/lib"
96+
97+
CONFIG(debug, debug|release) {
98+
LIBS += -lopencv_world4120d
99+
DEFINES += OPENCV_DEBUG
100+
} else {
101+
LIBS += -lopencv_world4120
102+
}
103+
}
86104

87105

88106

@@ -100,6 +118,7 @@ SOURCES += \
100118
screenshotwidget.cpp \
101119
ocrmanager.cpp \
102120
ocrresultdialog.cpp \
121+
scrollcapture.cpp \
103122
watermark_robust.cpp \
104123
i18nmanager.cpp \
105124
facedetector.cpp
@@ -112,6 +131,7 @@ HEADERS += \
112131
screenshotwidget.h \
113132
ocrmanager.h \
114133
ocrresultdialog.h \
134+
scrollcapture.h \
115135
watermark_robust.h \
116136
i18nmanager.h \
117137
facedetector.h

mainwindow.cpp

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <QHBoxLayout>
2222
#include <QDialogButtonBox>
2323
#include <QPointer>
24+
#include "ScrollCapture.h"
2425

2526
MainWindow::MainWindow(QWidget *parent)
2627
: QMainWindow(parent),
@@ -49,7 +50,7 @@ MainWindow::MainWindow(QWidget *parent)
4950
currentLanguage = I18nManager::instance()->currentLanguage();
5051

5152
setWindowTitle(getText("app_title", "ScreenSniper - 截图工具"));
52-
resize(400, 300);
53+
resize(400, 350);
5354

5455
setupUI();
5556
setupTrayIcon();
@@ -71,14 +72,17 @@ void MainWindow::setupUI()
7172
// 添加按钮(使用多语言文本)
7273
btnFullScreen = new QPushButton(getText("btn_fullscreen", "截取全屏 (Ctrl+Shift+F)"), this);
7374
btnArea = new QPushButton(getText("btn_area", "截取区域 (Ctrl+Shift+A)"), this);
75+
btnScroll = new QPushButton(getText("btnScroll ", "滚动截图"), this);
7476
btnSettings = new QPushButton(getText("btn_settings", "设置"), this);
7577

7678
btnFullScreen->setMinimumHeight(40);
7779
btnArea->setMinimumHeight(40);
80+
btnScroll->setMinimumHeight(40); // 设置相同的高度
7881
btnSettings->setMinimumHeight(40);
7982

8083
layout->addWidget(btnFullScreen);
8184
layout->addWidget(btnArea);
85+
layout->addWidget(btnScroll); // 将按钮加入布局
8286
layout->addWidget(btnSettings);
8387
layout->addStretch();
8488

@@ -87,6 +91,7 @@ void MainWindow::setupUI()
8791
// 连接按钮信号
8892
connect(btnFullScreen, &QPushButton::clicked, this, &MainWindow::onCaptureScreen);
8993
connect(btnArea, &QPushButton::clicked, this, &MainWindow::onCaptureArea);
94+
connect(btnScroll, &QPushButton::clicked, this, &MainWindow::onCaptureScroll);
9095
connect(btnSettings, &QPushButton::clicked, this, &MainWindow::onSettings);
9196
}
9297

@@ -102,12 +107,15 @@ void MainWindow::setupTrayIcon()
102107

103108
actionFullScreen = new QAction(getText("tray_fullscreen", "截取全屏"), this);
104109
actionArea = new QAction(getText("tray_area", "截取区域"), this);
110+
actionScroll= new QAction(getText("tray_roll", "滚动截图"), this);
105111
actionShow = new QAction(getText("tray_show", "显示主窗口"), this);
112+
106113
actionAbout = new QAction(getText("tray_about", "关于"), this);
107114
actionQuit = new QAction(getText("tray_quit", "退出"), this);
108115

109116
trayMenu->addAction(actionFullScreen);
110117
trayMenu->addAction(actionArea);
118+
trayMenu->addAction(actionScroll);
111119
trayMenu->addSeparator();
112120
trayMenu->addAction(actionShow);
113121
trayMenu->addAction(actionAbout);
@@ -120,6 +128,7 @@ void MainWindow::setupTrayIcon()
120128
// 连接托盘信号
121129
connect(actionFullScreen, &QAction::triggered, this, &MainWindow::onCaptureScreen);
122130
connect(actionArea, &QAction::triggered, this, &MainWindow::onCaptureArea);
131+
connect(actionScroll, &QAction::triggered, this, &MainWindow::onCaptureScroll);
123132
connect(actionShow, &QAction::triggered, this, &MainWindow::show);
124133
connect(actionAbout, &QAction::triggered, this, &MainWindow::onAbout);
125134
connect(actionQuit, &QAction::triggered, qApp, &QApplication::quit);
@@ -192,7 +201,25 @@ void MainWindow::onCaptureWindow()
192201
{
193202
onCaptureArea();
194203
}
204+
void MainWindow::onCaptureScroll()
205+
{
206+
hide();
207+
ScrollCaptureWindow *scrollWin = new ScrollCaptureWindow(nullptr);
208+
209+
connect(scrollWin, &ScrollCaptureWindow::captureFinished, this, [this](QImage result){
210+
if(result.isNull()) {
211+
this->show();
212+
return;
213+
}
195214

215+
// 直接进入 ScreenshotWidget 编辑/查看
216+
ScreenshotWidget *widget = new ScreenshotWidget();
217+
widget->setCapturedImage(result);
218+
widget->show();
219+
});
220+
221+
QTimer::singleShot(300, scrollWin, &ScrollCaptureWindow::startCapture);
222+
}
196223
void MainWindow::onSettings()
197224
{
198225
QDialog dialog(this);
@@ -298,6 +325,8 @@ void MainWindow::updateUI()
298325
btnFullScreen->setText(getText("btn_fullscreen", "截取全屏 (Ctrl+Shift+F)"));
299326
if (btnArea)
300327
btnArea->setText(getText("btn_area", "截取区域 (Ctrl+Shift+A)"));
328+
if (btnArea)
329+
btnArea->setText(getText("btn_area", "截取区域 (Ctrl+Shift+A)"));
301330
if (btnSettings)
302331
btnSettings->setText(getText("btn_settings", "设置"));
303332

mainwindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private slots:
3232
void onCaptureScreen();
3333
void onCaptureArea();
3434
void onCaptureWindow();
35+
void onCaptureScroll();
3536
void onSettings();
3637
void onAbout();
3738
void onTrayIconActivated(QSystemTrayIcon::ActivationReason reason);
@@ -51,7 +52,9 @@ private slots:
5152
QPushButton *btnFullScreen;
5253
QPushButton *btnArea;
5354
QPushButton *btnSettings;
55+
QPushButton *btnScroll;
5456
QAction *actionFullScreen;
57+
QAction *actionScroll;
5558
QAction *actionArea;
5659
QAction *actionShow;
5760
QAction *actionAbout;

0 commit comments

Comments
 (0)