mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
added proper startup dialogue (still missing icons)
This commit is contained in:
parent
5a792b10b9
commit
17bf7e59a4
3 changed files with 120 additions and 11 deletions
|
@ -15,7 +15,8 @@ CS::Editor::Editor() : mViewManager (mDocumentManager)
|
|||
connect (&mViewManager, SIGNAL (newDocumentRequest ()), this, SLOT (createDocument ()));
|
||||
connect (&mViewManager, SIGNAL (loadDocumentRequest ()), this, SLOT (loadDocument ()));
|
||||
|
||||
connect (&mStartup, SIGNAL (createDocument()), this, SLOT (createDocument ()));
|
||||
connect (&mStartup, SIGNAL (createGame()), this, SLOT (createDocument ())); /// \todo split
|
||||
connect (&mStartup, SIGNAL (createAddon()), this, SLOT (createDocument ()));
|
||||
connect (&mStartup, SIGNAL (loadDocument()), this, SLOT (loadDocument ()));
|
||||
|
||||
connect (&mFileDialog, SIGNAL(openFiles()), this, SLOT(openFiles()));
|
||||
|
|
|
@ -3,21 +3,107 @@
|
|||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QRect>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QIcon>
|
||||
#include <QPushButton>
|
||||
|
||||
CSVDoc::StartupDialogue::StartupDialogue()
|
||||
QPushButton *CSVDoc::StartupDialogue::addButton (const QString& label, const QIcon& icon)
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout (this);
|
||||
int column = mColumn++;
|
||||
|
||||
QPushButton *createDocument = new QPushButton ("new", this);
|
||||
connect (createDocument, SIGNAL (clicked()), this, SIGNAL (createDocument()));
|
||||
layout->addWidget (createDocument);
|
||||
QPushButton *button = new QPushButton (this);
|
||||
|
||||
QPushButton *loadDocument = new QPushButton ("load", this);
|
||||
button->setIcon (QIcon (icon));
|
||||
|
||||
button->setSizePolicy (QSizePolicy (QSizePolicy::Preferred, QSizePolicy::Preferred));
|
||||
|
||||
mLayout->addWidget (button, 0, column);
|
||||
|
||||
mLayout->addWidget (new QLabel (label, this), 1, column, Qt::AlignCenter);
|
||||
|
||||
int width = mLayout->itemAtPosition (1, column)->widget()->sizeHint().width();
|
||||
|
||||
if (width>mWidth)
|
||||
mWidth = width;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
QWidget *CSVDoc::StartupDialogue::createButtons()
|
||||
{
|
||||
QWidget *widget = new QWidget (this);
|
||||
|
||||
mLayout = new QGridLayout (widget);
|
||||
|
||||
/// \todo add icons
|
||||
QPushButton *createGame = addButton ("Create A New Game", QIcon (""));
|
||||
connect (createGame, SIGNAL (clicked()), this, SIGNAL (createGame()));
|
||||
|
||||
QPushButton *createAddon = addButton ("Create A New Addon", QIcon (""));
|
||||
connect (createAddon, SIGNAL (clicked()), this, SIGNAL (createAddon()));
|
||||
|
||||
QPushButton *loadDocument = addButton ("Edit A Content File", QIcon (""));
|
||||
connect (loadDocument, SIGNAL (clicked()), this, SIGNAL (loadDocument()));
|
||||
layout->addWidget (loadDocument);
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
mLayout->setColumnMinimumWidth (i, mWidth);
|
||||
|
||||
mLayout->setRowMinimumHeight (0, mWidth);
|
||||
|
||||
mLayout->setSizeConstraint (QLayout::SetMinimumSize);
|
||||
mLayout->setHorizontalSpacing (32);
|
||||
|
||||
mLayout->setContentsMargins (16, 16, 16, 8);
|
||||
|
||||
loadDocument->setIconSize (QSize (mWidth, mWidth));
|
||||
createGame->setIconSize (QSize (mWidth, mWidth));
|
||||
createAddon->setIconSize (QSize (mWidth, mWidth));
|
||||
|
||||
widget->setLayout (mLayout);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
#include <QStyle>
|
||||
QWidget *CSVDoc::StartupDialogue::createTools()
|
||||
{
|
||||
QWidget *widget = new QWidget (this);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout (widget);
|
||||
layout->setDirection (QBoxLayout::RightToLeft);
|
||||
layout->setContentsMargins (4, 4, 4, 4);
|
||||
|
||||
QPushButton *config = new QPushButton (widget);
|
||||
|
||||
config->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed));
|
||||
config->setIcon (style()->standardIcon (QStyle::SP_FileDialogStart)); /// \todo replace icon
|
||||
|
||||
layout->addWidget (config);
|
||||
|
||||
layout->addWidget (new QWidget, 1); // dummy icon; stops buttons from taking all the space
|
||||
|
||||
widget->setLayout (layout);
|
||||
|
||||
connect (config, SIGNAL (clicked()), this, SIGNAL (editConfig()));
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
CSVDoc::StartupDialogue::StartupDialogue() : mWidth (0), mColumn (0)
|
||||
{
|
||||
setWindowTitle ("Open CS");
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout (this);
|
||||
|
||||
layout->setContentsMargins (0, 0, 0, 0);
|
||||
|
||||
layout->addWidget (createButtons());
|
||||
layout->addWidget (createTools());
|
||||
|
||||
setLayout (layout);
|
||||
|
||||
|
|
|
@ -3,21 +3,43 @@
|
|||
|
||||
#include <QWidget>
|
||||
|
||||
class QGridLayout;
|
||||
class QString;
|
||||
class QPushButton;
|
||||
class QWidget;
|
||||
class QIcon;
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class StartupDialogue : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
int mWidth;
|
||||
int mColumn;
|
||||
QGridLayout *mLayout;
|
||||
|
||||
QPushButton *addButton (const QString& label, const QIcon& icon);
|
||||
|
||||
QWidget *createButtons();
|
||||
|
||||
QWidget *createTools();
|
||||
|
||||
public:
|
||||
|
||||
StartupDialogue();
|
||||
|
||||
signals:
|
||||
|
||||
void createDocument();
|
||||
void createGame();
|
||||
|
||||
void createAddon();
|
||||
|
||||
void loadDocument();
|
||||
|
||||
void editConfig();
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue