mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-08-07 19:25:30 -05:00
add scroll bar to properties in cardinfotextwidget (#6201)
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 42) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 41) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, skip, 22.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-13, Intel, 13, Release, 14.3.1) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-14, Apple, 14, Release, 15.4) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-15, Apple, 15, Release, 16.2) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macos-15, Apple, 15, Debug, 16.2) (push) Blocked by required conditions
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, 5.15.*, 7) (push) Blocked by required conditions
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, 10) (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, 13) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 11) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Debian, DEB, skip, 12) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, 42) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Fedora, RPM, skip, 41) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, 24.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (Ubuntu, DEB, skip, 22.04) (push) Blocked by required conditions
Build Desktop / ${{matrix.distro}} ${{matrix.version}} (yes, Arch, skip) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-13, Intel, 13, Release, 14.3.1) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-14, Apple, 14, Release, 15.4) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (1, macos-15, Apple, 15, Release, 16.2) (push) Blocked by required conditions
Build Desktop / macOS ${{matrix.target}}${{ matrix.soc == 'Intel' && ' Intel' || '' }}${{ matrix.type == 'Debug' && ' Debug' || '' }} (macos-15, Apple, 15, Debug, 16.2) (push) Blocked by required conditions
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, 5.15.*, 7) (push) Blocked by required conditions
Build Desktop / Windows ${{matrix.target}} (msvc2019_64, qtimageformats qtmultimedia qtwebsockets, 6.6.*, 10) (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* add scroll bar to properties in cardinfotextwidget * remove resizeevent trigger
This commit is contained in:
parent
c5b361e94d
commit
a69bfb8cb8
|
|
@ -6,32 +6,55 @@
|
|||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QScrollArea>
|
||||
#include <QScrollBar>
|
||||
#include <QSizePolicy>
|
||||
#include <QTextEdit>
|
||||
|
||||
CardInfoTextWidget::CardInfoTextWidget(QWidget *parent) : QFrame(parent), info(nullptr)
|
||||
{
|
||||
nameLabel = new QLabel;
|
||||
nameLabel->setOpenExternalLinks(false);
|
||||
nameLabel->setWordWrap(true);
|
||||
connect(nameLabel, SIGNAL(linkActivated(const QString &)), this, SIGNAL(linkActivated(const QString &)));
|
||||
propsLabel = new QLabel;
|
||||
propsLabel->setOpenExternalLinks(false);
|
||||
propsLabel->setWordWrap(true);
|
||||
connect(propsLabel, SIGNAL(linkActivated(const QString &)), this, SIGNAL(linkActivated(const QString &)));
|
||||
|
||||
textLabel = new QTextEdit();
|
||||
textLabel->setReadOnly(true);
|
||||
textLabel->setMinimumSize(35, 35);
|
||||
|
||||
propsScroll = new QScrollArea(this);
|
||||
propsScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
propsScroll->setWidgetResizable(true);
|
||||
propsScroll->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
propsScroll->setContentsMargins(0, 0, 0, 0);
|
||||
propsScroll->setFrameStyle(QFrame::NoFrame);
|
||||
propsScroll->setWidget(propsLabel);
|
||||
|
||||
// blend into normal background color, note that themes may override this!
|
||||
propsScroll->viewport()->setStyleSheet("QWidget{background: transparent}");
|
||||
|
||||
auto *grid = new QGridLayout(this);
|
||||
grid->addWidget(nameLabel, 0, 0);
|
||||
grid->addWidget(textLabel, 1, 0, -1, 2);
|
||||
grid->addWidget(propsScroll, 0, 0);
|
||||
grid->addWidget(textLabel, 1, 0);
|
||||
grid->setRowStretch(0, 2);
|
||||
grid->setRowStretch(1, 1);
|
||||
grid->setColumnStretch(1, 1);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void CardInfoTextWidget::setTexts(const QString &propsText, const QString &textText)
|
||||
{
|
||||
propsScroll->setMaximumHeight(0); // reset the max height, otherwise the scrollbar will blink in and out sometimes
|
||||
propsLabel->setText(propsText);
|
||||
propsScroll->setMinimumWidth(propsLabel->minimumWidth() + propsScroll->verticalScrollBar()->width());
|
||||
propsScroll->setMaximumHeight(propsLabel->sizeHint().height());
|
||||
textLabel->setText(textText);
|
||||
}
|
||||
|
||||
void CardInfoTextWidget::setCard(CardInfoPtr card)
|
||||
{
|
||||
if (card == nullptr) {
|
||||
nameLabel->setText("");
|
||||
textLabel->setText("");
|
||||
setTexts("", "");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -61,14 +84,12 @@ void CardInfoTextWidget::setCard(CardInfoPtr card)
|
|||
}
|
||||
|
||||
text += "</table>";
|
||||
nameLabel->setText(text);
|
||||
textLabel->setText(card->getText());
|
||||
setTexts(text, card->getText());
|
||||
}
|
||||
|
||||
void CardInfoTextWidget::setInvalidCardName(const QString &cardName)
|
||||
{
|
||||
nameLabel->setText(tr("Unknown card:") + " " + cardName);
|
||||
textLabel->setText("");
|
||||
setTexts(tr("Unknown card:") + " " + cardName, "");
|
||||
}
|
||||
|
||||
void CardInfoTextWidget::retranslateUi()
|
||||
|
|
@ -77,5 +98,5 @@ void CardInfoTextWidget::retranslateUi()
|
|||
* There's no way we can really translate the text currently being rendered.
|
||||
* The best we can do is invalidate the current text.
|
||||
*/
|
||||
setInvalidCardName("");
|
||||
setTexts("", "");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <QFrame>
|
||||
class QLabel;
|
||||
class QScrollArea;
|
||||
class QTextEdit;
|
||||
|
||||
class CardInfoTextWidget : public QFrame
|
||||
|
|
@ -18,9 +19,11 @@ class CardInfoTextWidget : public QFrame
|
|||
Q_OBJECT
|
||||
|
||||
private:
|
||||
QLabel *nameLabel;
|
||||
QLabel *propsLabel;
|
||||
QScrollArea *propsScroll;
|
||||
QTextEdit *textLabel;
|
||||
CardInfoPtr info;
|
||||
void setTexts(const QString &propsText, const QString &textText);
|
||||
|
||||
public:
|
||||
explicit CardInfoTextWidget(QWidget *parent = nullptr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user