Skip to content

Commit

Permalink
feat(debug): option to show launcher as regular Qt.Window
Browse files Browse the repository at this point in the history
提供选项来有边框的窗口化显示launcher。旨在方便一些场景下进行调试。
GammaRay 有时无法成功 attach 到无边框的程序中并显示 QML Scene,启用
此选项对 GammaRay 调试的挂接也有用。

注意,目前调整此选项后需要重启程序来完整生效。

Log:
  • Loading branch information
BLumia committed Nov 6, 2023
1 parent 1cf7e8b commit ae1dc93
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions debughelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ DebugHelper::DebugHelper(QObject *parent)
const QString debugSettingPath(QDir(debugSettingBasePath).absoluteFilePath("debug.ini"));

m_debugSettings = new QSettings(debugSettingPath, QSettings::NativeFormat, this);
m_useRegularWindow = m_debugSettings->value("useRegularWindow", false).toBool();
m_avoidLaunchApp = m_debugSettings->value("avoidLaunchApp", false).toBool();
m_avoidHideWindow = m_debugSettings->value("avoidHideWindow", false).toBool();

connect(this, &DebugHelper::onUseRegularWindowChanged, this, [=](bool val){
m_debugSettings->setValue("useRegularWindow", val);
});

connect(this, &DebugHelper::onAvoidLaunchAppChanged, this, [=](bool val){
m_debugSettings->setValue("avoidLaunchApp", val);
});
Expand Down
3 changes: 3 additions & 0 deletions debughelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class DebugHelper : public QObject
Q_OBJECT

Q_PROPERTY(bool qtDebugEnabled READ qtDebugEnabled CONSTANT)
Q_PROPERTY(bool useRegularWindow MEMBER m_useRegularWindow NOTIFY onUseRegularWindowChanged)
Q_PROPERTY(bool avoidLaunchApp MEMBER m_avoidLaunchApp NOTIFY onAvoidLaunchAppChanged)
Q_PROPERTY(bool avoidHideWindow MEMBER m_avoidHideWindow NOTIFY onAvoidHideWindowChanged)
public:
Expand All @@ -24,13 +25,15 @@ class DebugHelper : public QObject
bool qtDebugEnabled() const;

signals:
void onUseRegularWindowChanged(bool);
void onAvoidLaunchAppChanged(bool);
void onAvoidHideWindowChanged(bool);

private:
explicit DebugHelper(QObject * parent = nullptr);

QSettings * m_debugSettings;
bool m_useRegularWindow;
bool m_avoidLaunchApp;
bool m_avoidHideWindow;
};
8 changes: 8 additions & 0 deletions qml/DebugDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ import org.deepin.launchpad 1.0
Column {
spacing: 15

Switch {
text: "Use regular window (need restart)"
checked: DebugHelper.useRegularWindow
onCheckedChanged: {
DebugHelper.useRegularWindow = checked
}
}

Switch {
text: "Avoid launch application"
checked: DebugHelper.avoidLaunchApp
Expand Down
5 changes: 4 additions & 1 deletion qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ ApplicationWindow {
height: 600
visible: LauncherController.visible
flags: {
if (DebugHelper.useRegularWindow) {
return Qt.Window
}
if (LauncherController.currentFrame === "WindowedFrame") {
return (Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool) // X11BypassWindowManagerHint
} else {
return (Qt.FramelessWindowHint | Qt.Tool)
}
}
DWindow.enabled: true
DWindow.enabled: !DebugHelper.useRegularWindow
DWindow.enableBlurWindow: true
DWindow.enableSystemResize: false
DWindow.enableSystemMove: false
Expand Down

0 comments on commit ae1dc93

Please sign in to comment.