warp-pipe/gui/main.cpp

62 lines
1.6 KiB
C++

#include <warppipe/warppipe.hpp>
#include "GraphEditorWidget.h"
#include <QAction>
#include <QApplication>
#include <QKeySequence>
#include <QLabel>
#include <QMainWindow>
#include <QStatusBar>
#include <QTimer>
#include <iostream>
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QCoreApplication::setApplicationName("Warppipe");
QCoreApplication::setApplicationVersion("0.1.0");
warppipe::ConnectionOptions opts;
opts.application_name = "warppipe-gui";
auto result = warppipe::Client::Create(opts);
if (!result.ok()) {
std::cerr << "warppipe: failed to connect: " << result.status.message
<< "\n";
return 1;
}
auto &client = result.value;
QMainWindow window;
window.setWindowTitle("Warppipe \u2014 Audio Router");
auto *editor = new GraphEditorWidget(client.get(), &window);
window.setCentralWidget(editor);
window.resize(1280, 720);
auto *statusLabel = new QLabel(&window);
window.statusBar()->addWidget(statusLabel);
auto *statusTimer = new QTimer(&window);
QObject::connect(statusTimer, &QTimer::timeout, [&]() {
int nodes = editor->nodeCount();
int links = editor->linkCount();
statusLabel->setText(
QString("PipeWire connected | %1 nodes | %2 links")
.arg(nodes)
.arg(links));
});
statusTimer->start(500);
auto *closeAction = new QAction(&window);
closeAction->setShortcut(QKeySequence::Quit);
QObject::connect(closeAction, &QAction::triggered, &window,
&QMainWindow::close);
window.addAction(closeAction);
window.show();
return app.exec();
}