From 99bb4fe0be6a364b77e351efc1571c8e84f7d456 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 18 Jul 2021 11:20:15 -0600 Subject: [PATCH 1/3] Remove deprecated code --- applications/launcher/controller.cpp | 2 +- applications/launcher/main.cpp | 4 ++-- applications/lockscreen/controller.h | 4 ++-- applications/process-manager/controller.cpp | 8 ++++++-- applications/settings-manager/main.cpp | 14 +++++++------- applications/system-service/application.cpp | 2 +- applications/system-service/application.h | 9 ++++++--- applications/system-service/main.cpp | 2 +- applications/system-service/notification.cpp | 2 +- applications/system-service/wlan.cpp | 3 ++- 10 files changed, 29 insertions(+), 21 deletions(-) diff --git a/applications/launcher/controller.cpp b/applications/launcher/controller.cpp index ebc8ec25d..7ff505cc9 100644 --- a/applications/launcher/controller.cpp +++ b/applications/launcher/controller.cpp @@ -209,7 +209,7 @@ QList Controller::getApps(){ } // Sort by name std::sort(applications.begin(), applications.end(), [=](const QObject* a, const QObject* b) -> bool { - return a->property("name") < b->property("name"); + return a->property("name").toString() < b->property("name").toString(); }); return applications; } diff --git a/applications/launcher/main.cpp b/applications/launcher/main.cpp index eb68cbb8b..ff46dc995 100644 --- a/applications/launcher/main.cpp +++ b/applications/launcher/main.cpp @@ -59,8 +59,8 @@ int main(int argc, char *argv[]){ QQmlContext* context = engine.rootContext(); Controller* controller = new Controller(); controller->filter = filter; - qmlRegisterType(); - qmlRegisterType(); + qmlRegisterAnonymousType("codes.eeems.oxide", 2); + qmlRegisterAnonymousType("codes.eeems.oxide", 2); context->setContextProperty("screenGeometry", app.primaryScreen()->geometry()); context->setContextProperty("apps", QVariant::fromValue(controller->getApps())); context->setContextProperty("controller", controller); diff --git a/applications/lockscreen/controller.h b/applications/lockscreen/controller.h index 5602d00ab..e9e6af6d0 100644 --- a/applications/lockscreen/controller.h +++ b/applications/lockscreen/controller.h @@ -408,7 +408,7 @@ private slots: qWarning() << "onLogin script is not executable" << path; return; } - QProcess::execute(path); + QProcess::execute(path, QStringList()); } void onFailedLogin(){ if(!settings.contains("onFailedLogin")){ @@ -423,7 +423,7 @@ private slots: qWarning() << "onFailedLogin script is not executable" << path; return; } - QProcess::execute(path); + QProcess::execute(path, QStringList()); } private: diff --git a/applications/process-manager/controller.cpp b/applications/process-manager/controller.cpp index c4a8108cf..50108d427 100755 --- a/applications/process-manager/controller.cpp +++ b/applications/process-manager/controller.cpp @@ -106,8 +106,12 @@ void Controller::sort(){ auto aprop = a->property(sortBy.c_str()); auto bprop = b->property(sortBy.c_str()); if(sortBy != lastSortBy && aprop == bprop){ - return a->property(lastSortBy.c_str()) < b->property(lastSortBy.c_str()); + aprop = a->property(lastSortBy.c_str()); + bprop = b->property(lastSortBy.c_str()); } - return aprop < bprop; + if(sortBy == "name"){ + return aprop.toString() < bprop.toString(); + } + return aprop.toInt() < bprop.toInt(); }); } diff --git a/applications/settings-manager/main.cpp b/applications/settings-manager/main.cpp index f2ca0e946..ee40c287b 100644 --- a/applications/settings-manager/main.cpp +++ b/applications/settings-manager/main.cpp @@ -183,11 +183,11 @@ public slots: args << QVariant(typeId, ptr); } if(args.size() > 1){ - qStdOut << toJson(args).toStdString().c_str() << endl; + qStdOut << toJson(args).toStdString().c_str() << Qt::endl; }else if(args.size() == 1 && !args.first().isNull()){ - qStdOut << toJson(args.first()).toStdString().c_str() << endl; + qStdOut << toJson(args.first()).toStdString().c_str() << Qt::endl; }else{ - qStdOut << "undefined" << endl; + qStdOut << "undefined" << Qt::endl; } if(once){ qApp->quit(); @@ -367,7 +367,7 @@ int main(int argc, char *argv[]){ qDebug() << "Failed to get value" << api->lastError(); return EXIT_FAILURE; } - qStdOut << toJson(value).toStdString().c_str() << endl; + qStdOut << toJson(value).toStdString().c_str() << Qt::endl; }else if(action == "set"){ auto property = args.at(2).toStdString(); if(!api->setProperty(property.c_str(), args.at(3).toStdString().c_str())){ @@ -385,7 +385,7 @@ int main(int argc, char *argv[]){ for(int i = 0, j = method.parameterCount(); i < j; ++i){ parameters << QMetaType::typeName(method.parameterType(i)); } - slotName.append(parameters.join(",")).append(")"); + slotName.append(parameters.join(",").toUtf8()).append(")"); QByteArray theSignal = QMetaObject::normalizedSignature(method.methodSignature().constData()); QByteArray theSlot = QMetaObject::normalizedSignature(slotName); if(!QMetaObject::checkConnectArgs(theSignal, theSlot)){ @@ -439,9 +439,9 @@ int main(int argc, char *argv[]){ QDBusMessage reply = api->callWithArgumentList(QDBus::Block, method, arguments); auto result = reply.arguments(); if(result.size() > 1){ - qStdOut << toJson(result).toStdString().c_str() << endl; + qStdOut << toJson(result).toStdString().c_str() << Qt::endl; }else if(!result.first().isNull()){ - qStdOut << toJson(result.first()).toStdString().c_str() << endl; + qStdOut << toJson(result.first()).toStdString().c_str() << Qt::endl; } if(!reply.errorName().isEmpty()){ return EXIT_FAILURE; diff --git a/applications/system-service/application.cpp b/applications/system-service/application.cpp index b8aac9cf4..0354136ad 100644 --- a/applications/system-service/application.cpp +++ b/applications/system-service/application.cpp @@ -202,7 +202,7 @@ void Application::stopNoSecurityCheck(){ } qDebug() << "Stopping " << path(); if(!onStop().isEmpty()){ - QProcess::execute(onStop()); + QProcess::execute(onStop(), QStringList()); } Application* pausedApplication = nullptr; if(state == Paused){ diff --git a/applications/system-service/application.h b/applications/system-service/application.h index 013803c44..57939a0f0 100644 --- a/applications/system-service/application.h +++ b/applications/system-service/application.h @@ -147,7 +147,10 @@ class Application : public QObject{ Application(QString path, QObject* parent) : QObject(parent), m_path(path), m_backgrounded(false), fifos() { m_process = new SandBoxProcess(this); connect(m_process, &SandBoxProcess::started, this, &Application::started); - connect(m_process, QOverload::of(&SandBoxProcess::finished), this, &Application::finished); + connect(m_process, QOverload::of(&SandBoxProcess::finished), [=](int exitCode, QProcess::ExitStatus status){ + Q_UNUSED(status); + finished(exitCode); + }); connect(m_process, &SandBoxProcess::readyReadStandardError, this, &Application::readyReadStandardError); connect(m_process, &SandBoxProcess::readyReadStandardOutput, this, &Application::readyReadStandardOutput); connect(m_process, &SandBoxProcess::stateChanged, this, &Application::stateChanged); @@ -412,7 +415,7 @@ private slots: void readyReadStandardError(){ const char* prefix = ("[" + name() + " " + QString::number(m_process->processId()) + "]").toUtf8(); QString error = m_process->readAllStandardError(); - for(QString line : error.split(QRegExp("[\r\n]"), QString::SkipEmptyParts)){ + for(QString line : error.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts)){ if(!line.isEmpty()){ sd_journal_print(LOG_ERR, "%s %s", prefix, (const char*)line.toUtf8()); } @@ -421,7 +424,7 @@ private slots: void readyReadStandardOutput(){ const char* prefix = ("[" + name() + " " + QString::number(m_process->processId()) + "]").toUtf8(); QString output = m_process->readAllStandardOutput(); - for(QString line : output.split(QRegExp("[\r\n]"), QString::SkipEmptyParts)){ + for(QString line : output.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts)){ if(!line.isEmpty()){ sd_journal_print(LOG_INFO, "%s %s", prefix, (const char*)line.toUtf8()); } diff --git a/applications/system-service/main.cpp b/applications/system-service/main.cpp index 826f884e3..98a95ef8f 100755 --- a/applications/system-service/main.cpp +++ b/applications/system-service/main.cpp @@ -18,7 +18,7 @@ void sigHandler(int signal){ int main(int argc, char *argv[]){ if(deviceSettings.getDeviceType() == DeviceSettings::RM2 && getenv("RM2FB_ACTIVE") == nullptr){ qWarning() << "rm2fb not detected. Running xochitl instead!"; - return QProcess::execute("/usr/bin/xochitl"); + return QProcess::execute("/usr/bin/xochitl", QStringList()); } if (strcmp(qt_version, QT_VERSION_STR) != 0){ qDebug() << "Version mismatch, Runtime: " << qt_version << ", Build: " << QT_VERSION_STR; diff --git a/applications/system-service/notification.cpp b/applications/system-service/notification.cpp index 7ec3a0249..da7637b23 100644 --- a/applications/system-service/notification.cpp +++ b/applications/system-service/notification.cpp @@ -65,7 +65,7 @@ void Notification::paintNotification(Application* resumeApp){ auto fm = painter.fontMetrics(); auto padding = 10; auto radius = 10; - auto width = fm.width(text()) + (padding * 2); + auto width = fm.horizontalAdvance(text()) + (padding * 2); auto height = fm.height() + (padding * 2); auto left = size.width() - width; auto top = size.height() - height; diff --git a/applications/system-service/wlan.cpp b/applications/system-service/wlan.cpp index fc804d873..1de1bd596 100644 --- a/applications/system-service/wlan.cpp +++ b/applications/system-service/wlan.cpp @@ -9,7 +9,8 @@ void Wlan::setInterface(QString path){ removeInterface(); auto bus = QDBusConnection::systemBus(); m_interface = new Interface(WPA_SUPPLICANT_SERVICE, path, bus, this); - m_blobs = m_interface->blobs().toSet(); + auto blobs =m_interface->blobs(); + m_blobs = QSet(blobs.begin(), blobs.end()); connect(m_interface, &Interface::BSSAdded, this, &Wlan::onBSSAdded, Qt::QueuedConnection); connect(m_interface, &Interface::BSSRemoved, this, &Wlan::onBSSRemoved, Qt::QueuedConnection); connect(m_interface, &Interface::BlobAdded, this, &Wlan::onBlobAdded, Qt::QueuedConnection); From b1fd61cc221c0a5cb382f3fdae880f2a042967ef Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 18 Jul 2021 12:16:27 -0600 Subject: [PATCH 2/3] Give feedback when quitting --- applications/system-service/application.h | 2 +- applications/system-service/appsapi.h | 41 +++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/applications/system-service/application.h b/applications/system-service/application.h index 57939a0f0..c12789905 100644 --- a/applications/system-service/application.h +++ b/applications/system-service/application.h @@ -410,6 +410,7 @@ public slots: } private slots: + void showSplashScreen(); void started(); void finished(int exitCode); void readyReadStandardError(){ @@ -458,7 +459,6 @@ private slots: QMap fifos; bool hasPermission(QString permission, const char* sender = __builtin_FUNCTION()); - void showSplashScreen(); void delayUpTo(int milliseconds){ timer.invalidate(); timer.start(); diff --git a/applications/system-service/appsapi.h b/applications/system-service/appsapi.h index 9e87c3ab8..b1b25157f 100644 --- a/applications/system-service/appsapi.h +++ b/applications/system-service/appsapi.h @@ -48,14 +48,55 @@ class AppsAPI : public APIBase { m_stopping = true; writeApplications(); settings.sync(); + auto frameBuffer = EPFrameBuffer::framebuffer(); + qDebug() << "Waiting for other painting to finish..."; + while(frameBuffer->paintingActive()){ + EPFrameBuffer::waitForLastUpdate(); + } + QPainter painter(frameBuffer); + auto rect = frameBuffer->rect(); + auto fm = painter.fontMetrics(); + auto size = frameBuffer->size(); + qDebug() << "Clearing screen..."; + painter.setPen(Qt::white); + painter.fillRect(rect, Qt::black); + EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Mono, EPFrameBuffer::FullUpdate, true); + EPFrameBuffer::waitForLastUpdate(); + qDebug() << "Stopping applications..."; for(auto app : applications){ + if(app->stateNoSecurityCheck() != Application::Inactive){ + auto text = "Stopping " + app->displayName() + "..."; + qDebug() << text.toStdString().c_str(); + int padding = 10; + int textHeight = fm.height() + padding; + QRect textRect( + QPoint(0 + padding, size.height() - textHeight), + QSize(size.width() - padding * 2, textHeight) + ); + painter.fillRect(textRect, Qt::black); + painter.drawText( + textRect, + Qt::AlignVCenter | Qt::AlignRight, + text + ); + EPFrameBuffer::sendUpdate(textRect, EPFrameBuffer::Mono, EPFrameBuffer::PartialUpdate, true); + EPFrameBuffer::waitForLastUpdate(); + } app->stopNoSecurityCheck(); } + qDebug() << "Ensuring all applications have stopped..."; for(auto app : applications){ app->waitForFinished(); delete app; } applications.clear(); + qDebug() << "Displaying final quit message..."; + painter.fillRect(rect, Qt::black); + painter.drawText(rect, Qt::AlignCenter,"Goodbye!"); + EPFrameBuffer::waitForLastUpdate(); + EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Mono, EPFrameBuffer::FullUpdate, true); + painter.end(); + EPFrameBuffer::waitForLastUpdate(); } void startup(); int state() { return 0; } // Ignore this, it's a kludge to get the xml to generate From adcc738978e06bc210e27c55ff9ead223a500a16 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Sun, 18 Jul 2021 12:34:56 -0600 Subject: [PATCH 3/3] Add dependency --- package | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package b/package index d51d06d81..036b7bfa3 100644 --- a/package +++ b/package @@ -132,7 +132,7 @@ anxiety() { pkgdesc="Screenshot viewer for Oxide" url=https://github.com/Eeems/oxide/tree/master/applications/screenshot-viewer section=utils - installdepends=("tarnish=$pkgver") + installdepends=("tarnish=$pkgver" "imagemagick-png") package() { install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/release/opt/bin/anxiety