mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
kscreen: Retry fetching config if kscreen gives nullptr
Apparently GetConfigOperation can retrieve a nullptr config, in which case we just need to retry until kscreen gives us something.
This commit is contained in:
parent
1bdd4bf1ee
commit
088c0d985b
6 changed files with 26 additions and 7 deletions
|
|
@ -58,15 +58,17 @@ void PanelSettingsDBusObjectManager::registerObjects()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_initialized = true;
|
|
||||||
|
|
||||||
// Fetch kscreen config
|
// Fetch kscreen config
|
||||||
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
||||||
m_kscreenConfig = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
m_kscreenConfig = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
||||||
if (!m_kscreenConfig) {
|
if (!m_kscreenConfig) {
|
||||||
|
qDebug() << "PanelSettingsDBusObjectManager: Failed to get kscreen config, attempting again";
|
||||||
|
registerObjects();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_initialized = true;
|
||||||
|
|
||||||
KScreen::ConfigMonitor::instance()->addConfig(m_kscreenConfig);
|
KScreen::ConfigMonitor::instance()->addConfig(m_kscreenConfig);
|
||||||
|
|
||||||
// Listen to all new screens and create a new output
|
// Listen to all new screens and create a new output
|
||||||
|
|
|
||||||
|
|
@ -53,10 +53,20 @@ RotationUtil::Rotation mapRotation(KScreen::Output::Rotation rotation)
|
||||||
RotationUtil::RotationUtil(QObject *parent)
|
RotationUtil::RotationUtil(QObject *parent)
|
||||||
: QObject{parent}
|
: QObject{parent}
|
||||||
, m_sensor{new QOrientationSensor(this)}
|
, m_sensor{new QOrientationSensor(this)}
|
||||||
|
{
|
||||||
|
retrieveKScreen();
|
||||||
|
|
||||||
|
connect(m_sensor, &QOrientationSensor::readingChanged, this, &RotationUtil::updateShowRotationButton);
|
||||||
|
m_sensor->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RotationUtil::retrieveKScreen()
|
||||||
{
|
{
|
||||||
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
||||||
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
||||||
if (!m_config) {
|
if (!m_config) {
|
||||||
|
qDebug() << "RotationUtil: Failed to get kscreen config, attempting again";
|
||||||
|
retrieveKScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
||||||
|
|
@ -71,9 +81,6 @@ RotationUtil::RotationUtil(QObject *parent)
|
||||||
connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &RotationUtil::updateShowRotationButton);
|
connect(output.data(), &KScreen::Output::autoRotatePolicyChanged, this, &RotationUtil::updateShowRotationButton);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_sensor, &QOrientationSensor::readingChanged, this, &RotationUtil::updateShowRotationButton);
|
|
||||||
m_sensor->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RotationUtil::rotateToSuggestedRotation()
|
void RotationUtil::rotateToSuggestedRotation()
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,8 @@ private Q_SLOTS:
|
||||||
void updateShowRotationButton();
|
void updateShowRotationButton();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void retrieveKScreen();
|
||||||
|
|
||||||
bool m_showRotationButton{false};
|
bool m_showRotationButton{false};
|
||||||
KScreen::Output::Rotation m_rotateTo;
|
KScreen::Output::Rotation m_rotateTo;
|
||||||
Rotation m_deviceRotation;
|
Rotation m_deviceRotation;
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,12 @@ void PrepareUtil::initKScreen(std::function<void()> callback)
|
||||||
{
|
{
|
||||||
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this, callback](auto *op) {
|
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this, callback](auto *op) {
|
||||||
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
||||||
|
|
||||||
if (!m_config) {
|
if (!m_config) {
|
||||||
|
qDebug() << "PrepareUtil: Failed to get kscreen config, attempting again";
|
||||||
|
initKScreen(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
||||||
|
|
||||||
int scaling = 100;
|
int scaling = 100;
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,15 @@ KScreenOSDUtil::KScreenOSDUtil(QObject *parent)
|
||||||
}
|
}
|
||||||
setOutputs(m_config->outputs().size());
|
setOutputs(m_config->outputs().size());
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void KScreenOSDUtil::retrieveKScreen()
|
||||||
|
{
|
||||||
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished, this, [this](auto *op) {
|
||||||
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
m_config = qobject_cast<KScreen::GetConfigOperation *>(op)->config();
|
||||||
if (!m_config) {
|
if (!m_config) {
|
||||||
qDebug() << "kscreenosdutil: Unable to obtain kscreen config";
|
qDebug() << "kscreenosdutil: Unable to obtain kscreen config, attempting again";
|
||||||
|
retrieveKScreen();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
KScreen::ConfigMonitor::instance()->addConfig(m_config);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ Q_SIGNALS:
|
||||||
void outputsChanged();
|
void outputsChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void retrieveKScreen();
|
||||||
|
|
||||||
KScreen::ConfigPtr m_config{nullptr};
|
KScreen::ConfigPtr m_config{nullptr};
|
||||||
int m_outputs{0};
|
int m_outputs{0};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue