Skip to content

Commit

Permalink
fix: Switching unresponsive in technical preview
Browse files Browse the repository at this point in the history
Remove input method support and related code
Remove package installation operation

Log:
pms: BUG-282157
  • Loading branch information
robertkill authored and deepin-bot[bot] committed Nov 28, 2024
1 parent 35d30e2 commit 519f6d0
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 282 deletions.
11 changes: 1 addition & 10 deletions dcc-insider/operation/dccinsider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ DccInsider::DccInsider(QObject *parent)
: QObject(parent)
, m_insider(new InsiderWorker(this))
{
m_currentItems.append({ m_insider->displayManager(), m_insider->inputMethod() });
m_currentItems.append({ m_insider->displayManager() });
connect(m_insider, &InsiderWorker::displayManagerChanged, this, &DccInsider::updateCurrentItem);
connect(m_insider, &InsiderWorker::inputMethodChanged, this, &DccInsider::updateCurrentItem);
}

DccInsider::~DccInsider() { }
Expand All @@ -29,8 +28,6 @@ void DccInsider::setCurrentItem(const QString &item)
{
if (item == "lightdm" || item == "treeland") {
m_insider->setDisplayManager(item);
} else if (item == "fcitx5" || item == "deepin-im") {
m_insider->setInputMethod(item);
}
}

Expand All @@ -42,12 +39,6 @@ void DccInsider::updateCurrentItem(const QString &item)
} else if (item == "treeland") {
m_currentItems.removeOne("lightdm");
m_currentItems.append("treeland");
} else if (item == "fcitx5") {
m_currentItems.removeOne("deepin-im");
m_currentItems.append("fcitx5");
} else if (item == "deepin-im") {
m_currentItems.removeOne("fcitx5");
m_currentItems.append("deepin-im");
}
Q_EMIT currentItemsChanged(m_currentItems);
}
Expand Down
99 changes: 0 additions & 99 deletions dcc-insider/operation/insiderworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
#include "insiderworker.h"

#include "pkpackagesproxy.h"

#include <QDir>
#include <QProcess>

Expand All @@ -13,11 +11,8 @@ namespace insider {
InsiderWorker::InsiderWorker(QObject *parent)
: QObject(parent)
, m_displayManager("lightdm")
, m_inputMethod("fcitx5")
, m_pkProxy(new PkPackagesProxy(this))
{
QMetaObject::invokeMethod(this, &InsiderWorker::checkEnabledDisplayManager, Qt::QueuedConnection);
QMetaObject::invokeMethod(this, &InsiderWorker::checkEnabledInputMethod, Qt::QueuedConnection);
}

InsiderWorker::~InsiderWorker() { }
Expand All @@ -27,44 +22,16 @@ QString InsiderWorker::displayManager() const
return m_displayManager;
}

QString InsiderWorker::inputMethod() const
{
return m_inputMethod;
}

void InsiderWorker::setDisplayManager(const QString &id)
{
if (m_displayManager == id) {
return;
}
bool isNew = id == "treeland";
if (isNew && !installPackage("ddm")) {
return;
}
if (!installPackage(id)) {
return;
}
switchDisplayManager(isNew);
if (isNew) {
setInputMethod("deepin-im");
installDDEShell();
}
checkEnabledDisplayManager();
}

void InsiderWorker::setInputMethod(const QString &id)
{
if (m_inputMethod == id) {
return;
}
bool isNew = id == "deepin-im";
if (!installPackage(id)) {
return;
}
switchInputMethod(isNew);
checkEnabledInputMethod();
}

void InsiderWorker::checkEnabledDisplayManager()
{
QProcess *process = new QProcess(this);
Expand All @@ -75,35 +42,6 @@ void InsiderWorker::checkEnabledDisplayManager()
process->start();
}

static bool imConfigIsDim()
{
auto home = QDir::home();
QFile file(home.filePath(".xinputrc"));

if (file.exists() && file.open(QFile::ReadOnly)) {
QTextStream in(&file);
QString line;
do {
line = in.readLine();
if (line.contains("run_im dim")) {
return true;
}
} while (!line.isNull());
}

return false;
}

void InsiderWorker::checkEnabledInputMethod()
{
bool isDim = imConfigIsDim();
QString inputMethod = isDim ? "deepin-im" : "fcitx5";
if (m_inputMethod != inputMethod) {
m_inputMethod = inputMethod;
Q_EMIT inputMethodChanged(m_inputMethod);
}
}

void InsiderWorker::onDisplayManagerFinished()
{
QProcess *process = qobject_cast<QProcess *>(sender());
Expand All @@ -118,8 +56,6 @@ void InsiderWorker::onDisplayManagerFinished()
}
}

void InsiderWorker::onInputMethodFinished() { }

void InsiderWorker::switchDisplayManager(bool isNew)
{
QProcess process;
Expand All @@ -142,40 +78,5 @@ void InsiderWorker::switchDisplayManager(bool isNew)
qDebug() << "switchDisplayManager: " << process.readAll();
}

void InsiderWorker::installDDEShell()
{
if (installPackage("dde-shell")) {
checkEnabledDisplayManager();
}
}

bool InsiderWorker::installPackage(const QString &package)
{
m_pkProxy->resolve(package);
if (m_pkProxy->packageID().isEmpty()) {
return false;
}
m_pkProxy->installPackage(m_pkProxy->packageID());
if (m_pkProxy->error() != 0) {
return false;
}
return true;
}

void InsiderWorker::switchInputMethod(bool isNew)
{
if (isNew) {
QProcess process;
process.setProgram("im-config");
process.setArguments({ "-n", "dim" });
process.start();
process.waitForFinished();
} else {
if (imConfigIsDim()) {
QDir home = QDir::home();
home.remove(".xinputrc");
}
}
}
} // namespace insider
} // namespace dde
10 changes: 0 additions & 10 deletions dcc-insider/operation/insiderworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,22 @@ class InsiderWorker : public QObject
~InsiderWorker() override;

QString displayManager() const;
QString inputMethod() const;

public Q_SLOTS:
void setDisplayManager(const QString &id);
void setInputMethod(const QString &id);

Q_SIGNALS:
void displayManagerChanged(const QString &displayManager);
void inputMethodChanged(const QString &inputMethod);

protected Q_SLOTS:
void checkEnabledDisplayManager();
void checkEnabledInputMethod();

void onDisplayManagerFinished();
void onInputMethodFinished();

void switchDisplayManager(bool isNew);
void switchInputMethod(bool isNew);
void installDDEShell();
bool installPackage(const QString &package);

private:
QString m_displayManager;
QString m_inputMethod;
PkPackagesProxy *m_pkProxy;
};
} // namespace insider
} // namespace dde
Expand Down
117 changes: 0 additions & 117 deletions dcc-insider/operation/pkpackagesproxy.cpp

This file was deleted.

44 changes: 0 additions & 44 deletions dcc-insider/operation/pkpackagesproxy.h

This file was deleted.

4 changes: 2 additions & 2 deletions dcc-insider/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ DccTitleObject {
name: "imTitle"
parentName: "insider"
weight: 30
visible: dccData.currentItems.includes("treeland")
visible: false
displayName: qsTr("New Input Method")
}
DccObject {
name: "selectInputMethod"
parentName: "insider"
weight: 40
visible: dccData.currentItems.includes("treeland")
visible: false
pageType: DccObject.Item
page: DccGroupView {}
DccObject {
Expand Down
Loading

0 comments on commit 519f6d0

Please sign in to comment.