1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-24 12:53:54 +00:00
openmw/apps/opencs/view/doc/startup.cpp

130 lines
3.7 KiB
C++
Raw Normal View History

2013-02-02 15:14:58 +00:00
#include "startup.hpp"
2022-09-22 18:26:05 +00:00
#include <QGridLayout>
2022-06-16 19:29:55 +00:00
#include <QGuiApplication>
2013-02-02 15:14:58 +00:00
#include <QHBoxLayout>
#include <QIcon>
2022-09-22 18:26:05 +00:00
#include <QLabel>
#include <QPushButton>
2022-09-22 18:26:05 +00:00
#include <QRect>
#include <QScreen>
2022-09-22 18:26:05 +00:00
#include <QVBoxLayout>
2022-09-22 18:26:05 +00:00
QPushButton* CSVDoc::StartupDialogue::addButton(const QString& label, const QIcon& icon)
{
int column = mColumn--;
2022-09-22 18:26:05 +00:00
QPushButton* button = new QPushButton(this);
2022-09-22 18:26:05 +00:00
button->setIcon(QIcon(icon));
2022-09-22 18:26:05 +00:00
button->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
2022-09-22 18:26:05 +00:00
mLayout->addWidget(button, 0, column);
2022-09-22 18:26:05 +00:00
mLayout->addWidget(new QLabel(label, this), 1, column, Qt::AlignCenter);
2022-09-22 18:26:05 +00:00
int width = mLayout->itemAtPosition(1, column)->widget()->sizeHint().width();
2013-02-02 15:14:58 +00:00
2022-09-22 18:26:05 +00:00
if (width > mWidth)
mWidth = width;
return button;
}
2022-09-22 18:26:05 +00:00
QWidget* CSVDoc::StartupDialogue::createButtons()
2013-02-02 15:14:58 +00:00
{
2022-09-22 18:26:05 +00:00
QWidget* widget = new QWidget(this);
2022-09-22 18:26:05 +00:00
mLayout = new QGridLayout(widget);
2013-02-02 15:14:58 +00:00
/// \todo add icons
2022-09-22 18:26:05 +00:00
QPushButton* loadDocument = addButton("Edit A Content File", QIcon(":startup/edit-content"));
connect(loadDocument, &QPushButton::clicked, this, &StartupDialogue::loadDocument);
2013-02-02 15:14:58 +00:00
2022-09-22 18:26:05 +00:00
QPushButton* createAddon = addButton("Create A New Addon", QIcon(":startup/create-addon"));
connect(createAddon, &QPushButton::clicked, this, &StartupDialogue::createAddon);
2022-09-22 18:26:05 +00:00
QPushButton* createGame = addButton("Create A New Game", QIcon(":startup/create-game"));
connect(createGame, &QPushButton::clicked, this, &StartupDialogue::createGame);
2022-09-22 18:26:05 +00:00
for (int i = 0; i < 3; ++i)
mLayout->setColumnMinimumWidth(i, mWidth);
2022-09-22 18:26:05 +00:00
mLayout->setRowMinimumHeight(0, mWidth);
2022-09-22 18:26:05 +00:00
mLayout->setSizeConstraint(QLayout::SetMinimumSize);
mLayout->setHorizontalSpacing(32);
2022-09-22 18:26:05 +00:00
mLayout->setContentsMargins(16, 16, 16, 8);
2022-09-22 18:26:05 +00:00
loadDocument->setIconSize(QSize(mWidth, mWidth));
createGame->setIconSize(QSize(mWidth, mWidth));
createAddon->setIconSize(QSize(mWidth, mWidth));
2022-09-22 18:26:05 +00:00
widget->setLayout(mLayout);
return widget;
}
2022-09-22 18:26:05 +00:00
QWidget* CSVDoc::StartupDialogue::createTools()
{
2022-09-22 18:26:05 +00:00
QWidget* widget = new QWidget(this);
2022-09-22 18:26:05 +00:00
QHBoxLayout* layout = new QHBoxLayout(widget);
layout->setDirection(QBoxLayout::RightToLeft);
layout->setContentsMargins(4, 4, 4, 4);
2022-09-22 18:26:05 +00:00
QPushButton* config = new QPushButton(widget);
2022-09-22 18:26:05 +00:00
config->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
config->setIcon(QIcon(":startup/configure"));
config->setToolTip("Open user settings");
2022-09-22 18:26:05 +00:00
layout->addWidget(config);
2022-09-22 18:26:05 +00:00
layout->addWidget(new QWidget, 1); // dummy widget; stops buttons from taking all the space
2022-09-22 18:26:05 +00:00
widget->setLayout(layout);
2022-09-22 18:26:05 +00:00
connect(config, &QPushButton::clicked, this, &StartupDialogue::editConfig);
return widget;
}
2022-09-22 18:26:05 +00:00
CSVDoc::StartupDialogue::StartupDialogue()
: mWidth(0)
, mColumn(2)
{
2022-09-22 18:26:05 +00:00
setWindowTitle("OpenMW-CS");
2022-09-22 18:26:05 +00:00
QVBoxLayout* layout = new QVBoxLayout(this);
2022-09-22 18:26:05 +00:00
layout->setContentsMargins(0, 0, 0, 0);
2022-09-22 18:26:05 +00:00
layout->addWidget(createButtons());
layout->addWidget(createTools());
2013-02-02 15:14:58 +00:00
/// \todo remove this label once we are feature complete and convinced that this thing is
/// working properly.
2022-09-22 18:26:05 +00:00
QLabel* warning = new QLabel(
"<font color=Red>WARNING: OpenMW-CS is in alpha stage.<p>The editor is not feature complete and not "
"sufficiently tested.<br>In theory your data should be safe. But we strongly advise to make backups regularly "
"if you are working with live data.</font color>");
QFont font;
2022-09-22 18:26:05 +00:00
font.setPointSize(12);
font.setBold(true);
2022-09-22 18:26:05 +00:00
warning->setFont(font);
warning->setWordWrap(true);
2022-09-22 18:26:05 +00:00
layout->addWidget(warning, 1);
2022-09-22 18:26:05 +00:00
setLayout(layout);
2013-05-08 01:33:42 +00:00
QRect scr = QGuiApplication::primaryScreen()->geometry();
2013-05-08 01:33:42 +00:00
QRect rect = geometry();
2022-09-22 18:26:05 +00:00
move(scr.center().x() - rect.center().x(), scr.center().y() - rect.center().y());
2013-05-08 01:33:42 +00:00
}