Change VirtualDesktop::id type from QByteArray to QString

This removes a lot of UTF-16 - UTF-8 conversions.
This commit is contained in:
Vlad Zahorodnii 2021-08-16 16:12:56 +03:00
parent 7f883fa724
commit 19cc22102c
4 changed files with 20 additions and 20 deletions

View file

@ -1637,7 +1637,7 @@ void AbstractClient::setupWindowManagementInterface()
//show/hide when the window enters/exits from desktop
connect(w, &PlasmaWindowInterface::enterPlasmaVirtualDesktopRequested, this,
[this] (const QString &desktopId) {
VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8());
VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId);
if (vd) {
enterDesktop(vd);
}
@ -1651,7 +1651,7 @@ void AbstractClient::setupWindowManagementInterface()
);
connect(w, &PlasmaWindowInterface::leavePlasmaVirtualDesktopRequested, this,
[this] (const QString &desktopId) {
VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId.toUtf8());
VirtualDesktop *vd = VirtualDesktopManager::self()->desktopForId(desktopId);
if (vd) {
leaveDesktop(vd);
}

View file

@ -458,7 +458,7 @@ void VirtualDesktopManagerDBusInterface::setCurrent(const QString &id)
return;
}
auto *vd = m_manager->desktopForId(id.toUtf8());
auto *vd = m_manager->desktopForId(id);
if (vd) {
m_manager->setCurrent(vd);
}
@ -506,7 +506,7 @@ void VirtualDesktopManagerDBusInterface::createDesktop(uint position, const QStr
void VirtualDesktopManagerDBusInterface::setDesktopName(const QString &id, const QString &name)
{
VirtualDesktop *vd = m_manager->desktopForId(id.toUtf8());
VirtualDesktop *vd = m_manager->desktopForId(id);
if (!vd) {
return;
}
@ -520,7 +520,7 @@ void VirtualDesktopManagerDBusInterface::setDesktopName(const QString &id, const
void VirtualDesktopManagerDBusInterface::removeDesktop(const QString &id)
{
m_manager->removeVirtualDesktop(id.toUtf8());
m_manager->removeVirtualDesktop(id);
}
PluginManagerDBusInterface::PluginManagerDBusInterface(PluginManager *manager)

View file

@ -26,9 +26,9 @@ namespace KWin {
static bool s_loadingDesktopSettings = false;
static QByteArray generateDesktopId()
static QString generateDesktopId()
{
return QUuid::createUuid().toString(QUuid::WithoutBraces).toUtf8();
return QUuid::createUuid().toString(QUuid::WithoutBraces);
}
VirtualDesktop::VirtualDesktop(QObject *parent)
@ -93,7 +93,7 @@ void VirtualDesktopManager::setVirtualDesktopManagement(KWaylandServer::PlasmaVi
[this](const QString &id) {
//here there can be some nice kauthorized check?
//remove only from VirtualDesktopManager, the other connections will remove it from m_virtualDesktopManagement as well
removeVirtualDesktop(id.toUtf8());
removeVirtualDesktop(id);
}
);
@ -115,7 +115,7 @@ void VirtualDesktopManager::setVirtualDesktopManagement(KWaylandServer::PlasmaVi
);
}
void VirtualDesktop::setId(const QByteArray &id)
void VirtualDesktop::setId(const QString &id)
{
Q_ASSERT(m_id.isEmpty());
m_id = id;
@ -427,7 +427,7 @@ VirtualDesktop *VirtualDesktopManager::desktopForX11Id(uint id) const
return m_desktops.at(id - 1);
}
VirtualDesktop *VirtualDesktopManager::desktopForId(const QByteArray &id) const
VirtualDesktop *VirtualDesktopManager::desktopForId(const QString &id) const
{
auto desk = std::find_if(
m_desktops.constBegin(),
@ -488,7 +488,7 @@ VirtualDesktop *VirtualDesktopManager::createVirtualDesktop(uint position, const
return vd;
}
void VirtualDesktopManager::removeVirtualDesktop(const QByteArray &id)
void VirtualDesktopManager::removeVirtualDesktop(const QString &id)
{
//don't end up without any desktop
if (m_desktops.count() == 1) {
@ -699,14 +699,14 @@ void VirtualDesktopManager::load()
if (m_rootInfo) {
m_rootInfo->setDesktopName(i, s.toUtf8().data());
}
m_desktops[i-1]->setName(s.toUtf8().data());
m_desktops[i-1]->setName(s);
const QString sId = group.readEntry(QStringLiteral("Id_%1").arg(i), QString());
if (m_desktops[i-1]->id().isEmpty()) {
m_desktops[i-1]->setId(sId.isEmpty() ? generateDesktopId() : sId.toUtf8());
m_desktops[i-1]->setId(sId.isEmpty() ? generateDesktopId() : sId);
} else {
Q_ASSERT(sId.isEmpty() || m_desktops[i-1]->id() == sId.toUtf8().data());
Q_ASSERT(sId.isEmpty() || m_desktops[i-1]->id() == sId);
}
// TODO: update desktop focus chain, why?

View file

@ -35,15 +35,15 @@ namespace KWin {
class KWIN_EXPORT VirtualDesktop : public QObject
{
Q_OBJECT
Q_PROPERTY(QByteArray id READ id CONSTANT)
Q_PROPERTY(QString id READ id CONSTANT)
Q_PROPERTY(uint x11DesktopNumber READ x11DesktopNumber NOTIFY x11DesktopNumberChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
public:
explicit VirtualDesktop(QObject *parent = nullptr);
~VirtualDesktop() override;
void setId(const QByteArray &id);
QByteArray id() const {
void setId(const QString &id);
QString id() const {
return m_id;
}
@ -66,7 +66,7 @@ Q_SIGNALS:
void aboutToBeDestroyed();
private:
QByteArray m_id;
QString m_id;
QString m_name;
int m_x11DesktopNumber = 0;
@ -272,7 +272,7 @@ public:
/**
* @returns The VirtualDesktop for the internal desktop string @p id, if no such VirtualDesktop @c null is returned
*/
VirtualDesktop *desktopForId(const QByteArray &id) const;
VirtualDesktop *desktopForId(const QString &id) const;
/**
* Create a new virtual desktop at the requested position.
@ -289,7 +289,7 @@ public:
* not only the last one.
* @param id the string id of the desktop to remove
*/
void removeVirtualDesktop(const QByteArray &id);
void removeVirtualDesktop(const QString &id);
/**
* Updates the net root info for new number of desktops