Skip to content

Commit 4b6e7ad

Browse files
committed
fullscreen / unfullscreen added
1 parent 164c056 commit 4b6e7ad

File tree

7 files changed

+88
-13
lines changed

7 files changed

+88
-13
lines changed

data/images/fullscreen-exit.svg

Lines changed: 5 additions & 0 deletions
Loading

data/images/fullscreen.svg

Lines changed: 5 additions & 0 deletions
Loading

data/resources.qrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<file>images/pen-settings.svg</file>
2222
<file>images/color-picker.svg</file>
2323
<file>images/close.svg</file>
24+
<file>images/fullscreen.svg</file>
25+
<file>images/fullscreen-exit.svg</file>
2426
<file>images/turkiye-map.svg</file>
2527
<file>images/go-page-previous.svg</file>
2628
<file>images/go-page-next.svg</file>

src/FloatingSettings.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
#include "FloatingSettings.h"
2-
extern int screenWidth;
3-
extern int screenHeight;
2+
3+
#include <QMainWindow>
44

55
extern "C" {
66
#include "settings.h"
77
}
88

99

10+
extern QMainWindow* tool2;
11+
1012
#include <QMap>
1113

1214
class SettingsPages {
@@ -59,6 +61,10 @@ void FloatingSettings::reload(){
5961
cur_width = settingsPages.getPage(current_page)->size().width();
6062
cur_height = settingsPages.getPage(current_page)->size().height();
6163
setFixedSize(cur_width, cur_height);
64+
if(tool2 != nullptr) {
65+
tool2->setFixedSize(cur_width, cur_height);
66+
}
67+
6268
}
6369

6470
void FloatingSettings::setPage(int num){

src/FloatingWidget.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ int new_y;
66

77
extern float scale;
88

9+
extern QMainWindow* tool2;
10+
911
#define padding 8*scale
1012

1113

@@ -82,12 +84,19 @@ void FloatingWidget::moveAction(){
8284
new_x = 0;
8385
}if (new_y < 0) {
8486
new_y = 0;
85-
}if (new_x > mainWindow->geometry().width() - cur_width) {
86-
new_x = mainWindow->geometry().width() - cur_width;
87-
}if (new_y > mainWindow->geometry().height() - cur_height) {
88-
new_y = mainWindow->geometry().height() - cur_height;
8987
}
90-
if(!getenv("WAYLAND_DISPLAY")){
88+
int max_width = mainWindow->geometry().width();
89+
int max_height = mainWindow->geometry().height();
90+
if(tool2 != nullptr){
91+
max_width = QGuiApplication::primaryScreen()->size().width();
92+
max_height = QGuiApplication::primaryScreen()->size().height();
93+
}
94+
if (new_x > max_width- cur_width) {
95+
new_x = max_width - cur_width;
96+
}if (new_y > max_height - cur_height) {
97+
new_y = max_height - cur_height;
98+
}
99+
if(tool2 != nullptr){
91100
fparent->move(new_x, new_y);
92101
} else {
93102
move(new_x, new_y);
@@ -113,7 +122,11 @@ void FloatingWidget::moveAction(){
113122
new_yy = new_y - padding - floatingSettings->cur_height;
114123
}
115124
}
116-
floatingSettings->move(new_xx, new_yy + padding);
125+
if(tool2 != nullptr){
126+
tool2->move(new_xx, new_yy + padding);
127+
} else {
128+
floatingSettings->move(new_xx, new_yy + padding);
129+
}
117130
}
118131
}
119132

src/SetupWidgets.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ QPushButton *lineLineLineButton;
5555

5656
QPushButton *backgroundButton;
5757

58+
QPushButton* fullscreen;
59+
5860
QPushButton* transparentButton;
5961
QPushButton* blackButton;
6062
QPushButton* whiteButton;
@@ -821,6 +823,17 @@ static void setupBackground(){
821823
backgroundStyleEvent();
822824
});
823825
overlayTurkiye->setStyleSheet(QString("background-color: none;"));
826+
827+
fullscreen = create_button(":images/fullscreen-exit.svg", [=](){
828+
if(mainWindow->isFullScreen()){
829+
set_icon(":images/fullscreen.svg", fullscreen);
830+
mainWindow->showNormal();
831+
} else {
832+
set_icon(":images/fullscreen-exit.svg", fullscreen);
833+
mainWindow->showFullScreen();
834+
}
835+
});
836+
fullscreen->setStyleSheet(QString("background-color: none;"));
824837

825838

826839
gridLayout->addWidget(overlayNone, 0, 0, Qt::AlignCenter);
@@ -830,6 +843,9 @@ static void setupBackground(){
830843
gridLayout->addWidget(overlayMusic, 0, 2, Qt::AlignCenter);
831844
gridLayout->addWidget(overlayCustom, 1, 2, Qt::AlignCenter);
832845
gridLayout->addWidget(overlayTurkiye, 2, 0, Qt::AlignCenter);
846+
847+
848+
gridLayout->addWidget(fullscreen, 2, 1, Qt::AlignCenter);
833849

834850
// set sizes
835851
pageLabel->setFixedSize(

src/main.cpp

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ FloatingSettings *floatingSettings;
3030
WhiteBoard *board;
3131
QMainWindow* mainWindow;
3232
QMainWindow* tool;
33+
QMainWindow* tool2;
3334

3435
#ifdef screenshot
3536
#include "ScreenShot.h"
@@ -77,7 +78,9 @@ class MainWindow : public QMainWindow {
7778
// tool is not set under wayland
7879
if(tool != nullptr){
7980
tool->resize(floatingWidget->geometry().width(), floatingWidget->geometry().height());
80-
floatingWidget->moveAction();
81+
}
82+
if(tool2 != nullptr){
83+
tool2->resize(floatingSettings->geometry().width(), floatingSettings->geometry().height());
8184
}
8285
floatingWidget->moveAction();
8386
// Call the base class implementation
@@ -96,6 +99,15 @@ class MainWindow : public QMainWindow {
9699
}
97100
}
98101
}
102+
if(tool2 != nullptr){
103+
if (event->type() == QEvent::WindowStateChange) {
104+
if (isMinimized()) {
105+
tool2->hide();
106+
} else {
107+
tool2->show();
108+
}
109+
}
110+
}
99111
drawing->update();
100112
}
101113
};
@@ -174,19 +186,21 @@ int main(int argc, char *argv[]) {
174186
mainWindow->setWindowIcon(QIcon(":tr.org.pardus.pen.svg"));
175187
mainWindow->setWindowTitle(QString(_("Pardus Pen")));
176188

177-
floatingSettings = new FloatingSettings(mainWindow);
178-
floatingSettings->hide();
179189

180190
// detect x11
181191
if(!getenv("WAYLAND_DISPLAY")){
182192
tool = new QMainWindow();
193+
tool2 = new QMainWindow();
194+
floatingSettings = new FloatingSettings(tool2);
183195
floatingWidget = new FloatingWidget(tool);
184196
} else {
185197
tool = nullptr;
198+
floatingSettings = new FloatingSettings(mainWindow);
186199
floatingWidget = new FloatingWidget(mainWindow);
187200
}
188201
floatingWidget->setMainWindow(mainWindow);
189202
floatingWidget->setSettings(floatingSettings);
203+
floatingSettings->hide();
190204

191205
setupWidgets();
192206
if (tool != nullptr) {
@@ -203,9 +217,23 @@ int main(int argc, char *argv[]) {
203217

204218
tool->show();
205219
}
220+
if (tool2 != nullptr) {
221+
tool2->setWindowFlags(Qt::WindowStaysOnTopHint
222+
| Qt::Tool
223+
| Qt::WindowSystemMenuHint
224+
| Qt::FramelessWindowHint);
225+
tool2->setAttribute(Qt::WA_TranslucentBackground, true);
226+
tool2->setAttribute(Qt::WA_NoSystemBackground, true);
227+
tool2->setStyleSheet(
228+
"background: none;"
229+
"font-size: "+QString::number(18*scale)+"px;"
230+
);
231+
232+
tool2->show();
233+
}
206234

207-
mainWindow->setWindowFlags(Qt::WindowSystemMenuHint
208-
| Qt::FramelessWindowHint);
235+
//mainWindow->setWindowFlags(Qt::WindowSystemMenuHint
236+
// | Qt::FramelessWindowHint);
209237

210238
mainWindow->setAttribute(Qt::WA_TranslucentBackground, true);
211239
mainWindow->setAttribute(Qt::WA_NoSystemBackground, true);

0 commit comments

Comments
 (0)