Skip to content

Commit b82732f

Browse files
committed
refactor: separate DesktopPortal classes
- separate UBDesktopPortal into UBScreenshotDesktopPortalWrapper and UBScreenCastDesktopPortalWrapper - extract token generator to UBDesktopPortalTokenGenerator - move showGlassPane to UBApplicationController - move Desktop Portal classes to frameworks/linux subdirectory
1 parent fc91f50 commit b82732f

17 files changed

Lines changed: 420 additions & 278 deletions

src/core/UBApplicationController.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,19 @@ void UBApplicationController::hideDesktop()
620620
emit desktopMode(false);
621621
}
622622

623+
void UBApplicationController::showGlassPane(bool show)
624+
{
625+
if (isShowingDesktop())
626+
{
627+
uninotesController()->drawingView()->setVisible(show);
628+
629+
if (show)
630+
{
631+
UBPlatformUtils::keepOnTop();
632+
}
633+
}
634+
}
635+
623636
void UBApplicationController::setMirrorSourceWidget(QWidget* pWidget)
624637
{
625638
if (mMirror)

src/core/UBApplicationController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ class UBApplicationController : public QObject
132132

133133
// defaulting to false to match QAction triggered(bool checked = false)
134134
void showDesktop(bool dontSwitchFrontProcess = false);
135-
136135
void hideDesktop();
136+
void showGlassPane(bool show);
137137

138138
void useMultiScreen(bool use);
139139

src/frameworks/CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ target_sources(openboard PRIVATE
2323

2424
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
2525
target_sources(openboard PRIVATE
26-
UBDesktopPortal.cpp
27-
UBDesktopPortal.h
28-
UBPipewireSink.cpp
29-
UBPipewireSink.h
26+
linux/UBScreenCastDesktopPortalWrapper.cpp
27+
linux/UBScreenCastDesktopPortalWrapper.h
28+
linux/UBScreenshotDesktopPortalWrapper.cpp
29+
linux/UBScreenshotDesktopPortalWrapper.h
30+
linux/UBDesktopPortalTokenGenerator.cpp
31+
linux/UBDesktopPortalTokenGenerator.h
32+
linux/UBPipewireSink.cpp
33+
linux/UBPipewireSink.h
3034
UBPlatformUtils_linux.cpp
3135
)
3236
endif()

src/frameworks/UBPlatformUtils_linux.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include <unistd.h>
3838

39-
#include "frameworks/UBDesktopPortal.h"
39+
#include "frameworks/linux/UBScreenshotDesktopPortalWrapper.h"
4040
#include "frameworks/UBFileSystemUtils.h"
4141
#include "core/UBApplication.h"
4242
#include "core/UBDisplayManager.h"
@@ -573,9 +573,9 @@ void UBPlatformUtils::grabScreen(QScreen* screen, std::function<void (QPixmap)>
573573
{
574574
if (sessionType() == WAYLAND)
575575
{
576-
UBDesktopPortal* portal = new UBDesktopPortal;
576+
auto* portal = new UBScreenshotDesktopPortalWrapper;
577577

578-
QObject::connect(portal, &UBDesktopPortal::screenGrabbed, portal, [portal,callback](QPixmap screenshot){
578+
QObject::connect(portal, &UBScreenshotDesktopPortalWrapper::screenGrabbed, portal, [portal,callback](QPixmap screenshot){
579579
callback(screenshot);
580580
portal->deleteLater();
581581
});

src/frameworks/frameworks.pri

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,24 @@ SOURCES += src/frameworks/UBGeometryUtils.cpp \
2525
win32 {
2626

2727
SOURCES += src/frameworks/UBPlatformUtils_win.cpp
28-
}
28+
}
2929

3030

31-
macx {
31+
macx {
3232

3333
OBJECTIVE_SOURCES += src/frameworks/UBPlatformUtils_mac.mm
34-
35-
}
34+
35+
}
3636

3737

3838
linux-g++* {
39-
HEADERS += src/frameworks/UBDesktopPortal.h \
40-
src/frameworks/UBPipewireSink.h
39+
HEADERS += src/frameworks/linux/UBScreenCastDesktopPortalWrapper.h \
40+
src/frameworks/linux/UBScreenshotDesktopPortalWrapper.h \
41+
src/frameworks/linux/UBPipewireSink.h
4142
SOURCES += src/frameworks/UBPlatformUtils_linux.cpp \
42-
src/frameworks/UBDesktopPortal.cpp \
43-
src/frameworks/UBPipewireSink.cpp
43+
src/frameworks/linux/UBScreenCastDesktopPortalWrapper.cpp \
44+
src/frameworks/linux/UBScreenshotDesktopPortalWrapper.cpp \
45+
src/frameworks/linux/UBPipewireSink.cpp
4446

4547
CONFIG += link_pkgconfig
4648
PKGCONFIG += libpipewire-0.3
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2015-2026 Département de l'Instruction Publique (DIP-SEM)
3+
*
4+
* This file is part of OpenBoard.
5+
*
6+
* OpenBoard is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, version 3 of the License,
9+
* with a specific linking exception for the OpenSSL project's
10+
* "OpenSSL" library (or with modified versions of it that use the
11+
* same license as the "OpenSSL" library).
12+
*
13+
* OpenBoard is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
23+
#include "UBDesktopPortalTokenGenerator.h"
24+
25+
#include <QRandomGenerator>
26+
27+
28+
QString UBDesktopPortalTokenGenerator::generateToken()
29+
{
30+
const auto randomValue = QRandomGenerator::global()->generate();
31+
return "OB_" + QString::number(randomValue, 16);
32+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2015-2026 Département de l'Instruction Publique (DIP-SEM)
3+
*
4+
* This file is part of OpenBoard.
5+
*
6+
* OpenBoard is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, version 3 of the License,
9+
* with a specific linking exception for the OpenSSL project's
10+
* "OpenSSL" library (or with modified versions of it that use the
11+
* same license as the "OpenSSL" library).
12+
*
13+
* OpenBoard is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with OpenBoard. If not, see <http://www.gnu.org/licenses/>.
20+
*/
21+
22+
23+
#pragma once
24+
25+
#include <QString>
26+
27+
class UBDesktopPortalTokenGenerator
28+
{
29+
public:
30+
UBDesktopPortalTokenGenerator() = delete;
31+
32+
static QString generateToken();
33+
};
34+

0 commit comments

Comments
 (0)