fix: algin instance icon
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
3009356c8a
commit
39c582297e
@ -872,6 +872,8 @@ SET(LAUNCHER_SOURCES
|
||||
# GUI - instance group view
|
||||
ui/instanceview/InstanceProxyModel.cpp
|
||||
ui/instanceview/InstanceProxyModel.h
|
||||
ui/instanceview/InstanceDelegate.h
|
||||
ui/instanceview/InstanceDelegate.cpp
|
||||
ui/instanceview/InstanceView.h
|
||||
ui/instanceview/InstanceView.cpp
|
||||
)
|
||||
|
31
launcher/ui/instanceview/InstanceDelegate.cpp
Normal file
31
launcher/ui/instanceview/InstanceDelegate.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "InstanceDelegate.h"
|
||||
#include "InstanceList.h"
|
||||
|
||||
InstanceDelegate::InstanceDelegate(QObject* parent) : QStyledItemDelegate(parent) {}
|
||||
|
||||
void InstanceDelegate::initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const
|
||||
{
|
||||
QStyledItemDelegate::initStyleOption(option, index);
|
||||
if (index.column() == InstanceList::Icon) {
|
||||
// make decoration fill cell, subtract default margins
|
||||
option->decorationSize = option->rect.size().shrunkBy(QMargins(3, 1, 3, 1));
|
||||
}
|
||||
}
|
30
launcher/ui/instanceview/InstanceDelegate.h
Normal file
30
launcher/ui/instanceview/InstanceDelegate.h
Normal file
@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* PolyMC - Minecraft Launcher
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QStyledItemDelegate>
|
||||
|
||||
class InstanceDelegate : public QStyledItemDelegate {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
InstanceDelegate(QObject* parent = 0);
|
||||
|
||||
void initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const override;
|
||||
};
|
@ -32,7 +32,7 @@ QVariant InstanceProxyModel::data(const QModelIndex& index, int role) const
|
||||
QVariant data = QSortFilterProxyModel::data(index, role);
|
||||
if (role == Qt::DecorationRole) {
|
||||
if (!data.toString().isEmpty())
|
||||
return APPLICATION->icons()->getIcon(data.toString()); // FIXME: Needs QStyledItemDelegate
|
||||
return APPLICATION->icons()->getIcon(data.toString());
|
||||
}
|
||||
|
||||
switch (index.column()) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "InstanceView.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include "InstanceDelegate.h"
|
||||
#include "InstanceList.h"
|
||||
#include "ui/instanceview/InstanceProxyModel.h"
|
||||
|
||||
@ -57,6 +58,7 @@ void InstanceView::createTable()
|
||||
{
|
||||
m_table = new QTableView(this);
|
||||
m_table->setModel(m_proxy);
|
||||
m_table->setItemDelegate(new InstanceDelegate(this));
|
||||
|
||||
m_table->setTabKeyNavigation(false);
|
||||
m_table->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
|
Loading…
x
Reference in New Issue
Block a user