mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 16:06:44 +00:00
Preliminary support for new profiles and some other modifications and cleanups
This commit is contained in:
parent
557e659e15
commit
314bac7862
7 changed files with 169 additions and 94 deletions
|
@ -4,12 +4,14 @@ set(LAUNCHER
|
||||||
main.cpp
|
main.cpp
|
||||||
maindialog.cpp
|
maindialog.cpp
|
||||||
playpage.cpp
|
playpage.cpp
|
||||||
|
graphicspage.cpp
|
||||||
|
|
||||||
datafilespage.hpp
|
datafilespage.hpp
|
||||||
lineedit.hpp
|
lineedit.hpp
|
||||||
maindialog.hpp
|
maindialog.hpp
|
||||||
playpage.hpp
|
playpage.hpp
|
||||||
combobox.hpp
|
combobox.hpp
|
||||||
|
graphicspage.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(MOC_HDRS
|
set(MOC_HDRS
|
||||||
|
@ -18,6 +20,7 @@ set(MOC_HDRS
|
||||||
maindialog.hpp
|
maindialog.hpp
|
||||||
playpage.hpp
|
playpage.hpp
|
||||||
combobox.hpp
|
combobox.hpp
|
||||||
|
graphicspage.hpp
|
||||||
)
|
)
|
||||||
|
|
||||||
find_package(Qt4 REQUIRED)
|
find_package(Qt4 REQUIRED)
|
||||||
|
|
|
@ -31,6 +31,32 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
mMastersWidget = new QTableWidget(this); // Contains the available masters
|
mMastersWidget = new QTableWidget(this); // Contains the available masters
|
||||||
mPluginsTable = new QTableView(this);
|
mPluginsTable = new QTableView(this);
|
||||||
|
|
||||||
|
mMastersWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
mMastersWidget->setSelectionMode(QAbstractItemView::MultiSelection);
|
||||||
|
mMastersWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
mMastersWidget->setAlternatingRowColors(true);
|
||||||
|
mMastersWidget->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
mMastersWidget->horizontalHeader()->hide();
|
||||||
|
mMastersWidget->verticalHeader()->hide();
|
||||||
|
mMastersWidget->insertColumn(0);
|
||||||
|
|
||||||
|
mPluginsTable->setModel(mPluginsModel);
|
||||||
|
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
||||||
|
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||||
|
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||||
|
mPluginsTable->setAlternatingRowColors(true);
|
||||||
|
mPluginsTable->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
mPluginsTable->horizontalHeader()->hide();
|
||||||
|
|
||||||
|
mPluginsTable->setDragEnabled(true);
|
||||||
|
mPluginsTable->setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
|
mPluginsTable->setDropIndicatorShown(true);
|
||||||
|
mPluginsTable->setDragDropOverwriteMode(false);
|
||||||
|
mPluginsTable->viewport()->setAcceptDrops(true);
|
||||||
|
|
||||||
|
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
|
||||||
// Add both tables to a splitter
|
// Add both tables to a splitter
|
||||||
QSplitter *splitter = new QSplitter(this);
|
QSplitter *splitter = new QSplitter(this);
|
||||||
splitter->setOrientation(Qt::Horizontal);
|
splitter->setOrientation(Qt::Horizontal);
|
||||||
|
@ -46,31 +72,31 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
// Bottom part with profile options
|
// Bottom part with profile options
|
||||||
QLabel *profileLabel = new QLabel(tr("Current Profile:"), this);
|
QLabel *profileLabel = new QLabel(tr("Current Profile:"), this);
|
||||||
|
|
||||||
mProfilesModel = new QStringListModel();
|
//mProfilesModel = new QStringListModel();
|
||||||
|
|
||||||
mProfilesComboBox = new ComboBox(this);
|
mProfilesComboBox = new ComboBox(this);
|
||||||
mProfilesComboBox->setModel(mProfilesModel);
|
//mProfilesComboBox->setModel(mProfilesModel);
|
||||||
|
|
||||||
mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
|
||||||
mProfilesComboBox->setInsertPolicy(QComboBox::InsertAtBottom);
|
mProfilesComboBox->setInsertPolicy(QComboBox::InsertAtBottom);
|
||||||
//mProfileComboBox->addItem(QString("New Profile"));
|
//mProfileComboBox->addItem(QString("New Profile"));
|
||||||
|
|
||||||
QToolButton *NewProfileToolButton = new QToolButton(this);
|
mNewProfileButton = new QPushButton(this);
|
||||||
NewProfileToolButton->setIcon(QIcon::fromTheme("document-new"));
|
mNewProfileButton->setIcon(QIcon::fromTheme("document-new"));
|
||||||
|
|
||||||
QToolButton *CopyProfileToolButton = new QToolButton(this);
|
mCopyProfileButton = new QPushButton(this);
|
||||||
CopyProfileToolButton->setIcon(QIcon::fromTheme("edit-copy"));
|
mCopyProfileButton->setIcon(QIcon::fromTheme("edit-copy"));
|
||||||
|
|
||||||
QToolButton *DeleteProfileToolButton = new QToolButton(this);
|
mDeleteProfileButton = new QPushButton(this);
|
||||||
DeleteProfileToolButton->setIcon(QIcon::fromTheme("document-close"));
|
mDeleteProfileButton->setIcon(QIcon::fromTheme("document-close"));
|
||||||
|
|
||||||
QHBoxLayout *bottomLayout = new QHBoxLayout();
|
QHBoxLayout *bottomLayout = new QHBoxLayout();
|
||||||
|
|
||||||
bottomLayout->addWidget(profileLabel);
|
bottomLayout->addWidget(profileLabel);
|
||||||
bottomLayout->addWidget(mProfilesComboBox);
|
bottomLayout->addWidget(mProfilesComboBox);
|
||||||
bottomLayout->addWidget(NewProfileToolButton);
|
bottomLayout->addWidget(mNewProfileButton);
|
||||||
bottomLayout->addWidget(CopyProfileToolButton);
|
bottomLayout->addWidget(mCopyProfileButton);
|
||||||
bottomLayout->addWidget(DeleteProfileToolButton);
|
bottomLayout->addWidget(mDeleteProfileButton);
|
||||||
|
|
||||||
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
QVBoxLayout *pageLayout = new QVBoxLayout(this);
|
||||||
// Add some space above and below the page items
|
// Add some space above and below the page items
|
||||||
|
@ -95,43 +121,42 @@ DataFilesPage::DataFilesPage(QWidget *parent) : QWidget(parent)
|
||||||
//connect(mProfileComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(profileChanged(const QString&)));
|
//connect(mProfileComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(profileChanged(const QString&)));
|
||||||
connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&)));
|
connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&)));
|
||||||
|
|
||||||
|
connect(mNewProfileButton, SIGNAL(pressed()), this, SLOT(newProfile()));
|
||||||
|
|
||||||
setupDataFiles();
|
|
||||||
setupConfig();
|
setupConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles()
|
void DataFilesPage::newProfile()
|
||||||
{
|
{
|
||||||
mMastersWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
|
bool ok;
|
||||||
mMastersWidget->setSelectionMode(QAbstractItemView::MultiSelection);
|
QString text = QInputDialog::getText(this, tr("New Profile"),
|
||||||
mMastersWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
tr("Profile Name:"), QLineEdit::Normal,
|
||||||
mMastersWidget->setAlternatingRowColors(true);
|
tr("New Profile"), &ok);
|
||||||
mMastersWidget->horizontalHeader()->setStretchLastSection(true);
|
if (ok && !text.isEmpty()) {
|
||||||
mMastersWidget->horizontalHeader()->hide();
|
if (mProfilesComboBox->findText(text) != -1)
|
||||||
mMastersWidget->verticalHeader()->hide();
|
{
|
||||||
mMastersWidget->insertColumn(0);
|
QMessageBox::warning(this, tr("Profile already exists"),
|
||||||
|
tr("the profile %0 already exists.").arg(text),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
} else {
|
||||||
|
// Add the new profile to the combobox
|
||||||
|
mProfilesComboBox->addItem(text);
|
||||||
|
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text));
|
||||||
|
|
||||||
mPluginsTable->setModel(mPluginsModel);
|
}
|
||||||
mPluginsTable->setSelectionModel(mPluginsSelectModel);
|
|
||||||
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
||||||
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
||||||
mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
||||||
mPluginsTable->setAlternatingRowColors(true);
|
|
||||||
mPluginsTable->horizontalHeader()->setStretchLastSection(true);
|
|
||||||
mPluginsTable->horizontalHeader()->hide();
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
mPluginsTable->setDragEnabled(true);
|
//textLabel->setText(text);
|
||||||
mPluginsTable->setDragDropMode(QAbstractItemView::InternalMove);
|
|
||||||
mPluginsTable->setDropIndicatorShown(true);
|
|
||||||
mPluginsTable->setDragDropOverwriteMode(false);
|
|
||||||
mPluginsTable->viewport()->setAcceptDrops(true);
|
|
||||||
|
|
||||||
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::setupDataFiles(const QString &path)
|
||||||
|
{
|
||||||
|
qDebug() << "setupDataFiles called!";
|
||||||
// TODO: Add a warning when a master is missing
|
// TODO: Add a warning when a master is missing
|
||||||
|
|
||||||
QDir dataFilesDir("data/");
|
QDir dataFilesDir(path);
|
||||||
|
|
||||||
if (!dataFilesDir.exists())
|
if (!dataFilesDir.exists())
|
||||||
qWarning("Cannot find the plugin directory");
|
qWarning("Cannot find the plugin directory");
|
||||||
|
@ -165,8 +190,10 @@ void DataFilesPage::setupDataFiles()
|
||||||
QString currentFile = pluginFiles.at(i);
|
QString currentFile = pluginFiles.at(i);
|
||||||
QStringList availableMasters; // Will contain all found masters
|
QStringList availableMasters; // Will contain all found masters
|
||||||
|
|
||||||
QString path = QString("data/").append(currentFile);
|
QString filePath = dataFilesDir.absolutePath();
|
||||||
fileReader.open(path.toStdString());
|
filePath.append("/");
|
||||||
|
filePath.append(currentFile);
|
||||||
|
fileReader.open(filePath.toStdString());
|
||||||
|
|
||||||
// First we fill the availableMasters and the mMastersWidget
|
// First we fill the availableMasters and the mMastersWidget
|
||||||
ESMReader::MasterList mlist = fileReader.getMasters();
|
ESMReader::MasterList mlist = fileReader.getMasters();
|
||||||
|
@ -203,6 +230,8 @@ void DataFilesPage::setupDataFiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupConfig()
|
void DataFilesPage::setupConfig()
|
||||||
|
@ -230,7 +259,8 @@ void DataFilesPage::setupConfig()
|
||||||
profiles.append("Default");
|
profiles.append("Default");
|
||||||
}
|
}
|
||||||
|
|
||||||
mProfilesModel->setStringList(profiles);
|
//mProfilesModel->setStringList(profiles);
|
||||||
|
mProfilesComboBox->addItems(profiles);
|
||||||
|
|
||||||
QString currentProfile = mLauncherConfig->value("CurrentProfile").toString();
|
QString currentProfile = mLauncherConfig->value("CurrentProfile").toString();
|
||||||
if (currentProfile.isEmpty()) {
|
if (currentProfile.isEmpty()) {
|
||||||
|
@ -239,8 +269,6 @@ void DataFilesPage::setupConfig()
|
||||||
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(currentProfile));
|
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(currentProfile));
|
||||||
|
|
||||||
mLauncherConfig->endGroup();
|
mLauncherConfig->endGroup();
|
||||||
|
|
||||||
readConfig();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
|
||||||
|
@ -419,7 +447,8 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
|
||||||
}
|
}
|
||||||
|
|
||||||
uncheckPlugins();
|
uncheckPlugins();
|
||||||
|
// Deselect the masters
|
||||||
|
mMastersWidget->selectionModel()->clearSelection();
|
||||||
readConfig();
|
readConfig();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -438,7 +467,6 @@ void DataFilesPage::readConfig()
|
||||||
mLauncherConfig->beginGroup(profile);
|
mLauncherConfig->beginGroup(profile);
|
||||||
|
|
||||||
QStringList childKeys = mLauncherConfig->childKeys();
|
QStringList childKeys = mLauncherConfig->childKeys();
|
||||||
qDebug() << childKeys << "SJILDKIEJS";
|
|
||||||
|
|
||||||
foreach (const QString &key, childKeys) {
|
foreach (const QString &key, childKeys) {
|
||||||
const QString keyValue = mLauncherConfig->value(key).toString();
|
const QString keyValue = mLauncherConfig->value(key).toString();
|
||||||
|
@ -456,7 +484,7 @@ void DataFilesPage::readConfig()
|
||||||
|
|
||||||
if (key.startsWith("Master")) {
|
if (key.startsWith("Master")) {
|
||||||
qDebug() << "Read master: " << keyValue;
|
qDebug() << "Read master: " << keyValue;
|
||||||
QList<QTableWidgetItem*> masterList = mMastersWidget->findItems(keyValue, Qt::MatchExactly);
|
QList<QTableWidgetItem*> masterList = mMastersWidget->findItems(keyValue, Qt::MatchFixedString);
|
||||||
|
|
||||||
if (!masterList.isEmpty()) {
|
if (!masterList.isEmpty()) {
|
||||||
foreach (QTableWidgetItem *currentMaster, masterList) {
|
foreach (QTableWidgetItem *currentMaster, masterList) {
|
||||||
|
@ -486,11 +514,12 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
|
|
||||||
// Open the profile-name subgroup
|
// Open the profile-name subgroup
|
||||||
mLauncherConfig->beginGroup(profile);
|
mLauncherConfig->beginGroup(profile);
|
||||||
mLauncherConfig->remove("");
|
mLauncherConfig->remove(""); // Clear the subgroup
|
||||||
|
|
||||||
// First write the masters to the config
|
// First write the masters to the config
|
||||||
QList<QTableWidgetItem *> selectedMasters = mMastersWidget->selectedItems();
|
QList<QTableWidgetItem *> selectedMasters = mMastersWidget->selectedItems();
|
||||||
|
|
||||||
|
// We don't use foreach because we need i
|
||||||
for (int i = 0; i < selectedMasters.size(); ++i) {
|
for (int i = 0; i < selectedMasters.size(); ++i) {
|
||||||
const QTableWidgetItem *item = selectedMasters.at(i);
|
const QTableWidgetItem *item = selectedMasters.at(i);
|
||||||
mLauncherConfig->setValue(QString("Master%0").arg(i), item->data(Qt::DisplayRole).toString());
|
mLauncherConfig->setValue(QString("Master%0").arg(i), item->data(Qt::DisplayRole).toString());
|
||||||
|
@ -504,9 +533,7 @@ void DataFilesPage::writeConfig(QString profile)
|
||||||
mLauncherConfig->setValue(QString("Plugin%1").arg(i), plugins.at(i));
|
mLauncherConfig->setValue(QString("Plugin%1").arg(i), plugins.at(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << mLauncherConfig->childKeys();
|
|
||||||
mLauncherConfig->endGroup();
|
mLauncherConfig->endGroup();
|
||||||
qDebug() << mLauncherConfig->childKeys();
|
|
||||||
mLauncherConfig->endGroup();
|
mLauncherConfig->endGroup();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ class QItemSelection;
|
||||||
class QItemSelectionModel;
|
class QItemSelectionModel;
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
class QPushButton;
|
||||||
|
|
||||||
class DataFilesPage : public QWidget
|
class DataFilesPage : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -22,7 +23,7 @@ public:
|
||||||
DataFilesPage(QWidget *parent = 0);
|
DataFilesPage(QWidget *parent = 0);
|
||||||
|
|
||||||
ComboBox *mProfilesComboBox;
|
ComboBox *mProfilesComboBox;
|
||||||
QStringListModel *mProfilesModel;
|
//QStringListModel *mProfilesModel;
|
||||||
QSettings *mLauncherConfig;
|
QSettings *mLauncherConfig;
|
||||||
|
|
||||||
const QStringList checkedPlugins();
|
const QStringList checkedPlugins();
|
||||||
|
@ -30,11 +31,14 @@ public:
|
||||||
void readConfig();
|
void readConfig();
|
||||||
void writeConfig(QString profile = QString());
|
void writeConfig(QString profile = QString());
|
||||||
|
|
||||||
|
void setupDataFiles(const QString &path);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
|
||||||
void setCheckstate(QModelIndex index);
|
void setCheckstate(QModelIndex index);
|
||||||
void resizeRows();
|
void resizeRows();
|
||||||
void profileChanged(const QString &previous, const QString ¤t);
|
void profileChanged(const QString &previous, const QString ¤t);
|
||||||
|
void newProfile();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTableWidget *mMastersWidget;
|
QTableWidget *mMastersWidget;
|
||||||
|
@ -45,7 +49,10 @@ private:
|
||||||
|
|
||||||
QItemSelectionModel *mPluginsSelectModel;
|
QItemSelectionModel *mPluginsSelectModel;
|
||||||
|
|
||||||
void setupDataFiles();
|
QPushButton *mNewProfileButton;
|
||||||
|
QPushButton *mCopyProfileButton;
|
||||||
|
QPushButton *mDeleteProfileButton;
|
||||||
|
|
||||||
void addPlugins(const QModelIndex &index);
|
void addPlugins(const QModelIndex &index);
|
||||||
void removePlugins(const QModelIndex &index);
|
void removePlugins(const QModelIndex &index);
|
||||||
void uncheckPlugins();
|
void uncheckPlugins();
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include "graphicspage.hpp"
|
||||||
|
|
||||||
|
GraphicsPage::GraphicsPage(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1 +1,15 @@
|
||||||
|
#ifndef GRAPHICSPAGE_H
|
||||||
|
#define GRAPHICSPAGE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class GraphicsPage : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
GraphicsPage(QWidget *parent = 0);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <components/files/path.hpp>
|
||||||
|
|
||||||
#include "maindialog.hpp"
|
#include "maindialog.hpp"
|
||||||
#include "playpage.hpp"
|
#include "playpage.hpp"
|
||||||
|
#include "graphicspage.hpp"
|
||||||
#include "datafilespage.hpp"
|
#include "datafilespage.hpp"
|
||||||
|
|
||||||
MainDialog::MainDialog()
|
MainDialog::MainDialog()
|
||||||
{
|
{
|
||||||
/* TODO: Should be an install path
|
|
||||||
QFile file("apps/launcher/resources/launcher.qss");
|
|
||||||
|
|
||||||
file.open(QFile::ReadOnly);
|
|
||||||
QString styleSheet = QLatin1String(file.readAll());
|
|
||||||
qDebug() << styleSheet;
|
|
||||||
setStyleSheet(styleSheet);*/
|
|
||||||
|
|
||||||
mIconWidget = new QListWidget;
|
mIconWidget = new QListWidget;
|
||||||
mIconWidget->setViewMode(QListView::IconMode);
|
mIconWidget->setViewMode(QListView::IconMode);
|
||||||
mIconWidget->setWrapping(false);
|
mIconWidget->setWrapping(false);
|
||||||
|
|
||||||
mIconWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Just to be sure
|
mIconWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // Just to be sure
|
||||||
|
|
||||||
|
|
||||||
mIconWidget->setIconSize(QSize(48, 48));
|
mIconWidget->setIconSize(QSize(48, 48));
|
||||||
mIconWidget->setMovement(QListView::Static);
|
mIconWidget->setMovement(QListView::Static);
|
||||||
|
|
||||||
|
mIconWidget->setStyleSheet("background-image: url(:/images/openmw-header.png); \
|
||||||
|
background-color: white; \
|
||||||
|
background-repeat: no-repeat; \
|
||||||
|
background-attachment: scroll; \
|
||||||
|
background-position: right;");
|
||||||
|
|
||||||
mIconWidget->setMinimumWidth(400);
|
mIconWidget->setMinimumWidth(400);
|
||||||
mIconWidget->setFixedHeight(80);
|
mIconWidget->setFixedHeight(80);
|
||||||
mIconWidget->setSpacing(4);
|
mIconWidget->setSpacing(4);
|
||||||
|
@ -33,27 +31,8 @@ MainDialog::MainDialog()
|
||||||
|
|
||||||
QGroupBox *groupBox = new QGroupBox(this);
|
QGroupBox *groupBox = new QGroupBox(this);
|
||||||
QVBoxLayout *groupLayout = new QVBoxLayout(groupBox);
|
QVBoxLayout *groupLayout = new QVBoxLayout(groupBox);
|
||||||
// TODO: TESTING
|
|
||||||
|
|
||||||
/*mProfileModel = new QStringListModel();
|
|
||||||
QStringList profileList;
|
|
||||||
profileList << "Default" << "Warrior" << "Redemption" << "Cool stuff bro!";
|
|
||||||
mProfileModel->setStringList(profileList);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Various pages
|
|
||||||
mPlayPage = new PlayPage(this);
|
|
||||||
//mPlayPage->mProfileModel->setStringList(profileList);
|
|
||||||
|
|
||||||
mDataFilesPage = new DataFilesPage(this);
|
|
||||||
//mDataFilesPage->mProfileComboBox->setModel(mProfileModel);
|
|
||||||
|
|
||||||
mPagesWidget = new QStackedWidget(groupBox);
|
mPagesWidget = new QStackedWidget(groupBox);
|
||||||
mPagesWidget->addWidget(mPlayPage);
|
|
||||||
mPagesWidget->addWidget(new PlayPage);
|
|
||||||
mPagesWidget->addWidget(mDataFilesPage);
|
|
||||||
//mPagesWidget->addWidget(new QueryPage);
|
|
||||||
|
|
||||||
groupLayout->addWidget(mPagesWidget);
|
groupLayout->addWidget(mPagesWidget);
|
||||||
|
|
||||||
QPushButton *playButton = new QPushButton(tr("Play"));
|
QPushButton *playButton = new QPushButton(tr("Play"));
|
||||||
|
@ -76,46 +55,55 @@ MainDialog::MainDialog()
|
||||||
setWindowTitle(tr("OpenMW Launcher"));
|
setWindowTitle(tr("OpenMW Launcher"));
|
||||||
setMinimumSize(QSize(550, 450));
|
setMinimumSize(QSize(550, 450));
|
||||||
|
|
||||||
createIcons();
|
|
||||||
|
|
||||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(play()));
|
||||||
|
|
||||||
|
setupConfig();
|
||||||
|
createIcons();
|
||||||
|
createPages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainDialog::createIcons()
|
void MainDialog::createIcons()
|
||||||
{
|
{
|
||||||
//QSize itemSize(80, 66);
|
|
||||||
|
|
||||||
QListWidgetItem *configButton = new QListWidgetItem(mIconWidget);
|
QListWidgetItem *configButton = new QListWidgetItem(mIconWidget);
|
||||||
configButton->setIcon(QIcon(":/images/openmw-icon.png"));
|
configButton->setIcon(QIcon(":/images/openmw-icon.png"));
|
||||||
configButton->setText(tr("Play"));
|
configButton->setText(tr("Play"));
|
||||||
configButton->setTextAlignment(Qt::AlignCenter);
|
configButton->setTextAlignment(Qt::AlignCenter);
|
||||||
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
|
||||||
//configButton->setSizeHint(itemSize);
|
|
||||||
QListWidgetItem *updateButton = new QListWidgetItem(mIconWidget);
|
QListWidgetItem *updateButton = new QListWidgetItem(mIconWidget);
|
||||||
updateButton->setIcon(QIcon::fromTheme("video-display"));
|
updateButton->setIcon(QIcon::fromTheme("video-display"));
|
||||||
updateButton->setText(tr("Graphics"));
|
updateButton->setText(tr("Graphics"));
|
||||||
updateButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom | Qt::AlignAbsolute);
|
updateButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom | Qt::AlignAbsolute);
|
||||||
updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
updateButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
|
||||||
//updateButton->setSizeHint(itemSize);
|
|
||||||
|
|
||||||
QListWidgetItem *queryButton = new QListWidgetItem(mIconWidget);
|
QListWidgetItem *queryButton = new QListWidgetItem(mIconWidget);
|
||||||
queryButton->setIcon(QIcon(":/images/openmw-plugin-icon.png"));
|
queryButton->setIcon(QIcon(":/images/openmw-plugin-icon.png"));
|
||||||
queryButton->setText(tr("Data Files"));
|
queryButton->setText(tr("Data Files"));
|
||||||
queryButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
queryButton->setTextAlignment(Qt::AlignHCenter | Qt::AlignBottom);
|
||||||
queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
queryButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||||
|
|
||||||
//queryButton->setSizeHint(itemSize);
|
|
||||||
|
|
||||||
connect(mIconWidget,
|
connect(mIconWidget,
|
||||||
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
||||||
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
|
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
|
||||||
|
|
||||||
connect(mIconWidget,
|
}
|
||||||
SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
|
|
||||||
this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*)));
|
void MainDialog::createPages()
|
||||||
|
{
|
||||||
|
// Various pages
|
||||||
|
mPlayPage = new PlayPage(this);
|
||||||
|
mGraphicsPage = new GraphicsPage(this);
|
||||||
|
mDataFilesPage = new DataFilesPage(this);
|
||||||
|
|
||||||
|
QString dataDir = mGameConfig->value("data").toString();
|
||||||
|
mDataFilesPage->setupDataFiles(dataDir);
|
||||||
|
|
||||||
|
// Add the pages to the stacked widget
|
||||||
|
mPagesWidget->addWidget(mPlayPage);
|
||||||
|
mPagesWidget->addWidget(mGraphicsPage);
|
||||||
|
mPagesWidget->addWidget(mDataFilesPage);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
|
@ -131,13 +119,13 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
|
|
||||||
// The user switched from Data Files to Play
|
// The user switched from Data Files to Play
|
||||||
if (previousPage == QString("Data Files") && currentPage == QString("Play")) {
|
if (previousPage == QString("Data Files") && currentPage == QString("Play")) {
|
||||||
mPlayPage->mProfilesModel->setStringList(mDataFilesPage->mProfilesModel->stringList());
|
//mPlayPage->mProfilesModel->setStringList(mDataFilesPage->mProfilesModel->stringList());
|
||||||
mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
|
//mPlayPage->mProfilesComboBox->setCurrentIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user switched from Play to Data Files
|
// The user switched from Play to Data Files
|
||||||
if (previousPage == QString("Play") && currentPage == QString("Data Files")) {
|
if (previousPage == QString("Play") && currentPage == QString("Data Files")) {
|
||||||
mDataFilesPage->mProfilesComboBox->setCurrentIndex(mPlayPage->mProfilesComboBox->currentIndex());
|
//mDataFilesPage->mProfilesComboBox->setCurrentIndex(mPlayPage->mProfilesComboBox->currentIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,3 +144,24 @@ void MainDialog::play()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainDialog::setupConfig()
|
||||||
|
{
|
||||||
|
// First we read the OpenMW config
|
||||||
|
QString config = "openmw.cfg";
|
||||||
|
QFile file(config);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
config = QString::fromStdString(Files::getPath(Files::Path_ConfigUser,
|
||||||
|
"openmw", "launcher.cfg"));
|
||||||
|
}
|
||||||
|
|
||||||
|
file.setFileName(config); // Just for displaying information
|
||||||
|
qDebug() << "Using config file from " << file.fileName();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
// Open our config file
|
||||||
|
mGameConfig = new QSettings(config, QSettings::IniFormat);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -7,8 +7,10 @@ class QListWidget;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
|
class QSettings;
|
||||||
|
|
||||||
class PlayPage;
|
class PlayPage;
|
||||||
|
class GraphicsPage;
|
||||||
class DataFilesPage;
|
class DataFilesPage;
|
||||||
|
|
||||||
class MainDialog : public QDialog
|
class MainDialog : public QDialog
|
||||||
|
@ -27,13 +29,18 @@ public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createIcons();
|
void createIcons();
|
||||||
|
void createPages();
|
||||||
|
void setupConfig();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
QListWidget *mIconWidget;
|
QListWidget *mIconWidget;
|
||||||
QStackedWidget *mPagesWidget;
|
QStackedWidget *mPagesWidget;
|
||||||
|
|
||||||
PlayPage *mPlayPage;
|
PlayPage *mPlayPage;
|
||||||
|
GraphicsPage *mGraphicsPage;
|
||||||
DataFilesPage *mDataFilesPage;
|
DataFilesPage *mDataFilesPage;
|
||||||
|
|
||||||
|
QSettings *mGameConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue