mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 22:25:41 +12:00
parent
80527edcb6
commit
aa7a6bfe7a
6 changed files with 33 additions and 33 deletions
|
@ -449,11 +449,11 @@ if(NOT BUILD_HYDRA_CORE)
|
||||||
|
|
||||||
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
set(FRONTEND_SOURCE_FILES src/panda_qt/main.cpp src/panda_qt/screen.cpp src/panda_qt/main_window.cpp src/panda_qt/about_window.cpp
|
||||||
src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp src/panda_qt/mappings.cpp
|
src/panda_qt/config_window.cpp src/panda_qt/zep.cpp src/panda_qt/text_editor.cpp src/panda_qt/cheats_window.cpp src/panda_qt/mappings.cpp
|
||||||
src/panda_qt/patch_window.cpp src/panda_qt/ellided_label.cpp
|
src/panda_qt/patch_window.cpp src/panda_qt/elided_label.cpp
|
||||||
)
|
)
|
||||||
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp
|
set(FRONTEND_HEADER_FILES include/panda_qt/screen.hpp include/panda_qt/main_window.hpp include/panda_qt/about_window.hpp
|
||||||
include/panda_qt/config_window.hpp include/panda_qt/text_editor.hpp include/panda_qt/cheats_window.hpp
|
include/panda_qt/config_window.hpp include/panda_qt/text_editor.hpp include/panda_qt/cheats_window.hpp
|
||||||
include/panda_qt/patch_window.hpp include/panda_qt/ellided_label.hpp
|
include/panda_qt/patch_window.hpp include/panda_qt/elided_label.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES})
|
source_group("Source Files\\Qt" FILES ${FRONTEND_SOURCE_FILES})
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class EllidedLabel : public QLabel {
|
class ElidedLabel : public QLabel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit EllidedLabel(Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
|
explicit ElidedLabel(Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
|
||||||
explicit EllidedLabel(QString text, Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
|
explicit ElidedLabel(QString text, Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
|
||||||
void setText(QString text);
|
void setText(QString text);
|
||||||
|
|
||||||
protected:
|
protected:
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include "panda_qt/ellided_label.hpp"
|
#include "panda_qt/elided_label.hpp"
|
||||||
|
|
||||||
class PatchWindow final : public QWidget {
|
class PatchWindow final : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
25
src/panda_qt/elided_label.cpp
Normal file
25
src/panda_qt/elided_label.cpp
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#include "panda_qt/elided_label.hpp"
|
||||||
|
|
||||||
|
// Based on https://stackoverflow.com/questions/7381100/text-overflow-for-a-qlabel-s-text-rendering-in-qt
|
||||||
|
ElidedLabel::ElidedLabel(Qt::TextElideMode elideMode, QWidget* parent) : ElidedLabel("", elideMode, parent) {}
|
||||||
|
|
||||||
|
ElidedLabel::ElidedLabel(QString text, Qt::TextElideMode elideMode, QWidget* parent) : QLabel(parent) {
|
||||||
|
m_elideMode = elideMode;
|
||||||
|
setText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElidedLabel::setText(QString text) {
|
||||||
|
m_text = text;
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElidedLabel::resizeEvent(QResizeEvent* event) {
|
||||||
|
QLabel::resizeEvent(event);
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ElidedLabel::updateText() {
|
||||||
|
QFontMetrics metrics(font());
|
||||||
|
QString elided = metrics.elidedText(m_text, m_elideMode, width());
|
||||||
|
QLabel::setText(elided);
|
||||||
|
}
|
|
@ -1,25 +0,0 @@
|
||||||
#include "panda_qt/ellided_label.hpp"
|
|
||||||
|
|
||||||
// Based on https://stackoverflow.com/questions/7381100/text-overflow-for-a-qlabel-s-text-rendering-in-qt
|
|
||||||
EllidedLabel::EllidedLabel(Qt::TextElideMode elideMode, QWidget* parent) : EllidedLabel("", elideMode, parent) {}
|
|
||||||
|
|
||||||
EllidedLabel::EllidedLabel(QString text, Qt::TextElideMode elideMode, QWidget* parent) : QLabel(parent) {
|
|
||||||
m_elideMode = elideMode;
|
|
||||||
setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EllidedLabel::setText(QString text) {
|
|
||||||
m_text = text;
|
|
||||||
updateText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EllidedLabel::resizeEvent(QResizeEvent* event) {
|
|
||||||
QLabel::resizeEvent(event);
|
|
||||||
updateText();
|
|
||||||
}
|
|
||||||
|
|
||||||
void EllidedLabel::updateText() {
|
|
||||||
QFontMetrics metrics(font());
|
|
||||||
QString elided = metrics.elidedText(m_text, m_elideMode, width());
|
|
||||||
QLabel::setText(elided);
|
|
||||||
}
|
|
|
@ -20,7 +20,7 @@ PatchWindow::PatchWindow(QWidget* parent) : QWidget(parent, Qt::Window) {
|
||||||
QHBoxLayout* inputLayout = new QHBoxLayout;
|
QHBoxLayout* inputLayout = new QHBoxLayout;
|
||||||
QLabel* inputText = new QLabel(tr("Select input file"));
|
QLabel* inputText = new QLabel(tr("Select input file"));
|
||||||
QPushButton* inputButton = new QPushButton(tr("Select"));
|
QPushButton* inputButton = new QPushButton(tr("Select"));
|
||||||
inputPathLabel = new EllidedLabel("");
|
inputPathLabel = new ElidedLabel("");
|
||||||
inputPathLabel->setFixedWidth(200);
|
inputPathLabel->setFixedWidth(200);
|
||||||
|
|
||||||
inputLayout->addWidget(inputText);
|
inputLayout->addWidget(inputText);
|
||||||
|
@ -32,7 +32,7 @@ PatchWindow::PatchWindow(QWidget* parent) : QWidget(parent, Qt::Window) {
|
||||||
QHBoxLayout* patchLayout = new QHBoxLayout;
|
QHBoxLayout* patchLayout = new QHBoxLayout;
|
||||||
QLabel* patchText = new QLabel(tr("Select patch file"));
|
QLabel* patchText = new QLabel(tr("Select patch file"));
|
||||||
QPushButton* patchButton = new QPushButton(tr("Select"));
|
QPushButton* patchButton = new QPushButton(tr("Select"));
|
||||||
patchPathLabel = new EllidedLabel("");
|
patchPathLabel = new ElidedLabel("");
|
||||||
patchPathLabel->setFixedWidth(200);
|
patchPathLabel->setFixedWidth(200);
|
||||||
|
|
||||||
patchLayout->addWidget(patchText);
|
patchLayout->addWidget(patchText);
|
||||||
|
|
Loading…
Add table
Reference in a new issue