Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ set(SOURCES
src/core/ShortcutManager.cpp
src/core/OperationMode.cpp
src/core/DCAMapping.cpp
src/core/AppLogger.cpp
src/core/ConnectionLogBridge.cpp
src/ui/MainWindow.cpp
src/ui/CueListView.cpp
src/ui/CueEditor.cpp
Expand Down Expand Up @@ -117,6 +119,9 @@ set(SOURCES
src/midi/MidiInputManager.cpp
src/ui/MidiConfigDialog.cpp
src/ui/KeyboardShortcutsDialog.cpp
src/ui/LogViewerDialog.cpp
src/ui/LogListModel.cpp
src/ui/LogItemDelegate.cpp
)

# header files
Expand All @@ -134,6 +139,8 @@ set(HEADERS
src/core/ShortcutManager.h
src/core/OperationMode.h
src/core/DCAMapping.h
src/core/AppLogger.h
src/core/ConnectionLogBridge.h
src/ui/MainWindow.h
src/ui/CueListView.h
src/ui/CueEditor.h
Expand Down Expand Up @@ -193,6 +200,9 @@ set(HEADERS
src/midi/MidiInputManager.h
src/ui/MidiConfigDialog.h
src/ui/KeyboardShortcutsDialog.h
src/ui/LogViewerDialog.h
src/ui/LogListModel.h
src/ui/LogItemDelegate.h
)

# Qt resources
Expand Down
29 changes: 25 additions & 4 deletions resources/styles/main.qss
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,13 @@ QLabel[role="warning"] {
color: #f59e0b;
}

QFrame[frameShape="4"] { /* HLine */
QFrame[frameShape="4"] {
background-color: #2e323b;
max-height: 1px;
border: none;
}

QFrame[frameShape="5"] { /* VLine */
QFrame[frameShape="5"] {
background-color: #2e323b;
max-width: 1px;
border: none;
Expand Down Expand Up @@ -761,13 +761,13 @@ QListView::item:hover {
QTableView::item:selected,
QTreeView::item:selected,
QListView::item:selected {
background-color: rgba(59, 130, 246, 0.2);
background-color: rgba(59, 130, 246, 0.4);
}

QTableView::item:selected:hover,
QTreeView::item:selected:hover,
QListView::item:selected:hover {
background-color: rgba(59, 130, 246, 0.25);
background-color: rgba(59, 130, 246, 0.45);
}

QHeaderView {
Expand Down Expand Up @@ -1168,4 +1168,25 @@ QTableView:focus {

QPushButton:focus {
border-color: #3b82f6;
}

QListView#LogListView {
background-color: #131416;
border: 1px solid #2e323b;
border-radius: 6px;
font-family: "JetBrains Mono", "Cascadia Code", "SF Mono", "Consolas", monospace;
font-size: 11px;
}

QListView#LogListView::item {
padding: 4px 0;
border-bottom: 1px solid #1e2024;
}

QListView#LogListView::item:hover {
background-color: #22252a;
}

QListView#LogListView::item:selected {
background-color: rgba(59, 130, 246, 0.4);
}
68 changes: 67 additions & 1 deletion src/app/Application.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "Application.h"
#include "core/AppLogger.h"
#include "core/ConnectionLogBridge.h"
#include "core/Cue.h"
#include "core/CueList.h"
#include "core/CueValidator.h"
Expand All @@ -20,6 +22,9 @@
#include "protocol/discovery/probes/BehringerWingProbeStrategy.h"
#include "protocol/discovery/probes/BehringerX32ProbeStrategy.h"
#include "protocol/discovery/probes/YamahaOscProbeStrategy.h"
#include <QDir>
#include <QSettings>
#include <QStandardPaths>

namespace OpenMix {

Expand Down Expand Up @@ -51,6 +56,15 @@ Application::Application(QObject* parent) : QObject(parent) {
m_discoveryService->registerStrategy(std::make_shared<BehringerX32ProbeStrategy>());
m_discoveryService->registerStrategy(std::make_shared<BehringerWingProbeStrategy>());
m_discoveryService->registerStrategy(std::make_shared<YamahaOscProbeStrategy>());

// application logging
m_appLogger = new AppLogger(this);
m_connectionLogBridge = new ConnectionLogBridge(m_appLogger, this);

// setup log file
QString logDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir().mkpath(logDir);
m_appLogger->setLogFile(logDir + "/application.log");
}

Application::~Application() {
Expand Down Expand Up @@ -128,10 +142,22 @@ void Application::connectToMixer(const QString& type, const QString& host, int p

m_playbackEngine->setMixer(m_mixer);

// setup connection logging
m_connectionLogBridge->setConnectionContext(type, host, port);
m_connectionLogBridge->attachToMixer(m_mixer);
m_appLogger->logConnectionAttempt(type, host, port);

connect(m_mixer, &MixerProtocol::connected, this, [this]() { emit mixerConnected(); });
connect(m_mixer, &MixerProtocol::disconnected, this, [this]() { emit mixerDisconnected(); });

m_mixer->connect(host, port);

QSettings settings;
settings.beginGroup("LastMixer");
settings.setValue("host", host);
settings.setValue("type", type);
settings.setValue("port", port);
settings.endGroup();
}

void Application::connectToDiscoveredConsole(const DiscoveredConsole& console) {
Expand All @@ -148,19 +174,59 @@ void Application::connectToDiscoveredConsole(const DiscoveredConsole& console) {

m_playbackEngine->setMixer(m_mixer);

// setup connection logging
QString host = console.address.toString();
QString protocol = console.modelName;
m_connectionLogBridge->setConnectionContext(protocol, host, console.port);
m_connectionLogBridge->attachToMixer(m_mixer);
m_appLogger->logConnectionAttempt(protocol, host, console.port);

connect(m_mixer, &MixerProtocol::connected, this, [this]() { emit mixerConnected(); });
connect(m_mixer, &MixerProtocol::disconnected, this, [this]() { emit mixerDisconnected(); });

m_mixer->connect(console.address.toString(), console.port);
m_mixer->connect(host, console.port);

QSettings settings;
settings.beginGroup("LastMixer");
settings.setValue("host", host);
settings.setValue("type", console.toCapabilities().protocolId);
settings.setValue("port", console.port);
settings.endGroup();
}

void Application::disconnectFromMixer() {
if (m_mixer) {
m_connectionLogBridge->detachFromMixer();
m_mixer->disconnect();
m_playbackEngine->setMixer(nullptr);
delete m_mixer;
m_mixer = nullptr;
}
}

void Application::startupScan() {
QSettings settings;
settings.beginGroup("LastMixer");
QString savedHost = settings.value("host").toString();
settings.endGroup();

if (!savedHost.isEmpty()) {
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = connect(m_discoveryService, &ConsoleDiscoveryService::consoleDiscovered,
this, [this, savedHost, conn](const DiscoveredConsole& console) {
if (m_mixer == nullptr && console.address.toString() == savedHost) {
QObject::disconnect(*conn);
connectToDiscoveredConsole(console);
}
});

connect(m_discoveryService, &ConsoleDiscoveryService::scanFinished,
this, [conn]() {
QObject::disconnect(*conn);
}, Qt::SingleShotConnection);
}

m_discoveryService->startScan(3000);
}

} // namespace OpenMix
12 changes: 12 additions & 0 deletions src/app/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class OperationModeManager;
class CrashRecovery;
class MidiInputManager;
class ConsoleDiscoveryService;
class AppLogger;
class ConnectionLogBridge;
struct DiscoveredConsole;

class Application : public QObject {
Expand Down Expand Up @@ -58,6 +60,9 @@ class Application : public QObject {
// console discovery
ConsoleDiscoveryService* discoveryService() { return m_discoveryService; }

// application logging
AppLogger* appLogger() { return m_appLogger; }

// mixer connection
void connectToMixer(const QString& type, const QString& host, int port);
void connectToDiscoveredConsole(const DiscoveredConsole& console);
Expand All @@ -70,6 +75,9 @@ class Application : public QObject {
// initialization
void initialize();

// startup auto-connect
void startupScan();

signals:
void mixerConnected();
void mixerDisconnected();
Expand Down Expand Up @@ -102,6 +110,10 @@ class Application : public QObject {

// console discovery
ConsoleDiscoveryService* m_discoveryService;

// application logging
AppLogger* m_appLogger;
ConnectionLogBridge* m_connectionLogBridge;
};

} // namespace OpenMix
Loading
Loading