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

WIP: Implementing the .ui for the DataFilesPage

This commit is contained in:
Pieter van der Kloet 2013-03-05 03:13:39 +01:00
parent fb5213a754
commit 4c9d0563fe
9 changed files with 155 additions and 160 deletions

View file

@ -12,8 +12,6 @@ set(LAUNCHER
settings/launchersettings.cpp settings/launchersettings.cpp
utils/checkablemessagebox.cpp utils/checkablemessagebox.cpp
utils/comboboxlineedit.cpp
utils/profilescombobox.cpp
utils/textinputdialog.cpp utils/textinputdialog.cpp
launcher.rc launcher.rc
@ -33,8 +31,6 @@ set(LAUNCHER_HEADER
settings/settingsbase.hpp settings/settingsbase.hpp
utils/checkablemessagebox.hpp utils/checkablemessagebox.hpp
utils/comboboxlineedit.hpp
utils/profilescombobox.hpp
utils/textinputdialog.hpp utils/textinputdialog.hpp
) )
@ -49,15 +45,14 @@ set(LAUNCHER_HEADER_MOC
model/pluginsproxymodel.hpp model/pluginsproxymodel.hpp
utils/checkablemessagebox.hpp utils/checkablemessagebox.hpp
utils/comboboxlineedit.hpp
utils/profilescombobox.hpp
utils/textinputdialog.hpp utils/textinputdialog.hpp
) )
set(LAUNCHER_UI set(LAUNCHER_UI
./ui/graphicspage.ui ui/datafilespage.ui
./ui/mainwindow.ui ui/graphicspage.ui
./ui/playpage.ui ui/mainwindow.ui
ui/playpage.ui
) )
source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER}) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER})

View file

