- code cleanup
- modified layout of config dialog
This commit is contained in:
spacy51 2008-02-21 15:58:29 +00:00
parent a858169d2f
commit bf948ffd1a
7 changed files with 237 additions and 204 deletions

View File

@ -29,7 +29,7 @@
CleanCommandLine="nmake distclean
rmdir /S /Q debug
rmdir /S /Q release"
Output="$(OutDir)\VisualBoyAdvance.exe"
PreprocessorDefinitions="WIN32;_DEBUG"
IncludeSearchPath=""$(ProjectDir)";D:\qt\4.3.3\include"
IncludeSearchPath=""$(ProjectDir)""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
@ -49,7 +49,7 @@
CleanCommandLine="nmake distclean
rmdir /S /Q debug
rmdir /S /Q release"
Output="$(OutDir)\VisualBoyAdvance.exe"
PreprocessorDefinitions="WIN32;NDEBUG"
IncludeSearchPath=""$(ProjectDir)";D:\qt\4.3.3\include"
IncludeSearchPath=""$(ProjectDir)""
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
@ -108,15 +108,43 @@
</File>
</Filter>
</Filter>
<Filter
Name="Config Dialog"
>
<File
RelativePath="..\..\src\qt\configdialog.cpp"
>
</File>
<File
RelativePath="..\..\src\qt\configdialog.h"
>
</File>
<Filter
Name="Pages"
>
<File
RelativePath="..\..\src\qt\MainOptions.cpp"
>
</File>
<File
RelativePath="..\..\src\qt\MainOptions.h"
>
</File>
</Filter>
</Filter>
</Filter>
<Filter
Name="Makefile"
Name="Build"
Filter="pro"
>
<File
RelativePath="..\qmake\vba-m.pro"
>
</File>
<File
RelativePath="..\..\src\qt\vba-m.qrc"
>
</File>
</Filter>
<Filter
Name="Other"

View File

