refactored setTitle to just be a normal AutoConnection signal

This commit is contained in:
Joakim L. Gilje
2021-12-14 20:30:09 +01:00
parent 61ab0e60ca
commit dec90c7ae0
3 changed files with 5 additions and 19 deletions

View File

@@ -63,7 +63,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection);
connect(this, &MainWindow::setTitleForNonQtThread, this, &MainWindow::setTitle_, Qt::BlockingQueuedConnection);
connect(this, &MainWindow::setTitle, this, [this](const QString& title) {
setWindowTitle(title);
});
connect(this, &MainWindow::getTitleForNonQtThread, this, &MainWindow::getTitle_, Qt::BlockingQueuedConnection);
connect(this, &MainWindow::updateMenuResizeOptions, [this]() {
@@ -873,20 +875,6 @@ void MainWindow::on_actionFullscreen_triggered() {
rc->onResize(widget->width(), widget->height());
}
void MainWindow::setTitle_(const wchar_t *title)
{
this->setWindowTitle(QString::fromWCharArray(title));
}
void MainWindow::setTitle(const wchar_t *title)
{
if (QThread::currentThread() == this->thread()) {
setTitle_(title);
} else {
emit setTitleForNonQtThread(title);
}
}
void MainWindow::getTitle_(wchar_t *title)
{
this->windowTitle().toWCharArray(title);

View File

@@ -25,7 +25,6 @@ public:
~MainWindow();
void showMessage(const QString& header, const QString& message);
void setTitle(const wchar_t* title);
void getTitle(wchar_t* title);
void blitToWidget(int x, int y, int w, int h);
QSize getRenderWidgetSize();
@@ -41,11 +40,11 @@ signals:
void updateMenuResizeOptions();
void updateWindowRememberOption();
void setTitle(const QString& title);
void setFullscreen(bool state);
void setMouseCapture(bool state);
void showMessageForNonQtThread(const QString& header, const QString& message);
void setTitleForNonQtThread(const wchar_t* title);
void getTitleForNonQtThread(wchar_t* title);
private slots:
void on_actionFullscreen_triggered();
@@ -94,7 +93,6 @@ private slots:
void refreshMediaMenu();
void showMessage_(const QString& header, const QString& message);
void setTitle_(const wchar_t* title);
void getTitle_(wchar_t* title);
void on_actionTake_screenshot_triggered();

View File

@@ -28,7 +28,7 @@ wchar_t* ui_window_title(wchar_t* str)
main_window->getTitle(title);
str = title;
} else {
main_window->setTitle(str);
emit main_window->setTitle(QString::fromWCharArray(str));
}
return str;
}