wip
This commit is contained in:
BIN
system/clearpilot/tools/qt_shell
Executable file
BIN
system/clearpilot/tools/qt_shell
Executable file
Binary file not shown.
76
system/clearpilot/tools/qt_shell.cc
Normal file
76
system/clearpilot/tools/qt_shell.cc
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QProcess>
|
||||
#include <QVBoxLayout>
|
||||
#include <QFont>
|
||||
#include <QScreen>
|
||||
#include <QScrollBar>
|
||||
#include <QGuiApplication>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
|
||||
if (argc < 2) {
|
||||
printf("Usage: %s '<command>'\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
QWidget window;
|
||||
window.setWindowTitle("Shell Command Output Viewer");
|
||||
window.setStyleSheet("background-color: black;");
|
||||
window.showFullScreen();
|
||||
|
||||
auto windowHandle = window.windowHandle();
|
||||
if (!windowHandle) {
|
||||
fprintf(stderr, "Error: Unable to obtain window handle.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
auto *s = static_cast<wl_surface*>(native->nativeResourceForWindow("surface", windowHandle));
|
||||
if (!s) {
|
||||
fprintf(stderr, "Error: Unable to obtain native Wayland surface.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
|
||||
window.setFixedSize(2160, 1080);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(&window);
|
||||
QTextEdit *outputDisplay = new QTextEdit;
|
||||
outputDisplay->setFont(QFont("Consolas", 32));
|
||||
outputDisplay->setReadOnly(true);
|
||||
outputDisplay->setFixedSize(2160, 1080);
|
||||
outputDisplay->setStyleSheet("color: white; background-color: black;");
|
||||
outputDisplay->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Hide the vertical scrollbar
|
||||
|
||||
layout->addWidget(outputDisplay);
|
||||
|
||||
QProcess process;
|
||||
QObject::connect(&process, &QProcess::readyReadStandardOutput, [&]() {
|
||||
static QStringList lines;
|
||||
QString output = process.readAllStandardOutput();
|
||||
lines += output.split("\n", QString::SkipEmptyParts);
|
||||
while (lines.size() > 100) {
|
||||
lines.removeFirst();
|
||||
}
|
||||
outputDisplay->setPlainText(lines.join("\n"));
|
||||
outputDisplay->verticalScrollBar()->setValue(outputDisplay->verticalScrollBar()->maximum());
|
||||
});
|
||||
|
||||
QObject::connect(&process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), [&]() {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
QString command = argv[1];
|
||||
process.start(QString("bash -c \"%1\"").arg(command));
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
sudo su comma -c "python3 shell.py \"echo hello; sleep 5\"
|
||||
sudo su comma -c "python3 /data/openpilot/system/clearpilot/tools/shell.py \"echo hello; sleep 5\"
|
||||
|
||||
Reference in New Issue
Block a user