2013-02-02 15:14:58 +00:00
# include "startup.hpp"
2013-05-08 01:33:42 +00:00
# include <QApplication>
# include <QDesktopWidget>
2013-09-08 07:15:26 +00:00
# include <QVBoxLayout>
2013-02-02 15:14:58 +00:00
# include <QHBoxLayout>
2013-05-08 01:33:42 +00:00
# include <QRect>
2013-09-08 07:15:26 +00:00
# include <QGridLayout>
# include <QLabel>
# include <QIcon>
# include <QPushButton>
QPushButton * CSVDoc : : StartupDialogue : : addButton ( const QString & label , const QIcon & icon )
{
2013-09-08 09:24:06 +00:00
int column = mColumn - - ;
2013-09-08 07:15:26 +00:00
QPushButton * button = new QPushButton ( 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 ( ) ;
2013-02-02 15:14:58 +00:00
2013-09-08 07:15:26 +00:00
if ( width > mWidth )
mWidth = width ;
return button ;
}
QWidget * CSVDoc : : StartupDialogue : : createButtons ( )
2013-02-02 15:14:58 +00:00
{
2013-09-08 07:15:26 +00:00
QWidget * widget = new QWidget ( this ) ;
mLayout = new QGridLayout ( widget ) ;
2013-02-02 15:14:58 +00:00
2013-09-08 07:15:26 +00:00
/// \todo add icons
2013-09-09 07:41:43 +00:00
QPushButton * loadDocument = addButton ( " Edit A Content File " , QIcon ( " :startup/edit-content " ) ) ;
2013-09-08 09:24:06 +00:00
connect ( loadDocument , SIGNAL ( clicked ( ) ) , this , SIGNAL ( loadDocument ( ) ) ) ;
2013-02-02 15:14:58 +00:00
2013-09-09 07:41:43 +00:00
QPushButton * createAddon = addButton ( " Create A New Addon " , QIcon ( " :startup/create-addon " ) ) ;
2013-09-08 07:15:26 +00:00
connect ( createAddon , SIGNAL ( clicked ( ) ) , this , SIGNAL ( createAddon ( ) ) ) ;
2013-09-09 07:41:43 +00:00
QPushButton * createGame = addButton ( " Create A New Game " , QIcon ( " :startup/create-game " ) ) ;
2013-09-08 09:24:06 +00:00
connect ( createGame , SIGNAL ( clicked ( ) ) , this , SIGNAL ( createGame ( ) ) ) ;
2013-09-08 07:15:26 +00:00
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 ;
}
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 ) ) ;
2013-09-09 07:41:43 +00:00
config - > setIcon ( QIcon ( " :startup/configure " ) ) ;
2014-07-13 08:52:33 +00:00
config - > setToolTip ( " Open user settings " ) ;
2013-09-08 07:15:26 +00:00
layout - > addWidget ( config ) ;
2013-09-09 07:41:43 +00:00
layout - > addWidget ( new QWidget , 1 ) ; // dummy widget; stops buttons from taking all the space
2013-09-08 07:15:26 +00:00
widget - > setLayout ( layout ) ;
connect ( config , SIGNAL ( clicked ( ) ) , this , SIGNAL ( editConfig ( ) ) ) ;
return widget ;
}
2013-09-08 09:24:06 +00:00
CSVDoc : : StartupDialogue : : StartupDialogue ( ) : mWidth ( 0 ) , mColumn ( 2 )
2013-09-08 07:15:26 +00:00
{
2015-02-24 22:37:53 +00:00
setWindowTitle ( " OpenMW-CS " ) ;
2013-09-08 07:15:26 +00:00
QVBoxLayout * layout = new QVBoxLayout ( this ) ;
layout - > setContentsMargins ( 0 , 0 , 0 , 0 ) ;
layout - > addWidget ( createButtons ( ) ) ;
layout - > addWidget ( createTools ( ) ) ;
2013-02-02 15:14:58 +00:00
2013-09-14 12:00:07 +00:00
/// \todo remove this label once loading and saving are fully implemented
QLabel * warning = new QLabel ( " <font color=Red>WARNING:<p>OpenCS is in alpha stage.<br>The code for loading and saving is incomplete.<br>This version of OpenCS is only a preview.<br>Do NOT use it for real editing!<br>You will lose records both on loading and on saving.<p>Please note:<br>If you lose data and come to the OpenMW forum to complain,<br>we will mock you.</font color> " ) ;
QFont font ;
font . setPointSize ( 12 ) ;
font . setBold ( true ) ;
warning - > setFont ( font ) ;
layout - > addWidget ( warning , 1 ) ;
2013-02-02 15:14:58 +00:00
setLayout ( layout ) ;
2013-05-08 01:33:42 +00:00
QRect scr = QApplication : : desktop ( ) - > screenGeometry ( ) ;
QRect rect = geometry ( ) ;
move ( scr . center ( ) . x ( ) - rect . center ( ) . x ( ) , scr . center ( ) . y ( ) - rect . center ( ) . y ( ) ) ;
}