2121#include < QHBoxLayout>
2222#include < QDialogButtonBox>
2323#include < QPointer>
24+ #include " ScrollCapture.h"
2425
2526MainWindow::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+ }
196223void 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
0 commit comments