@ -10,13 +10,13 @@
#include <components/fileorderlist/utils/lineedit.hpp> #include <components/fileorderlist/utils/lineedit.hpp>
#include <components/fileorderlist/utils/naturalsort.hpp> #include <components/fileorderlist/utils/naturalsort.hpp>
#include <components/fileorderlist/utils/profilescombobox.hpp>
#include "model/pluginsproxymodel.hpp" #include "model/pluginsproxymodel.hpp"
#include "settings/gamesettings.hpp" #include "settings/gamesettings.hpp"
#include "settings/launchersettings.hpp" #include "settings/launchersettings.hpp"
#include "utils/profilescombobox.hpp"
#include "utils/textinputdialog.hpp" #include "utils/textinputdialog.hpp"
using namespace ESM; using namespace ESM;
@ -40,6 +40,8 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
, mLauncherSettings(launcherSettings) , mLauncherSettings(launcherSettings)
, QWidget(parent) , QWidget(parent)
{ {
setupUi(this);
// Models // Models
mDataFilesModel = new DataFilesModel(this); mDataFilesModel = new DataFilesModel(this);
@ -57,113 +59,117 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
mFilterProxyModel->setDynamicSortFilter(true); mFilterProxyModel->setDynamicSortFilter(true);
mFilterProxyModel->setSourceModel(mPluginsProxyModel); mFilterProxyModel->setSourceModel(mPluginsProxyModel);
// Filter toolbar
QLabel *filterLabel = new QLabel(tr("&Filter:"), this);
LineEdit *filterLineEdit = new LineEdit(this);
filterLabel->setBuddy(filterLineEdit);
QToolBar *filterToolBar = new QToolBar(this);
filterToolBar->setMovable(false);
// Create a container widget and a layout to get the spacer to work
QWidget *filterWidget = new QWidget(this);
QHBoxLayout *filterLayout = new QHBoxLayout(filterWidget);
QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
filterLayout->addItem(hSpacer1);
filterLayout->addWidget(filterLabel);
filterLayout->addWidget(filterLineEdit);
filterToolBar->addWidget(filterWidget);
QCheckBox checkBox; QCheckBox checkBox;
unsigned int height = checkBox.sizeHint().height() + 4; unsigned int height = checkBox.sizeHint().height() + 4;
mMastersTable = new QTableView(this); mastersTable->setModel(mMastersProxyModel);
mMastersTable->setModel(mMastersProxyModel); mastersTable->setObjectName("MastersTable");
mMastersTable->setObjectName("MastersTable"); mastersTable->setContextMenuPolicy(Qt::CustomContextMenu);
mMastersTable->setContextMenuPolicy(Qt::CustomContextMenu); mastersTable->setSortingEnabled(false);
mMastersTable->setSortingEnabled(false); mastersTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mMastersTable->setSelectionBehavior(QAbstractItemView::SelectRows); mastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
mMastersTable->setSelectionMode(QAbstractItemView::ExtendedSelection); mastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mMastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers); mastersTable->setAlternatingRowColors(true);
mMastersTable->setAlternatingRowColors(true); mastersTable->horizontalHeader()->setStretchLastSection(true);
mMastersTable->horizontalHeader()->setStretchLastSection(true); mastersTable->horizontalHeader()->hide();
mMastersTable->horizontalHeader()->hide();
// Set the row height to the size of the checkboxes // Set the row height to the size of the checkboxes
mMastersTable->verticalHeader()->setDefaultSectionSize(height); mastersTable->verticalHeader()->setDefaultSectionSize(height);
mMastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); mastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
mMastersTable->verticalHeader()->hide(); mastersTable->verticalHeader()->hide();
mPluginsTable = new QTableView(this); pluginsTable->setModel(mFilterProxyModel);
mPluginsTable->setModel(mFilterProxyModel); pluginsTable->setObjectName("PluginsTable");
mPluginsTable->setObjectName("PluginsTable"); pluginsTable->setContextMenuPolicy(Qt::CustomContextMenu);
mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu); pluginsTable->setSortingEnabled(false);
mPluginsTable->setSortingEnabled(false); pluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows);
mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows); pluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection);
mPluginsTable->setSelectionMode(QAbstractItemView::ExtendedSelection); pluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); pluginsTable->setAlternatingRowColors(true);
mPluginsTable->setAlternatingRowColors(true); pluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); pluginsTable->horizontalHeader()->setStretchLastSection(true);
mPluginsTable->horizontalHeader()->setStretchLastSection(true); pluginsTable->horizontalHeader()->hide();
mPluginsTable->horizontalHeader()->hide();
mPluginsTable->verticalHeader()->setDefaultSectionSize(height); pluginsTable->verticalHeader()->setDefaultSectionSize(height);
mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); pluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed);
// Add both tables to a splitter // Adjust the tableview widths inside the splitter
mSplitter = new QSplitter(this);
mSplitter->setOrientation(Qt::Horizontal);
mSplitter->setChildrenCollapsible(false); // Don't allow the widgets to be hidden
mSplitter->addWidget(mMastersTable);
mSplitter->addWidget(mPluginsTable);
// Adjust the default widget widths inside the splitter
QList<int> sizeList; QList<int> sizeList;
sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt(); sizeList << mLauncherSettings.value(QString("General/MastersTable/width"), QString("200")).toInt();
sizeList << mLauncherSettings.value(QString("General/PluginTable/width"), QString("340")).toInt(); sizeList << mLauncherSettings.value(QString("General/PluginTable/width"), QString("340")).toInt();
mSplitter->setSizes(sizeList); splitter->setSizes(sizeList);
// Bottom part with profile options // // Filter toolbar
QLabel *profileLabel = new QLabel(tr("Current Profile: "), this); // QLabel *filterLabel = new QLabel(tr("&Filter:"), this);
// LineEdit *filterLineEdit = new LineEdit(this);
// filterLabel->setBuddy(filterLineEdit);
mProfilesComboBox = new ProfilesComboBox(this); // QToolBar *filterToolBar = new QToolBar(this);
mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); // filterToolBar->setMovable(false);
mProfilesComboBox->setInsertPolicy(QComboBox::NoInsert);
mProfilesComboBox->setDuplicatesEnabled(false);
mProfilesComboBox->setEditEnabled(false);
mProfileToolBar = new QToolBar(this); // // Create a container widget and a layout to get the spacer to work
mProfileToolBar->setMovable(false); // QWidget *filterWidget = new QWidget(this);
mProfileToolBar->setIconSize(QSize(16, 16)); // QHBoxLayout *filterLayout = new QHBoxLayout(filterWidget);
// QSpacerItem *hSpacer1 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
mProfileToolBar->addWidget(profileLabel); // filterLayout->addItem(hSpacer1);
mProfileToolBar->addWidget(mProfilesComboBox); // filterLayout->addWidget(filterLabel);
// filterLayout->addWidget(filterLineEdit);
QVBoxLayout *pageLayout = new QVBoxLayout(this); // filterToolBar->addWidget(filterWidget);
pageLayout->addWidget(filterToolBar);
pageLayout->addWidget(mSplitter);
pageLayout->addWidget(mProfileToolBar); // // Add both tables to a splitter
// mSplitter = new QSplitter(this);
// mSplitter->setOrientation(Qt::Horizontal);
// mSplitter->setChildrenCollapsible(false); // Don't allow the widgets to be hidden
// mSplitter->addWidget(mastersTable);
// mSplitter->addWidget(pluginsTable);
//
// // Bottom part with profile options
// QLabel *profileLabel = new QLabel(tr("Current Profile: "), this);
// profilesComboBox = new ProfilesComboBox(this);
// profilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
// profilesComboBox->setInsertPolicy(QComboBox::NoInsert);
// profilesComboBox->setDuplicatesEnabled(false);
// profilesComboBox->setEditEnabled(false);
// mProfileToolBar = new QToolBar(this);
// mProfileToolBar->setMovable(false);
// mProfileToolBar->setIconSize(QSize(16, 16));
// mProfileToolBar->addWidget(profileLabel);
// mProfileToolBar->addWidget(profilesComboBox);
// QVBoxLayout *pageLayout = new QVBoxLayout(this);
// pageLayout->addWidget(filterToolBar);
// pageLayout->addWidget(mSplitter);
// pageLayout->addWidget(mProfileToolBar);
// Create a dialog for the new profile name input // Create a dialog for the new profile name input
mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this); mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this);
connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString))); connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString)));
connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(pluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex)));
connect(mPluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(pluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(mMastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(mastersTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews())); connect(mDataFilesModel, SIGNAL(layoutChanged()), this, SLOT(updateViews()));
connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
connect(mSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter())); connect(splitter, SIGNAL(splitterMoved(int,int)), this, SLOT(updateSplitter()));
createActions(); createActions();
setupDataFiles(); setupDataFiles();
@ -188,9 +194,9 @@ void DataFilesPage::createActions()
connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile())); connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile()));
// Add the newly created actions to the toolbar // Add the newly created actions to the toolbar
mProfileToolBar->addSeparator(); // mProfileToolBar->addSeparator();
mProfileToolBar->addAction(mNewProfileAction); // mProfileToolBar->addAction(mNewProfileAction);
mProfileToolBar->addAction(mDeleteProfileAction); // mProfileToolBar->addAction(mDeleteProfileAction);
// Context menu actions // Context menu actions
mCheckAction = new QAction(tr("Check Selection"), this); mCheckAction = new QAction(tr("Check Selection"), this);
@ -226,25 +232,25 @@ void DataFilesPage::setupDataFiles()
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile")); QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
if (!profiles.isEmpty()) if (!profiles.isEmpty())
mProfilesComboBox->addItems(profiles); profilesComboBox->addItems(profiles);
// Add the current profile if empty // Add the current profile if empty
if (mProfilesComboBox->findText(profile) == -1) if (profilesComboBox->findText(profile) == -1)
mProfilesComboBox->addItem(profile); profilesComboBox->addItem(profile);
if (mProfilesComboBox->findText(QString("Default")) == -1) if (profilesComboBox->findText(QString("Default")) == -1)
mProfilesComboBox->addItem(QString("Default")); profilesComboBox->addItem(QString("Default"));
if (profile.isEmpty() || profile == QLatin1String("Default")) { if (profile.isEmpty() || profile == QLatin1String("Default")) {
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(QString("Default"))); profilesComboBox->setCurrentIndex(profilesComboBox->findText(QString("Default")));
} else { } else {
mProfilesComboBox->setEditEnabled(true); profilesComboBox->setEditEnabled(true);
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(profile)); profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
} }
// We do this here to prevent deletion of profiles when initializing the combobox // We do this here to prevent deletion of profiles when initializing the combobox
connect(mProfilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString))); connect(profilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString)));
connect(mProfilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString))); connect(profilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString)));
loadSettings(); loadSettings();
@ -283,7 +289,7 @@ void DataFilesPage::saveSettings()
QString profile = mLauncherSettings.value(QString("Profiles/currentprofile")); QString profile = mLauncherSettings.value(QString("Profiles/currentprofile"));
if (profile.isEmpty()) { if (profile.isEmpty()) {
profile = mProfilesComboBox->currentText(); profile = profilesComboBox->currentText();
mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile); mLauncherSettings.setValue(QString("Profiles/currentprofile"), profile);
} }
@ -313,8 +319,8 @@ void DataFilesPage::newProfile()
{ {
if (mNewProfileDialog->exec() == QDialog::Accepted) { if (mNewProfileDialog->exec() == QDialog::Accepted) {
QString profile = mNewProfileDialog->lineEdit()->text(); QString profile = mNewProfileDialog->lineEdit()->text();
mProfilesComboBox->addItem(profile); profilesComboBox->addItem(profile);
mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(profile)); profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
} }
} }
@ -326,7 +332,7 @@ void DataFilesPage::updateOkButton(const QString &text)
return; return;
} }
(mProfilesComboBox->findText(text) == -1) (profilesComboBox->findText(text) == -1)
? mNewProfileDialog->setOkButtonEnabled(true) ? mNewProfileDialog->setOkButtonEnabled(true)
: mNewProfileDialog->setOkButtonEnabled(false); : mNewProfileDialog->setOkButtonEnabled(false);
} }
@ -335,7 +341,7 @@ void DataFilesPage::updateSplitter()
{ {
// Sigh, update the saved splitter size in settings only when moved // Sigh, update the saved splitter size in settings only when moved
// Since getting mSplitter->sizes() if page is hidden returns invalid values // Since getting mSplitter->sizes() if page is hidden returns invalid values
QList<int> sizes = mSplitter->sizes(); QList<int> sizes = splitter->sizes();
mLauncherSettings.setValue(QString("General/MastersTable/width"), QString::number(sizes.at(0))); mLauncherSettings.setValue(QString("General/MastersTable/width"), QString::number(sizes.at(0)));
mLauncherSettings.setValue(QString("General/PluginsTable/width"), QString::number(sizes.at(1))); mLauncherSettings.setValue(QString("General/PluginsTable/width"), QString::number(sizes.at(1)));
@ -344,28 +350,28 @@ void DataFilesPage::updateSplitter()
void DataFilesPage::updateViews() void DataFilesPage::updateViews()
{ {
// Ensure the columns are hidden because sort() re-enables them // Ensure the columns are hidden because sort() re-enables them
mMastersTable->setColumnHidden(1, true); mastersTable->setColumnHidden(1, true);
mMastersTable->setColumnHidden(2, true); mastersTable->setColumnHidden(2, true);
mMastersTable->setColumnHidden(3, true); mastersTable->setColumnHidden(3, true);
mMastersTable->setColumnHidden(4, true); mastersTable->setColumnHidden(4, true);
mMastersTable->setColumnHidden(5, true); mastersTable->setColumnHidden(5, true);
mMastersTable->setColumnHidden(6, true); mastersTable->setColumnHidden(6, true);
mMastersTable->setColumnHidden(7, true); mastersTable->setColumnHidden(7, true);
mMastersTable->setColumnHidden(8, true); mastersTable->setColumnHidden(8, true);
mPluginsTable->setColumnHidden(1, true); pluginsTable->setColumnHidden(1, true);
mPluginsTable->setColumnHidden(2, true); pluginsTable->setColumnHidden(2, true);
mPluginsTable->setColumnHidden(3, true); pluginsTable->setColumnHidden(3, true);
mPluginsTable->setColumnHidden(4, true); pluginsTable->setColumnHidden(4, true);
mPluginsTable->setColumnHidden(5, true); pluginsTable->setColumnHidden(5, true);
mPluginsTable->setColumnHidden(6, true); pluginsTable->setColumnHidden(6, true);
mPluginsTable->setColumnHidden(7, true); pluginsTable->setColumnHidden(7, true);
mPluginsTable->setColumnHidden(8, true); pluginsTable->setColumnHidden(8, true);
} }
void DataFilesPage::deleteProfile() void DataFilesPage::deleteProfile()
{ {
QString profile = mProfilesComboBox->currentText(); QString profile = profilesComboBox->currentText();
if (profile.isEmpty()) if (profile.isEmpty())
return; return;
@ -386,26 +392,26 @@ void DataFilesPage::deleteProfile()
mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin")); mLauncherSettings.remove(QString("Profiles/") + profile + QString("/plugin"));
// Remove the profile from the combobox // Remove the profile from the combobox
mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile)); profilesComboBox->removeItem(profilesComboBox->findText(profile));
} }
} }
void DataFilesPage::check() void DataFilesPage::check()
{ {
if (mPluginsTable->hasFocus()) if (pluginsTable->hasFocus())
setPluginsCheckstates(Qt::Checked); setPluginsCheckstates(Qt::Checked);
if (mMastersTable->hasFocus()) if (mastersTable->hasFocus())
setMastersCheckstates(Qt::Checked); setMastersCheckstates(Qt::Checked);
} }
void DataFilesPage::uncheck() void DataFilesPage::uncheck()
{ {
if (mPluginsTable->hasFocus()) if (pluginsTable->hasFocus())
setPluginsCheckstates(Qt::Unchecked); setPluginsCheckstates(Qt::Unchecked);
if (mMastersTable->hasFocus()) if (mastersTable->hasFocus())
setMastersCheckstates(Qt::Unchecked); setMastersCheckstates(Qt::Unchecked);
} }
@ -414,16 +420,16 @@ void DataFilesPage::refresh()
// mDataFilesModel->sort(0); // mDataFilesModel->sort(0);
// Refresh the plugins table // Refresh the plugins table
mPluginsTable->scrollToTop(); pluginsTable->scrollToTop();
} }
void DataFilesPage::setMastersCheckstates(Qt::CheckState state) void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
{ {
if (!mMastersTable->selectionModel()->hasSelection()) { if (!mastersTable->selectionModel()->hasSelection()) {
return; return;
} }
QModelIndexList indexes = mMastersTable->selectionModel()->selectedIndexes(); QModelIndexList indexes = mastersTable->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, indexes) foreach (const QModelIndex &index, indexes)
{ {
@ -441,11 +447,11 @@ void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
void DataFilesPage::setPluginsCheckstates(Qt::CheckState state) void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
{ {
if (!mPluginsTable->selectionModel()->hasSelection()) { if (!pluginsTable->selectionModel()->hasSelection()) {
return; return;
} }
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); QModelIndexList indexes = pluginsTable->selectionModel()->selectedIndexes();
foreach (const QModelIndex &index, indexes) foreach (const QModelIndex &index, indexes)
{ {
@ -509,16 +515,16 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre
// Prevent the deletion of the default profile // Prevent the deletion of the default profile
if (current == QLatin1String("Default")) { if (current == QLatin1String("Default")) {
mDeleteProfileAction->setEnabled(false); mDeleteProfileAction->setEnabled(false);
mProfilesComboBox->setEditEnabled(false); profilesComboBox->setEditEnabled(false);
} else { } else {
mDeleteProfileAction->setEnabled(true); mDeleteProfileAction->setEnabled(true);
mProfilesComboBox->setEditEnabled(true); profilesComboBox->setEditEnabled(true);
} }
if (previous.isEmpty()) if (previous.isEmpty())
return; return;
if (mProfilesComboBox->findText(previous) == -1) if (profilesComboBox->findText(previous) == -1)
return; // Profile was deleted return; // Profile was deleted
// Store the previous profile // Store the previous profile
@ -543,7 +549,7 @@ void DataFilesPage::profileRenamed(const QString &previous, const QString &curre
mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin")); mLauncherSettings.remove(QString("Profiles/") + previous + QString("/plugin"));
// Remove the profile from the combobox // Remove the profile from the combobox
mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous)); profilesComboBox->removeItem(profilesComboBox->findText(previous));
loadSettings(); loadSettings();
@ -558,11 +564,11 @@ void DataFilesPage::showContextMenu(const QPoint &point)
return; return;
if (object->objectName() == QLatin1String("PluginsTable")) { if (object->objectName() == QLatin1String("PluginsTable")) {
if (!mPluginsTable->selectionModel()->hasSelection()) if (!pluginsTable->selectionModel()->hasSelection())
return; return;
QPoint globalPos = mPluginsTable->mapToGlobal(point); QPoint globalPos = pluginsTable->mapToGlobal(point);
QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); QModelIndexList indexes = pluginsTable->selectionModel()->selectedIndexes();
// Show the check/uncheck actions depending on the state of the selected items // Show the check/uncheck actions depending on the state of the selected items
mUncheckAction->setEnabled(false); mUncheckAction->setEnabled(false);
@ -589,11 +595,11 @@ void DataFilesPage::showContextMenu(const QPoint &point)
} }
if (object->objectName() == QLatin1String("MastersTable")) { if (object->objectName() == QLatin1String("MastersTable")) {
if (!mMastersTable->selectionModel()->hasSelection()) if (!mastersTable->selectionModel()->hasSelection())
return; return;
QPoint globalPos = mMastersTable->mapToGlobal(point); QPoint globalPos = mastersTable->mapToGlobal(point);
QModelIndexList indexes = mMastersTable->selectionModel()->selectedIndexes(); QModelIndexList indexes = mastersTable->selectionModel()->selectedIndexes();
// Show the check/uncheck actions depending on the state of the selected items // Show the check/uncheck actions depending on the state of the selected items
mUncheckAction->setEnabled(false); mUncheckAction->setEnabled(false);

View file

@ -4,33 +4,28 @@
#include <QWidget> #include <QWidget>
#include <QModelIndex> #include <QModelIndex>
class QTableView; #include "ui_datafilespage.h"
class QSortFilterProxyModel; class QSortFilterProxyModel;
class QAction; class QAction;
class QToolBar;
class QSplitter;
class QMenu; class QMenu;
class ProfilesComboBox;
class DataFilesModel; class DataFilesModel;
class TextInputDialog; class TextInputDialog;
class ProfilesComboBox;
class GameSettings; class GameSettings;
class LauncherSettings; class LauncherSettings;
class PluginsProxyModel; class PluginsProxyModel;
namespace Files { struct ConfigurationManager; } namespace Files { struct ConfigurationManager; }
class DataFilesPage : public QWidget class DataFilesPage : public QWidget, private Ui::DataFilesPage
{ {
Q_OBJECT Q_OBJECT
public: public:
DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0); DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent = 0);
ProfilesComboBox *mProfilesComboBox;
void writeConfig(QString profile = QString()); void writeConfig(QString profile = QString());
void saveSettings(); void saveSettings();
@ -60,13 +55,13 @@ private:
QSortFilterProxyModel *mFilterProxyModel; QSortFilterProxyModel *mFilterProxyModel;
QTableView *mMastersTable; // QTableView *mMastersTable;
QTableView *mPluginsTable; // QTableView *mPluginsTable;
QToolBar *mProfileToolBar; // QToolBar *mProfileToolBar;
QMenu *mContextMenu; QMenu *mContextMenu;
QSplitter *mSplitter; // QSplitter *mSplitter;
QAction *mNewProfileAction; QAction *mNewProfileAction;
QAction *mDeleteProfileAction; QAction *mDeleteProfileAction;

View file

@ -3,7 +3,6 @@
#include <QtGui> #include <QtGui>
#include "utils/checkablemessagebox.hpp" #include "utils/checkablemessagebox.hpp"
#include "utils/profilescombobox.hpp"
#include "playpage.hpp" #include "playpage.hpp"
#include "graphicspage.hpp" #include "graphicspage.hpp"
@ -94,8 +93,8 @@ void MainDialog::createPages()
mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this); mDataFilesPage = new DataFilesPage(mCfgMgr, mGameSettings, mLauncherSettings, this);
// Set the combobox of the play page to imitate the combobox on the datafilespage // Set the combobox of the play page to imitate the combobox on the datafilespage
mPlayPage->setProfilesComboBoxModel(mDataFilesPage->mProfilesComboBox->model()); // mPlayPage->setProfilesComboBoxModel(mDataFilesPage->mProfilesComboBox->model());
mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->mProfilesComboBox->currentIndex()); // mPlayPage->setProfilesComboBoxIndex(mDataFilesPage->mProfilesComboBox->currentIndex());
// Add the pages to the stacked widget // Add the pages to the stacked widget
pagesWidget->addWidget(mPlayPage); pagesWidget->addWidget(mPlayPage);
@ -107,8 +106,8 @@ void MainDialog::createPages()
connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play())); connect(mPlayPage, SIGNAL(playButtonClicked()), this, SLOT(play()));
connect(mPlayPage, SIGNAL(profileChanged(int)), mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int))); // connect(mPlayPage, SIGNAL(profileChanged(int)), mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int)));
connect(mDataFilesPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), mPlayPage, SLOT(setProfilesComboBoxIndex(int))); // connect(mDataFilesPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), mPlayPage, SLOT(setProfilesComboBoxIndex(int)));
} }

View file

@ -71,7 +71,7 @@ find_package(Qt4 COMPONENTS QtCore QtGui)
if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY) if(QT_QTGUI_LIBRARY AND QT_QTCORE_LIBRARY)
add_component_qt_dir (fileorderlist add_component_qt_dir (fileorderlist
datafileslist model/modelitem model/datafilesmodel model/esm/esmfile datafileslist model/modelitem model/datafilesmodel model/esm/esmfile
utils/filedialog utils/lineedit utils/naturalsort utils/profilescombobox utils/comboboxlineedit utils/lineedit utils/naturalsort
) )
include(${QT_USE_FILE}) include(${QT_USE_FILE})