s/ellided/elided (#510)

* s/ellided/elided

* Fix header name
This commit is contained in:
wheremyfoodat 2024-05-08 00:20:39 +00:00 committed by GitHub
parent 80527edcb6
commit aa7a6bfe7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 33 additions and 33 deletions

View file

@ -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
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
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})

View file

@ -4,11 +4,11 @@
#include <QString>
#include <QWidget>
class EllidedLabel : public QLabel {
class ElidedLabel : public QLabel {
Q_OBJECT
public:
explicit EllidedLabel(Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
explicit EllidedLabel(QString text, Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
explicit ElidedLabel(Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
explicit ElidedLabel(QString text, Qt::TextElideMode elideMode = Qt::ElideLeft, QWidget* parent = nullptr);
void setText(QString text);
protected:

View file

@ -4,7 +4,7 @@
#include <QWidget>
#include <filesystem>
#include "panda_qt/ellided_label.hpp"
#include "panda_qt/elided_label.hpp"
class PatchWindow final : public QWidget {
Q_OBJECT

View 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);
}

View file

@ -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);
}

View file

@ -20,7 +20,7 @@ PatchWindow::PatchWindow(QWidget* parent) : QWidget(parent, Qt::Window) {
QHBoxLayout* inputLayout = new QHBoxLayout;
QLabel* inputText = new QLabel(tr("Select input file"));
QPushButton* inputButton = new QPushButton(tr("Select"));
inputPathLabel = new EllidedLabel("");
inputPathLabel = new ElidedLabel("");
inputPathLabel->setFixedWidth(200);
inputLayout->addWidget(inputText);
@ -32,7 +32,7 @@ PatchWindow::PatchWindow(QWidget* parent) : QWidget(parent, Qt::Window) {
QHBoxLayout* patchLayout = new QHBoxLayout;
QLabel* patchText = new QLabel(tr("Select patch file"));
QPushButton* patchButton = new QPushButton(tr("Select"));
patchPathLabel = new EllidedLabel("");
patchPathLabel = new ElidedLabel("");
patchPathLabel->setFixedWidth(200);
patchLayout->addWidget(patchText);