Commit 72382e8c authored by Sebastian Kügler's avatar Sebastian Kügler Committed by Daniel Vrátil
Browse files

various fixes

- fix administation of osd - output pairs
- don't parent to the output, may lead to unintended deletion while
showing the osd
- mark osd test as autotest
- static access to the osdmanager
parent aa7953fa
......@@ -246,11 +246,9 @@ void KScreenDaemon::showOsd(const QString &icon, const QString &text)
void KScreenDaemon::showOutputIdentifier()
{
auto osd = new KScreen::OsdManager(this);
osd->showOutputIdentifiers();
KScreen::OsdManager::self()->showOutputIdentifiers();
}
void KScreenDaemon::displayButton()
{
showOutputIdentifier();
......
......@@ -38,6 +38,7 @@ Osd::Osd(QObject *parent)
: QObject(parent)
, m_osdPath(QStandardPaths::locate(QStandardPaths::QStandardPaths::GenericDataLocation, QStringLiteral("kded_kscreen/qml/Osd.qml")))
{
qDebug()<<"NEW OSD";
init();
}
......@@ -79,6 +80,7 @@ void Osd::updatePosition()
if (m_output == nullptr) {
return;
}
auto *rootObject = m_osdObject->rootObject();
const int dialogWidth = rootObject->property("width").toInt();
......
......@@ -29,6 +29,8 @@
namespace KScreen {
OsdManager* OsdManager::m_instance = 0;
OsdManager::OsdManager(QObject *parent)
: QObject(parent)
{
......@@ -38,6 +40,15 @@ OsdManager::~OsdManager()
{
}
OsdManager* OsdManager::self()
{
if (!OsdManager::m_instance) {
m_instance = new OsdManager();
}
return m_instance;
}
void OsdManager::showOutputIdentifiers()
{
connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished,
......@@ -57,27 +68,26 @@ void OsdManager::slotIdentifyOutputs(KScreen::ConfigOperation *op)
this, [this](){
KScreen::Output *output = qobject_cast<KScreen::Output*>(sender());
qDebug() << "outputConnectedChanged():" << output->name();
if (!output->isConnected()) {
if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) {
KScreen::Osd* osd = nullptr;
if (m_osds.keys().contains(output)) {
if (m_osds.keys().contains(output->name())) {
osd->deleteLater();
m_osds.remove(output);
m_osds.remove(output->name());
}
}
},
Qt::UniqueConnection);
if (!output->isConnected() || !output->currentMode()) {
}, Qt::UniqueConnection);
if (!output->isConnected() || !output->isEnabled() || !output->currentMode()) {
continue;
}
const KScreen::ModePtr mode = output->currentMode();
KScreen::Osd* osd = nullptr;
if (m_osds.keys().contains(output.data())) {
osd = m_osds.value(output.data());
qDebug() << "output:" << output->name() << m_osds;
if (m_osds.keys().contains(output->name())) {
osd = m_osds.value(output->name());
} else {
osd = new KScreen::Osd(output.data());
osd = new KScreen::Osd(this);
m_osds.insert(output->name(), osd);
}
osd->showOutputIdentifier(output);
}
......
......@@ -38,13 +38,18 @@ public:
OsdManager(QObject *parent = nullptr);
~OsdManager() override;
static OsdManager* self();
public Q_SLOTS:
void showOutputIdentifiers();
private:
void slotIdentifyOutputs(KScreen::ConfigOperation *op);
QMap<KScreen::Output*, KScreen::Osd*> m_osds;
QMap<QString, KScreen::Osd*> m_osds;
static OsdManager* m_instance;
bool m_showing;
};
} // ns
......
......@@ -13,3 +13,5 @@ target_link_libraries(osdtest Qt5::Core
KF5::QuickAddons
)
add_test(kscreen-kded-osdtest osdtest)
ecm_mark_as_test(osdtest)
......@@ -32,7 +32,6 @@
#include <QLoggingCategory>
Q_LOGGING_CATEGORY(KSCREEN_KDED, "kscreen.kded")
namespace KScreen {
......@@ -48,8 +47,8 @@ OsdTest::~OsdTest()
void OsdTest::start()
{
QTimer::singleShot(5500, qApp, &QCoreApplication::quit);
auto osdManager = new KScreen::OsdManager(this);
osdManager->showOutputIdentifiers();
KScreen::OsdManager::self()->showOutputIdentifiers();
QTimer::singleShot(200, KScreen::OsdManager::self(), &KScreen::OsdManager::showOutputIdentifiers);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment