Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: window is closed after switching mode #343

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion launchercontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ LauncherController::LauncherController(QObject *parent)
// Interval set to 500=>1000ms for issue https://github.com/linuxdeepin/developer-center/issues/8137
m_timer->setInterval(1000);
m_timer->setSingleShot(true);
connect(m_timer, &QTimer::timeout, this, [this] {
if (m_pendingHide) {
m_pendingHide = false;
setVisible(false);
}
});

connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::newProcessInstance,
this, [this](qint64 pid, const QStringList & args) {
Expand Down Expand Up @@ -90,6 +96,7 @@ void LauncherController::Toggle()
{
if (m_timer->isActive()) {
qDebug() << "hit";
m_pendingHide = false;
m_timer->stop();
return;
}
Expand Down Expand Up @@ -137,6 +144,8 @@ void LauncherController::setCurrentFrame(const QString &frame)

m_currentFrame = frame;
qDebug() << "set current frame:" << m_currentFrame;
m_pendingHide = false;
m_timer->start();
emit currentFrameChanged();
}

Expand All @@ -147,12 +156,21 @@ void LauncherController::setCurrentFrame(const QString &frame)
void LauncherController::hideWithTimer()
{
if (visible()) {
m_timer->start();
if (m_timer->isActive()) {
m_pendingHide = true;
return;
}

qDebug() << "hide with timer";
setVisible(false);
}
}

void LauncherController::cancelHide()
{
m_pendingHide = false;
}

QFont LauncherController::adjustFontWeight(const QFont &f, QFont::Weight weight)
{
QFont font(f);
Expand Down
2 changes: 2 additions & 0 deletions launchercontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LauncherController : public QObject
void setCurrentFrame(const QString & frame);

Q_INVOKABLE void hideWithTimer();
Q_INVOKABLE void cancelHide();
Q_INVOKABLE QFont adjustFontWeight(const QFont& f, QFont::Weight weight);

signals:
Expand Down Expand Up @@ -77,4 +78,5 @@ class LauncherController : public QObject
Launcher1Adaptor * m_launcher1Adaptor;
bool m_visible;
QString m_currentFrame;
bool m_pendingHide = false;
};
22 changes: 19 additions & 3 deletions qml/Main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,20 @@ QtObject {
DWindow.borderColor: DTK.themeType === ApplicationHelper.DarkType ? Qt.rgba(0, 0, 0, windowedFrameWindow.blendColorAlpha(0.6) + 10 / 255) : Qt.rgba(0, 0, 0, 0.15)

onVisibleChanged: {
updateWindowVisibilityAndPosition()
if (visible) {
updateWindowVisibilityAndPosition()
}
}

onActiveChanged: {
if (!active && !DebugHelper.avoidHideWindow && (LauncherController.currentFrame === "WindowedFrame")) {
if (LauncherController.currentFrame !== "WindowedFrame") {
return;
}
if (active) {
LauncherController.cancelHide()
return;
}
if (!active && !DebugHelper.avoidHideWindow) {
LauncherController.hideWithTimer()
}
}
Expand Down Expand Up @@ -309,7 +318,14 @@ QtObject {
}

onActiveChanged: {
if (!active && !DebugHelper.avoidHideWindow && (LauncherController.currentFrame === "FullscreenFrame")) {
if (LauncherController.currentFrame !== "FullscreenFrame") {
return
}
if (active) {
LauncherController.cancelHide()
return;
}
if (!active && !DebugHelper.avoidHideWindow) {
LauncherController.hideWithTimer()
}
}
Expand Down
Loading