mirror of
https://github.com/libretro/FBNeo.git
synced 2024-11-24 09:29:55 +00:00
[Qt] Implements "Log Window"
This commit is contained in:
parent
029716c556
commit
891eeebe63
@ -6,7 +6,6 @@ TARGET = fbaqt
|
||||
|
||||
linux:QT += x11extras
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# DRIVERS
|
||||
#===============================================================================
|
||||
@ -43,6 +42,7 @@ GEN = $$SRC/dep/generated
|
||||
|
||||
# We need ld
|
||||
FBA_LD = ld
|
||||
DEFINES += FBA_DEBUG
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Additional include paths
|
||||
@ -96,10 +96,16 @@ QMAKE_CFLAGS += -w
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# C++11
|
||||
# C++11, OpenMP (software image flip/rotation)
|
||||
#-------------------------------------------------------------------------------
|
||||
CONFIG += c++11
|
||||
|
||||
ENABLE_OPENMP = false
|
||||
$${ENABLE_OPENMP} {
|
||||
QMAKE_CXXFLAGS += -fopenmp
|
||||
QMAKE_LFLAGS += -fopenmp
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# src/dep/generated
|
||||
#-------------------------------------------------------------------------------
|
||||
@ -762,7 +768,8 @@ SOURCES += \
|
||||
../../src/cpu/tlcs90_intf.cpp \
|
||||
../../src/burn/devices/kaneko_tmap.cpp \
|
||||
../../src/burner/qt/inputdialog.cpp \
|
||||
../../src/burner/qt/widgets/hexspinbox.cpp
|
||||
../../src/burner/qt/widgets/hexspinbox.cpp \
|
||||
../../src/burner/qt/logdialog.cpp
|
||||
|
||||
|
||||
HEADERS += \
|
||||
@ -935,7 +942,8 @@ HEADERS += \
|
||||
../../src/burn/devices/nmk004.h \
|
||||
../../src/burn/devices/kaneko_tmap.h \
|
||||
../../src/burner/qt/inputdialog.h \
|
||||
../../src/burner/qt/widgets/hexspinbox.h
|
||||
../../src/burner/qt/widgets/hexspinbox.h \
|
||||
../../src/burner/qt/logdialog.h
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Linux only drivers
|
||||
@ -956,4 +964,5 @@ FORMS += \
|
||||
../../src/burner/qt/romscandialog.ui \
|
||||
../../src/burner/qt/selectdialog.ui \
|
||||
../../src/burner/qt/supportdirsdialog.ui \
|
||||
../../src/burner/qt/inputdialog.ui
|
||||
../../src/burner/qt/inputdialog.ui \
|
||||
../../src/burner/qt/logdialog.ui
|
||||
|
59
src/burner/qt/logdialog.cpp
Normal file
59
src/burner/qt/logdialog.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <cstring>
|
||||
#include <cstdarg>
|
||||
#include "logdialog.h"
|
||||
#include "ui_logdialog.h"
|
||||
#include "burner.h"
|
||||
|
||||
LogDialog *LogDialog::m_instance = nullptr;
|
||||
|
||||
LogDialog::LogDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::LogDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("Messages");
|
||||
bprintf = &LogDialog::qprintf;
|
||||
}
|
||||
|
||||
LogDialog::~LogDialog()
|
||||
{
|
||||
delete ui;
|
||||
m_instance = nullptr;
|
||||
}
|
||||
|
||||
INT32 LogDialog::qprintf(INT32 level, TCHAR *fmt, ...)
|
||||
{
|
||||
|
||||
LogDialog *p = LogDialog::get();
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
static const QColor colorLevels[4] = {
|
||||
QColor( 0, 0, 0),
|
||||
QColor( 0, 0, 127),
|
||||
QColor( 0, 127, 0),
|
||||
QColor(127, 0, 0)
|
||||
};
|
||||
if (level >= 4)
|
||||
level = 0;
|
||||
|
||||
const int maxBuffer = 1024;
|
||||
char strBuffer[maxBuffer];
|
||||
|
||||
va_list args;
|
||||
va_start (args, fmt);
|
||||
::vsnprintf(strBuffer, maxBuffer, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
p->ui->teLogger->setTextColor(colorLevels[level]);
|
||||
p->ui->teLogger->append(strBuffer);
|
||||
return 1;
|
||||
}
|
||||
|
||||
LogDialog *LogDialog::get(QWidget *parent)
|
||||
{
|
||||
if (!m_instance)
|
||||
m_instance = new LogDialog(parent);
|
||||
return m_instance;
|
||||
}
|
||||
|
27
src/burner/qt/logdialog.h
Normal file
27
src/burner/qt/logdialog.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef LOGDIALOG_H
|
||||
#define LOGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTextEdit>
|
||||
#include "burner.h"
|
||||
|
||||
namespace Ui {
|
||||
class LogDialog;
|
||||
}
|
||||
|
||||
class LogDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
explicit LogDialog(QWidget *parent = 0);
|
||||
static LogDialog *m_instance;
|
||||
public:
|
||||
~LogDialog();
|
||||
|
||||
static LogDialog *get(QWidget *parent = 0);
|
||||
static INT32 qprintf(INT32 level, TCHAR *fmt, ...);
|
||||
private:
|
||||
Ui::LogDialog *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif // LOGDIALOG_H
|
92
src/burner/qt/logdialog.ui
Normal file
92
src/burner/qt/logdialog.ui
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LogDialog</class>
|
||||
<widget class="QDialog" name="LogDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>565</width>
|
||||
<height>388</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="teLogger">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClear">
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnOk">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>btnOk</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>LogDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>498</x>
|
||||
<y>365</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>412</x>
|
||||
<y>373</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>btnClear</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>teLogger</receiver>
|
||||
<slot>clear()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>53</x>
|
||||
<y>360</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>145</x>
|
||||
<y>286</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -168,6 +168,7 @@ void MainWindow::createMenus()
|
||||
m_menuMisc->addAction(m_actionConfigureSupportPaths);
|
||||
m_menuMisc->addSeparator();
|
||||
m_menuMisc->addAction(m_actionToogleMenu);
|
||||
m_menuMisc->addAction(m_actionLogWindow);
|
||||
|
||||
m_menuHelp = menuBar()->addMenu(tr("Help"));
|
||||
m_menuHelp->addAction(m_actionAbout);
|
||||
@ -186,6 +187,7 @@ void MainWindow::createControls()
|
||||
m_aboutDlg = new AboutDialog(this);
|
||||
m_dipSwitchDlg = new DipswitchDialog(this);
|
||||
m_inputDlg = new InputDialog(this);
|
||||
m_logDlg = LogDialog::get(this);
|
||||
|
||||
extern void ProgressSetParent(QWidget *);
|
||||
ProgressSetParent(this);
|
||||
@ -209,6 +211,7 @@ void MainWindow::createActions()
|
||||
m_actionDipswitch->setEnabled(false);
|
||||
m_actionMapGameInputs = new QAction(tr("Map game inputs"), this);
|
||||
m_actionMapGameInputs->setEnabled(false);
|
||||
m_actionLogWindow = new QAction(tr("Log window"), this);
|
||||
}
|
||||
|
||||
void MainWindow::connectActions()
|
||||
@ -224,6 +227,7 @@ void MainWindow::connectActions()
|
||||
connect(m_scutToogleFullscreen, SIGNAL(activated()), this, SLOT(toogleFullscreen()));
|
||||
connect(m_actionDipswitch, SIGNAL(triggered()), m_dipSwitchDlg, SLOT(exec()));
|
||||
connect(m_actionMapGameInputs, SIGNAL(triggered()), m_inputDlg, SLOT(exec()));
|
||||
connect(m_actionLogWindow, SIGNAL(triggered()), m_logDlg, SLOT(show()));
|
||||
}
|
||||
|
||||
void MainWindow::enableInGame()
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "aboutdialog.h"
|
||||
#include "dipswitchdialog.h"
|
||||
#include "inputdialog.h"
|
||||
#include "logdialog.h"
|
||||
#include "emuworker.h"
|
||||
#include "burner.h"
|
||||
|
||||
@ -59,6 +60,7 @@ private:
|
||||
AboutDialog *m_aboutDlg;
|
||||
DipswitchDialog *m_dipSwitchDlg;
|
||||
InputDialog *m_inputDlg;
|
||||
LogDialog *m_logDlg;
|
||||
QMenu *m_menuGame;
|
||||
QMenu *m_menuMisc;
|
||||
QMenu *m_menuHelp;
|
||||
@ -73,6 +75,7 @@ private:
|
||||
QAction *m_actionToogleMenu;
|
||||
QAction *m_actionDipswitch;
|
||||
QAction *m_actionMapGameInputs;
|
||||
QAction *m_actionLogWindow;
|
||||
QShortcut *m_scutToogleMenu;
|
||||
QShortcut *m_scutToogleFullscreen;
|
||||
QImage m_logo;
|
||||
|
@ -36,7 +36,7 @@ typedef struct { int x, y, width, height; } RECT;
|
||||
#undef __cdecl
|
||||
#define __cdecl
|
||||
|
||||
#define bprintf(...) {}
|
||||
//#define bprintf(...) {}
|
||||
#endif
|
||||
|
||||
#undef __fastcall
|
||||
|
Loading…
Reference in New Issue
Block a user