mirror of https://github.com/snes9xgit/snes9x.git
Qt: Remove old files. Clean whitespace.
This commit is contained in:
parent
fa16fbace4
commit
376e6de81c
|
@ -123,7 +123,6 @@ bool S9xPortAudioSoundDriver::tryHostAPI(int index)
|
|||
|
||||
bool S9xPortAudioSoundDriver::open_device(int playback_rate, int buffer_size_ms)
|
||||
{
|
||||
|
||||
const PaDeviceInfo *device_info;
|
||||
const PaHostApiInfo *hostapi_info;
|
||||
PaError err = paNoError;
|
||||
|
|
|
@ -93,7 +93,6 @@ set(QT_GUI_SOURCES
|
|||
src/Snes9xController.cpp
|
||||
src/EmuSettingsWindow.cpp
|
||||
src/EmuConfig.cpp
|
||||
src/EmuInputPanel.cpp
|
||||
src/EmuBinding.cpp
|
||||
src/EmuCanvas.cpp
|
||||
src/BindingPanel.cpp
|
||||
|
|
|
@ -130,7 +130,7 @@ void BindingPanel::finalizeCurrentBinding(EmuBinding b)
|
|||
accept_return = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
updateCellFromBinding(cell_row, cell_column);
|
||||
setRedirectInput(false);
|
||||
awaiting_binding = false;
|
||||
|
|
|
@ -133,7 +133,7 @@ void EmuApplication::startIdleLoop()
|
|||
void EmuApplication::idleLoop()
|
||||
{
|
||||
if (core->active && pause_count == 0)
|
||||
{
|
||||
{
|
||||
idle_loop->setInterval(0);
|
||||
pollJoysticks();
|
||||
bool muted = config->mute_audio || (config->mute_audio_during_alternate_speed && core->isAbnormalSpeed());
|
||||
|
@ -224,7 +224,7 @@ void EmuApplication::handleBinding(std::string name, bool pressed)
|
|||
{
|
||||
window->pauseContinue();
|
||||
}
|
||||
|
||||
|
||||
else if (name == "IncreaseSlot")
|
||||
{
|
||||
save_slot++;
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
#include "EmuCanvas.hpp"
|
||||
|
||||
EmuCanvas::EmuCanvas()
|
||||
{
|
||||
setAttribute(Qt::WA_NoSystemBackground, true);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
}
|
||||
|
||||
EmuCanvas::~EmuCanvas()
|
||||
{
|
||||
}
|
||||
|
||||
struct drawing_area : QWidget
|
||||
{
|
||||
public:
|
||||
|
||||
Window xid = 0;
|
||||
bool ready = false;
|
||||
XSetWindowAttributes xattr;
|
||||
Visual *visual;
|
||||
unsigned int xflags = 0;
|
||||
QWindow *wrapper_window = nullptr;
|
||||
QWidget *wrapper = nullptr;
|
||||
|
||||
drawing_area()
|
||||
{
|
||||
}
|
||||
|
||||
~drawing_area()
|
||||
{
|
||||
}
|
||||
|
||||
void recreateWindow()
|
||||
{
|
||||
if (xid)
|
||||
{
|
||||
XUnmapWindow(QX11Info::display(), xid);
|
||||
XDestroyWindow(QX11Info::display(), xid);
|
||||
xid = 0;
|
||||
}
|
||||
|
||||
|
||||
XSetErrorHandler([](Display *dpy, XErrorEvent *event) -> int{
|
||||
char text[4096];
|
||||
XGetErrorText(QX11Info::display(), event->error_code, text, 4096);
|
||||
printf("%s\n", text);
|
||||
return 0;
|
||||
});
|
||||
|
||||
createWinId();
|
||||
|
||||
int xwidth = width() * devicePixelRatio();
|
||||
int xheight = height() * devicePixelRatio();
|
||||
|
||||
printf ("%d %d to %d %d %f\n", width(), height(), xwidth, xheight, devicePixelRatioFScale());
|
||||
|
||||
memset(&xattr, 0, sizeof(XSetWindowAttributes));
|
||||
xattr.background_pixel = 0;
|
||||
xattr.backing_store = 0;
|
||||
xattr.event_mask = ExposureMask;
|
||||
xattr.border_pixel = 0;
|
||||
xflags = CWWidth | CWHeight | CWEventMask | CWBackPixel | CWBorderPixel | CWBackingStore;
|
||||
xid = XCreateWindow(QX11Info::display(), winId(), 0, 0, xwidth, xheight, 0, CopyFromParent, InputOutput, CopyFromParent, xflags, &xattr);
|
||||
XMapWindow(QX11Info::display(), xid);
|
||||
/*wrapper_window = QWindow::fromWinId((WId)xid);
|
||||
wrapper = QWidget::createWindowContainer(wrapper_window, this); */
|
||||
}
|
||||
|
||||
void paintEvent(QPaintEvent *event) override
|
||||
{
|
||||
|
||||
|
||||
return;
|
||||
|
||||
auto id = winId();
|
||||
|
||||
XGCValues gcvalues {};
|
||||
gcvalues.background = 0x00ff0000;
|
||||
|
||||
gcvalues.foreground = 0x00ff0000;
|
||||
|
||||
|
||||
/*
|
||||
|
||||
QPainter paint(this);
|
||||
QImage image((const uchar *)snes9x->GetScreen(), 256, 224, 1024, QImage::Format_RGB16);
|
||||
paint.drawImage(0, 0, image, 0, 0, 256, 224);
|
||||
paint.drawImage(QRect(0, 0, width(), height()), image, QRect(0, 0, 256, 224));
|
||||
paint.end();
|
||||
ready = false; */
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
ready = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void resizeEvent(QResizeEvent *event) override
|
||||
{
|
||||
recreateWindow();
|
||||
}
|
||||
};
|
|
@ -1,137 +0,0 @@
|
|||
#include "EmuInputPanel.hpp"
|
||||
#include <QFrame>
|
||||
#include <QtEvents>
|
||||
|
||||
EmuInputBinder::EmuInputBinder(const QString &text, std::vector<EmuBinding> *bindings, int min_label_width)
|
||||
{
|
||||
layout = new QHBoxLayout;
|
||||
setLayout(layout);
|
||||
//layout->setMargin(0);
|
||||
|
||||
label = new QLabel(text);
|
||||
layout->addWidget(label);
|
||||
label->setMinimumWidth(min_label_width);
|
||||
|
||||
this->bindings = bindings;
|
||||
|
||||
remove_icon = QIcon::fromTheme("remove");
|
||||
add_icon = QIcon::fromTheme("add");
|
||||
|
||||
auto frame = new QFrame;
|
||||
auto sublayout = new QHBoxLayout;
|
||||
//sublayout->setMargin(2);
|
||||
frame->setContentsMargins(0, 0, 0, 0);
|
||||
frame->setLayout(sublayout);
|
||||
frame->setFrameShape(QFrame::Shape::StyledPanel);
|
||||
frame->setFrameShadow(QFrame::Shadow::Sunken);
|
||||
|
||||
layout->addWidget(frame);
|
||||
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
buttons[i] = new QPushButton(this);
|
||||
sublayout->addWidget(buttons[i]);
|
||||
buttons[i]->connect(buttons[i], &QPushButton::clicked, [&, i] {
|
||||
this->bindings->erase(this->bindings->begin() + i);
|
||||
updateDisplay();
|
||||
});
|
||||
}
|
||||
|
||||
add_button = new QPushButton(add_icon, "");
|
||||
add_button->setCheckable(true);
|
||||
add_button->connect(add_button, &QPushButton::toggled, [&](bool checked) {
|
||||
if (checked)
|
||||
{
|
||||
grabKeyboard();
|
||||
if (add_button_func)
|
||||
add_button_func(this);
|
||||
}
|
||||
});
|
||||
|
||||
sublayout->addWidget(add_button);
|
||||
layout->addStretch();
|
||||
|
||||
updateDisplay();
|
||||
|
||||
add_button_func = nullptr;
|
||||
}
|
||||
|
||||
void EmuInputBinder::reset(const QString &text, std::vector<EmuBinding> *bindings)
|
||||
{
|
||||
label->setText(text);
|
||||
this->bindings = bindings;
|
||||
}
|
||||
|
||||
void EmuInputBinder::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
releaseKeyboard();
|
||||
|
||||
if (add_button->isChecked() && bindings->size() < 3)
|
||||
{
|
||||
auto key = EmuBinding::keyboard(
|
||||
event->key(),
|
||||
event->modifiers().testFlag(Qt::KeyboardModifier::ShiftModifier),
|
||||
event->modifiers().testFlag(Qt::KeyboardModifier::AltModifier),
|
||||
event->modifiers().testFlag(Qt::KeyboardModifier::ControlModifier),
|
||||
event->modifiers().testFlag(Qt::KeyboardModifier::MetaModifier));
|
||||
|
||||
bool skip = false;
|
||||
for (auto &b : *bindings)
|
||||
{
|
||||
if (b == key)
|
||||
{
|
||||
skip = true;
|
||||
}
|
||||
}
|
||||
if (event->key() == Qt::Key_Escape)
|
||||
skip = true;
|
||||
|
||||
if (!skip)
|
||||
{
|
||||
bindings->push_back(key);
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
add_button->setChecked(false);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuInputBinder::untoggleAddButton()
|
||||
{
|
||||
add_button->setChecked(false);
|
||||
}
|
||||
|
||||
void EmuInputBinder::updateDisplay()
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < bindings->size(); i++)
|
||||
{
|
||||
QPushButton &b = *buttons[i];
|
||||
b.setIcon(QIcon::fromTheme("remove"));
|
||||
b.setText((*bindings)[i].to_string().c_str());
|
||||
b.show();
|
||||
}
|
||||
for (; i < 3; i++)
|
||||
{
|
||||
buttons[i]->hide();
|
||||
}
|
||||
|
||||
if (bindings->size() >= 3)
|
||||
{
|
||||
add_button->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
add_button->show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void EmuInputBinder::connectAddButton(std::function<void (EmuInputBinder *)> func)
|
||||
{
|
||||
add_button_func = func;
|
||||
}
|
||||
|
||||
EmuInputBinder::~EmuInputBinder()
|
||||
{
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
#ifndef __EMU_INPUT_PANEL_HPP
|
||||
#define __EMU_INPUT_PANEL_HPP
|
||||
|
||||
#include <QWidget>
|
||||
#include <QBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
|
||||
#include "EmuBinding.hpp"
|
||||
|
||||
class EmuInputBinder : public QWidget
|
||||
{
|
||||
public:
|
||||
EmuInputBinder(const QString &text, std::vector<EmuBinding> *bindings, int min_label_width = 0);
|
||||
~EmuInputBinder();
|
||||
void updateDisplay();
|
||||
std::vector<EmuBinding> *bindings;
|
||||
void connectAddButton(std::function<void(EmuInputBinder *)>);
|
||||
void untoggleAddButton();
|
||||
void reset(const QString &text, std::vector<EmuBinding> *bindings);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
|
||||
private:
|
||||
QLabel *label;
|
||||
QHBoxLayout *layout;
|
||||
QPushButton *buttons[3];
|
||||
QPushButton *add_button;
|
||||
std::function<void(EmuInputBinder *)> add_button_func;
|
||||
QIcon remove_icon;
|
||||
QIcon add_icon;
|
||||
};
|
||||
|
||||
class EmuInputPanel : QWidget
|
||||
{
|
||||
};
|
||||
|
||||
#endif
|
|
@ -120,7 +120,7 @@ void EmuMainWindow::setCoreActionsEnabled(bool enable)
|
|||
void EmuMainWindow::createWidgets()
|
||||
{
|
||||
setWindowTitle("Snes9x");
|
||||
setWindowIcon(QIcon::fromTheme("snes9x"));
|
||||
setWindowIcon(QIcon(":/icons/snes9x.svg"));
|
||||
|
||||
// File menu
|
||||
auto file_menu = new QMenu(tr("&File"));
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
|
|
|
@ -5,6 +5,8 @@ int main(int argc, char *argv[])
|
|||
EmuApplication emu;
|
||||
emu.qtapp = std::make_unique<QApplication>(argc, argv);
|
||||
|
||||
QGuiApplication::setDesktopFileName("snes9x-gtk");
|
||||
|
||||
emu.config = std::make_unique<EmuConfig>();
|
||||
emu.config->setDefaults();
|
||||
emu.config->loadFile(EmuConfig::findConfigFile());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="icons">
|
||||
<file>snes9x.svg</file>
|
||||
<file>blackicons/settings.svg</file>
|
||||
<file>blackicons/folders.svg</file>
|
||||
<file>blackicons/emulation.svg</file>
|
||||
|
|
Loading…
Reference in New Issue