forked from teamnwah/openmw-tes3coop
Added actions to datafiles.ui and implemented them in the launcher
This commit is contained in:
parent
5e13614e08
commit
b4d408af5d
3 changed files with 71 additions and 89 deletions
|
@ -17,19 +17,6 @@
|
||||||
|
|
||||||
#include "utils/textinputdialog.hpp"
|
#include "utils/textinputdialog.hpp"
|
||||||
|
|
||||||
|
|
||||||
//sort QModelIndexList ascending
|
|
||||||
bool rowGreaterThan(const QModelIndex &index1, const QModelIndex &index2)
|
|
||||||
{
|
|
||||||
return index1.row() >= index2.row();
|
|
||||||
}
|
|
||||||
|
|
||||||
//sort QModelIndexList descending
|
|
||||||
bool rowSmallerThan(const QModelIndex &index1, const QModelIndex &index2)
|
|
||||||
{
|
|
||||||
return index1.row() <= index2.row();
|
|
||||||
}
|
|
||||||
|
|
||||||
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gameSettings, LauncherSettings &launcherSettings, QWidget *parent)
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
, mGameSettings(gameSettings)
|
, mGameSettings(gameSettings)
|
||||||
|
@ -121,35 +108,15 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, GameSettings &gam
|
||||||
|
|
||||||
void DataFilesPage::createActions()
|
void DataFilesPage::createActions()
|
||||||
{
|
{
|
||||||
// Refresh the plugins
|
|
||||||
QAction *refreshAction = new QAction(tr("Refresh"), this);
|
|
||||||
refreshAction->setShortcut(QKeySequence(tr("F5")));
|
|
||||||
connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh()));
|
|
||||||
|
|
||||||
// We can't create actions inside the .ui file
|
// Add the actions to the toolbuttons
|
||||||
mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this);
|
newProfileButton->setDefaultAction(newProfileAction);
|
||||||
mNewProfileAction->setToolTip(tr("New Profile"));
|
deleteProfileButton->setDefaultAction(deleteProfileAction);
|
||||||
mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N")));
|
|
||||||
connect(mNewProfileAction, SIGNAL(triggered()), this, SLOT(newProfile()));
|
|
||||||
|
|
||||||
mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this);
|
|
||||||
mDeleteProfileAction->setToolTip(tr("Delete Profile"));
|
|
||||||
connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile()));
|
|
||||||
|
|
||||||
// Add the newly created actions to the toolbuttons
|
|
||||||
newProfileButton->setDefaultAction(mNewProfileAction);
|
|
||||||
deleteProfileButton->setDefaultAction(mDeleteProfileAction);
|
|
||||||
|
|
||||||
// Context menu actions
|
// Context menu actions
|
||||||
mCheckAction = new QAction(tr("Check Selection"), this);
|
|
||||||
connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check()));
|
|
||||||
|
|
||||||
mUncheckAction = new QAction(tr("Uncheck Selection"), this);
|
|
||||||
connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck()));
|
|
||||||
|
|
||||||
mContextMenu = new QMenu(this);
|
mContextMenu = new QMenu(this);
|
||||||
mContextMenu->addAction(mCheckAction);
|
mContextMenu->addAction(checkAction);
|
||||||
mContextMenu->addAction(mUncheckAction);
|
mContextMenu->addAction(uncheckAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::setupDataFiles()
|
void DataFilesPage::setupDataFiles()
|
||||||
|
@ -184,6 +151,8 @@ void DataFilesPage::setupDataFiles()
|
||||||
profilesComboBox->addItem(QString("Default"));
|
profilesComboBox->addItem(QString("Default"));
|
||||||
|
|
||||||
if (profile.isEmpty() || profile == QLatin1String("Default")) {
|
if (profile.isEmpty() || profile == QLatin1String("Default")) {
|
||||||
|
deleteProfileAction->setEnabled(false);
|
||||||
|
profilesComboBox->setEditEnabled(false);
|
||||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(QString("Default")));
|
profilesComboBox->setCurrentIndex(profilesComboBox->findText(QString("Default")));
|
||||||
} else {
|
} else {
|
||||||
profilesComboBox->setEditEnabled(true);
|
profilesComboBox->setEditEnabled(true);
|
||||||
|
@ -257,15 +226,6 @@ void DataFilesPage::saveSettings()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::newProfile()
|
|
||||||
{
|
|
||||||
if (mNewProfileDialog->exec() == QDialog::Accepted) {
|
|
||||||
QString profile = mNewProfileDialog->lineEdit()->text();
|
|
||||||
profilesComboBox->addItem(profile);
|
|
||||||
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::updateOkButton(const QString &text)
|
void DataFilesPage::updateOkButton(const QString &text)
|
||||||
{
|
{
|
||||||
// We do this here because we need the profiles combobox text
|
// We do this here because we need the profiles combobox text
|
||||||
|
@ -331,7 +291,16 @@ int DataFilesPage::profilesComboBoxIndex()
|
||||||
return profilesComboBox->currentIndex();
|
return profilesComboBox->currentIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::deleteProfile()
|
void DataFilesPage::on_newProfileAction_triggered()
|
||||||
|
{
|
||||||
|
if (mNewProfileDialog->exec() == QDialog::Accepted) {
|
||||||
|
QString profile = mNewProfileDialog->lineEdit()->text();
|
||||||
|
profilesComboBox->addItem(profile);
|
||||||
|
profilesComboBox->setCurrentIndex(profilesComboBox->findText(profile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFilesPage::on_deleteProfileAction_triggered()
|
||||||
{
|
{
|
||||||
QString profile = profilesComboBox->currentText();
|
QString profile = profilesComboBox->currentText();
|
||||||
|
|
||||||
|
@ -358,7 +327,7 @@ void DataFilesPage::deleteProfile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::check()
|
void DataFilesPage::on_checkAction_triggered()
|
||||||
{
|
{
|
||||||
if (pluginsTable->hasFocus())
|
if (pluginsTable->hasFocus())
|
||||||
setPluginsCheckstates(Qt::Checked);
|
setPluginsCheckstates(Qt::Checked);
|
||||||
|
@ -368,7 +337,7 @@ void DataFilesPage::check()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::uncheck()
|
void DataFilesPage::on_uncheckAction_triggered()
|
||||||
{
|
{
|
||||||
if (pluginsTable->hasFocus())
|
if (pluginsTable->hasFocus())
|
||||||
setPluginsCheckstates(Qt::Unchecked);
|
setPluginsCheckstates(Qt::Unchecked);
|
||||||
|
@ -377,14 +346,6 @@ void DataFilesPage::uncheck()
|
||||||
setMastersCheckstates(Qt::Unchecked);
|
setMastersCheckstates(Qt::Unchecked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataFilesPage::refresh()
|
|
||||||
{
|
|
||||||
// mDataFilesModel->sort(0);
|
|
||||||
|
|
||||||
// Refresh the plugins table
|
|
||||||
pluginsTable->scrollToTop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
|
void DataFilesPage::setMastersCheckstates(Qt::CheckState state)
|
||||||
{
|
{
|
||||||
if (!mastersTable->selectionModel()->hasSelection()) {
|
if (!mastersTable->selectionModel()->hasSelection()) {
|
||||||
|
@ -476,10 +437,10 @@ 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);
|
deleteProfileAction->setEnabled(false);
|
||||||
profilesComboBox->setEditEnabled(false);
|
profilesComboBox->setEditEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
mDeleteProfileAction->setEnabled(true);
|
deleteProfileAction->setEnabled(true);
|
||||||
profilesComboBox->setEditEnabled(true);
|
profilesComboBox->setEditEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,8 +494,8 @@ void DataFilesPage::showContextMenu(const QPoint &point)
|
||||||
QModelIndexList indexes = pluginsTable->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);
|
uncheckAction->setEnabled(false);
|
||||||
mCheckAction->setEnabled(false);
|
checkAction->setEnabled(false);
|
||||||
|
|
||||||
foreach (const QModelIndex &index, indexes)
|
foreach (const QModelIndex &index, indexes)
|
||||||
{
|
{
|
||||||
|
@ -548,8 +509,8 @@ void DataFilesPage::showContextMenu(const QPoint &point)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||||
? mUncheckAction->setEnabled(true)
|
? uncheckAction->setEnabled(true)
|
||||||
: mCheckAction->setEnabled(true);
|
: checkAction->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show menu
|
// Show menu
|
||||||
|
@ -564,8 +525,8 @@ void DataFilesPage::showContextMenu(const QPoint &point)
|
||||||
QModelIndexList indexes = mastersTable->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);
|
uncheckAction->setEnabled(false);
|
||||||
mCheckAction->setEnabled(false);
|
checkAction->setEnabled(false);
|
||||||
|
|
||||||
foreach (const QModelIndex &index, indexes)
|
foreach (const QModelIndex &index, indexes)
|
||||||
{
|
{
|
||||||
|
@ -578,8 +539,8 @@ void DataFilesPage::showContextMenu(const QPoint &point)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
(mDataFilesModel->checkState(sourceIndex) == Qt::Checked)
|
||||||
? mUncheckAction->setEnabled(true)
|
? uncheckAction->setEnabled(true)
|
||||||
: mCheckAction->setEnabled(true);
|
: checkAction->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mContextMenu->exec(globalPos);
|
mContextMenu->exec(globalPos);
|
||||||
|
|
|
@ -48,11 +48,10 @@ public slots:
|
||||||
void updateViews();
|
void updateViews();
|
||||||
|
|
||||||
// Action slots
|
// Action slots
|
||||||
void newProfile();
|
void on_newProfileAction_triggered();
|
||||||
void deleteProfile();
|
void on_deleteProfileAction_triggered();
|
||||||
void check();
|
void on_checkAction_triggered();
|
||||||
void uncheck();
|
void on_uncheckAction_triggered();
|
||||||
void refresh();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotCurrentIndexChanged(int index);
|
void slotCurrentIndexChanged(int index);
|
||||||
|
@ -65,23 +64,7 @@ private:
|
||||||
|
|
||||||
QSortFilterProxyModel *mFilterProxyModel;
|
QSortFilterProxyModel *mFilterProxyModel;
|
||||||
|
|
||||||
// QTableView *mMastersTable;
|
|
||||||
// QTableView *mPluginsTable;
|
|
||||||
|
|
||||||
|
|
||||||
// QToolBar *mProfileToolBar;
|
|
||||||
QMenu *mContextMenu;
|
QMenu *mContextMenu;
|
||||||
// QSplitter *mSplitter;
|
|
||||||
|
|
||||||
QAction *mNewProfileAction;
|
|
||||||
QAction *mDeleteProfileAction;
|
|
||||||
QAction *mCheckAction;
|
|
||||||
QAction *mUncheckAction;
|
|
||||||
|
|
||||||
// QAction *mMoveUpAction;
|
|
||||||
// QAction *mMoveDownAction;
|
|
||||||
// QAction *mMoveTopAction;
|
|
||||||
// QAction *mMoveBottomAction;
|
|
||||||
|
|
||||||
Files::ConfigurationManager &mCfgMgr;
|
Files::ConfigurationManager &mCfgMgr;
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="ProfilesComboBox" name="profilesComboBox">
|
<widget class="ProfilesComboBox" name="profilesComboBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -107,6 +110,41 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
<action name="newProfileAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="document-new"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>New Profile</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>New Profile</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+N</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="deleteProfileAction">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="edit-delete"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Delete Profile</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Delete Profile</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="checkAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Check Selection</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="uncheckAction">
|
||||||
|
<property name="text">
|
||||||
|
<string>Uncheck Selection</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
Loading…
Reference in a new issue