adding in map list item
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QStackedWidget>
|
||||
#include <noggit/ui//windows/noggitWindow/widgets/MapListItem.hpp>
|
||||
#include <noggit/ui/windows/noggitWindow/widgets/MapListItem.hpp>
|
||||
#include <noggit/ui/windows/noggitWindow/widgets/MapBookmarkListItem.hpp>
|
||||
#include <QtNetwork/QTcpSocket>
|
||||
#include <sstream>
|
||||
#include <QSysInfo>
|
||||
@@ -239,8 +240,17 @@ namespace Noggit::Ui::Windows
|
||||
qulonglong bookmark_index (0);
|
||||
for (auto entry : _project->Bookmarks)
|
||||
{
|
||||
auto item (new QListWidgetItem (entry.Name.c_str(), bookmarks_table));
|
||||
auto item = new QListWidgetItem(bookmarks_table);
|
||||
|
||||
auto mapBookmarkData = Widget::MapListBookmarkData();
|
||||
mapBookmarkData.MapName = QString::fromStdString(entry.Name);
|
||||
mapBookmarkData.Position = entry.Position;
|
||||
|
||||
auto mapBookmarkItem = new Widget::MapListBookmarkItem(mapBookmarkData, bookmarks_table);
|
||||
|
||||
item->setData (Qt::UserRole, QVariant (bookmark_index++));
|
||||
item->setSizeHint(mapBookmarkItem->minimumSizeHint());
|
||||
bookmarks_table->setItemWidget(item, mapBookmarkItem);
|
||||
}
|
||||
|
||||
QObject::connect ( bookmarks_table, &QListWidget::itemDoubleClicked
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
#include <QListWidget>
|
||||
#include <noggit/ui/windows/noggitWindow/widgets/MapBookmarkListItem.hpp>
|
||||
#include <noggit/ui/FontAwesome.hpp>
|
||||
#include <sstream>
|
||||
namespace Noggit::Ui::Widget
|
||||
{
|
||||
MapListBookmarkItem::MapListBookmarkItem(const MapListBookmarkData& data, QWidget* parent = nullptr) : QWidget(parent)
|
||||
{
|
||||
auto layout = QGridLayout();
|
||||
|
||||
QIcon icon = FontAwesomeIcon(FontAwesome::bookmark);
|
||||
|
||||
auto colour = new QGraphicsColorizeEffect(this);
|
||||
colour->setColor(QColor(255, 204, 0));
|
||||
colour->setStrength(1.0f);
|
||||
|
||||
map_icon = new QLabel("", parent);
|
||||
map_icon->setPixmap(icon.pixmap(QSize(30, 30)));
|
||||
map_icon->setGeometry(0, 0, 32, 32);
|
||||
map_icon->setObjectName("project-icon-label");
|
||||
map_icon->setStyleSheet("QLabel#project-icon-label { font-size: 12px; padding: 0px;}");
|
||||
map_icon->setGraphicsEffect(colour);
|
||||
map_icon->setAutoFillBackground(true);
|
||||
|
||||
auto projectName = toCamelCase(QString(data.MapName));
|
||||
map_name = new QLabel(projectName, parent);
|
||||
map_name->setGeometry(32, 0, 300, 20);
|
||||
map_name->setObjectName("project-title-label");
|
||||
map_name->setStyleSheet("QLabel#project-title-label { font-size: 12px; }");
|
||||
|
||||
|
||||
auto sstream = std::stringstream();
|
||||
sstream << std::to_string((int)data.Position.x) << " , " << std::to_string((int)data.Position.y) << " , " << std::to_string((int)data.Position.z);
|
||||
|
||||
map_position = new QLabel(QString::fromStdString(sstream.str()), parent);
|
||||
map_position->setGeometry(32, 15, 300, 20);
|
||||
map_position->setObjectName("project-information");
|
||||
map_position->setStyleSheet("QLabel#project-information { font-size: 10px; }");
|
||||
|
||||
auto directoryEffect = new QGraphicsOpacityEffect(this);
|
||||
directoryEffect->setOpacity(0.5);
|
||||
|
||||
map_position->setGraphicsEffect(directoryEffect);
|
||||
map_position->setAutoFillBackground(true);
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
layout.addWidget(map_icon);
|
||||
layout.addWidget(map_name);
|
||||
layout.addWidget(map_position);
|
||||
|
||||
setLayout(layout.layout());
|
||||
}
|
||||
|
||||
QSize MapListBookmarkItem::minimumSizeHint() const
|
||||
{
|
||||
return QSize(300, 32);
|
||||
}
|
||||
|
||||
QString MapListBookmarkItem::toCamelCase(const QString& s)
|
||||
{
|
||||
QStringList parts = s.split(' ', QString::SkipEmptyParts);
|
||||
for (int i = 0; i < parts.size(); ++i)
|
||||
parts[i].replace(0, 1, parts[i][0].toUpper());
|
||||
|
||||
return parts.join(" ");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef NOGGIT_WIGDET_MAP_BOOKMARK_LIST_ITEM_HPP
|
||||
#define NOGGIT_WIGDET_MAP_BOOKMARK_LIST_ITEM_HPP
|
||||
|
||||
#include <QMenuBar>
|
||||
#include <QAction>
|
||||
#include <qgraphicseffect.h>
|
||||
#include <QGridLayout>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <noggit/project/ApplicationProject.h>
|
||||
|
||||
namespace Noggit::Ui::Widget
|
||||
{
|
||||
struct MapListBookmarkData
|
||||
{
|
||||
QString MapName;
|
||||
glm::vec3 Position;
|
||||
};
|
||||
|
||||
class MapListBookmarkItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QLabel* map_icon;
|
||||
QLabel* map_name;
|
||||
QLabel* map_position;
|
||||
int _maxWidth;
|
||||
public:
|
||||
MapListBookmarkItem(const MapListBookmarkData& data, QWidget* parent);
|
||||
QSize minimumSizeHint() const override;
|
||||
private:
|
||||
QString toCamelCase(const QString& s);
|
||||
};
|
||||
}
|
||||
|
||||
#endif //NOGGIT_WIGDET_MAP_BOOKMARK_LIST_ITEM_HPP
|
||||
Reference in New Issue
Block a user