File tree 10 files changed +74
-202
lines changed
10 files changed +74
-202
lines changed Original file line number Diff line number Diff line change
1
+ /qt_screenshot /cmake-build-debug /
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 4
4
int main (int argc, char *argv[])
5
5
{
6
6
QApplication a (argc, argv);
7
- MainWindow w ;
8
- w .show ();
7
+ TrayIcon tray (&a) ;
8
+ tray .show ();
9
9
10
10
return a.exec ();
11
11
}
Original file line number Diff line number Diff line change 1
1
#include " mainwindow.h"
2
- #include " ui_mainwindow.h"
3
2
4
- MainWindow::MainWindow (QWidget *parent) :
5
- QMainWindow(parent),
6
- ui(new Ui::MainWindow)
3
+ #include < QMenu>
4
+ #include < QSystemTrayIcon>
5
+
6
+
7
+ TrayIcon::TrayIcon (QObject *parent) : QSystemTrayIcon(parent)
7
8
{
8
- ui->setupUi (this );
9
- }
9
+ m_menu = new QMenu ();
10
10
11
+ auto * captureAction = new QAction (tr (" &Take Screenshot" ), this );
11
12
13
+ auto * launcherAction = new QAction (tr (" &Open Launcher" ), this );
12
14
15
+ auto * configAction = new QAction (tr (" &Configuration" ), this );
13
16
17
+ auto * infoAction = new QAction (tr (" &About" ), this );
18
+
19
+
20
+ QAction* quitAction = new QAction (tr (" &Quit" ), this );
21
+
22
+ // recent screenshots
23
+ QAction* recentAction = new QAction (tr (" &Latest Uploads" ), this );
24
+
25
+ m_menu->addAction (captureAction);
26
+ m_menu->addAction (launcherAction);
27
+ m_menu->addSeparator ();
28
+ m_menu->addAction (recentAction);
29
+ m_menu->addSeparator ();
30
+ m_menu->addAction (configAction);
31
+ m_menu->addSeparator ();
32
+
33
+ setToolTip (QStringLiteral (" FireShot" ));
34
+
35
+ setContextMenu (m_menu);
36
+ QIcon icon = QIcon::fromTheme (" flameshot-tray" , QIcon (" :/image/tv.png" ));
37
+ setIcon (icon);
14
38
15
- MainWindow::~MainWindow ()
16
- {
17
- delete ui;
18
39
}
40
+
Original file line number Diff line number Diff line change 1
- #ifndef MAINWINDOW_H
2
- #define MAINWINDOW_H
1
+ #include < QSystemTrayIcon>
3
2
4
- #include < QMainWindow >
3
+ #pragma once
5
4
6
- namespace Ui {
7
- class MainWindow ;
8
- }
5
+ class QAction ;
9
6
10
- class MainWindow : public QMainWindow
7
+ class TrayIcon : public QSystemTrayIcon
11
8
{
12
9
Q_OBJECT
13
-
14
10
public:
15
- explicit MainWindow (QWidget *parent = nullptr );
16
- ~MainWindow ();
11
+ explicit TrayIcon (QObject* parent);
12
+ ~TrayIcon () override = default ;
13
+
17
14
18
15
private:
19
- Ui::MainWindow *ui;
20
- };
16
+ void initMenu ();
21
17
22
- #endif // MAINWINDOW_H
18
+ static void startGuiCapture ();
19
+
20
+ QMenu* m_menu;
21
+ };
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -31,10 +31,12 @@ SOURCES += \
31
31
HEADERS += \
32
32
mainwindow.h
33
33
34
- FORMS += \
35
- mainwindow.ui
34
+ FORMS +=
36
35
37
36
# Default rules for deployment.
38
37
qnx: target.path = /tmp/ $${TARGET }/bin
39
38
else: unix :!android: target.path = /opt/ $${TARGET }/bin
40
39
!isEmpty (target.path ): INSTALLS += target
40
+
41
+ RESOURCES += \
42
+ res.qrc
Original file line number Diff line number Diff line change
1
+ <RCC>
2
+ <qresource prefix="/iamge">
3
+ <file>tv.png</file>
4
+ <file>fire.png</file>
5
+ </qresource>
6
+ </RCC>
You can’t perform that action at this time.
0 commit comments