mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-30 18:45:38 +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"
|
||||
|
||||
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)
|
||||
, mGameSettings(gameSettings)
|
||||
, mLauncherSettings(launcherSettings)
|
||||
|
@ -35,7 +35,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
|||
setupDataFiles();
|
||||
}
|
||||
|
||||
void DataFilesPage::loadSettings()
|
||||
void Launcher::DataFilesPage::loadSettings()
|
||||
{
|
||||
QString profileName = ui.profilesComboBox->currentText();
|
||||
|
||||
|
@ -53,7 +53,7 @@ void DataFilesPage::loadSettings()
|
|||
mSelector->setCheckStates(addons);
|
||||
}
|
||||
|
||||
void DataFilesPage::saveSettings(const QString &profile)
|
||||
void Launcher::DataFilesPage::saveSettings(const QString &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());
|
||||
|
||||
|
@ -111,13 +111,23 @@ void DataFilesPage::buildView()
|
|||
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("/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())
|
||||
{
|
||||
|
@ -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)
|
||||
if (previous == current)
|
||||
|
@ -144,18 +154,18 @@ void DataFilesPage::setProfile (const QString &previous, const QString ¤t,
|
|||
checkForDefaultProfile();
|
||||
}
|
||||
|
||||
void DataFilesPage::slotProfileDeleted (const QString &item)
|
||||
void Launcher::DataFilesPage::slotProfileDeleted (const QString &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);
|
||||
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())
|
||||
return;
|
||||
|
@ -169,12 +179,12 @@ void DataFilesPage::slotProfileRenamed(const QString &previous, const QString &c
|
|||
loadSettings();
|
||||
}
|
||||
|
||||
void DataFilesPage::slotProfileChanged(int index)
|
||||
void Launcher::DataFilesPage::slotProfileChanged(int index)
|
||||
{
|
||||
setProfile (index, true);
|
||||
}
|
||||
|
||||
void DataFilesPage::setupDataFiles()
|
||||
void Launcher::DataFilesPage::setupDataFiles()
|
||||
{
|
||||
QStringList paths = mGameSettings.getDataDirs();
|
||||
|
||||
|
@ -197,7 +207,7 @@ void DataFilesPage::setupDataFiles()
|
|||
loadSettings();
|
||||
}
|
||||
|
||||
void DataFilesPage::on_newProfileAction_triggered()
|
||||
void Launcher::DataFilesPage::on_newProfileAction_triggered()
|
||||
{
|
||||
TextInputDialog newDialog (tr("New Profile"), tr("Profile name:"), this);
|
||||
|
||||
|
@ -222,7 +232,7 @@ void DataFilesPage::on_newProfileAction_triggered()
|
|||
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())
|
||||
return;
|
||||
|
@ -236,7 +246,7 @@ void DataFilesPage::addProfile (const QString &profile, bool setAsCurrent)
|
|||
setProfile (ui.profilesComboBox->findText (profile), false);
|
||||
}
|
||||
|
||||
void DataFilesPage::on_deleteProfileAction_triggered()
|
||||
void Launcher::DataFilesPage::on_deleteProfileAction_triggered()
|
||||
{
|
||||
QString profile = ui.profilesComboBox->currentText();
|
||||
|
||||
|
@ -254,7 +264,7 @@ void DataFilesPage::on_deleteProfileAction_triggered()
|
|||
checkForDefaultProfile();
|
||||
}
|
||||
|
||||
void DataFilesPage::checkForDefaultProfile()
|
||||
void Launcher::DataFilesPage::checkForDefaultProfile()
|
||||
{
|
||||
//don't allow deleting "Default" profile
|
||||
bool success = (ui.profilesComboBox->currentText() != "Default");
|
||||
|
@ -263,7 +273,7 @@ void DataFilesPage::checkForDefaultProfile()
|
|||
ui.profilesComboBox->setEditEnabled (success);
|
||||
}
|
||||
|
||||
bool DataFilesPage::showDeleteMessageBox (const QString &text)
|
||||
bool Launcher::DataFilesPage::showDeleteMessageBox (const QString &text)
|
||||
{
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Delete Profile"));
|
||||
|
|
|
@ -3,49 +3,47 @@
|
|||
|
||||
#include "ui_datafilespage.h"
|
||||
#include <QWidget>
|
||||
#include <QModelIndex>
|
||||
|
||||
class QSortFilterProxyModel;
|
||||
class QAbstractItemModel;
|
||||
class QAction;
|
||||
class QMenu;
|
||||
|
||||
class TextInputDialog;
|
||||
class GameSettings;
|
||||
class LauncherSettings;
|
||||
class ProfilesComboBox;
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
namespace ContentSelectorView { class ContentSelector; }
|
||||
|
||||
class DataFilesPage : public QWidget
|
||||
namespace Launcher
|
||||
{
|
||||
class TextInputDialog;
|
||||
class GameSettings;
|
||||
class LauncherSettings;
|
||||
class ProfilesComboBox;
|
||||
|
||||
class DataFilesPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
ContentSelectorView::ContentSelector *mSelector;
|
||||
Ui::DataFilesPage ui;
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit DataFilesPage (Files::ConfigurationManager &cfg, GameSettings &gameSettings,
|
||||
LauncherSettings &launcherSettings, QWidget *parent = 0);
|
||||
|
||||
QAbstractItemModel* profilesModel() const
|
||||
{ return ui.profilesComboBox->model(); }
|
||||
QAbstractItemModel* profilesModel() const;
|
||||
|
||||
int profilesIndex() const
|
||||
{ return ui.profilesComboBox->currentIndex(); }
|
||||
int profilesIndex() const;
|
||||
|
||||
//void writeConfig(QString profile = QString());
|
||||
void saveSettings(const QString &profile = "");
|
||||
void loadSettings();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void signalProfileChanged (int index);
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void slotProfileChanged (int index);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
|
||||
void slotProfileChangedByUser(const QString &previous, const QString ¤t);
|
||||
void slotProfileRenamed(const QString &previous, const QString ¤t);
|
||||
|
@ -54,7 +52,7 @@ private slots:
|
|||
void on_newProfileAction_triggered();
|
||||
void on_deleteProfileAction_triggered();
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
QMenu *mContextMenu;
|
||||
|
||||
|
@ -75,6 +73,6 @@ private:
|
|||
bool showDeleteMessageBox (const QString &text);
|
||||
void addProfile (const QString &profile, bool setAsCurrent);
|
||||
void checkForDefaultProfile();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,7 @@ QString getAspect(int x, int y)
|
|||
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)
|
||||
, mGraphicsSettings(graphicsSetting)
|
||||
, 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
|
||||
Ogre::LogManager* logMgr = OGRE_NEW Ogre::LogManager;
|
||||
|
@ -157,7 +157,7 @@ bool GraphicsPage::setupOgre()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GraphicsPage::setupSDL()
|
||||
bool Launcher::GraphicsPage::setupSDL()
|
||||
{
|
||||
int displays = SDL_GetNumVideoDisplays();
|
||||
|
||||
|
@ -180,7 +180,7 @@ bool GraphicsPage::setupSDL()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GraphicsPage::loadSettings()
|
||||
bool Launcher::GraphicsPage::loadSettings()
|
||||
{
|
||||
if (!setupSDL())
|
||||
return false;
|
||||
|
@ -219,7 +219,7 @@ bool GraphicsPage::loadSettings()
|
|||
return true;
|
||||
}
|
||||
|
||||
void GraphicsPage::saveSettings()
|
||||
void Launcher::GraphicsPage::saveSettings()
|
||||
{
|
||||
vSyncCheckBox->checkState() ? mGraphicsSettings.setValue(QString("Video/vsync"), QString("true"))
|
||||
: mGraphicsSettings.setValue(QString("Video/vsync"), QString("false"));
|
||||
|
@ -246,7 +246,7 @@ void GraphicsPage::saveSettings()
|
|||
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;
|
||||
|
||||
|
@ -279,7 +279,7 @@ QStringList GraphicsPage::getAvailableOptions(const QString &key, Ogre::RenderSy
|
|||
return result;
|
||||
}
|
||||
|
||||
QStringList GraphicsPage::getAvailableResolutions(int screen)
|
||||
QStringList Launcher::GraphicsPage::getAvailableResolutions(int screen)
|
||||
{
|
||||
QStringList result;
|
||||
SDL_DisplayMode mode;
|
||||
|
@ -326,7 +326,7 @@ QStringList GraphicsPage::getAvailableResolutions(int screen)
|
|||
return result;
|
||||
}
|
||||
|
||||
QRect GraphicsPage::getMaximumResolution()
|
||||
QRect Launcher::GraphicsPage::getMaximumResolution()
|
||||
{
|
||||
QRect max;
|
||||
int screens = QApplication::desktop()->screenCount();
|
||||
|
@ -341,7 +341,7 @@ QRect GraphicsPage::getMaximumResolution()
|
|||
return max;
|
||||
}
|
||||
|
||||
void GraphicsPage::rendererChanged(const QString &renderer)
|
||||
void Launcher::GraphicsPage::rendererChanged(const QString &renderer)
|
||||
{
|
||||
mSelectedRenderSystem = mOgre->getRenderSystemByName(renderer.toStdString());
|
||||
|
||||
|
@ -350,7 +350,7 @@ void GraphicsPage::rendererChanged(const QString &renderer)
|
|||
antiAliasingComboBox->addItems(getAvailableOptions(QString("FSAA"), mSelectedRenderSystem));
|
||||
}
|
||||
|
||||
void GraphicsPage::screenChanged(int screen)
|
||||
void Launcher::GraphicsPage::screenChanged(int screen)
|
||||
{
|
||||
if (screen >= 0) {
|
||||
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) {
|
||||
standardRadioButton->toggle();
|
||||
|
@ -372,7 +372,7 @@ void GraphicsPage::slotFullScreenChanged(int state)
|
|||
}
|
||||
}
|
||||
|
||||
void GraphicsPage::slotStandardToggled(bool checked)
|
||||
void Launcher::GraphicsPage::slotStandardToggled(bool checked)
|
||||
{
|
||||
if (checked) {
|
||||
resolutionComboBox->setEnabled(true);
|
||||
|
|
|
@ -18,29 +18,32 @@
|
|||
|
||||
#include "ui_graphicspage.h"
|
||||
|
||||
class GraphicsSettings;
|
||||
|
||||
namespace Files { struct ConfigurationManager; }
|
||||
|
||||
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
||||
namespace Launcher
|
||||
{
|
||||
class GraphicsSettings;
|
||||
|
||||
class GraphicsPage : public QWidget, private Ui::GraphicsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
GraphicsPage(Files::ConfigurationManager &cfg, GraphicsSettings &graphicsSettings, QWidget *parent = 0);
|
||||
|
||||
void saveSettings();
|
||||
bool loadSettings();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void rendererChanged(const QString &renderer);
|
||||
void screenChanged(int screen);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void slotFullScreenChanged(int state);
|
||||
void slotStandardToggled(bool checked);
|
||||
|
||||
private:
|
||||
private:
|
||||
Ogre::Root *mOgre;
|
||||
Ogre::RenderSystem *mSelectedRenderSystem;
|
||||
Ogre::RenderSystem *mOpenGLRenderSystem;
|
||||
|
@ -61,6 +64,6 @@ private:
|
|||
|
||||
bool setupOgre();
|
||||
bool setupSDL();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char *argv[])
|
|||
// Support non-latin characters
|
||||
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
MainDialog mainWin;
|
||||
Launcher::MainDialog mainWin;
|
||||
|
||||
if (mainWin.setup()) {
|
||||
mainWin.show();
|
||||
|
@ -61,4 +61,3 @@ int main(int argc, char *argv[])
|
|||
SDL_Quit();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "maindialog.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QFontDatabase>
|
||||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
|
@ -23,8 +24,8 @@
|
|||
#include "graphicspage.hpp"
|
||||
#include "datafilespage.hpp"
|
||||
|
||||
MainDialog::MainDialog()
|
||||
: mGameSettings(mCfgMgr)
|
||||
Launcher::MainDialog::MainDialog(QWidget *parent)
|
||||
: mGameSettings(mCfgMgr), QMainWindow (parent)
|
||||
{
|
||||
// Install the stylesheet font
|
||||
QFile file;
|
||||
|
@ -69,7 +70,7 @@ MainDialog::MainDialog()
|
|||
createIcons();
|
||||
}
|
||||
|
||||
void MainDialog::createIcons()
|
||||
void Launcher::MainDialog::createIcons()
|
||||
{
|
||||
if (!QIcon::hasThemeIcon("document-new"))
|
||||
QIcon::setThemeName("tango");
|
||||
|
@ -101,7 +102,7 @@ void MainDialog::createIcons()
|
|||
|
||||
}
|
||||
|
||||
void MainDialog::createPages()
|
||||
void Launcher::MainDialog::createPages()
|
||||
{
|
||||
mPlayPage = new PlayPage(this);
|
||||
mGraphicsPage = new GraphicsPage(mCfgMgr, mGraphicsSettings, this);
|
||||
|
@ -126,7 +127,7 @@ void MainDialog::createPages()
|
|||
|
||||
}
|
||||
|
||||
bool MainDialog::showFirstRunDialog()
|
||||
bool Launcher::MainDialog::showFirstRunDialog()
|
||||
{
|
||||
QStringList iniPaths;
|
||||
|
||||
|
@ -282,7 +283,7 @@ bool MainDialog::showFirstRunDialog()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MainDialog::setup()
|
||||
bool Launcher::MainDialog::setup()
|
||||
{
|
||||
if (!setupLauncherSettings())
|
||||
return false;
|
||||
|
@ -311,7 +312,7 @@ bool MainDialog::setup()
|
|||
return true;
|
||||
}
|
||||
|
||||
void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
void Launcher::MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||
{
|
||||
if (!current)
|
||||
current = previous;
|
||||
|
@ -337,7 +338,7 @@ void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
|
|||
}
|
||||
}
|
||||
|
||||
bool MainDialog::setupLauncherSettings()
|
||||
bool Launcher::MainDialog::setupLauncherSettings()
|
||||
{
|
||||
mLauncherSettings.setMultiValueEnabled(true);
|
||||
|
||||
|
@ -374,7 +375,7 @@ bool MainDialog::setupLauncherSettings()
|
|||
}
|
||||
|
||||
#ifndef WIN32
|
||||
bool expansions(UnshieldThread& cd)
|
||||
bool Launcher::expansions(Launcher::UnshieldThread& cd)
|
||||
{
|
||||
if(cd.BloodmoonDone())
|
||||
{
|
||||
|
@ -445,7 +446,7 @@ bool expansions(UnshieldThread& cd)
|
|||
}
|
||||
#endif // WIN32
|
||||
|
||||
bool MainDialog::setupGameSettings()
|
||||
bool Launcher::MainDialog::setupGameSettings()
|
||||
{
|
||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
|
||||
|
@ -568,7 +569,7 @@ bool MainDialog::setupGameSettings()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool MainDialog::setupGraphicsSettings()
|
||||
bool Launcher::MainDialog::setupGraphicsSettings()
|
||||
{
|
||||
mGraphicsSettings.setMultiValueEnabled(false);
|
||||
|
||||
|
@ -622,7 +623,7 @@ bool MainDialog::setupGraphicsSettings()
|
|||
return true;
|
||||
}
|
||||
|
||||
void MainDialog::loadSettings()
|
||||
void Launcher::MainDialog::loadSettings()
|
||||
{
|
||||
int width = mLauncherSettings.value(QString("General/MainWindow/width")).toInt();
|
||||
int height = mLauncherSettings.value(QString("General/MainWindow/height")).toInt();
|
||||
|
@ -634,7 +635,7 @@ void MainDialog::loadSettings()
|
|||
move(posX, posY);
|
||||
}
|
||||
|
||||
void MainDialog::saveSettings()
|
||||
void Launcher::MainDialog::saveSettings()
|
||||
{
|
||||
QString width = QString::number(this->width());
|
||||
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
|
||||
saveSettings();
|
||||
|
@ -745,13 +746,13 @@ bool MainDialog::writeSettings()
|
|||
return true;
|
||||
}
|
||||
|
||||
void MainDialog::closeEvent(QCloseEvent *event)
|
||||
void Launcher::MainDialog::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
writeSettings();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void MainDialog::play()
|
||||
void Launcher::MainDialog::play()
|
||||
{
|
||||
if (!writeSettings()) {
|
||||
qApp->quit();
|
||||
|
@ -774,7 +775,7 @@ void MainDialog::play()
|
|||
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;
|
||||
#ifdef Q_OS_WIN
|
||||
|
|
|
@ -11,31 +11,33 @@
|
|||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QStackedWidget;
|
||||
class QStringList;
|
||||
class QStringListModel;
|
||||
class QString;
|
||||
|
||||
class PlayPage;
|
||||
class GraphicsPage;
|
||||
class DataFilesPage;
|
||||
|
||||
class MainDialog : public QMainWindow, private Ui::MainWindow
|
||||
namespace Launcher
|
||||
{
|
||||
class PlayPage;
|
||||
class GraphicsPage;
|
||||
class DataFilesPage;
|
||||
class UnshieldThread;
|
||||
|
||||
#ifndef WIN32
|
||||
bool expansions(Launcher::UnshieldThread& cd);
|
||||
#endif
|
||||
|
||||
class MainDialog : public QMainWindow, private Ui::MainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainDialog();
|
||||
public:
|
||||
explicit MainDialog(QWidget *parent = 0);
|
||||
bool setup();
|
||||
bool showFirstRunDialog();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void changePage(QListWidgetItem *current, QListWidgetItem *previous);
|
||||
void play();
|
||||
|
||||
private:
|
||||
private:
|
||||
void createIcons();
|
||||
void createPages();
|
||||
|
||||
|
@ -62,6 +64,6 @@ private:
|
|||
GraphicsSettings mGraphicsSettings;
|
||||
LauncherSettings mLauncherSettings;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <QPlastiqueStyle>
|
||||
#endif
|
||||
|
||||
PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
Launcher::PlayPage::PlayPage(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setObjectName ("PlayPage");
|
||||
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);
|
||||
}
|
||||
|
||||
void PlayPage::setProfilesIndex(int index)
|
||||
void Launcher::PlayPage::setProfilesIndex(int index)
|
||||
{
|
||||
profilesComboBox->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void PlayPage::slotPlayClicked()
|
||||
void Launcher::PlayPage::slotPlayClicked()
|
||||
{
|
||||
emit playButtonClicked();
|
||||
}
|
||||
|
|
|
@ -9,26 +9,28 @@ class QComboBox;
|
|||
class QPushButton;
|
||||
class QAbstractItemModel;
|
||||
|
||||
class PlayPage : public QWidget, private Ui::PlayPage
|
||||
namespace Launcher
|
||||
{
|
||||
class PlayPage : public QWidget, private Ui::PlayPage
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
PlayPage(QWidget *parent = 0);
|
||||
void setProfilesModel(QAbstractItemModel *model);
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void signalProfileChanged(int index);
|
||||
void playButtonClicked();
|
||||
|
||||
public slots:
|
||||
public slots:
|
||||
void setProfilesIndex(int index);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void slotPlayClicked();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -26,16 +26,16 @@ namespace boost
|
|||
#endif /* (BOOST_VERSION <= 104600) */
|
||||
|
||||
|
||||
GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
||||
Launcher::GameSettings::GameSettings(Files::ConfigurationManager &cfg)
|
||||
: mCfgMgr(cfg)
|
||||
{
|
||||
}
|
||||
|
||||
GameSettings::~GameSettings()
|
||||
Launcher::GameSettings::~GameSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void GameSettings::validatePaths()
|
||||
void Launcher::GameSettings::validatePaths()
|
||||
{
|
||||
if (mSettings.isEmpty() || !mDataDirs.isEmpty())
|
||||
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())
|
||||
return mSettings.values(key);
|
||||
return defaultValues;
|
||||
}
|
||||
|
||||
bool GameSettings::readFile(QTextStream &stream)
|
||||
bool Launcher::GameSettings::readFile(QTextStream &stream)
|
||||
{
|
||||
QMap<QString, QString> cache;
|
||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||
|
@ -130,7 +130,7 @@ bool GameSettings::readFile(QTextStream &stream)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GameSettings::writeFile(QTextStream &stream)
|
||||
bool Launcher::GameSettings::writeFile(QTextStream &stream)
|
||||
{
|
||||
// Iterate in reverse order to preserve insertion order
|
||||
QMapIterator<QString, QString> i(mSettings);
|
||||
|
|
|
@ -11,9 +11,11 @@
|
|||
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||
struct ConfigurationManager;}
|
||||
|
||||
class GameSettings
|
||||
namespace Launcher
|
||||
{
|
||||
public:
|
||||
class GameSettings
|
||||
{
|
||||
public:
|
||||
GameSettings(Files::ConfigurationManager &cfg);
|
||||
~GameSettings();
|
||||
|
||||
|
@ -49,7 +51,7 @@ public:
|
|||
bool readFile(QTextStream &stream);
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
private:
|
||||
private:
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
|
||||
void validatePaths();
|
||||
|
@ -57,6 +59,6 @@ private:
|
|||
|
||||
QStringList mDataDirs;
|
||||
QString mDataLocal;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // GAMESETTINGS_HPP
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
#include <QRegExp>
|
||||
#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;
|
||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||
|
|
|
@ -3,14 +3,16 @@
|
|||
|
||||
#include "settingsbase.hpp"
|
||||
|
||||
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
||||
namespace Launcher
|
||||
{
|
||||
public:
|
||||
class GraphicsSettings : public SettingsBase<QMap<QString, QString> >
|
||||
{
|
||||
public:
|
||||
GraphicsSettings();
|
||||
~GraphicsSettings();
|
||||
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // GRAPHICSSETTINGS_HPP
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
#include <QRegExp>
|
||||
#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();
|
||||
|
||||
|
@ -34,7 +34,7 @@ QStringList LauncherSettings::values(const QString &key, Qt::MatchFlags flags)
|
|||
return result;
|
||||
}
|
||||
|
||||
QStringList LauncherSettings::subKeys(const QString &key)
|
||||
QStringList Launcher::LauncherSettings::subKeys(const QString &key)
|
||||
{
|
||||
QMap<QString, QString> settings = SettingsBase::getSettings();
|
||||
QStringList keys = settings.uniqueKeys();
|
||||
|
@ -61,7 +61,7 @@ QStringList LauncherSettings::subKeys(const QString &key)
|
|||
return result;
|
||||
}
|
||||
|
||||
bool LauncherSettings::writeFile(QTextStream &stream)
|
||||
bool Launcher::LauncherSettings::writeFile(QTextStream &stream)
|
||||
{
|
||||
QString sectionPrefix;
|
||||
QRegExp sectionRe("([^/]+)/(.+)$");
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
|
||||
#include "settingsbase.hpp"
|
||||
|
||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
||||
namespace Launcher
|
||||
{
|
||||
public:
|
||||
class LauncherSettings : public SettingsBase<QMap<QString, QString> >
|
||||
{
|
||||
public:
|
||||
LauncherSettings();
|
||||
~LauncherSettings();
|
||||
|
||||
|
@ -14,6 +16,6 @@ public:
|
|||
|
||||
bool writeFile(QTextStream &stream);
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // LAUNCHERSETTINGS_HPP
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
#include <QRegExp>
|
||||
#include <QMap>
|
||||
|
||||
template <class Map>
|
||||
class SettingsBase
|
||||
namespace Launcher
|
||||
{
|
||||
template <class Map>
|
||||
class SettingsBase
|
||||
{
|
||||
|
||||
public:
|
||||
public:
|
||||
SettingsBase() { mMultiValue = false; }
|
||||
~SettingsBase() {}
|
||||
|
||||
|
@ -99,11 +101,11 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
Map mSettings;
|
||||
Map mCache;
|
||||
|
||||
bool mMultiValue;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // SETTINGSBASE_HPP
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "textslotmsgbox.hpp"
|
||||
|
||||
void TextSlotMsgBox::setTextSlot(const QString& string)
|
||||
void Launcher::TextSlotMsgBox::setTextSlot(const QString& string)
|
||||
{
|
||||
setText(string);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
|
||||
#include <QMessageBox>
|
||||
|
||||
class TextSlotMsgBox : public QMessageBox
|
||||
namespace Launcher
|
||||
{
|
||||
Q_OBJECT
|
||||
class TextSlotMsgBox : public QMessageBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void setTextSlot(const QString& string);
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -292,30 +292,30 @@ namespace
|
|||
|
||||
}
|
||||
|
||||
bool UnshieldThread::SetMorrowindPath(const std::string& path)
|
||||
bool Launcher::UnshieldThread::SetMorrowindPath(const std::string& path)
|
||||
{
|
||||
mMorrowindPath = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnshieldThread::SetTribunalPath(const std::string& path)
|
||||
bool Launcher::UnshieldThread::SetTribunalPath(const std::string& path)
|
||||
{
|
||||
mTribunalPath = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UnshieldThread::SetBloodmoonPath(const std::string& path)
|
||||
bool Launcher::UnshieldThread::SetBloodmoonPath(const std::string& path)
|
||||
{
|
||||
mBloodmoonPath = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnshieldThread::SetOutputPath(const std::string& path)
|
||||
void Launcher::UnshieldThread::SetOutputPath(const std::string& 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;
|
||||
bfs::path dirname;
|
||||
|
@ -349,7 +349,7 @@ bool UnshieldThread::extract_file(Unshield* unshield, bfs::path output_dir, cons
|
|||
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_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;
|
||||
outputDataFilesDir /= "Data Files";
|
||||
|
@ -475,7 +475,7 @@ bool UnshieldThread::extract()
|
|||
return true;
|
||||
}
|
||||
|
||||
void UnshieldThread::Done()
|
||||
void Launcher::UnshieldThread::Done()
|
||||
{
|
||||
// Get rid of unnecessary files
|
||||
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"));
|
||||
}
|
||||
|
||||
std::string UnshieldThread::GetMWEsmPath()
|
||||
std::string Launcher::UnshieldThread::GetMWEsmPath()
|
||||
{
|
||||
return findFile(mOutputPath / "Data Files", "morrowind.esm").string();
|
||||
}
|
||||
|
||||
bool UnshieldThread::TribunalDone()
|
||||
bool Launcher::UnshieldThread::TribunalDone()
|
||||
{
|
||||
return mTribunalDone;
|
||||
}
|
||||
|
||||
bool UnshieldThread::BloodmoonDone()
|
||||
bool Launcher::UnshieldThread::BloodmoonDone()
|
||||
{
|
||||
return mBloodmoonDone;
|
||||
}
|
||||
|
||||
void UnshieldThread::run()
|
||||
void Launcher::UnshieldThread::run()
|
||||
{
|
||||
extract();
|
||||
emit close();
|
||||
}
|
||||
|
||||
UnshieldThread::UnshieldThread()
|
||||
Launcher::UnshieldThread::UnshieldThread()
|
||||
{
|
||||
unshield_set_log_level(0);
|
||||
mMorrowindDone = false;
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
#include <libunshield.h>
|
||||
|
||||
class UnshieldThread : public QThread
|
||||
namespace Launcher
|
||||
{
|
||||
class UnshieldThread : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
@ -51,6 +53,6 @@ class UnshieldThread : public QThread
|
|||
signals:
|
||||
void signalGUI(QString);
|
||||
void close();
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -54,13 +54,9 @@
|
|||
Emulates the QMessageBox API with
|
||||
static conveniences. The message label can open external URLs.
|
||||
*/
|
||||
|
||||
class CheckableMessageBoxPrivate
|
||||
{
|
||||
public:
|
||||
CheckableMessageBoxPrivate(QDialog *q)
|
||||
Launcher::CheckableMessageBoxPrivate::CheckableMessageBoxPrivate(QDialog *q)
|
||||
: clickedButton(0)
|
||||
{
|
||||
{
|
||||
QSizePolicy sizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
|
||||
pixmapLabel = new QLabel(q);
|
||||
|
@ -85,7 +81,7 @@ public:
|
|||
new QSpacerItem(0, 1, QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
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->setOrientation(Qt::Horizontal);
|
||||
|
@ -108,18 +104,11 @@ public:
|
|||
verticalLayout_2->addLayout(horizontalLayout);
|
||||
verticalLayout_2->addItem(buttonSpacer);
|
||||
verticalLayout_2->addWidget(buttonBox);
|
||||
}
|
||||
}
|
||||
|
||||
QLabel *pixmapLabel;
|
||||
QLabel *messageLabel;
|
||||
QCheckBox *checkBox;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QAbstractButton *clickedButton;
|
||||
};
|
||||
|
||||
CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
|
||||
Launcher::CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
d(new CheckableMessageBoxPrivate(this))
|
||||
d(new Launcher::CheckableMessageBoxPrivate(this))
|
||||
{
|
||||
setModal(true);
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
@ -129,102 +118,102 @@ CheckableMessageBox::CheckableMessageBox(QWidget *parent) :
|
|||
SLOT(slotClicked(QAbstractButton*)));
|
||||
}
|
||||
|
||||
CheckableMessageBox::~CheckableMessageBox()
|
||||
Launcher::CheckableMessageBox::~CheckableMessageBox()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void CheckableMessageBox::slotClicked(QAbstractButton *b)
|
||||
void Launcher::CheckableMessageBox::slotClicked(QAbstractButton *b)
|
||||
{
|
||||
d->clickedButton = b;
|
||||
}
|
||||
|
||||
QAbstractButton *CheckableMessageBox::clickedButton() const
|
||||
QAbstractButton *Launcher::CheckableMessageBox::clickedButton() const
|
||||
{
|
||||
return d->clickedButton;
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton CheckableMessageBox::clickedStandardButton() const
|
||||
QDialogButtonBox::StandardButton Launcher::CheckableMessageBox::clickedStandardButton() const
|
||||
{
|
||||
if (d->clickedButton)
|
||||
return d->buttonBox->standardButton(d->clickedButton);
|
||||
return QDialogButtonBox::NoButton;
|
||||
}
|
||||
|
||||
QString CheckableMessageBox::text() const
|
||||
QString Launcher::CheckableMessageBox::text() const
|
||||
{
|
||||
return d->messageLabel->text();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setText(const QString &t)
|
||||
void Launcher::CheckableMessageBox::setText(const QString &t)
|
||||
{
|
||||
d->messageLabel->setText(t);
|
||||
}
|
||||
|
||||
QPixmap CheckableMessageBox::iconPixmap() const
|
||||
QPixmap Launcher::CheckableMessageBox::iconPixmap() const
|
||||
{
|
||||
if (const QPixmap *p = d->pixmapLabel->pixmap())
|
||||
return QPixmap(*p);
|
||||
return QPixmap();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setIconPixmap(const QPixmap &p)
|
||||
void Launcher::CheckableMessageBox::setIconPixmap(const QPixmap &p)
|
||||
{
|
||||
d->pixmapLabel->setPixmap(p);
|
||||
d->pixmapLabel->setVisible(!p.isNull());
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::isChecked() const
|
||||
bool Launcher::CheckableMessageBox::isChecked() const
|
||||
{
|
||||
return d->checkBox->isChecked();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setChecked(bool s)
|
||||
void Launcher::CheckableMessageBox::setChecked(bool s)
|
||||
{
|
||||
d->checkBox->setChecked(s);
|
||||
}
|
||||
|
||||
QString CheckableMessageBox::checkBoxText() const
|
||||
QString Launcher::CheckableMessageBox::checkBoxText() const
|
||||
{
|
||||
return d->checkBox->text();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setCheckBoxText(const QString &t)
|
||||
void Launcher::CheckableMessageBox::setCheckBoxText(const QString &t)
|
||||
{
|
||||
d->checkBox->setText(t);
|
||||
}
|
||||
|
||||
bool CheckableMessageBox::isCheckBoxVisible() const
|
||||
bool Launcher::CheckableMessageBox::isCheckBoxVisible() const
|
||||
{
|
||||
return d->checkBox->isVisible();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setCheckBoxVisible(bool v)
|
||||
void Launcher::CheckableMessageBox::setCheckBoxVisible(bool v)
|
||||
{
|
||||
d->checkBox->setVisible(v);
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButtons CheckableMessageBox::standardButtons() const
|
||||
QDialogButtonBox::StandardButtons Launcher::CheckableMessageBox::standardButtons() const
|
||||
{
|
||||
return d->buttonBox->standardButtons();
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons s)
|
||||
void Launcher::CheckableMessageBox::setStandardButtons(QDialogButtonBox::StandardButtons 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
|
||||
QDialogButtonBox::StandardButton Launcher::CheckableMessageBox::defaultButton() const
|
||||
{
|
||||
foreach (QAbstractButton *b, d->buttonBox->buttons())
|
||||
if (QPushButton *pb = qobject_cast<QPushButton *>(b))
|
||||
|
@ -233,7 +222,7 @@ QDialogButtonBox::StandardButton CheckableMessageBox::defaultButton() const
|
|||
return QDialogButtonBox::NoButton;
|
||||
}
|
||||
|
||||
void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
|
||||
void Launcher::CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
|
||||
{
|
||||
if (QPushButton *b = d->buttonBox->button(s)) {
|
||||
b->setDefault(true);
|
||||
|
@ -242,7 +231,7 @@ void CheckableMessageBox::setDefaultButton(QDialogButtonBox::StandardButton s)
|
|||
}
|
||||
|
||||
QDialogButtonBox::StandardButton
|
||||
CheckableMessageBox::question(QWidget *parent,
|
||||
Launcher::CheckableMessageBox::question(QWidget *parent,
|
||||
const QString &title,
|
||||
const QString &question,
|
||||
const QString &checkBoxText,
|
||||
|
@ -263,7 +252,7 @@ CheckableMessageBox::question(QWidget *parent,
|
|||
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));
|
||||
}
|
||||
|
|
|
@ -34,10 +34,26 @@
|
|||
#include <QMessageBox>
|
||||
#include <QDialog>
|
||||
|
||||
class CheckableMessageBoxPrivate;
|
||||
class QCheckBox;
|
||||
|
||||
class CheckableMessageBox : public QDialog
|
||||
namespace Launcher
|
||||
{
|
||||
class CheckableMessageBoxPrivate
|
||||
{
|
||||
public:
|
||||
|
||||
QLabel *pixmapLabel;
|
||||
QLabel *messageLabel;
|
||||
QCheckBox *checkBox;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QAbstractButton *clickedButton;
|
||||
|
||||
public:
|
||||
CheckableMessageBoxPrivate(QDialog *q);
|
||||
};
|
||||
|
||||
class CheckableMessageBox : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
|
||||
|
@ -46,7 +62,7 @@ class CheckableMessageBox : public QDialog
|
|||
Q_PROPERTY(QDialogButtonBox::StandardButtons buttons READ standardButtons WRITE setStandardButtons)
|
||||
Q_PROPERTY(QDialogButtonBox::StandardButton defaultButton READ defaultButton WRITE setDefaultButton)
|
||||
|
||||
public:
|
||||
public:
|
||||
explicit CheckableMessageBox(QWidget *parent);
|
||||
virtual ~CheckableMessageBox();
|
||||
|
||||
|
@ -90,11 +106,11 @@ public:
|
|||
// Conversion convenience
|
||||
static QMessageBox::StandardButton dialogButtonBoxToMessageBoxButton(QDialogButtonBox::StandardButton);
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void slotClicked(QAbstractButton *b);
|
||||
|
||||
private:
|
||||
private:
|
||||
CheckableMessageBoxPrivate *d;
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
#endif // CHECKABLEMESSAGEBOX_HPP
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <QValidator>
|
||||
#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)
|
||||
{
|
||||
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->setFocus();
|
||||
return QDialog::exec();
|
||||
}
|
||||
|
||||
QString TextInputDialog::getText() const
|
||||
QString Launcher::TextInputDialog::getText() const
|
||||
{
|
||||
return mLineEdit->text();
|
||||
}
|
||||
|
||||
void TextInputDialog::slotUpdateOkButton(QString text)
|
||||
void Launcher::TextInputDialog::slotUpdateOkButton(QString text)
|
||||
{
|
||||
bool enabled = !(text.isEmpty());
|
||||
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)
|
||||
{
|
||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
|
||||
class QDialogButtonBox;
|
||||
|
||||
class LineEdit;
|
||||
|
||||
class TextInputDialog : public QDialog
|
||||
namespace Launcher
|
||||
{
|
||||
class TextInputDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class DialogLineEdit : public LineEdit
|
||||
|
@ -22,7 +22,7 @@ class TextInputDialog : public QDialog
|
|||
DialogLineEdit *mLineEdit;
|
||||
QDialogButtonBox *mButtonBox;
|
||||
|
||||
public:
|
||||
public:
|
||||
|
||||
explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0);
|
||||
~TextInputDialog () {}
|
||||
|
@ -31,9 +31,10 @@ public:
|
|||
|
||||
int exec();
|
||||
|
||||
private slots:
|
||||
private slots:
|
||||
void slotUpdateOkButton(QString text);
|
||||
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // TEXTINPUTDIALOG_HPP
|
||||
|
|
Loading…
Reference in a new issue