Implement title bar statistics
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_mutex.h"
|
#include "SDL_mutex.h"
|
||||||
|
#include "SDL_timer.h"
|
||||||
#include "qt_mainwindow.hpp"
|
#include "qt_mainwindow.hpp"
|
||||||
#include "qt_sdl.h"
|
#include "qt_sdl.h"
|
||||||
#include "cocoa_mouse.hpp"
|
#include "cocoa_mouse.hpp"
|
||||||
@@ -76,6 +77,12 @@ main_thread_fn()
|
|||||||
is_quit = 1;
|
is_quit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t timer_onesec(uint32_t interval, void* param)
|
||||||
|
{
|
||||||
|
pc_onesec();
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
@@ -97,6 +104,7 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
/* Set the PAUSE mode depending on the renderer. */
|
/* Set the PAUSE mode depending on the renderer. */
|
||||||
// plat_pause(0);
|
// plat_pause(0);
|
||||||
|
SDL_AddTimer(1000, timer_onesec, nullptr);
|
||||||
|
|
||||||
/* Initialize the rendering window, or fullscreen. */
|
/* Initialize the rendering window, or fullscreen. */
|
||||||
QTimer::singleShot(50, []() { plat_resize(640, 480); } );
|
QTimer::singleShot(50, []() { plat_resize(640, 480); } );
|
||||||
|
@@ -48,6 +48,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection);
|
connect(this, &MainWindow::showMessageForNonQtThread, this, &MainWindow::showMessage_, Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
|
connect(this, &MainWindow::setTitleForNonQtThread, this, &MainWindow::setTitle_, Qt::BlockingQueuedConnection);
|
||||||
|
connect(this, &MainWindow::getTitleForNonQtThread, this, &MainWindow::getTitle_, Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
connect(this, &MainWindow::pollMouse, ui->glesWidget, &GLESWidget::qt_mouse_poll);
|
connect(this, &MainWindow::pollMouse, ui->glesWidget, &GLESWidget::qt_mouse_poll);
|
||||||
|
|
||||||
connect(this, &MainWindow::setMouseCapture, this, [this](bool state) {
|
connect(this, &MainWindow::setMouseCapture, this, [this](bool state) {
|
||||||
@@ -641,6 +644,34 @@ void MainWindow::on_actionFullscreen_triggered() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::getTitle(wchar_t *title)
|
||||||
|
{
|
||||||
|
if (QThread::currentThread() == this->thread()) {
|
||||||
|
getTitle_(title);
|
||||||
|
} else {
|
||||||
|
emit getTitleForNonQtThread(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::showMessage(const QString& header, const QString& message) {
|
void MainWindow::showMessage(const QString& header, const QString& message) {
|
||||||
if (QThread::currentThread() == this->thread()) {
|
if (QThread::currentThread() == this->thread()) {
|
||||||
showMessage_(header, message);
|
showMessage_(header, message);
|
||||||
|
@@ -20,6 +20,8 @@ public:
|
|||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void showMessage(const QString& header, const QString& message);
|
void showMessage(const QString& header, const QString& message);
|
||||||
|
void setTitle(const wchar_t* title);
|
||||||
|
void getTitle(wchar_t* title);
|
||||||
signals:
|
signals:
|
||||||
void paint(const QImage& image);
|
void paint(const QImage& image);
|
||||||
void blitToWidget(int x, int y, int w, int h);
|
void blitToWidget(int x, int y, int w, int h);
|
||||||
@@ -33,6 +35,8 @@ signals:
|
|||||||
void setMouseCapture(bool state);
|
void setMouseCapture(bool state);
|
||||||
|
|
||||||
void showMessageForNonQtThread(const QString& header, const QString& message);
|
void showMessageForNonQtThread(const QString& header, const QString& message);
|
||||||
|
void setTitleForNonQtThread(const wchar_t* title);
|
||||||
|
void getTitleForNonQtThread(wchar_t* title);
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionFullscreen_triggered();
|
void on_actionFullscreen_triggered();
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
@@ -45,6 +49,8 @@ private slots:
|
|||||||
void on_actionKeyboard_requires_capture_triggered();
|
void on_actionKeyboard_requires_capture_triggered();
|
||||||
|
|
||||||
void showMessage_(const QString& header, const QString& message);
|
void showMessage_(const QString& header, const QString& message);
|
||||||
|
void setTitle_(const wchar_t* title);
|
||||||
|
void getTitle_(wchar_t* title);
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
void keyReleaseEvent(QKeyEvent* event) override;
|
void keyReleaseEvent(QKeyEvent* event) override;
|
||||||
|
@@ -27,11 +27,11 @@ wchar_t* ui_window_title(wchar_t* str)
|
|||||||
{
|
{
|
||||||
if (str == nullptr) {
|
if (str == nullptr) {
|
||||||
static wchar_t title[512];
|
static wchar_t title[512];
|
||||||
int chars = main_window->windowTitle().toWCharArray(title);
|
memset(title, 0, sizeof(title));
|
||||||
title[chars] = 0;
|
main_window->getTitle(title);
|
||||||
str = title;
|
str = title;
|
||||||
} else {
|
} else {
|
||||||
main_window->setWindowTitle(QString::fromWCharArray(str));
|
main_window->setTitle(str);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user