mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 19:49:41 +00:00
Implemented Launcher namespace
This commit is contained in:
parent
16d87ea1d1
commit
1a23cccce3
24 changed files with 573 additions and 540 deletions
|
@ -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 ¤t, bool savePrevious)
|
void Launcher::DataFilesPage::setProfile (const QString &previous, const QString ¤t, 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 ¤t,
|
||||||
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 ¤t)
|
void Launcher::DataFilesPage::slotProfileChangedByUser(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
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 ¤t)
|
void Launcher::DataFilesPage::slotProfileRenamed(const QString &previous, const QString ¤t)
|
||||||
{
|
{
|
||||||
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"));
|
||||||
|
|
|
@ -3,78 +3,76 @@
|
||||||
|
|
||||||
#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;
|
||||||
|
|
||||||
class TextInputDialog;
|
|
||||||
class GameSettings;
|
|
||||||
class LauncherSettings;
|
|
||||||
class ProfilesComboBox;
|
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
namespace ContentSelectorView { class ContentSelector; }
|
namespace ContentSelectorView { class ContentSelector; }
|
||||||
|
|
||||||
class DataFilesPage : public QWidget
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class TextInputDialog;
|
||||||
|
class GameSettings;
|
||||||
|
class LauncherSettings;
|
||||||
|
class ProfilesComboBox;
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector *mSelector;
|
class DataFilesPage : public QWidget
|
||||||
Ui::DataFilesPage ui;
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
ContentSelectorView::ContentSelector *mSelector;
|
||||||
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
Ui::DataFilesPage ui;
|
||||||
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
|
||||||
|
|
||||||
QAbstractItemModel* profilesModel() const
|
public:
|
||||||
{ return ui.profilesComboBox->model(); }
|
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
||||||
|
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||||
|
|
||||||
int profilesIndex() const
|
QAbstractItemModel* profilesModel() const;
|
||||||
{ return ui.profilesComboBox->currentIndex(); }
|
|
||||||
|
|
||||||
//void writeConfig(QString profile = QString());
|
int profilesIndex() const;
|
||||||
void saveSettings(const QString &profile = "");
|
|
||||||
void loadSettings();
|
|
||||||
|
|
||||||
signals:
|
//void writeConfig(QString profile = QString());
|
||||||
void signalProfileChanged (int index);
|
void saveSettings(const QString &profile = "");
|
||||||
|
void loadSettings();
|
||||||
|
|
||||||
public slots:
|
signals:
|
||||||
void slotProfileChanged (int index);
|
void signalProfileChanged (int index);
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
|
void slotProfileChanged (int index);
|
||||||
|
|
||||||
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
private slots:
|
||||||
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
|
||||||
void slotProfileDeleted(const QString &item);
|
|
||||||
|
|
||||||
void on_newProfileAction_triggered();
|
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
||||||
void on_deleteProfileAction_triggered();
|
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
||||||
|
void slotProfileDeleted(const QString &item);
|
||||||
|
|
||||||
private:
|
void on_newProfileAction_triggered();
|
||||||
|
void on_deleteProfileAction_triggered();
|
||||||
|
|
||||||
QMenu *mContextMenu;
|
private:
|
||||||
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
QMenu *mContextMenu;
|
||||||
|
|
||||||
GameSettings &mGameSettings;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
LauncherSettings &mLauncherSettings;
|
|
||||||
|
|
||||||
void setPluginsCheckstates(Qt::CheckState state);
|
GameSettings &mGameSettings;
|
||||||
|
LauncherSettings &mLauncherSettings;
|
||||||
|
|
||||||
void buildView();
|
void setPluginsCheckstates(Qt::CheckState state);
|
||||||
void setupDataFiles();
|
|
||||||
void setupConfig();
|
|
||||||
void readConfig();
|
|
||||||
void setProfile (int index, bool savePrevious);
|
|
||||||
void setProfile (const QString &previous, const QString ¤t, bool savePrevious);
|
|
||||||
void removeProfile (const QString &profile);
|
|
||||||
bool showDeleteMessageBox (const QString &text);
|
|
||||||
void addProfile (const QString &profile, bool setAsCurrent);
|
|
||||||
void checkForDefaultProfile();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
void buildView();
|
||||||
|
void setupDataFiles();
|
||||||
|
void setupConfig();
|
||||||
|
void readConfig();
|
||||||
|
void setProfile (int index, bool savePrevious);
|
||||||
|
void setProfile (const QString &previous, const QString ¤t, bool savePrevious);
|
||||||
|
void removeProfile (const QString &profile);
|
||||||
|
bool showDeleteMessageBox (const QString &text);
|
||||||
|
void addProfile (const QString &profile, bool setAsCurrent);
|
||||||
|
void checkForDefaultProfile();
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -18,49 +18,52 @@
|
||||||
|
|
||||||
#include "ui_graphicspage.h"
|
#include "ui_graphicspage.h"
|
||||||
|
|
||||||
class GraphicsSettings;
|
|
||||||
|
|
||||||
namespace Files { struct ConfigurationManager; }
|
namespace Files { struct ConfigurationManager; }
|
||||||
|
|
||||||
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class GraphicsSettings;
|
||||||
|
|
||||||
public:
|
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
||||||
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0);
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
void saveSettings();
|
public:
|
||||||
bool loadSettings();
|
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0);
|
||||||
|
|
||||||
public slots:
|
void saveSettings();
|
||||||
void rendererChanged(const QString &renderer);
|
bool loadSettings();
|
||||||
void screenChanged(int screen);
|
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
void slotFullScreenChanged(int state);
|
void rendererChanged(const QString &renderer);
|
||||||
void slotStandardToggled(bool checked);
|
void screenChanged(int screen);
|
||||||
|
|
||||||
private:
|
private slots:
|
||||||
Ogre::Root *mOgre;
|
void slotFullScreenChanged(int state);
|
||||||
Ogre::RenderSystem *mSelectedRenderSystem;
|
void slotStandardToggled(bool checked);
|
||||||
Ogre::RenderSystem *mOpenGLRenderSystem;
|
|
||||||
Ogre::RenderSystem *mDirect3DRenderSystem;
|
|
||||||
#ifdef ENABLE_PLUGIN_GL
|
|
||||||
Ogre::GLPlugin* mGLPlugin;
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
|
||||||
Ogre::D3D9Plugin* mD3D9Plugin;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
private:
|
||||||
GraphicsSettings &mGraphicsSettings;
|
Ogre::Root *mOgre;
|
||||||
|
Ogre::RenderSystem *mSelectedRenderSystem;
|
||||||
|
Ogre::RenderSystem *mOpenGLRenderSystem;
|
||||||
|
Ogre::RenderSystem *mDirect3DRenderSystem;
|
||||||
|
#ifdef ENABLE_PLUGIN_GL
|
||||||
|
Ogre::GLPlugin* mGLPlugin;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||||
|
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||||
|
#endif
|
||||||
|
|
||||||
QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer);
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
QStringList getAvailableResolutions(int screen);
|
GraphicsSettings &mGraphicsSettings;
|
||||||
QRect getMaximumResolution();
|
|
||||||
|
|
||||||
bool setupOgre();
|
QStringList getAvailableOptions(const QString &key, Ogre::RenderSystem *renderer);
|
||||||
bool setupSDL();
|
QStringList getAvailableResolutions(int screen);
|
||||||
};
|
QRect getMaximumResolution();
|
||||||
|
|
||||||
|
bool setupOgre();
|
||||||
|
bool setupSDL();
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -11,57 +11,59 @@
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
class QListWidget;
|
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
class QStackedWidget;
|
|
||||||
class QStringList;
|
|
||||||
class QStringListModel;
|
|
||||||
class QString;
|
|
||||||
|
|
||||||
class PlayPage;
|
namespace Launcher
|
||||||
class GraphicsPage;
|
|
||||||
class DataFilesPage;
|
|
||||||
|
|
||||||
class MainDialog : public QMainWindow, private Ui::MainWindow
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class PlayPage;
|
||||||
|
class GraphicsPage;
|
||||||
public:
|
class DataFilesPage;
|
||||||
MainDialog();
|
class UnshieldThread;
|
||||||
bool setup();
|
|
||||||
bool showFirstRunDialog();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
|
||||||
void play();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void createIcons();
|
|
||||||
void createPages();
|
|
||||||
|
|
||||||
bool setupLauncherSettings();
|
|
||||||
bool setupGameSettings();
|
|
||||||
bool setupGraphicsSettings();
|
|
||||||
|
|
||||||
void loadSettings();
|
|
||||||
void saveSettings();
|
|
||||||
bool writeSettings();
|
|
||||||
|
|
||||||
inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); }
|
|
||||||
bool startProgram(const QString &name, const QStringList &arguments, bool detached = false);
|
|
||||||
|
|
||||||
void closeEvent(QCloseEvent *event);
|
|
||||||
|
|
||||||
PlayPage *mPlayPage;
|
|
||||||
GraphicsPage *mGraphicsPage;
|
|
||||||
DataFilesPage *mDataFilesPage;
|
|
||||||
|
|
||||||
Files::ConfigurationManager mCfgMgr;
|
|
||||||
|
|
||||||
GameSettings mGameSettings;
|
|
||||||
GraphicsSettings mGraphicsSettings;
|
|
||||||
LauncherSettings mLauncherSettings;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
#ifndef WIN32
|
||||||
|
bool expansions(Launcher::UnshieldThread& cd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class MainDialog : public QMainWindow, private Ui::MainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MainDialog(QWidget *parent = 0);
|
||||||
|
bool setup();
|
||||||
|
bool showFirstRunDialog();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||||
|
void play();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createIcons();
|
||||||
|
void createPages();
|
||||||
|
|
||||||
|
bool setupLauncherSettings();
|
||||||
|
bool setupGameSettings();
|
||||||
|
bool setupGraphicsSettings();
|
||||||
|
|
||||||
|
void loadSettings();
|
||||||
|
void saveSettings();
|
||||||
|
bool writeSettings();
|
||||||
|
|
||||||
|
inline bool startProgram(const QString &name, bool detached = false) { return startProgram(name, QStringList(), detached); }
|
||||||
|
bool startProgram(const QString &name, const QStringList &arguments, bool detached = false);
|
||||||
|
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
PlayPage *mPlayPage;
|
||||||
|
GraphicsPage *mGraphicsPage;
|
||||||
|
DataFilesPage *mDataFilesPage;
|
||||||
|
|
||||||
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
|
||||||
|
GameSettings mGameSettings;
|
||||||
|
GraphicsSettings mGraphicsSettings;
|
||||||
|
LauncherSettings mLauncherSettings;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,26 +9,28 @@ class QComboBox;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
class QAbstractItemModel;
|
class QAbstractItemModel;
|
||||||
|
|
||||||
class PlayPage : public QWidget, private Ui::PlayPage
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class PlayPage : public QWidget, private Ui::PlayPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PlayPage(QWidget *parent = 0);
|
PlayPage(QWidget *parent = 0);
|
||||||
void setProfilesModel(QAbstractItemModel *model);
|
void setProfilesModel(QAbstractItemModel *model);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalProfileChanged(int index);
|
void signalProfileChanged(int index);
|
||||||
void playButtonClicked();
|
void playButtonClicked();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setProfilesIndex(int index);
|
void setProfilesIndex(int index);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotPlayClicked();
|
void slotPlayClicked();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -11,52 +11,54 @@
|
||||||
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||||
struct ConfigurationManager;}
|
struct ConfigurationManager;}
|
||||||
|
|
||||||
class GameSettings
|
namespace Launcher
|
||||||
{
|
{
|
||||||
public:
|
class GameSettings
|
||||||
GameSettings(Files::ConfigurationManager &cfg);
|
|
||||||
~GameSettings();
|
|
||||||
|
|
||||||
inline QString value(const QString &key, const QString &defaultValue = QString())
|
|
||||||
{
|
{
|
||||||
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
public:
|
||||||
}
|
GameSettings(Files::ConfigurationManager &cfg);
|
||||||
|
~GameSettings();
|
||||||
|
|
||||||
|
inline QString value(const QString &key, const QString &defaultValue = QString())
|
||||||
|
{
|
||||||
|
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void setValue(const QString &key, const QString &value)
|
inline void setValue(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
mSettings.insert(key, value);
|
mSettings.insert(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setMultiValue(const QString &key, const QString &value)
|
inline void setMultiValue(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
QStringList values = mSettings.values(key);
|
QStringList values = mSettings.values(key);
|
||||||
if (!values.contains(value))
|
if (!values.contains(value))
|
||||||
mSettings.insertMulti(key, value);
|
mSettings.insertMulti(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void remove(const QString &key)
|
inline void remove(const QString &key)
|
||||||
{
|
{
|
||||||
mSettings.remove(key);
|
mSettings.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QStringList getDataDirs() { return mDataDirs; }
|
inline QStringList getDataDirs() { return mDataDirs; }
|
||||||
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
|
inline void addDataDir(const QString &dir) { if(!dir.isEmpty()) mDataDirs.append(dir); }
|
||||||
inline QString getDataLocal() {return mDataLocal; }
|
inline QString getDataLocal() {return mDataLocal; }
|
||||||
inline bool hasMaster() { return mSettings.count(QString("master")) > 0; }
|
inline bool hasMaster() { return mSettings.count(QString("master")) > 0; }
|
||||||
|
|
||||||
QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
|
QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
|
||||||
bool readFile(QTextStream &stream);
|
bool readFile(QTextStream &stream);
|
||||||
bool writeFile(QTextStream &stream);
|
bool writeFile(QTextStream &stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
void validatePaths();
|
void validatePaths();
|
||||||
QMap<QString, QString> mSettings;
|
QMap<QString, QString> mSettings;
|
||||||
|
|
||||||
QStringList mDataDirs;
|
|
||||||
QString mDataLocal;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
QStringList mDataDirs;
|
||||||
|
QString mDataLocal;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // GAMESETTINGS_HPP
|
#endif // GAMESETTINGS_HPP
|
||||||
|
|
|
@ -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("([^/]+)/(.+)$");
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
|
|
||||||
#include "settingsbase.hpp"
|
#include "settingsbase.hpp"
|
||||||
|
|
||||||
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
namespace Launcher
|
||||||
{
|
{
|
||||||
public:
|
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
||||||
GraphicsSettings();
|
{
|
||||||
~GraphicsSettings();
|
public:
|
||||||
|
GraphicsSettings();
|
||||||
|
~GraphicsSettings();
|
||||||
|
|
||||||
bool writeFile(QTextStream &stream);
|
bool writeFile(QTextStream &stream);
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // GRAPHICSSETTINGS_HPP
|
#endif // GRAPHICSSETTINGS_HPP
|
||||||
|
|
|
@ -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("([^/]+)/(.+)$");
|
||||||
|
|
|
@ -3,17 +3,19 @@
|
||||||
|
|
||||||
#include "settingsbase.hpp"
|
#include "settingsbase.hpp"
|
||||||
|
|
||||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
namespace Launcher
|
||||||
{
|
{
|
||||||
public:
|
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
||||||
LauncherSettings();
|
{
|
||||||
~LauncherSettings();
|
public:
|
||||||
|
LauncherSettings();
|
||||||
|
~LauncherSettings();
|
||||||
|
|
||||||
QStringList subKeys(const QString &key);
|
QStringList subKeys(const QString &key);
|
||||||
QStringList values(const QString &key, Qt::MatchFlags flags = Qt::MatchExactly);
|
QStringList values(const QString &key, Qt::MatchFlags flags = Qt::MatchExactly);
|
||||||
|
|
||||||
bool writeFile(QTextStream &stream);
|
bool writeFile(QTextStream &stream);
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // LAUNCHERSETTINGS_HPP
|
#endif // LAUNCHERSETTINGS_HPP
|
||||||
|
|
|
@ -7,103 +7,105 @@
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
template <class Map>
|
namespace Launcher
|
||||||
class SettingsBase
|
|
||||||
{
|
{
|
||||||
|
template <class Map>
|
||||||
public:
|
class SettingsBase
|
||||||
SettingsBase() { mMultiValue = false; }
|
|
||||||
~SettingsBase() {}
|
|
||||||
|
|
||||||
inline QString value(const QString &key, const QString &defaultValue = QString())
|
|
||||||
{
|
{
|
||||||
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setValue(const QString &key, const QString &value)
|
public:
|
||||||
{
|
SettingsBase() { mMultiValue = false; }
|
||||||
QStringList values = mSettings.values(key);
|
~SettingsBase() {}
|
||||||
if (!values.contains(value))
|
|
||||||
mSettings.insert(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setMultiValue(const QString &key, const QString &value)
|
inline QString value(const QString &key, const QString &defaultValue = QString())
|
||||||
{
|
{
|
||||||
QStringList values = mSettings.values(key);
|
return mSettings.value(key).isEmpty() ? defaultValue : mSettings.value(key);
|
||||||
if (!values.contains(value))
|
}
|
||||||
mSettings.insertMulti(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void setMultiValueEnabled(bool enable)
|
inline void setValue(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
mMultiValue = enable;
|
QStringList values = mSettings.values(key);
|
||||||
}
|
if (!values.contains(value))
|
||||||
|
mSettings.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
inline void remove(const QString &key)
|
inline void setMultiValue(const QString &key, const QString &value)
|
||||||
{
|
{
|
||||||
mSettings.remove(key);
|
QStringList values = mSettings.values(key);
|
||||||
}
|
if (!values.contains(value))
|
||||||
|
mSettings.insertMulti(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
Map getSettings() {return mSettings;}
|
inline void setMultiValueEnabled(bool enable)
|
||||||
|
{
|
||||||
|
mMultiValue = enable;
|
||||||
|
}
|
||||||
|
|
||||||
bool readFile(QTextStream &stream)
|
inline void remove(const QString &key)
|
||||||
{
|
{
|
||||||
mCache.clear();
|
mSettings.remove(key);
|
||||||
|
}
|
||||||
|
|
||||||
QString sectionPrefix;
|
Map getSettings() {return mSettings;}
|
||||||
|
|
||||||
QRegExp sectionRe("^\\[([^]]+)\\]");
|
bool readFile(QTextStream &stream)
|
||||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
{
|
||||||
|
mCache.clear();
|
||||||
|
|
||||||
while (!stream.atEnd()) {
|
QString sectionPrefix;
|
||||||
QString line = stream.readLine();
|
|
||||||
|
|
||||||
if (line.isEmpty() || line.startsWith("#"))
|
QRegExp sectionRe("^\\[([^]]+)\\]");
|
||||||
continue;
|
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
|
||||||
if (sectionRe.exactMatch(line)) {
|
while (!stream.atEnd()) {
|
||||||
sectionPrefix = sectionRe.cap(1);
|
QString line = stream.readLine();
|
||||||
sectionPrefix.append("/");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keyRe.indexIn(line) != -1) {
|
if (line.isEmpty() || line.startsWith("#"))
|
||||||
|
continue;
|
||||||
|
|
||||||
QString key = keyRe.cap(1).trimmed();
|
if (sectionRe.exactMatch(line)) {
|
||||||
QString value = keyRe.cap(2).trimmed();
|
sectionPrefix = sectionRe.cap(1);
|
||||||
|
sectionPrefix.append("/");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sectionPrefix.isEmpty())
|
if (keyRe.indexIn(line) != -1) {
|
||||||
key.prepend(sectionPrefix);
|
|
||||||
|
|
||||||
mSettings.remove(key);
|
QString key = keyRe.cap(1).trimmed();
|
||||||
|
QString value = keyRe.cap(2).trimmed();
|
||||||
|
|
||||||
QStringList values = mCache.values(key);
|
if (!sectionPrefix.isEmpty())
|
||||||
|
key.prepend(sectionPrefix);
|
||||||
|
|
||||||
if (!values.contains(value)) {
|
mSettings.remove(key);
|
||||||
if (mMultiValue) {
|
|
||||||
mCache.insertMulti(key, value);
|
QStringList values = mCache.values(key);
|
||||||
} else {
|
|
||||||
mCache.insert(key, value);
|
if (!values.contains(value)) {
|
||||||
|
if (mMultiValue) {
|
||||||
|
mCache.insertMulti(key, value);
|
||||||
|
} else {
|
||||||
|
mCache.insert(key, value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (mSettings.isEmpty()) {
|
if (mSettings.isEmpty()) {
|
||||||
mSettings = mCache; // This is the first time we read a file
|
mSettings = mCache; // This is the first time we read a file
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge the changed keys with those which didn't
|
||||||
|
mSettings.unite(mCache);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge the changed keys with those which didn't
|
private:
|
||||||
mSettings.unite(mCache);
|
Map mSettings;
|
||||||
return true;
|
Map mCache;
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Map mSettings;
|
|
||||||
Map mCache;
|
|
||||||
|
|
||||||
bool mMultiValue;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
bool mMultiValue;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // SETTINGSBASE_HPP
|
#endif // SETTINGSBASE_HPP
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
class TextSlotMsgBox : public QMessageBox
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class TextSlotMsgBox : public QMessageBox
|
||||||
public slots:
|
{
|
||||||
void setTextSlot(const QString& string);
|
Q_OBJECT
|
||||||
};
|
public slots:
|
||||||
|
void setTextSlot(const QString& string);
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -7,50 +7,52 @@
|
||||||
|
|
||||||
#include <libunshield.h>
|
#include <libunshield.h>
|
||||||
|
|
||||||
class UnshieldThread : public QThread
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class UnshieldThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool SetMorrowindPath(const std::string& path);
|
bool SetMorrowindPath(const std::string& path);
|
||||||
bool SetTribunalPath(const std::string& path);
|
bool SetTribunalPath(const std::string& path);
|
||||||
bool SetBloodmoonPath(const std::string& path);
|
bool SetBloodmoonPath(const std::string& path);
|
||||||
|
|
||||||
void SetOutputPath(const std::string& path);
|
void SetOutputPath(const std::string& path);
|
||||||
|
|
||||||
bool extract();
|
bool extract();
|
||||||
|
|
||||||
bool TribunalDone();
|
bool TribunalDone();
|
||||||
bool BloodmoonDone();
|
bool BloodmoonDone();
|
||||||
|
|
||||||
void Done();
|
void Done();
|
||||||
|
|
||||||
std::string GetMWEsmPath();
|
std::string GetMWEsmPath();
|
||||||
|
|
||||||
UnshieldThread();
|
UnshieldThread();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void extract_cab(const boost::filesystem::path& cab, const boost::filesystem::path& output_dir, bool extract_ini = false);
|
void extract_cab(const boost::filesystem::path& cab, const boost::filesystem::path& output_dir, bool extract_ini = false);
|
||||||
bool extract_file(Unshield* unshield, boost::filesystem::path output_dir, const char* prefix, int index);
|
bool extract_file(Unshield* unshield, boost::filesystem::path output_dir, const char* prefix, int index);
|
||||||
|
|
||||||
boost::filesystem::path mMorrowindPath;
|
boost::filesystem::path mMorrowindPath;
|
||||||
boost::filesystem::path mTribunalPath;
|
boost::filesystem::path mTribunalPath;
|
||||||
boost::filesystem::path mBloodmoonPath;
|
boost::filesystem::path mBloodmoonPath;
|
||||||
|
|
||||||
bool mMorrowindDone;
|
bool mMorrowindDone;
|
||||||
bool mTribunalDone;
|
bool mTribunalDone;
|
||||||
bool mBloodmoonDone;
|
bool mBloodmoonDone;
|
||||||
|
|
||||||
boost::filesystem::path mOutputPath;
|
boost::filesystem::path mOutputPath;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void run();
|
virtual void run();
|
||||||
|
|
||||||
signals:
|
|
||||||
void signalGUI(QString);
|
|
||||||
void close();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void signalGUI(QString);
|
||||||
|
void close();
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,72 +54,61 @@
|
||||||
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);
|
||||||
|
|
||||||
pixmapLabel = new QLabel(q);
|
pixmapLabel = new QLabel(q);
|
||||||
sizePolicy.setHorizontalStretch(0);
|
sizePolicy.setHorizontalStretch(0);
|
||||||
sizePolicy.setVerticalStretch(0);
|
sizePolicy.setVerticalStretch(0);
|
||||||
sizePolicy.setHeightForWidth(pixmapLabel->sizePolicy().hasHeightForWidth());
|
sizePolicy.setHeightForWidth(pixmapLabel->sizePolicy().hasHeightForWidth());
|
||||||
pixmapLabel->setSizePolicy(sizePolicy);
|
pixmapLabel->setSizePolicy(sizePolicy);
|
||||||
pixmapLabel->setVisible(false);
|
pixmapLabel->setVisible(false);
|
||||||
|
|
||||||
QSpacerItem *pixmapSpacer =
|
QSpacerItem *pixmapSpacer =
|
||||||
new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
new QSpacerItem(0, 5, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
|
||||||
|
|
||||||
messageLabel = new QLabel(q);
|
messageLabel = new QLabel(q);
|
||||||
messageLabel->setMinimumSize(QSize(300, 0));
|
messageLabel->setMinimumSize(QSize(300, 0));
|
||||||
messageLabel->setWordWrap(true);
|
messageLabel->setWordWrap(true);
|
||||||
messageLabel->setOpenExternalLinks(true);
|
messageLabel->setOpenExternalLinks(true);
|
||||||
messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse);
|
messageLabel->setTextInteractionFlags(Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse);
|
||||||
|
|
||||||
QSpacerItem *checkBoxRightSpacer =
|
QSpacerItem *checkBoxRightSpacer =
|
||||||
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||||
QSpacerItem *buttonSpacer =
|
QSpacerItem *buttonSpacer =
|
||||||
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);
|
||||||
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
|
||||||
|
|
||||||
QVBoxLayout *verticalLayout = new QVBoxLayout();
|
QVBoxLayout *verticalLayout = new QVBoxLayout();
|
||||||
verticalLayout->addWidget(pixmapLabel);
|
verticalLayout->addWidget(pixmapLabel);
|
||||||
verticalLayout->addItem(pixmapSpacer);
|
verticalLayout->addItem(pixmapSpacer);
|
||||||
|
|
||||||
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
QHBoxLayout *horizontalLayout_2 = new QHBoxLayout();
|
||||||
horizontalLayout_2->addLayout(verticalLayout);
|
horizontalLayout_2->addLayout(verticalLayout);
|
||||||
horizontalLayout_2->addWidget(messageLabel);
|
horizontalLayout_2->addWidget(messageLabel);
|
||||||
|
|
||||||
QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
QHBoxLayout *horizontalLayout = new QHBoxLayout();
|
||||||
horizontalLayout->addWidget(checkBox);
|
horizontalLayout->addWidget(checkBox);
|
||||||
horizontalLayout->addItem(checkBoxRightSpacer);
|
horizontalLayout->addItem(checkBoxRightSpacer);
|
||||||
|
|
||||||
QVBoxLayout *verticalLayout_2 = new QVBoxLayout(q);
|
QVBoxLayout *verticalLayout_2 = new QVBoxLayout(q);
|
||||||
verticalLayout_2->addLayout(horizontalLayout_2);
|
verticalLayout_2->addLayout(horizontalLayout_2);
|
||||||
verticalLayout_2->addLayout(horizontalLayout);
|
verticalLayout_2->addLayout(horizontalLayout);
|
||||||
verticalLayout_2->addItem(buttonSpacer);
|
verticalLayout_2->addItem(buttonSpacer);
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,67 +34,83 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
class CheckableMessageBoxPrivate;
|
class QCheckBox;
|
||||||
|
|
||||||
class CheckableMessageBox : public QDialog
|
namespace Launcher
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class CheckableMessageBoxPrivate
|
||||||
Q_PROPERTY(QString text READ text WRITE setText)
|
{
|
||||||
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
|
public:
|
||||||
Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
|
|
||||||
Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText)
|
|
||||||
Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
|
|
||||||
Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
|
|
||||||
|
|
||||||
public:
|
QLabel *pixmapLabel;
|
||||||
explicit CheckableMessageBox(QWidget *parent);
|
QLabel *messageLabel;
|
||||||
virtual ~CheckableMessageBox();
|
QCheckBox *checkBox;
|
||||||
|
QDialogButtonBox *buttonBox;
|
||||||
|
QAbstractButton *clickedButton;
|
||||||
|
|
||||||
static QDialogButtonBox::StandardButton
|
public:
|
||||||
question(QWidget *parent,
|
CheckableMessageBoxPrivate(QDialog *q);
|
||||||
const QString &title,
|
};
|
||||||
const QString &question,
|
|
||||||
const QString &checkBoxText,
|
|
||||||
bool *checkBoxSetting,
|
|
||||||
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
|
|
||||||
QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No);
|
|
||||||
|
|
||||||
QString text() const;
|
class CheckableMessageBox : public QDialog
|
||||||
void setText(const QString &);
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
|
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
|
||||||
|
Q_PROPERTY(bool isChecked READ isChecked WRITE setChecked)
|
||||||
|
Q_PROPERTY(QString checkBoxText READ checkBoxText WRITE setCheckBoxText)
|
||||||
|
Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
|
||||||
|
Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
|
||||||
|
|
||||||
bool isChecked() const;
|
public:
|
||||||
void setChecked(bool s);
|
explicit CheckableMessageBox(QWidget *parent);
|
||||||
|
virtual ~CheckableMessageBox();
|
||||||
|
|
||||||
QString checkBoxText() const;
|
static QDialogButtonBox::StandardButton
|
||||||
void setCheckBoxText(const QString &);
|
question(QWidget *parent,
|
||||||
|
const QString &title,
|
||||||
|
const QString &question,
|
||||||
|
const QString &checkBoxText,
|
||||||
|
bool *checkBoxSetting,
|
||||||
|
QDialogButtonBox::StandardButtons buttons = QDialogButtonBox::Yes|QDialogButtonBox::No,
|
||||||
|
QDialogButtonBox::StandardButton defaultButton = QDialogButtonBox::No);
|
||||||
|
|
||||||
bool isCheckBoxVisible() const;
|
QString text() const;
|
||||||
void setCheckBoxVisible(bool);
|
void setText(const QString &);
|
||||||
|
|
||||||
QDialogButtonBox::StandardButtons standardButtons() const;
|
bool isChecked() const;
|
||||||
void setStandardButtons(QDialogButtonBox::StandardButtons s);
|
void setChecked(bool s);
|
||||||
QPushButton *button(QDialogButtonBox::StandardButton b) const;
|
|
||||||
QPushButton *addButton(const QString &text, QDialogButtonBox::ButtonRole role);
|
|
||||||
|
|
||||||
QDialogButtonBox::StandardButton defaultButton() const;
|
QString checkBoxText() const;
|
||||||
void setDefaultButton(QDialogButtonBox::StandardButton s);
|
void setCheckBoxText(const QString &);
|
||||||
|
|
||||||
// See static QMessageBox::standardPixmap()
|
bool isCheckBoxVisible() const;
|
||||||
QPixmap iconPixmap() const;
|
void setCheckBoxVisible(bool);
|
||||||
void setIconPixmap (const QPixmap &p);
|
|
||||||
|
|
||||||
// Query the result
|
QDialogButtonBox::StandardButtons standardButtons() const;
|
||||||
QAbstractButton *clickedButton() const;
|
void setStandardButtons(QDialogButtonBox::StandardButtons s);
|
||||||
QDialogButtonBox::StandardButton clickedStandardButton() const;
|
QPushButton *button(QDialogButtonBox::StandardButton b) const;
|
||||||
|
QPushButton *addButton(const QString &text, QDialogButtonBox::ButtonRole role);
|
||||||
|
|
||||||
// Conversion convenience
|
QDialogButtonBox::StandardButton defaultButton() const;
|
||||||
static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
|
void setDefaultButton(QDialogButtonBox::StandardButton s);
|
||||||
|
|
||||||
private slots:
|
// See static QMessageBox::standardPixmap()
|
||||||
void slotClicked(QAbstractButton *b);
|
QPixmap iconPixmap() const;
|
||||||
|
void setIconPixmap (const QPixmap &p);
|
||||||
|
|
||||||
private:
|
// Query the result
|
||||||
CheckableMessageBoxPrivate *d;
|
QAbstractButton *clickedButton() const;
|
||||||
};
|
QDialogButtonBox::StandardButton clickedStandardButton() const;
|
||||||
|
|
||||||
|
// Conversion convenience
|
||||||
|
static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotClicked(QAbstractButton *b);
|
||||||
|
|
||||||
|
private:
|
||||||
|
CheckableMessageBoxPrivate *d;
|
||||||
|
};
|
||||||
|
}
|
||||||
#endif // CHECKABLEMESSAGEBOX_HPP
|
#endif // CHECKABLEMESSAGEBOX_HPP
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -7,33 +7,34 @@
|
||||||
|
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
|
|
||||||
class LineEdit;
|
namespace Launcher
|
||||||
|
|
||||||
class TextInputDialog : public QDialog
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
class TextInputDialog : public QDialog
|
||||||
|
|
||||||
class DialogLineEdit : public LineEdit
|
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
class DialogLineEdit : public LineEdit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit DialogLineEdit (QWidget *parent = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
DialogLineEdit *mLineEdit;
|
||||||
|
QDialogButtonBox *mButtonBox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DialogLineEdit (QWidget *parent = 0);
|
|
||||||
|
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
||||||
|
~TextInputDialog () {}
|
||||||
|
|
||||||
|
QString getText() const;
|
||||||
|
|
||||||
|
int exec();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void slotUpdateOkButton(QString text);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
DialogLineEdit *mLineEdit;
|
|
||||||
QDialogButtonBox *mButtonBox;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
|
||||||
~TextInputDialog () {}
|
|
||||||
|
|
||||||
QString getText() const;
|
|
||||||
|
|
||||||
int exec();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void slotUpdateOkButton(QString text);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // TEXTINPUTDIALOG_HPP
|
#endif // TEXTINPUTDIALOG_HPP
|
||||||
|
|
Loading…
Reference in a new issue