@ -16,116 +16,124 @@
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <QtGui>
#include "MainOptions.h"
#include "MainOptions.h"
VideoOptionsPage::VideoOptionsPage(QWidget *parent)
: QWidget(parent)
{
QGroupBox *RenderGroup = new QGroupBox(tr("Renderer Selection"));
: QWidget(parent)
{
QGroupBox *RenderGroup = new QGroupBox(tr("Renderer Selection"));
QLabel *RenderLabel = new QLabel(tr("Renderer:"));
QComboBox *RenderCombo = new QComboBox;
RenderCombo->addItem(tr("OGL"));
RenderCombo->addItem(tr("D3D"));
RenderCombo->addItem(tr("QPainter"));
QLabel *RenderLabel = new QLabel(tr("Renderer:"));
QComboBox *RenderCombo = new QComboBox;
RenderCombo->addItem(tr("OGL"));
RenderCombo->addItem(tr("D3D"));
RenderCombo->addItem(tr("QPainter"));
QHBoxLayout *RenderLayout = new QHBoxLayout;
RenderLayout->addWidget(RenderLabel);
RenderLayout->addWidget(RenderCombo);
QHBoxLayout *RenderLayout = new QHBoxLayout;
RenderLayout->addWidget(RenderLabel);
RenderLayout->addWidget(RenderCombo);
QVBoxLayout *configLayout = new QVBoxLayout;
configLayout->addLayout(RenderLayout);
RenderGroup->setLayout(configLayout);
QVBoxLayout *configLayout = new QVBoxLayout;
configLayout->addLayout(RenderLayout);
RenderGroup->setLayout(configLayout);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(RenderGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(RenderGroup);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
InputOptionsPage::InputOptionsPage(QWidget *parent)
: QWidget(parent)
{
QGroupBox *InputGroup = new QGroupBox(tr("Input Keys"));
: QWidget(parent)
{
QGroupBox *InputGroup = new QGroupBox(tr("Input Keys"));
QLabel *StartLabel = new QLabel(tr("Start:"));
QLineEdit *StartEdit = new QLineEdit;
QLabel *SelectLabel = new QLabel(tr("Select:"));
QLineEdit *SelectEdit = new QLineEdit;
QLabel *UpLabel = new QLabel(tr("Up:"));
QLineEdit *UpEdit = new QLineEdit;
QLabel *DownLabel = new QLabel(tr("Down:"));
QLineEdit *DownEdit = new QLineEdit;
QLabel *LeftLabel = new QLabel(tr("Left:"));
QLineEdit *LeftEdit = new QLineEdit;
QLabel *RightLabel = new QLabel(tr("Right:"));
QLineEdit *RightEdit = new QLineEdit;
QLabel *ALabel = new QLabel(tr("A:"));
QLineEdit *AEdit = new QLineEdit;
QLabel *BLabel = new QLabel(tr("B:"));
QLineEdit *BEdit = new QLineEdit;
QLabel *LLabel = new QLabel(tr("L:"));
QLineEdit *LEdit = new QLineEdit;
QLabel *RLabel = new QLabel(tr("R:"));
QLineEdit *REdit = new QLineEdit;
QLabel *GSLabel = new QLabel(tr("Gameshark:"));
QLineEdit *GSEdit = new QLineEdit;
QLabel *SpeedUpLabel = new QLabel(tr("Speed Up:"));
QLineEdit *SpeedUpEdit = new QLineEdit;
QLabel *ScreenshotLabel = new QLabel(tr("Screenshot:"));
QLineEdit *ScreenshotEdit = new QLineEdit;
QCheckBox *MultipleAssignCheckBox = new QCheckBox(tr("Multiple key assignments"));
QLabel *StartLabel = new QLabel(tr("Start:"));
QLineEdit *StartEdit = new QLineEdit;
QLabel *SelectLabel = new QLabel(tr("Select:"));
QLineEdit *SelectEdit = new QLineEdit;
QGridLayout *InputLayout = new QGridLayout;
InputLayout->addWidget(StartLabel, 0, 0);
InputLayout->addWidget(StartEdit, 0, 1);
InputLayout->addWidget(SelectLabel, 1, 0);
InputLayout->addWidget(SelectEdit, 1, 1);
InputLayout->addWidget(UpLabel, 2, 0);
InputLayout->addWidget(UpEdit, 2, 1);
InputLayout->addWidget(DownLabel, 3, 0);
InputLayout->addWidget(DownEdit, 3, 1);
InputLayout->addWidget(LeftLabel, 4, 0);
InputLayout->addWidget(LeftEdit, 4, 1);
InputLayout->addWidget(RightLabel, 5, 0);
InputLayout->addWidget(RightEdit, 5, 1);
InputLayout->addWidget(ALabel, 6, 0);
InputLayout->addWidget(AEdit, 6, 1);
InputLayout->addWidget(BLabel, 7, 0);
InputLayout->addWidget(BEdit, 7, 1);
InputLayout->addWidget(LLabel, 8, 0);
InputLayout->addWidget(LEdit, 8, 1);
InputLayout->addWidget(RLabel, 9, 0);
InputLayout->addWidget(REdit, 9, 1);
InputLayout->addWidget(GSLabel, 0, 2);
InputLayout->addWidget(GSEdit, 0, 3);
InputLayout->addWidget(SpeedUpLabel, 1, 2);
InputLayout->addWidget(SpeedUpEdit, 1, 3);
InputLayout->addWidget(ScreenshotLabel, 2, 2);
InputLayout->addWidget(ScreenshotEdit, 2, 3);
InputLayout->addWidget(MultipleAssignCheckBox, 3, 2);
QLabel *UpLabel = new QLabel(tr("Up:"));
QLineEdit *UpEdit = new QLineEdit;
QLabel *DownLabel = new QLabel(tr("Down:"));
QLineEdit *DownEdit = new QLineEdit;
QLabel *LeftLabel = new QLabel(tr("Left:"));
QLineEdit *LeftEdit = new QLineEdit;
QLabel *RightLabel = new QLabel(tr("Right:"));
QLineEdit *RightEdit = new QLineEdit;
QLabel *ALabel = new QLabel(tr("A:"));
QLineEdit *AEdit = new QLineEdit;
QLabel *BLabel = new QLabel(tr("B:"));
QLineEdit *BEdit = new QLineEdit;
QLabel *LLabel = new QLabel(tr("L:"));
QLineEdit *LEdit = new QLineEdit;
QLabel *RLabel = new QLabel(tr("R:"));
QLineEdit *REdit = new QLineEdit;
QLabel *GSLabel = new QLabel(tr("Gameshark:"));
QLineEdit *GSEdit = new QLineEdit;
QLabel *SpeedUpLabel = new QLabel(tr("Speed Up:"));
QLineEdit *SpeedUpEdit = new QLineEdit;
QLabel *ScreenshotLabel = new QLabel(tr("Screenshot:"));
QLineEdit *ScreenshotEdit = new QLineEdit;
QCheckBox *MultipleAssignCheckBox = new QCheckBox(tr("Multiple key assignments"));
InputGroup->setLayout(InputLayout);
QGridLayout *InputLayout = new QGridLayout;
InputLayout->addWidget(StartLabel, 0, 0);
InputLayout->addWidget(StartEdit, 0, 1);
InputLayout->addWidget(SelectLabel, 1, 0);
InputLayout->addWidget(SelectEdit, 1, 1);
InputLayout->addWidget(UpLabel, 2, 0);
InputLayout->addWidget(UpEdit, 2, 1);
InputLayout->addWidget(DownLabel, 3, 0);
InputLayout->addWidget(DownEdit, 3, 1);
InputLayout->addWidget(LeftLabel, 4, 0);
InputLayout->addWidget(LeftEdit, 4, 1);
InputLayout->addWidget(RightLabel, 5, 0);
InputLayout->addWidget(RightEdit, 5, 1);
InputLayout->addWidget(ALabel, 6, 0);
InputLayout->addWidget(AEdit, 6, 1);
InputLayout->addWidget(BLabel, 7, 0);
InputLayout->addWidget(BEdit, 7, 1);
InputLayout->addWidget(LLabel, 8, 0);
InputLayout->addWidget(LEdit, 8, 1);
InputLayout->addWidget(RLabel, 9, 0);
InputLayout->addWidget(REdit, 9, 1);
InputLayout->addWidget(GSLabel, 0, 2);
InputLayout->addWidget(GSEdit, 0, 3);
InputLayout->addWidget(SpeedUpLabel, 1, 2);
InputLayout->addWidget(SpeedUpEdit, 1, 3);
InputLayout->addWidget(ScreenshotLabel, 2, 2);
InputLayout->addWidget(ScreenshotEdit, 2, 3);
InputLayout->addWidget(MultipleAssignCheckBox, 3, 2);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(InputGroup);
mainLayout->addSpacing(12);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
InputGroup->setLayout(InputLayout);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(InputGroup);
mainLayout->addSpacing(12);
mainLayout->addStretch(1);
setLayout(mainLayout);
}
SoundOptionsPage::SoundOptionsPage(QWidget *parent)
: QWidget(parent)
{
}
: QWidget(parent)
{
}

View File

@ -16,29 +16,27 @@
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef MAINOPTIONS_H
#define MAINOPTIONS_H
#include <QWidget>
#include "precompile.h"
class VideoOptionsPage : public QWidget
{
public:
VideoOptionsPage(QWidget *parent = 0);
};
class VideoOptionsPage : public QWidget
{
public:
VideoOptionsPage(QWidget *parent = 0);
};
class InputOptionsPage : public QWidget
{
public:
InputOptionsPage(QWidget *parent = 0);
};
class InputOptionsPage : public QWidget
{
public:
InputOptionsPage(QWidget *parent = 0);
};
class SoundOptionsPage : public QWidget
{
public:
SoundOptionsPage(QWidget *parent = 0);
};
class SoundOptionsPage : public QWidget
{
public:
SoundOptionsPage(QWidget *parent = 0);
};
#endif
#endif

View File

@ -96,13 +96,13 @@ void MainWnd::createMenus()
// File menu
fileMenu = menuBar()->addMenu( tr( "&File" ) );
fileMenu->addAction( tr( "Open ROM" ), this, SLOT( showOpenROM() ) );
fileMenu->addAction( tr( "Open ROM" ), this, SLOT( showOpenROM() ) );
fileMenu->addAction( tr( "Exit" ), this, SLOT( close() ) );
// Settings menu
settingsMenu = menuBar()->addMenu( tr( "&Settings" ) );
settingsMenu->addAction( tr( "Main options..." ), this, SLOT( showMainOptions() ));
settingsMenu->addAction( tr( "Main options..." ), this, SLOT( showMainOptions() ) );
settingsMenu->addAction( tr( "Select language..." ), this, SLOT( selectLanguage() ) );
settingsMenu->addAction( enableTranslationAct );

View File

@ -53,8 +53,8 @@ private slots:
void showAbout();
void showAboutOpenGL();
void showAboutQt();
void showOpenROM();
void showMainOptions();
void showOpenROM();
void showMainOptions();
};
#endif // #ifndef MAINWND_H

View File

@ -15,80 +15,82 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <QtGui>
#include "configdialog.h"
#include "MainOptions.h"
#include "configdialog.h"
ConfigDialog::ConfigDialog()
{
contentsWidget = new QListWidget;
contentsWidget->setViewMode(QListView::IconMode);
contentsWidget->setIconSize(QSize(64, 64));
contentsWidget->setMovement(QListView::Static);
contentsWidget->setResizeMode(QListView::Adjust);
contentsWidget->setMaximumWidth(130);
contentsWidget->setSpacing(12);
#include "MainOptions.h"
pagesWidget = new QStackedWidget;
pagesWidget->addWidget(new VideoOptionsPage);
pagesWidget->addWidget(new SoundOptionsPage);
pagesWidget->addWidget(new InputOptionsPage);
ConfigDialog::ConfigDialog()
{
// close button
QPushButton *closeButton = new QPushButton( tr( "Close" ) );
closeButton->setMaximumSize( closeButton->sizeHint() );
connect( closeButton, SIGNAL( clicked() ), this, SLOT( close() ) );
QPushButton *closeButton = new QPushButton(tr("Close"));
// settings
pagesWidget = new QStackedWidget;
pagesWidget->addWidget( new VideoOptionsPage( pagesWidget ) );
pagesWidget->addWidget( new SoundOptionsPage( pagesWidget ) );
pagesWidget->addWidget( new InputOptionsPage( pagesWidget ) );
createIcons();
contentsWidget->setCurrentRow(0);
// item box
contentsWidget = new QListWidget;
contentsWidget->setViewMode( QListView::IconMode );
contentsWidget->setIconSize( QSize( 64, 64 ) );
contentsWidget->setUniformItemSizes( true ); // enable optimizations
contentsWidget->setMovement( QListView::Static );
contentsWidget->setResizeMode( QListView::Adjust );
contentsWidget->setFlow( QListView::TopToBottom );
contentsWidget->setSpacing( 8 );
createIcons();
contentsWidget->setCurrentRow( 0 );
// set optimal width
int width = contentsWidget->sizeHintForColumn( 0 ) + 16; // not 100% accurate yet!
contentsWidget->setMinimumWidth( width );
contentsWidget->setMaximumWidth( width );
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
// set up layout
QVBoxLayout *verticalLayout = new QVBoxLayout;
verticalLayout->addWidget( pagesWidget );
verticalLayout->addWidget( closeButton, 0, Qt::AlignRight );
QHBoxLayout *horizontalLayout = new QHBoxLayout;
horizontalLayout->addWidget(contentsWidget);
horizontalLayout->addWidget(pagesWidget, 1);
QHBoxLayout *horizontalLayout = new QHBoxLayout( this );
horizontalLayout->addWidget( contentsWidget );
horizontalLayout->addLayout( verticalLayout );
QHBoxLayout *buttonsLayout = new QHBoxLayout;
buttonsLayout->addStretch(1);
buttonsLayout->addWidget(closeButton);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(horizontalLayout);
mainLayout->addStretch(1);
mainLayout->addSpacing(12);
mainLayout->addLayout(buttonsLayout);
setLayout(mainLayout);
setWindowTitle(tr("Options"));
}
setWindowTitle(tr("VBA-M Options"));
}
void ConfigDialog::createIcons()
{
QListWidgetItem *VideoButton = new QListWidgetItem(contentsWidget); // automatically inserts item into parent
VideoButton->setIcon(QIcon(":/resources/video.png"));
VideoButton->setText(tr("Video"));
VideoButton->setTextAlignment(Qt::AlignHCenter);
VideoButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
void ConfigDialog::createIcons()
{
QListWidgetItem *VideoButton = new QListWidgetItem(contentsWidget);
VideoButton->setIcon(QIcon(":/resources/video.png"));
VideoButton->setText(tr("Video"));
VideoButton->setTextAlignment(Qt::AlignHCenter);
VideoButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *SoundButton = new QListWidgetItem(contentsWidget);
SoundButton->setIcon(QIcon(":/resources/sound.png"));
SoundButton->setText(tr("Sound"));
SoundButton->setTextAlignment(Qt::AlignHCenter);
SoundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *SoundButton = new QListWidgetItem(contentsWidget);
SoundButton->setIcon(QIcon(":/resources/sound.png"));
SoundButton->setText(tr("Sound"));
SoundButton->setTextAlignment(Qt::AlignHCenter);
SoundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *InputButton = new QListWidgetItem(contentsWidget);
InputButton->setIcon(QIcon(":/resources/input.png"));
InputButton->setText(tr("Input"));
InputButton->setTextAlignment(Qt::AlignHCenter);
InputButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
QListWidgetItem *InputButton = new QListWidgetItem(contentsWidget);
InputButton->setIcon(QIcon(":/resources/input.png"));
InputButton->setText(tr("Input"));
InputButton->setTextAlignment(Qt::AlignHCenter);
InputButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
}
connect(contentsWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(changePage(QListWidgetItem *, QListWidgetItem*)));
}
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{
if (!current)
current = previous;
void ConfigDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{
if (!current)
current = previous;
pagesWidget->setCurrentIndex(contentsWidget->row(current));
}
pagesWidget->setCurrentIndex(contentsWidget->row(current));
}

View File

@ -15,30 +15,27 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
#include <QDialog>
#ifndef CONFIGDIALOG_H
#define CONFIGDIALOG_H
class QListWidget;
class QListWidgetItem;
class QStackedWidget;
#include "precompile.h"
class ConfigDialog : public QDialog
{
Q_OBJECT
class ConfigDialog : public QDialog
{
Q_OBJECT
public:
ConfigDialog();
public:
ConfigDialog();
public slots:
void changePage( QListWidgetItem *current, QListWidgetItem *previous );
public slots:
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
private:
void createIcons();
QListWidget *contentsWidget;
QStackedWidget *pagesWidget;
};
private:
void createIcons();
QListWidget *contentsWidget;
QStackedWidget *pagesWidget;
};
#endif
#endif