Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into welcome_background
This commit is contained in:
@ -367,7 +367,9 @@ class NoReturnTextEdit : public QTextEdit {
|
||||
void editingDone();
|
||||
};
|
||||
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
void ListViewDelegate::updateEditorGeometry(QWidget* editor,
|
||||
const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
const int iconSize = 48;
|
||||
QRect textRect = option.rect;
|
||||
@ -379,17 +381,17 @@ void ListViewDelegate::updateEditorGeometry(QWidget* editor, const QStyleOptionV
|
||||
void ListViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
|
||||
{
|
||||
auto text = index.data(Qt::EditRole).toString();
|
||||
QTextEdit* realeditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
realeditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realeditor->append(text);
|
||||
realeditor->selectAll();
|
||||
realeditor->document()->clearUndoRedoStacks();
|
||||
QTextEdit* realEditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
realEditor->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||
realEditor->append(text);
|
||||
realEditor->selectAll();
|
||||
realEditor->document()->clearUndoRedoStacks();
|
||||
}
|
||||
|
||||
void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
|
||||
{
|
||||
QTextEdit* realeditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
QString text = realeditor->toPlainText();
|
||||
QTextEdit* realEditor = qobject_cast<NoReturnTextEdit*>(editor);
|
||||
QString text = realEditor->toPlainText();
|
||||
text.replace(QChar('\n'), QChar(' '));
|
||||
text = text.trimmed();
|
||||
// Prevent instance names longer than 128 chars
|
||||
@ -399,7 +401,9 @@ void ListViewDelegate::setModelData(QWidget* editor, QAbstractItemModel* model,
|
||||
}
|
||||
}
|
||||
|
||||
QWidget* ListViewDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
QWidget* ListViewDelegate::createEditor(QWidget* parent,
|
||||
[[maybe_unused]] const QStyleOptionViewItem& option,
|
||||
[[maybe_unused]] const QModelIndex& index) const
|
||||
{
|
||||
auto editor = new NoReturnTextEdit(parent);
|
||||
connect(editor, &NoReturnTextEdit::editingDone, this, &ListViewDelegate::editingDone);
|
||||
|
@ -48,8 +48,8 @@
|
||||
#include <QScrollBar>
|
||||
#include <QtMath>
|
||||
|
||||
#include <QDebug>
|
||||
#include "VisualGroup.h"
|
||||
#include "ui/themes/ThemeManager.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <InstanceList.h>
|
||||
@ -87,16 +87,18 @@ void InstanceView::setModel(QAbstractItemModel* model)
|
||||
connect(model, &QAbstractItemModel::rowsRemoved, this, &InstanceView::rowsRemoved);
|
||||
}
|
||||
|
||||
void InstanceView::dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles)
|
||||
void InstanceView::dataChanged([[maybe_unused]] const QModelIndex& topLeft,
|
||||
[[maybe_unused]] const QModelIndex& bottomRight,
|
||||
[[maybe_unused]] const QVector<int>& roles)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
void InstanceView::rowsInserted(const QModelIndex& parent, int start, int end)
|
||||
void InstanceView::rowsInserted([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
|
||||
void InstanceView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
|
||||
void InstanceView::rowsAboutToBeRemoved([[maybe_unused]] const QModelIndex& parent, [[maybe_unused]] int start, [[maybe_unused]] int end)
|
||||
{
|
||||
scheduleDelayedItemsLayout();
|
||||
}
|
||||
@ -240,9 +242,9 @@ QString InstanceView::groupNameAt(const QPoint& point)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(point + offset(), hitresult);
|
||||
if (group && (hitresult & (VisualGroup::HeaderHit | VisualGroup::BodyHit))) {
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(point + offset(), hitResult);
|
||||
if (group && (hitResult & (VisualGroup::HeaderHit | VisualGroup::BodyHit))) {
|
||||
return group->text;
|
||||
}
|
||||
return QString();
|
||||
@ -276,9 +278,9 @@ void InstanceView::mousePressEvent(QMouseEvent* event)
|
||||
m_pressedAlreadySelected = selectionModel()->isSelected(m_pressedIndex);
|
||||
m_pressedPosition = geometryPos;
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitresult);
|
||||
if (m_pressedCategory && hitresult & VisualGroup::CheckboxHit) {
|
||||
VisualGroup::HitResults hitResult;
|
||||
m_pressedCategory = categoryAt(geometryPos, hitResult);
|
||||
if (m_pressedCategory && hitResult & VisualGroup::CheckboxHit) {
|
||||
setState(m_pressedCategory->collapsed ? ExpandingState : CollapsingState);
|
||||
event->accept();
|
||||
return;
|
||||
@ -362,10 +364,10 @@ void InstanceView::mouseReleaseEvent(QMouseEvent* event)
|
||||
QPoint geometryPos = event->pos() + offset();
|
||||
QPersistentModelIndex index = indexAt(visualPos);
|
||||
|
||||
VisualGroup::HitResults hitresult;
|
||||
VisualGroup::HitResults hitResult;
|
||||
|
||||
bool click =
|
||||
(index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitresult));
|
||||
(index == m_pressedIndex && index.isValid()) || (m_pressedCategory && m_pressedCategory == categoryAt(geometryPos, hitResult));
|
||||
|
||||
if (click && m_pressedCategory) {
|
||||
if (state() == ExpandingState) {
|
||||
@ -445,12 +447,12 @@ void InstanceView::setPaintCat(bool visible)
|
||||
{
|
||||
m_catVisible = visible;
|
||||
if (visible)
|
||||
m_catPixmap.load(APPLICATION->getCatPack());
|
||||
m_catPixmap.load(APPLICATION->themeManager()->getCatPack());
|
||||
else
|
||||
m_catPixmap = QPixmap();
|
||||
}
|
||||
|
||||
void InstanceView::paintEvent(QPaintEvent* event)
|
||||
void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -578,7 +580,7 @@ void InstanceView::paintEvent(QPaintEvent* event)
|
||||
#endif
|
||||
}
|
||||
|
||||
void InstanceView::resizeEvent(QResizeEvent* event)
|
||||
void InstanceView::resizeEvent([[maybe_unused]] QResizeEvent* event)
|
||||
{
|
||||
int newItemsPerRow = calculateItemsPerRow();
|
||||
if (newItemsPerRow != m_currentItemsPerRow) {
|
||||
@ -614,7 +616,7 @@ void InstanceView::dragMoveEvent(QDragMoveEvent* event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void InstanceView::dragLeaveEvent(QDragLeaveEvent* event)
|
||||
void InstanceView::dragLeaveEvent([[maybe_unused]] QDragLeaveEvent* event)
|
||||
{
|
||||
executeDelayedItemsLayout();
|
||||
|
||||
@ -637,9 +639,9 @@ void InstanceView::dropEvent(QDropEvent* event)
|
||||
if (event->possibleActions() & Qt::MoveAction) {
|
||||
std::pair<VisualGroup*, VisualGroup::HitResults> dropPos = rowDropPos(event->pos());
|
||||
const VisualGroup* group = dropPos.first;
|
||||
auto hitresult = dropPos.second;
|
||||
auto hitResult = dropPos.second;
|
||||
|
||||
if (hitresult == VisualGroup::HitResult::NoHit) {
|
||||
if (hitResult == VisualGroup::HitResult::NoHit) {
|
||||
viewport()->update();
|
||||
return;
|
||||
}
|
||||
@ -676,15 +678,15 @@ void InstanceView::startDrag(Qt::DropActions supportedActions)
|
||||
if (indexes.count() == 0)
|
||||
return;
|
||||
|
||||
QMimeData* data = model()->mimeData(indexes);
|
||||
if (!data) {
|
||||
QMimeData* mimeData = model()->mimeData(indexes);
|
||||
if (!mimeData) {
|
||||
return;
|
||||
}
|
||||
QRect rect;
|
||||
QPixmap pixmap = renderToPixmap(indexes, &rect);
|
||||
QDrag* drag = new QDrag(this);
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setMimeData(data);
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setHotSpot(m_pressedPosition - rect.topLeft());
|
||||
Qt::DropAction defaultDropAction = Qt::IgnoreAction;
|
||||
if (this->defaultDropAction() != Qt::IgnoreAction && (supportedActions & this->defaultDropAction())) {
|
||||
@ -800,16 +802,16 @@ QList<std::pair<QRect, QModelIndex>> InstanceView::draggablePaintPairs(const QMo
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool InstanceView::isDragEventAccepted(QDropEvent* event)
|
||||
bool InstanceView::isDragEventAccepted([[maybe_unused]] QDropEvent* event)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::pair<VisualGroup*, VisualGroup::HitResults> InstanceView::rowDropPos(const QPoint& pos)
|
||||
{
|
||||
VisualGroup::HitResults hitresult;
|
||||
auto group = categoryAt(pos + offset(), hitresult);
|
||||
return std::make_pair(group, hitresult);
|
||||
VisualGroup::HitResults hitResult;
|
||||
auto group = categoryAt(pos + offset(), hitResult);
|
||||
return std::make_pair(group, hitResult);
|
||||
}
|
||||
|
||||
QPoint InstanceView::offset() const
|
||||
@ -835,7 +837,7 @@ QRegion InstanceView::visualRegionForSelection(const QItemSelection& selection)
|
||||
return region;
|
||||
}
|
||||
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
|
||||
QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorAction, [[maybe_unused]] Qt::KeyboardModifiers modifiers)
|
||||
{
|
||||
auto current = currentIndex();
|
||||
if (!current.isValid()) {
|
||||
@ -855,20 +857,20 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
switch (cursorAction) {
|
||||
case MoveUp: {
|
||||
if (row == 0) {
|
||||
int prevgroupindex = group_index - 1;
|
||||
while (prevgroupindex >= 0) {
|
||||
auto prevgroup = m_groups[prevgroupindex];
|
||||
if (prevgroup->collapsed) {
|
||||
prevgroupindex--;
|
||||
int prevGroupIndex = group_index - 1;
|
||||
while (prevGroupIndex >= 0) {
|
||||
auto prevGroup = m_groups[prevGroupIndex];
|
||||
if (prevGroup->collapsed) {
|
||||
prevGroupIndex--;
|
||||
continue;
|
||||
}
|
||||
int newRow = prevgroup->numRows() - 1;
|
||||
int newRowSize = prevgroup->rows[newRow].size();
|
||||
int newRow = prevGroup->numRows() - 1;
|
||||
int newRowSize = prevGroup->rows[newRow].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize) {
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return prevgroup->rows[newRow][newColumn];
|
||||
return prevGroup->rows[newRow][newColumn];
|
||||
}
|
||||
} else {
|
||||
int newRow = row - 1;
|
||||
@ -883,19 +885,19 @@ QModelIndex InstanceView::moveCursor(QAbstractItemView::CursorAction cursorActio
|
||||
}
|
||||
case MoveDown: {
|
||||
if (row == cat->rows.size() - 1) {
|
||||
int nextgroupindex = group_index + 1;
|
||||
while (nextgroupindex < m_groups.size()) {
|
||||
auto nextgroup = m_groups[nextgroupindex];
|
||||
if (nextgroup->collapsed) {
|
||||
nextgroupindex++;
|
||||
int nextGroupIndex = group_index + 1;
|
||||
while (nextGroupIndex < m_groups.size()) {
|
||||
auto nextGroup = m_groups[nextGroupIndex];
|
||||
if (nextGroup->collapsed) {
|
||||
nextGroupIndex++;
|
||||
continue;
|
||||
}
|
||||
int newRowSize = nextgroup->rows[0].size();
|
||||
int newRowSize = nextGroup->rows[0].size();
|
||||
int newColumn = m_currentCursorColumn;
|
||||
if (m_currentCursorColumn >= newRowSize) {
|
||||
newColumn = newRowSize - 1;
|
||||
}
|
||||
return nextgroup->rows[0][newColumn];
|
||||
return nextGroup->rows[0][newColumn];
|
||||
}
|
||||
} else {
|
||||
int newRow = row + 1;
|
||||
@ -969,7 +971,7 @@ void InstanceView::scrollTo(const QModelIndex& index, ScrollHint hint)
|
||||
verticalScrollBar()->setValue(verticalScrollToValue(index, rect, hint));
|
||||
}
|
||||
|
||||
int InstanceView::verticalScrollToValue(const QModelIndex& index, const QRect& rect, QListView::ScrollHint hint) const
|
||||
int InstanceView::verticalScrollToValue([[maybe_unused]] const QModelIndex& index, const QRect& rect, QListView::ScrollHint hint) const
|
||||
{
|
||||
const QRect area = viewport()->rect();
|
||||
const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
|
||||
|
Reference in New Issue
Block a user