Skip to content
Extraits de code Groupes Projets
Valider f01b5cb4 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Connect mpvwidget to mainwindow to update window title

parent 45e0d2c4
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #2629 en échec
Ce commit fait partie de la requête de fusion !186. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
......@@ -4,6 +4,7 @@ MainWindow::MainWindow(struct module_qt_window_s *qt_window, QWidget *parent)
: QMainWindow(parent)
{
qt_window->mpv_widget = new MpvWidget(qt_window->queue, qt_window->db, this);
connect(qt_window->mpv_widget, &MpvWidget::titleChanged, this, &MainWindow::updateWindowTitle);
setCentralWidget(qt_window->mpv_widget);
setFocusPolicy(Qt::StrongFocus);
}
......@@ -10,4 +10,9 @@ class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(struct module_qt_window_s *qt_window, QWidget *parent = nullptr);
public slots:
inline void updateWindowTitle(QString str) noexcept {
setWindowTitle(str);
}
};
......@@ -5,10 +5,13 @@
#include <QtCore/QMetaObject>
#include <QApplication>
#include <QKeyEvent>
#include <QString>
#include "qthelper.hh"
#include "../mpv.h"
#include <lektor/mkv.h>
PRIVATE_FUNCTION void
wakeup(void *ctx)
{
......@@ -235,7 +238,7 @@ MpvWidget::load_file(const char *filepath)
if (ret) {
LOG_DEBUG("WINDOW", "Loaded file: %s", filepath);
//set_window_title(win);
update_window_title();
} else {
LOG_ERROR("WINDOW", "Failed to load kara with path: %s", filepath);
}
......@@ -244,6 +247,27 @@ MpvWidget::load_file(const char *filepath)
return ret;
}
void
MpvWidget::update_window_title()
{
struct kara_metadata kara_mdt;
int changed_kara = 0;
char *kara_title = NULL;
char window_title[LKT_LINE_MAX];
if (database_queue_current_kara(m_db, &kara_mdt, &changed_kara)) {
mdtcat(&kara_mdt, &kara_title);
safe_snprintf(window_title, LKT_LINE_MAX, "[Lektord] %d: %s", changed_kara, kara_title);
LOG_DEBUG("WINDOW", "Set window title to: %s", window_title);
titleChanged(QString::fromLocal8Bit(window_title));
free(kara_title);
}
else {
LOG_ERROR("WINDOW", "Failed to get current kara, can't change window title");
}
}
bool
MpvWidget::toggle_pause()
{
......
......@@ -48,4 +48,10 @@ public:
bool set_position(int);
bool load_file(const char *);
bool toggle_pause();
private:
void update_window_title();
signals:
void titleChanged(QString str);
};
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter