1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-07 00:15:34 +00:00

Implemented Launcher namespace

This commit is contained in:
graffy76 2013-10-25 11:17:26 -05:00
parent 16d87ea1d1
commit 1a23cccce3
24 changed files with 573 additions and 540 deletions

View file

@ -21,7 +21,7 @@
#include "components/contentselector/view/contentselector.hpp" #include "components/contentselector/view/contentselector.hpp"
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent) Launcher::DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
: mCfgMgr(cfg) : mCfgMgr(cfg)
, mGameSettings(gameSettings) , mGameSettings(gameSettings)
, mLauncherSettings(launcherSettings) , mLauncherSettings(launcherSettings)
@ -35,7 +35,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
setupDataFiles(); setupDataFiles();
} }
void DataFilesPage::loadSettings() void Launcher::DataFilesPage::loadSettings()
{ {
QString profileName = ui.profilesComboBox->currentText(); QString profileName = ui.profilesComboBox->currentText();
@ -53,7 +53,7 @@ void DataFilesPage::loadSettings()
mSelector->setCheckStates(addons); mSelector->setCheckStates(addons);
} }
void DataFilesPage::saveSettings(const QString &profile) void Launcher::DataFilesPage::saveSettings(const QString &profile)
{ {
QString profileName = profile; QString profileName = profile;
@ -84,7 +84,7 @@ void DataFilesPage::saveSettings(const QString &profile)
} }
void DataFilesPage::buildView() void Launcher::DataFilesPage::buildView()
{ {
ui.verticalLayout->insertWidget (0, mSelector->uiWidget()); ui.verticalLayout->insertWidget (0, mSelector->uiWidget());
@ -111,13 +111,23 @@ void DataFilesPage::buildView()
this, SLOT (slotProfileChangedByUser(QString, QString))); this, SLOT (slotProfileChangedByUser(QString, QString)));
} }
void DataFilesPage::removeProfile(const QString &profile) void Launcher::DataFilesPage::removeProfile(const QString &profile)
{ {
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/game")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/game"));
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/addon")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/addon"));
} }
void DataFilesPage::setProfile(int index, bool savePrevious) QAbstractItemModel *Launcher::DataFilesPage::profilesModel() const
{
return ui.profilesComboBox->model();
}
int Launcher::DataFilesPage::profilesIndex() const
{
return ui.profilesComboBox->currentIndex();
}
void Launcher::DataFilesPage::setProfile(int index, bool savePrevious)
{ {
if (index >= -1 && index < ui.profilesComboBox->count()) if (index >= -1 && index < ui.profilesComboBox->count())
{ {
@ -128,7 +138,7 @@ void DataFilesPage::setProfile(int index, bool savePrevious)
} }
} }
void DataFilesPage::setProfile (const QString &previous, const QString &current, bool savePrevious) void Launcher::DataFilesPage::setProfile (const QString &previous, const QString &current, bool savePrevious)
{ {
//abort if no change (poss. duplicate signal) //abort if no change (poss. duplicate signal)
if (previous == current) if (previous == current)
@ -144,18 +154,18 @@ void DataFilesPage::setProfile (const QString &previous, const QString &current,
checkForDefaultProfile(); checkForDefaultProfile();
} }
void DataFilesPage::slotProfileDeleted (const QString &item) void Launcher::DataFilesPage::slotProfileDeleted (const QString &item)
{ {
removeProfile (item); removeProfile (item);
} }
void DataFilesPage::slotProfileChangedByUser(const QString &previous, const QString &current) void Launcher::DataFilesPage::slotProfileChangedByUser(const QString &previous, const QString &current)
{ {
setProfile(previous, current, true); setProfile(previous, current, true);
emit signalProfileChanged (ui.profilesComboBox->findText(current)); emit signalProfileChanged (ui.profilesComboBox->findText(current));
} }
void DataFilesPage::slotProfileRenamed(const QString &previous, const QString &current) void Launcher::DataFilesPage::slotProfileRenamed(const QString &previous, const QString &current)
{ {
if (previous.isEmpty()) if (previous.isEmpty())
return; return;
@ -169,12 +179,12 @@ void DataFilesPage::slotProfileRenamed(const QString &previous, const QString &c
loadSettings(); loadSettings();
} }
void DataFilesPage::slotProfileChanged(int index) void Launcher::DataFilesPage::slotProfileChanged(int index)
{ {
setProfile (index, true); setProfile (index, true);
} }
void DataFilesPage::setupDataFiles() void Launcher::DataFilesPage::setupDataFiles()
{ {
QStringList paths = mGameSettings.getDataDirs(); QStringList paths = mGameSettings.getDataDirs();
@ -197,7 +207,7 @@ void DataFilesPage::setupDataFiles()
loadSettings(); loadSettings();
} }
void DataFilesPage::on_newProfileAction_triggered() void Launcher::DataFilesPage::on_newProfileAction_triggered()
{ {
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this); TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
@ -222,7 +232,7 @@ void DataFilesPage::on_newProfileAction_triggered()
emit signalProfileChanged (ui.profilesComboBox->findText(profile)); emit signalProfileChanged (ui.profilesComboBox->findText(profile));
} }
void DataFilesPage::addProfile (const QString &profile, bool setAsCurrent) void Launcher::DataFilesPage::addProfile (const QString &profile, bool setAsCurrent)
{ {
if (profile.isEmpty()) if (profile.isEmpty())
return; return;
@ -236,7 +246,7 @@ void DataFilesPage::addProfile (const QString &profile, bool setAsCurrent)
setProfile (ui.profilesComboBox->findText (profile), false); setProfile (ui.profilesComboBox->findText (profile), false);
} }
void DataFilesPage::on_deleteProfileAction_triggered() void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
{ {
QString profile = ui.profilesComboBox->currentText(); QString profile = ui.profilesComboBox->currentText();
@ -254,7 +264,7 @@ void DataFilesPage::on_deleteProfileAction_triggered()
checkForDefaultProfile(); checkForDefaultProfile();
} }
void DataFilesPage::checkForDefaultProfile() void Launcher::DataFilesPage::checkForDefaultProfile()
{ {
//don't allow deleting "Default" profile //don't allow deleting "Default" profile
bool success = (ui.profilesComboBox->currentText() != "Default"); bool success = (ui.profilesComboBox->currentText() != "Default");
@ -263,7 +273,7 @@ void DataFilesPage::checkForDefaultProfile()
ui.profilesComboBox->setEditEnabled (success); ui.profilesComboBox->setEditEnabled (success);
} }
bool DataFilesPage::showDeleteMessageBox (const QString &text) bool Launcher::DataFilesPage::showDeleteMessageBox (const QString &text)
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Delete Profile")); msgBox.setWindowTitle(tr("Delete Profile"));

View file

@ -3,21 +3,21 @@
#include "ui_datafilespage.h" #include "ui_datafilespage.h"
#include <QWidget> #include <QWidget>
#include <QModelIndex>
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QAbstractItemModel; class QAbstractItemModel;
class QAction;
class QMenu; class QMenu;
namespace Files { struct ConfigurationManager; }
namespace ContentSelectorView { class ContentSelector; }
namespace Launcher
{
class TextInputDialog; class TextInputDialog;
class GameSettings; class GameSettings;
class LauncherSettings; class LauncherSettings;
class ProfilesComboBox; class ProfilesComboBox;
namespace Files { struct ConfigurationManager; }
namespace ContentSelectorView { class ContentSelector; }
class DataFilesPage : public QWidget class DataFilesPage : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -29,11 +29,9 @@ public:
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings, explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
LauncherSettings &launcherSettings, QWidget *parent = 0); LauncherSettings &launcherSettings, QWidget *parent = 0);
QAbstractItemModel* profilesModel() const QAbstractItemModel* profilesModel() const;
{ return ui.profilesComboBox->model(); }
int profilesIndex() const int profilesIndex() const;
{ return ui.profilesComboBox->currentIndex(); }
//void writeConfig(QString profile = QString()); //void writeConfig(QString profile = QString());
void saveSettings(const QString &profile = ""); void saveSettings(const QString &profile = "");
@ -76,5 +74,5 @@ private:
void addProfile (const QString &profile, bool setAsCurrent); void addProfile (const QString &profile, bool setAsCurrent);
void checkForDefaultProfile(); void checkForDefaultProfile();
}; };
}
#endif #endif

View file

@ -33,7 +33,7 @@ QString getAspect(int x, int y)
return QString(QString::number(xaspect) + ":" + QString::number(yaspect)); return QString(QString::number(xaspect) + ":" + QString::number(yaspect));
} }
GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent) Launcher::GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSetting, QWidget *parent)
: mCfgMgr(cfg) : mCfgMgr(cfg)
, mGraphicsSettings(graphicsSetting) , mGraphicsSettings(graphicsSetting)
, QWidget(parent) , QWidget(parent)
@ -53,7 +53,7 @@ GraphicsPage::GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &g
} }
bool GraphicsPage::setupOgre() bool Launcher::GraphicsPage::setupOgre()
{ {
// Create a log manager so we can surpress debug text to stdout/stderr // Create a log manager so we can surpress debug text to stdout/stderr
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager; Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
@ -157,7 +157,7 @@ bool GraphicsPage::setupOgre()
return true; return true;
} }
bool GraphicsPage::setupSDL() bool Launcher::GraphicsPage::setupSDL()
{ {
int displays = SDL_GetNumVideoDisplays(); int displays = SDL_GetNumVideoDisplays();
@ -180,7 +180,7 @@ bool GraphicsPage::setupSDL()
return true; return true;
} }
bool GraphicsPage::loadSettings() bool Launcher::GraphicsPage::loadSettings()
{ {
if (!setupSDL()) if (!setupSDL())
return false; return false;
@ -219,7 +219,7 @@ bool GraphicsPage::loadSettings()
return true; return true;
} }
void GraphicsPage::saveSettings() void Launcher::GraphicsPage::saveSettings()
{ {
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true")) vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false")); : mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
@ -246,7 +246,7 @@ void GraphicsPage::saveSettings()
mGraphicsSettings.setValue(QString("Video/screen"), QString::number(screenComboBox->currentIndex())); mGraphicsSettings.setValue(QString("Video/screen"), QString::number(screenComboBox->currentIndex()));
} }
QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer) QStringList Launcher::GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer)
{ {
QStringList result; QStringList result;
@ -279,7 +279,7 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
return result; return result;
} }
QStringList GraphicsPage::getAvailableResolutions(int screen) QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
{ {
QStringList result; QStringList result;
SDL_DisplayMode mode; SDL_DisplayMode mode;
@ -326,7 +326,7 @@ QStringList GraphicsPage::getAvailableResolutions(int screen)
return result; return result;
} }
QRect GraphicsPage::getMaximumResolution() QRect Launcher::GraphicsPage::getMaximumResolution()
{ {
QRect max; QRect max;
int screens = QApplication::desktop()->screenCount(); int screens = QApplication::desktop()->screenCount();
@ -341,7 +341,7 @@ QRect GraphicsPage::getMaximumResolution()
return max; return max;
} }
void GraphicsPage::rendererChanged(const QString &renderer) void Launcher::GraphicsPage::rendererChanged(const QString &renderer)
{ {
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString()); mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
@ -350,7 +350,7 @@ void GraphicsPage::rendererChanged(const QString &renderer)
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem)); antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
} }
void GraphicsPage::screenChanged(int screen) void Launcher::GraphicsPage::screenChanged(int screen)
{ {
if (screen >= 0) { if (screen >= 0) {
resolutionComboBox->clear(); resolutionComboBox->clear();
@ -358,7 +358,7 @@ void GraphicsPage::screenChanged(int screen)
} }
} }
void GraphicsPage::slotFullScreenChanged(int state) void Launcher::GraphicsPage::slotFullScreenChanged(int state)
{ {
if (state == Qt::Checked) { if (state == Qt::Checked) {
standardRadioButton->toggle(); standardRadioButton->toggle();
@ -372,7 +372,7 @@ void GraphicsPage::slotFullScreenChanged(int state)
} }
} }
void GraphicsPage::slotStandardToggled(bool checked) void Launcher::GraphicsPage::slotStandardToggled(bool checked)
{ {
if (checked) { if (checked) {
resolutionComboBox->setEnabled(true); resolutionComboBox->setEnabled(true);

View file

@ -18,10 +18,13 @@
#include "ui_graphicspage.h" #include "ui_graphicspage.h"
class GraphicsSettings;
namespace Files { struct ConfigurationManager; } namespace Files { struct ConfigurationManager; }
namespace Launcher
{
class GraphicsSettings;
class GraphicsPage : public QWidget, private Ui::GraphicsPage class GraphicsPage : public QWidget, private Ui::GraphicsPage
{ {
Q_OBJECT Q_OBJECT
@ -62,5 +65,5 @@ private:
bool setupOgre(); bool setupOgre();
bool setupSDL(); bool setupSDL();
}; };
}
#endif #endif

View file

@ -49,7 +49,7 @@ int main(int argc, char *argv[])
// Support non-latin characters // Support non-latin characters
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
MainDialog mainWin; Launcher::MainDialog mainWin;
if (mainWin.setup()) { if (mainWin.setup()) {
mainWin.show(); mainWin.show();
@ -61,4 +61,3 @@ int main(int argc, char *argv[])
SDL_Quit(); SDL_Quit();
return returnValue; return returnValue;
} }

View file

@ -1,5 +1,6 @@
#include "maindialog.hpp" #include "maindialog.hpp"
#include <QPushButton>
#include <QFontDatabase> #include <QFontDatabase>
#include <QInputDialog> #include <QInputDialog>
#include <QFileDialog> #include <QFileDialog>
@ -23,8 +24,8 @@
#include "graphicspage.hpp" #include "graphicspage.hpp"
#include "datafilespage.hpp" #include "datafilespage.hpp"
MainDialog::MainDialog() Launcher::MainDialog::MainDialog(QWidget *parent)
: mGameSettings(mCfgMgr) : mGameSettings(mCfgMgr), QMainWindow (parent)
{ {
// Install the stylesheet font // Install the stylesheet font
QFile file; QFile file;
@ -69,7 +70,7 @@ MainDialog::MainDialog()
createIcons(); createIcons();
} }
void MainDialog::createIcons() void Launcher::MainDialog::createIcons()
{ {
if (!QIcon::hasThemeIcon("document-new")) if (!QIcon::hasThemeIcon("document-new"))
QIcon::setThemeName("tango"); QIcon::setThemeName("tango");
@ -101,7 +102,7 @@ void MainDialog::createIcons()
} }
void MainDialog::createPages() void Launcher::MainDialog::createPages()
{ {
mPlayPage = new PlayPage(this); mPlayPage = new PlayPage(this);
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this); mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
@ -126,7 +127,7 @@ void MainDialog::createPages()
} }
bool MainDialog::showFirstRunDialog() bool Launcher::MainDialog::showFirstRunDialog()
{ {
QStringList iniPaths; QStringList iniPaths;
@ -282,7 +283,7 @@ bool MainDialog::showFirstRunDialog()
return true; return true;
} }
bool MainDialog::setup() bool Launcher::MainDialog::setup()
{ {
if (!setupLauncherSettings()) if (!setupLauncherSettings())
return false; return false;
@ -311,7 +312,7 @@ bool MainDialog::setup()
return true; return true;
} }
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) void Launcher::MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{ {
if (!current) if (!current)
current = previous; current = previous;
@ -337,7 +338,7 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
} }
} }
bool MainDialog::setupLauncherSettings() bool Launcher::MainDialog::setupLauncherSettings()
{ {
mLauncherSettings.setMultiValueEnabled(true); mLauncherSettings.setMultiValueEnabled(true);
@ -374,7 +375,7 @@ bool MainDialog::setupLauncherSettings()
} }
#ifndef WIN32 #ifndef WIN32
bool expansions(UnshieldThread& cd) bool Launcher::expansions(Launcher::UnshieldThread& cd)
{ {
if(cd.BloodmoonDone()) if(cd.BloodmoonDone())
{ {
@ -445,7 +446,7 @@ bool expansions(UnshieldThread& cd)
} }
#endif // WIN32 #endif // WIN32
bool MainDialog::setupGameSettings() bool Launcher::MainDialog::setupGameSettings()
{ {
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string()); QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string()); QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
@ -568,7 +569,7 @@ bool MainDialog::setupGameSettings()
return true; return true;
} }
bool MainDialog::setupGraphicsSettings() bool Launcher::MainDialog::setupGraphicsSettings()
{ {
mGraphicsSettings.setMultiValueEnabled(false); mGraphicsSettings.setMultiValueEnabled(false);
@ -622,7 +623,7 @@ bool MainDialog::setupGraphicsSettings()
return true; return true;
} }
void MainDialog::loadSettings() void Launcher::MainDialog::loadSettings()
{ {
int width = mLauncherSettings.value(QString("General/MainWindow/width")).toInt(); int width = mLauncherSettings.value(QString("General/MainWindow/width")).toInt();
int height = mLauncherSettings.value(QString("General/MainWindow/height")).toInt(); int height = mLauncherSettings.value(QString("General/MainWindow/height")).toInt();
@ -634,7 +635,7 @@ void MainDialog::loadSettings()
move(posX, posY); move(posX, posY);
} }
void MainDialog::saveSettings() void Launcher::MainDialog::saveSettings()
{ {
QString width = QString::number(this->width()); QString width = QString::number(this->width());
QString height = QString::number(this->height()); QString height = QString::number(this->height());
@ -652,7 +653,7 @@ void MainDialog::saveSettings()
} }
bool MainDialog::writeSettings() bool Launcher::MainDialog::writeSettings()
{ {
// Now write all config files // Now write all config files
saveSettings(); saveSettings();
@ -745,13 +746,13 @@ bool MainDialog::writeSettings()
return true; return true;
} }
void MainDialog::closeEvent(QCloseEvent *event) void Launcher::MainDialog::closeEvent(QCloseEvent *event)
{ {
writeSettings(); writeSettings();
event->accept(); event->accept();
} }
void MainDialog::play() void Launcher::MainDialog::play()
{ {
if (!writeSettings()) { if (!writeSettings()) {
qApp->quit(); qApp->quit();
@ -774,7 +775,7 @@ void MainDialog::play()
qApp->quit(); qApp->quit();
} }
bool MainDialog::startProgram(const QString &name, const QStringList &arguments, bool detached) bool Launcher::MainDialog::startProgram(const QString &name, const QStringList &arguments, bool detached)
{ {
QString path = name; QString path = name;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN

View file

@ -11,23 +11,25 @@
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
class QListWidget;
class QListWidgetItem; class QListWidgetItem;
class QStackedWidget;
class QStringList;
class QStringListModel;
class QString;
namespace Launcher
{
class PlayPage; class PlayPage;
class GraphicsPage; class GraphicsPage;
class DataFilesPage; class DataFilesPage;
class UnshieldThread;
#ifndef WIN32
bool expansions(Launcher::UnshieldThread& cd);
#endif
class MainDialog : public QMainWindow, private Ui::MainWindow class MainDialog : public QMainWindow, private Ui::MainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
MainDialog(); explicit MainDialog(QWidget *parent = 0);
bool setup(); bool setup();
bool showFirstRunDialog(); bool showFirstRunDialog();
@ -63,5 +65,5 @@ private:
LauncherSettings mLauncherSettings; LauncherSettings mLauncherSettings;
}; };
}
#endif #endif

View file

@ -6,7 +6,7 @@
#include <QPlastiqueStyle> #include <QPlastiqueStyle>
#endif #endif
PlayPage::PlayPage(QWidget *parent) : QWidget(parent) Launcher::PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
{ {
setObjectName ("PlayPage"); setObjectName ("PlayPage");
setupUi(this); setupUi(this);
@ -23,17 +23,17 @@ PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
} }
void PlayPage::setProfilesModel(QAbstractItemModel *model) void Launcher::PlayPage::setProfilesModel(QAbstractItemModel *model)
{ {
profilesComboBox->setModel(model); profilesComboBox->setModel(model);
} }
void PlayPage::setProfilesIndex(int index) void Launcher::PlayPage::setProfilesIndex(int index)
{ {
profilesComboBox->setCurrentIndex(index); profilesComboBox->setCurrentIndex(index);
} }
void PlayPage::slotPlayClicked() void Launcher::PlayPage::slotPlayClicked()
{ {
emit playButtonClicked(); emit playButtonClicked();
} }

View file

@ -9,6 +9,8 @@ class QComboBox;
class QPushButton; class QPushButton;
class QAbstractItemModel; class QAbstractItemModel;
namespace Launcher
{
class PlayPage : public QWidget, private Ui::PlayPage class PlayPage : public QWidget, private Ui::PlayPage
{ {
Q_OBJECT Q_OBJECT
@ -30,5 +32,5 @@ private slots:
}; };
}
#endif #endif

View file

@ -26,16 +26,16 @@ namespace boost
#endif /* (BOOST_VERSION <= 104600) */ #endif /* (BOOST_VERSION <= 104600) */
GameSettings::GameSettings(Files::ConfigurationManager &cfg) Launcher::GameSettings::GameSettings(Files::ConfigurationManager &cfg)
: mCfgMgr(cfg) : mCfgMgr(cfg)
{ {
} }
GameSettings::~GameSettings() Launcher::GameSettings::~GameSettings()
{ {
} }
void GameSettings::validatePaths() void Launcher::GameSettings::validatePaths()
{ {
if (mSettings.isEmpty() || !mDataDirs.isEmpty()) if (mSettings.isEmpty() || !mDataDirs.isEmpty())
return; // Don't re-validate paths if they are already parsed return; // Don't re-validate paths if they are already parsed
@ -81,14 +81,14 @@ void GameSettings::validatePaths()
} }
} }
QStringList GameSettings::values(const QString &key, const QStringList &defaultValues) QStringList Launcher::GameSettings::values(const QString &key, const QStringList &defaultValues)
{ {
if (!mSettings.values(key).isEmpty()) if (!mSettings.values(key).isEmpty())
return mSettings.values(key); return mSettings.values(key);
return defaultValues; return defaultValues;
} }
bool GameSettings::readFile(QTextStream &stream) bool Launcher::GameSettings::readFile(QTextStream &stream)
{ {
QMap<QString, QString> cache; QMap<QString, QString> cache;
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$"); QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
@ -130,7 +130,7 @@ bool GameSettings::readFile(QTextStream &stream)
return true; return true;
} }
bool GameSettings::writeFile(QTextStream &stream) bool Launcher::GameSettings::writeFile(QTextStream &stream)
{ {
// Iterate in reverse order to preserve insertion order // Iterate in reverse order to preserve insertion order
QMapIterator<QString, QString> i(mSettings); QMapIterator<QString, QString> i(mSettings);

View file

@ -11,6 +11,8 @@
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer; namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
struct ConfigurationManager;} struct ConfigurationManager;}
namespace Launcher
{
class GameSettings class GameSettings
{ {
public: public:
@ -58,5 +60,5 @@ private:
QStringList mDataDirs; QStringList mDataDirs;
QString mDataLocal; QString mDataLocal;
}; };
}
#endif // GAMESETTINGS_HPP #endif // GAMESETTINGS_HPP

View file

@ -5,15 +5,15 @@
#include <QRegExp> #include <QRegExp>
#include <QMap> #include <QMap>
GraphicsSettings::GraphicsSettings() Launcher::GraphicsSettings::GraphicsSettings()
{ {
} }
GraphicsSettings::~GraphicsSettings() Launcher::GraphicsSettings::~GraphicsSettings()
{ {
} }
bool GraphicsSettings::writeFile(QTextStream &stream) bool Launcher::GraphicsSettings::writeFile(QTextStream &stream)
{ {
QString sectionPrefix; QString sectionPrefix;
QRegExp sectionRe("([^/]+)/(.+)$"); QRegExp sectionRe("([^/]+)/(.+)$");

View file

@ -3,6 +3,8 @@
#include "settingsbase.hpp" #include "settingsbase.hpp"
namespace Launcher
{
class GraphicsSettings : public SettingsBase<QMap<QString, QString> > class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
{ {
public: public:
@ -12,5 +14,5 @@ public:
bool writeFile(QTextStream &stream); bool writeFile(QTextStream &stream);
}; };
}
#endif // GRAPHICSSETTINGS_HPP #endif // GRAPHICSSETTINGS_HPP

View file

@ -5,15 +5,15 @@
#include <QRegExp> #include <QRegExp>
#include <QMap> #include <QMap>
LauncherSettings::LauncherSettings() Launcher::LauncherSettings::LauncherSettings()
{ {
} }
LauncherSettings::~LauncherSettings() Launcher::LauncherSettings::~LauncherSettings()
{ {
} }
QStringList LauncherSettings::values(const QString &key, Qt::MatchFlags flags) QStringList Launcher::LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
{ {
QMap<QString, QString> settings = SettingsBase::getSettings(); QMap<QString, QString> settings = SettingsBase::getSettings();
@ -34,7 +34,7 @@ QStringList LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
return result; return result;
} }
QStringList LauncherSettings::subKeys(const QString &key) QStringList Launcher::LauncherSettings::subKeys(const QString &key)
{ {
QMap<QString, QString> settings = SettingsBase::getSettings(); QMap<QString, QString> settings = SettingsBase::getSettings();
QStringList keys = settings.uniqueKeys(); QStringList keys = settings.uniqueKeys();
@ -61,7 +61,7 @@ QStringList LauncherSettings::subKeys(const QString &key)
return result; return result;
} }
bool LauncherSettings::writeFile(QTextStream &stream) bool Launcher::LauncherSettings::writeFile(QTextStream &stream)
{ {
QString sectionPrefix; QString sectionPrefix;
QRegExp sectionRe("([^/]+)/(.+)$"); QRegExp sectionRe("([^/]+)/(.+)$");

View file

@ -3,6 +3,8 @@
#include "settingsbase.hpp" #include "settingsbase.hpp"
namespace Launcher
{
class LauncherSettings : public SettingsBase<QMap<QString, QString> > class LauncherSettings : public SettingsBase<QMap<QString, QString> >
{ {
public: public:
@ -15,5 +17,5 @@ public:
bool writeFile(QTextStream &stream); bool writeFile(QTextStream &stream);
}; };
}
#endif // LAUNCHERSETTINGS_HPP #endif // LAUNCHERSETTINGS_HPP

View file

@ -7,6 +7,8 @@
#include <QRegExp> #include <QRegExp>
#include <QMap> #include <QMap>
namespace Launcher
{
template <class Map> template <class Map>
class SettingsBase class SettingsBase
{ {
@ -105,5 +107,5 @@ private:
bool mMultiValue; bool mMultiValue;
}; };
}
#endif // SETTINGSBASE_HPP #endif // SETTINGSBASE_HPP

View file

@ -1,6 +1,6 @@
#include "textslotmsgbox.hpp" #include "textslotmsgbox.hpp"
void TextSlotMsgBox::setTextSlot(const QString& string) void Launcher::TextSlotMsgBox::setTextSlot(const QString& string)
{ {
setText(string); setText(string);
} }

View file

@ -3,11 +3,13 @@
#include <QMessageBox> #include <QMessageBox>
namespace Launcher
{
class TextSlotMsgBox : public QMessageBox class TextSlotMsgBox : public QMessageBox
{ {
Q_OBJECT Q_OBJECT
public slots: public slots:
void setTextSlot(const QString& string); void setTextSlot(const QString& string);
}; };
}
#endif #endif

View file

@ -292,30 +292,30 @@ namespace
} }
bool UnshieldThread::SetMorrowindPath(const std::string& path) bool Launcher::UnshieldThread::SetMorrowindPath(const std::string& path)
{ {
mMorrowindPath = path; mMorrowindPath = path;
return true; return true;
} }
bool UnshieldThread::SetTribunalPath(const std::string& path) bool Launcher::UnshieldThread::SetTribunalPath(const std::string& path)
{ {
mTribunalPath = path; mTribunalPath = path;
return true; return true;
} }
bool UnshieldThread::SetBloodmoonPath(const std::string& path) bool Launcher::UnshieldThread::SetBloodmoonPath(const std::string& path)
{ {
mBloodmoonPath = path; mBloodmoonPath = path;
return true; return true;
} }
void UnshieldThread::SetOutputPath(const std::string& path) void Launcher::UnshieldThread::SetOutputPath(const std::string& path)
{ {
mOutputPath = path; mOutputPath = path;
} }
bool UnshieldThread::extract_file(Unshield* unshield, bfs::path output_dir, const char* prefix, int index) bool Launcher::UnshieldThread::extract_file(Unshield* unshield, bfs::path output_dir, const char* prefix, int index)
{ {
bool success; bool success;
bfs::path dirname; bfs::path dirname;
@ -349,7 +349,7 @@ bool UnshieldThread::extract_file(Unshield* unshield, bfs::path output_dir, cons
return success; return success;
} }
void UnshieldThread::extract_cab(const bfs::path& cab, const bfs::path& output_dir, bool extract_ini) void Launcher::UnshieldThread::extract_cab(const bfs::path& cab, const bfs::path& output_dir, bool extract_ini)
{ {
Unshield * unshield; Unshield * unshield;
unshield = unshield_open(cab.c_str()); unshield = unshield_open(cab.c_str());
@ -369,7 +369,7 @@ void UnshieldThread::extract_cab(const bfs::path& cab, const bfs::path& output_d
} }
bool UnshieldThread::extract() bool Launcher::UnshieldThread::extract()
{ {
bfs::path outputDataFilesDir = mOutputPath; bfs::path outputDataFilesDir = mOutputPath;
outputDataFilesDir /= "Data Files"; outputDataFilesDir /= "Data Files";
@ -475,7 +475,7 @@ bool UnshieldThread::extract()
return true; return true;
} }
void UnshieldThread::Done() void Launcher::UnshieldThread::Done()
{ {
// Get rid of unnecessary files // Get rid of unnecessary files
bfs::remove_all(mOutputPath / "extract-temp"); bfs::remove_all(mOutputPath / "extract-temp");
@ -491,28 +491,28 @@ void UnshieldThread::Done()
bfs::last_write_time(findFile(mOutputPath, "bloodmoon.esm"), getTime("3 June 2003")); bfs::last_write_time(findFile(mOutputPath, "bloodmoon.esm"), getTime("3 June 2003"));
} }
std::string UnshieldThread::GetMWEsmPath() std::string Launcher::UnshieldThread::GetMWEsmPath()
{ {
return findFile(mOutputPath / "Data Files", "morrowind.esm").string(); return findFile(mOutputPath / "Data Files", "morrowind.esm").string();
} }
bool UnshieldThread::TribunalDone() bool Launcher::UnshieldThread::TribunalDone()
{ {
return mTribunalDone; return mTribunalDone;
} }
bool UnshieldThread::BloodmoonDone() bool Launcher::UnshieldThread::BloodmoonDone()
{ {
return mBloodmoonDone; return mBloodmoonDone;
} }
void UnshieldThread::run() void Launcher::UnshieldThread::run()
{ {
extract(); extract();
emit close(); emit close();
} }
UnshieldThread::UnshieldThread() Launcher::UnshieldThread::UnshieldThread()
{ {
unshield_set_log_level(0); unshield_set_log_level(0);
mMorrowindDone = false; mMorrowindDone = false;

View file

@ -7,6 +7,8 @@
#include <libunshield.h> #include <libunshield.h>
namespace Launcher
{
class UnshieldThread : public QThread class UnshieldThread : public QThread
{ {
Q_OBJECT Q_OBJECT
@ -52,5 +54,5 @@ class UnshieldThread : public QThread
void signalGUI(QString); void signalGUI(QString);
void close(); void close();
}; };
}
#endif #endif

View file

@ -54,11 +54,7 @@
Emulates the QMessageBox API with Emulates the QMessageBox API with
static conveniences. The message label can open external URLs. static conveniences. The message label can open external URLs.
*/ */
Launcher::CheckableMessageBoxPrivate::CheckableMessageBoxPrivate(QDialog *q)
class CheckableMessageBoxPrivate
{
public:
CheckableMessageBoxPrivate(QDialog *q)
: clickedButton(0) : clickedButton(0)
{ {
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
@ -85,7 +81,7 @@ public:
new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum); new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
checkBox = new QCheckBox(q); checkBox = new QCheckBox(q);
checkBox->setText(CheckableMessageBox::tr("Do not ask again")); checkBox->setText(Launcher::CheckableMessageBox::tr("Do not ask again"));
buttonBox = new QDialogButtonBox(q); buttonBox = new QDialogButtonBox(q);
buttonBox->setOrientation(Qt::Horizontal); buttonBox->setOrientation(Qt::Horizontal);
@ -110,16 +106,9 @@ public:
verticalLayout_2->addWidget(buttonBox); verticalLayout_2->addWidget(buttonBox);
} }
QLabel *pixmapLabel; Launcher::CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
QLabel *messageLabel;
QCheckBox *checkBox;
QDialogButtonBox *buttonBox;
QAbstractButton *clickedButton;
};
CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
QDialog(parent), QDialog(parent),
d(new CheckableMessageBoxPrivate(this)) d(new Launcher::CheckableMessageBoxPrivate(this))
{ {
setModal(true); setModal(true);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -129,102 +118,102 @@ CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
SLOT(slotClicked(QAbstractButton*))); SLOT(slotClicked(QAbstractButton*)));
} }
CheckableMessageBox::~CheckableMessageBox() Launcher::CheckableMessageBox::~CheckableMessageBox()
{ {
delete d; delete d;
} }
void CheckableMessageBox::slotClicked(QAbstractButton *b) void Launcher::CheckableMessageBox::slotClicked(QAbstractButton *b)
{ {
d->clickedButton = b; d->clickedButton = b;
} }
QAbstractButton *CheckableMessageBox::clickedButton() const QAbstractButton *Launcher::CheckableMessageBox::clickedButton() const
{ {
return d->clickedButton; return d->clickedButton;
} }
QDialogButtonBox::StandardButton CheckableMessageBox::clickedStandardButton() const QDialogButtonBox::StandardButton Launcher::CheckableMessageBox::clickedStandardButton() const
{ {
if (d->clickedButton) if (d->clickedButton)
return d->buttonBox->standardButton(d->clickedButton); return d->buttonBox->standardButton(d->clickedButton);
return QDialogButtonBox::NoButton; return QDialogButtonBox::NoButton;
} }
QString CheckableMessageBox::text() const QString Launcher::CheckableMessageBox::text() const
{ {
return d->messageLabel->text(); return d->messageLabel->text();
} }
void CheckableMessageBox::setText(const QString &t) void Launcher::CheckableMessageBox::setText(const QString &t)
{ {
d->messageLabel->setText(t); d->messageLabel->setText(t);
} }
QPixmap CheckableMessageBox::iconPixmap() const QPixmap Launcher::CheckableMessageBox::iconPixmap() const
{ {
if (const QPixmap *p = d->pixmapLabel->pixmap()) if (const QPixmap *p = d->pixmapLabel->pixmap())
return QPixmap(*p); return QPixmap(*p);
return QPixmap(); return QPixmap();
} }
void CheckableMessageBox::setIconPixmap(const QPixmap &p) void Launcher::CheckableMessageBox::setIconPixmap(const QPixmap &p)
{ {
d->pixmapLabel->setPixmap(p); d->pixmapLabel->setPixmap(p);
d->pixmapLabel->setVisible(!p.isNull()); d->pixmapLabel->setVisible(!p.isNull());
} }
bool CheckableMessageBox::isChecked() const bool Launcher::CheckableMessageBox::isChecked() const
{ {
return d->checkBox->isChecked(); return d->checkBox->isChecked();
} }
void CheckableMessageBox::setChecked(bool s) void Launcher::CheckableMessageBox::setChecked(bool s)
{ {
d->checkBox->setChecked(s); d->checkBox->setChecked(s);
} }
QString CheckableMessageBox::checkBoxText() const QString Launcher::CheckableMessageBox::checkBoxText() const
{ {
return d->checkBox->text(); return d->checkBox->text();
} }
void CheckableMessageBox::setCheckBoxText(const QString &t) void Launcher::CheckableMessageBox::setCheckBoxText(const QString &t)
{ {
d->checkBox->setText(t); d->checkBox->setText(t);
} }
bool CheckableMessageBox::isCheckBoxVisible() const bool Launcher::CheckableMessageBox::isCheckBoxVisible() const
{ {
return d->checkBox->isVisible(); return d->checkBox->isVisible();
} }
void CheckableMessageBox::setCheckBoxVisible(bool v) void Launcher::CheckableMessageBox::setCheckBoxVisible(bool v)
{ {
d->checkBox->setVisible(v); d->checkBox->setVisible(v);
} }
QDialogButtonBox::StandardButtons CheckableMessageBox::standardButtons() const QDialogButtonBox::StandardButtons Launcher::CheckableMessageBox::standardButtons() const
{ {
return d->buttonBox->standardButtons(); return d->buttonBox->standardButtons();
} }
void CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons s) void Launcher::CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons s)
{ {
d->buttonBox->setStandardButtons(s); d->buttonBox->setStandardButtons(s);
} }
QPushButton *CheckableMessageBox::button(QDialogButtonBox::StandardButton b) const QPushButton *Launcher::CheckableMessageBox::button(QDialogButtonBox::StandardButton b) const
{ {
return d->buttonBox->button(b); return d->buttonBox->button(b);
} }
QPushButton *CheckableMessageBox::addButton(const QString &text, QDialogButtonBox::ButtonRole role) QPushButton *Launcher::CheckableMessageBox::addButton(const QString &text, QDialogButtonBox::ButtonRole role)
{ {
return d->buttonBox->addButton(text, role); return d->buttonBox->addButton(text, role);
} }
QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const QDialogButtonBox::StandardButton Launcher::CheckableMessageBox::defaultButton() const
{ {
foreach (QAbstractButton *b, d->buttonBox->buttons()) foreach (QAbstractButton *b, d->buttonBox->buttons())
if (QPushButton *pb = qobject_cast<QPushButton *>(b)) if (QPushButton *pb = qobject_cast<QPushButton *>(b))
@ -233,7 +222,7 @@ QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
return QDialogButtonBox::NoButton; return QDialogButtonBox::NoButton;
} }
void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s) void Launcher::CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
{ {
if (QPushButton *b = d->buttonBox->button(s)) { if (QPushButton *b = d->buttonBox->button(s)) {
b->setDefault(true); b->setDefault(true);
@ -242,7 +231,7 @@ void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
} }
QDialogButtonBox::StandardButton QDialogButtonBox::StandardButton
CheckableMessageBox::question(QWidget *parent, Launcher::CheckableMessageBox::question(QWidget *parent,
const QString &title, const QString &title,
const QString &question, const QString &question,
const QString &checkBoxText, const QString &checkBoxText,
@ -263,7 +252,7 @@ CheckableMessageBox::question(QWidget *parent,
return mb.clickedStandardButton(); return mb.clickedStandardButton();
} }
QMessageBox::StandardButton CheckableMessageBox::dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton db) QMessageBox::StandardButton Launcher::CheckableMessageBox::dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton db)
{ {
return static_cast<QMessageBox::StandardButton>(int(db)); return static_cast<QMessageBox::StandardButton>(int(db));
} }

View file

@ -34,7 +34,23 @@
#include <QMessageBox> #include <QMessageBox>
#include <QDialog> #include <QDialog>
class CheckableMessageBoxPrivate; class QCheckBox;
namespace Launcher
{
class CheckableMessageBoxPrivate
{
public:
QLabel *pixmapLabel;
QLabel *messageLabel;
QCheckBox *checkBox;
QDialogButtonBox *buttonBox;
QAbstractButton *clickedButton;
public:
CheckableMessageBoxPrivate(QDialog *q);
};
class CheckableMessageBox : public QDialog class CheckableMessageBox : public QDialog
{ {
@ -96,5 +112,5 @@ private slots:
private: private:
CheckableMessageBoxPrivate *d; CheckableMessageBoxPrivate *d;
}; };
}
#endif // CHECKABLEMESSAGEBOX_HPP #endif // CHECKABLEMESSAGEBOX_HPP

View file

@ -7,7 +7,7 @@
#include <QValidator> #include <QValidator>
#include <QLabel> #include <QLabel>
TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) : Launcher::TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) :
QDialog(parent) QDialog(parent)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
@ -45,19 +45,19 @@ TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWid
} }
int TextInputDialog::exec() int Launcher::TextInputDialog::exec()
{ {
mLineEdit->clear(); mLineEdit->clear();
mLineEdit->setFocus(); mLineEdit->setFocus();
return QDialog::exec(); return QDialog::exec();
} }
QString TextInputDialog::getText() const QString Launcher::TextInputDialog::getText() const
{ {
return mLineEdit->text(); return mLineEdit->text();
} }
void TextInputDialog::slotUpdateOkButton(QString text) void Launcher::TextInputDialog::slotUpdateOkButton(QString text)
{ {
bool enabled = !(text.isEmpty()); bool enabled = !(text.isEmpty());
mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled); mButtonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
@ -73,7 +73,7 @@ void TextInputDialog::slotUpdateOkButton(QString text)
} }
} }
TextInputDialog::DialogLineEdit::DialogLineEdit (QWidget *parent) : Launcher::TextInputDialog::DialogLineEdit::DialogLineEdit (QWidget *parent) :
LineEdit (parent) LineEdit (parent)
{ {
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);

View file

@ -7,8 +7,8 @@
class QDialogButtonBox; class QDialogButtonBox;
class LineEdit; namespace Launcher
{
class TextInputDialog : public QDialog class TextInputDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
@ -35,5 +35,6 @@ private slots:
void slotUpdateOkButton(QString text); void slotUpdateOkButton(QString text);
}; };
}
#endif // TEXTINPUTDIALOG_HPP #endif // TEXTINPUTDIALOG_HPP