mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
Implemented file/adjuster widgets into new addon creation dialog
This commit is contained in:
parent
70ac14b8ba
commit
513f0c4b3e
10 changed files with 152 additions and 28 deletions
|
@ -306,7 +306,7 @@ void DataFilesPage::setPluginsCheckstates(Qt::CheckState state)
|
||||||
if (!sourceIndex.isValid())
|
if (!sourceIndex.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool isChecked = ( state == Qt::Checked );
|
//bool isChecked = ( state == Qt::Checked );
|
||||||
|
|
||||||
mContentModel->setData(sourceIndex, state, Qt::CheckStateRole);
|
mContentModel->setData(sourceIndex, state, Qt::CheckStateRole);
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ void DataFilesPage::slotCurrentGameFileIndexChanged(int index)
|
||||||
void DataFilesPage::slotAddonTableItemClicked(const QModelIndex &index)
|
void DataFilesPage::slotAddonTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = addonView->model();
|
QAbstractItemModel *const model = addonView->model();
|
||||||
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
||||||
|
|
||||||
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
||||||
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
||||||
|
|
|
@ -43,6 +43,10 @@ boost::filesystem::path CSVDoc::AdjusterWidget::getPath() const
|
||||||
return mResultPath;
|
return mResultPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CSVDoc::AdjusterWidget::isValid() const
|
||||||
|
{
|
||||||
|
return mValid;
|
||||||
|
}
|
||||||
void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
void CSVDoc::AdjusterWidget::setName (const QString& name, bool addon)
|
||||||
{
|
{
|
||||||
QString message;
|
QString message;
|
||||||
|
|
|
@ -25,6 +25,9 @@ namespace CSVDoc
|
||||||
|
|
||||||
void setLocalData (const boost::filesystem::path& localData);
|
void setLocalData (const boost::filesystem::path& localData);
|
||||||
|
|
||||||
|
QString getText() const;
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
boost::filesystem::path getPath() const;
|
boost::filesystem::path getPath() const;
|
||||||
///< This function must not be called if there is no valid path.
|
///< This function must not be called if there is no valid path.
|
||||||
|
|
||||||
|
|
|
@ -9,12 +9,22 @@
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QGroupBox>
|
||||||
|
|
||||||
#include <components/contentselector/model/esmfile.hpp>
|
#include <components/contentselector/model/esmfile.hpp>
|
||||||
#include <components/contentselector/view/lineedit.hpp>
|
#include <components/contentselector/view/lineedit.hpp>
|
||||||
|
|
||||||
|
#include "filewidget.hpp"
|
||||||
|
#include "adjusterwidget.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||||
ContentSelector(parent)
|
ContentSelector(parent),
|
||||||
|
mFileWidget (new FileWidget (this)),
|
||||||
|
mAdjusterWidget (new AdjusterWidget (this)),
|
||||||
|
mEnable_1(false),
|
||||||
|
mEnable_2(false)
|
||||||
{
|
{
|
||||||
// Hide the profile elements
|
// Hide the profile elements
|
||||||
profileGroupBox->hide();
|
profileGroupBox->hide();
|
||||||
|
@ -22,12 +32,20 @@ CSVDoc::FileDialog::FileDialog(QWidget *parent) :
|
||||||
|
|
||||||
resize(400, 400);
|
resize(400, 400);
|
||||||
|
|
||||||
connect(projectNameLineEdit, SIGNAL(textChanged(QString)), this, SLOT(updateCreateButton(QString)));
|
mFileWidget->setType(true);
|
||||||
|
mFileWidget->extensionLabelIsVisible(false);
|
||||||
|
|
||||||
connect(projectCreateButton, SIGNAL(clicked()), this, SIGNAL(createNewFile()));
|
connect(projectCreateButton, SIGNAL(clicked()), this, SIGNAL(createNewFile()));
|
||||||
|
|
||||||
connect(projectButtonBox, SIGNAL(accepted()), this, SIGNAL(openFiles()));
|
connect(projectButtonBox, SIGNAL(accepted()), this, SIGNAL(openFiles()));
|
||||||
connect(projectButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(projectButtonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
|
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
|
||||||
|
mAdjusterWidget, SLOT (setName (const QString&, bool)));
|
||||||
|
|
||||||
|
connect (mAdjusterWidget, SIGNAL (stateChanged (bool)), this, SLOT (slotAdjusterChanged(bool)));
|
||||||
|
connect (this, SIGNAL (signalGameFileChanged(int)), this, SLOT (slotGameFileSelected(int)));
|
||||||
|
connect (this, SIGNAL (signalUpdateCreateButton(bool, int)), this, SLOT (slotEnableCreateButton(bool, int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
|
void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
|
||||||
|
@ -40,24 +58,30 @@ void CSVDoc::FileDialog::updateOpenButton(const QStringList &items)
|
||||||
openButton->setEnabled(!items.isEmpty());
|
openButton->setEnabled(!items.isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::updateCreateButton(const QString &name)
|
void CSVDoc::FileDialog::slotEnableCreateButton(bool enable, int widgetNumber)
|
||||||
{
|
{
|
||||||
if (!projectCreateButton->isVisible())
|
|
||||||
return;
|
|
||||||
|
|
||||||
projectCreateButton->setEnabled(!name.isEmpty());
|
if (widgetNumber == 1)
|
||||||
|
mEnable_1 = enable;
|
||||||
|
|
||||||
|
if (widgetNumber == 2)
|
||||||
|
mEnable_2 = enable;
|
||||||
|
|
||||||
|
qDebug() << "update enabled" << mEnable_1 << mEnable_2 << enable;
|
||||||
|
projectCreateButton->setEnabled(mEnable_1 && mEnable_2);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSVDoc::FileDialog::fileName()
|
QString CSVDoc::FileDialog::fileName()
|
||||||
{
|
{
|
||||||
return projectNameLineEdit->text();
|
return mFileWidget->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::FileDialog::openFile()
|
void CSVDoc::FileDialog::openFile()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Open"));
|
setWindowTitle(tr("Open"));
|
||||||
|
|
||||||
projectNameLineEdit->hide();
|
mFileWidget->hide();
|
||||||
|
adjusterWidgetFrame->hide();
|
||||||
projectCreateButton->hide();
|
projectCreateButton->hide();
|
||||||
projectGroupBox->setTitle(tr(""));
|
projectGroupBox->setTitle(tr(""));
|
||||||
projectButtonBox->button(QDialogButtonBox::Open)->setEnabled(false);
|
projectButtonBox->button(QDialogButtonBox::Open)->setEnabled(false);
|
||||||
|
@ -71,6 +95,9 @@ void CSVDoc::FileDialog::newFile()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("New"));
|
setWindowTitle(tr("New"));
|
||||||
|
|
||||||
|
fileWidgetFrame->layout()->addWidget(mFileWidget);
|
||||||
|
adjusterWidgetFrame->layout()->addWidget(mAdjusterWidget);
|
||||||
|
|
||||||
projectButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
|
projectButtonBox->setStandardButtons(QDialogButtonBox::Cancel);
|
||||||
projectButtonBox->addButton(projectCreateButton, QDialogButtonBox::ActionRole);
|
projectButtonBox->addButton(projectCreateButton, QDialogButtonBox::ActionRole);
|
||||||
|
|
||||||
|
@ -78,3 +105,13 @@ void CSVDoc::FileDialog::newFile()
|
||||||
raise();
|
raise();
|
||||||
activateWindow();
|
activateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::FileDialog::slotAdjusterChanged(bool value)
|
||||||
|
{
|
||||||
|
emit signalUpdateCreateButton(mAdjusterWidget->isValid(), 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVDoc::FileDialog::slotGameFileSelected(int value)
|
||||||
|
{
|
||||||
|
emit signalUpdateCreateButton(value > -1, 1);
|
||||||
|
}
|
||||||
|
|
|
@ -26,9 +26,19 @@ namespace ContentSelectorView
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
|
class FileWidget;
|
||||||
|
class AdjusterWidget;
|
||||||
|
|
||||||
class FileDialog : public ContentSelectorView::ContentSelector
|
class FileDialog : public ContentSelectorView::ContentSelector
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
FileWidget *mFileWidget;
|
||||||
|
AdjusterWidget *mAdjusterWidget;
|
||||||
|
|
||||||
|
bool mEnable_1;
|
||||||
|
bool mEnable_2;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit FileDialog(QWidget *parent = 0);
|
explicit FileDialog(QWidget *parent = 0);
|
||||||
|
|
||||||
|
@ -41,12 +51,17 @@ namespace CSVDoc
|
||||||
void openFiles();
|
void openFiles();
|
||||||
void createNewFile();
|
void createNewFile();
|
||||||
|
|
||||||
|
void signalUpdateCreateButton (bool, int);
|
||||||
|
void signalUpdateCreateButtonFlags(int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//void updateViews();
|
//void updateViews();
|
||||||
void updateOpenButton(const QStringList &items);
|
void updateOpenButton(const QStringList &items);
|
||||||
void updateCreateButton(const QString &name);
|
void slotEnableCreateButton(bool enable, int widgetNumber);
|
||||||
|
void slotAdjusterChanged(bool value);
|
||||||
|
void slotGameFileSelected(int value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // FILEDIALOG_HPP
|
#endif // FILEDIALOG_HPP
|
||||||
|
|
|
@ -51,3 +51,8 @@ void CSVDoc::FileWidget::textChanged (const QString& text)
|
||||||
{
|
{
|
||||||
emit nameChanged (getName(), mAddon);
|
emit nameChanged (getName(), mAddon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::FileWidget::extensionLabelIsVisible(bool visible)
|
||||||
|
{
|
||||||
|
mType->setVisible(visible);
|
||||||
|
}
|
||||||
|
|
|
@ -27,6 +27,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
QString getName() const;
|
QString getName() const;
|
||||||
|
|
||||||
|
void extensionLabelIsVisible(bool visible);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void textChanged (const QString& text);
|
void textChanged (const QString& text);
|
||||||
|
|
|
@ -40,6 +40,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
gameFileView->setModel(mGameFileProxyModel);
|
gameFileView->setModel(mGameFileProxyModel);
|
||||||
|
|
||||||
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentGameFileIndexChanged(int)));
|
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCurrentGameFileIndexChanged(int)));
|
||||||
|
connect(gameFileView, SIGNAL(currentIndexChanged(int)), this, SIGNAL(signalGameFileChanged(int)));
|
||||||
|
|
||||||
gameFileView->setCurrentIndex(-1);
|
gameFileView->setCurrentIndex(-1);
|
||||||
gameFileView->setCurrentIndex(0);
|
gameFileView->setCurrentIndex(0);
|
||||||
|
@ -120,12 +121,14 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||||
|
|
||||||
if (proxy)
|
if (proxy)
|
||||||
proxy->setDynamicSortFilter(true);
|
proxy->setDynamicSortFilter(true);
|
||||||
|
|
||||||
|
emit signalGameFileChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
void ContentSelectorView::ContentSelector::slotAddonTableItemClicked(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QAbstractItemModel *const model = addonView->model();
|
QAbstractItemModel *const model = addonView->model();
|
||||||
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
//QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
||||||
|
|
||||||
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
if (model->data(index, Qt::CheckStateRole).toInt() == Qt::Unchecked)
|
||||||
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
model->setData(index, Qt::Checked, Qt::CheckStateRole);
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace ContentSelectorView
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void profileChanged(int index);
|
void profileChanged(int index);
|
||||||
|
void signalGameFileChanged(int value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateViews();
|
void updateViews();
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
<height>313</height>
|
<height>313</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="contextMenuPolicy">
|
<property name="contextMenuPolicy">
|
||||||
<enum>Qt::DefaultContextMenu</enum>
|
<enum>Qt::DefaultContextMenu</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -97,15 +103,44 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="projectGroupBox">
|
<widget class="QGroupBox" name="projectGroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Project</string>
|
<string>Project</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="ContentSelectorView::LineEdit" name="projectNameLineEdit">
|
<widget class="QFrame" name="fileWidgetFrame">
|
||||||
<property name="placeholderText">
|
<property name="sizePolicy">
|
||||||
<string>Enter project name...</string>
|
<sizepolicy hsizetype="Minimum" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -126,9 +161,33 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<zorder>projectButtonBox</zorder>
|
</widget>
|
||||||
<zorder>projectCreateButton</zorder>
|
</item>
|
||||||
<zorder>projectNameLineEdit</zorder>
|
<item>
|
||||||
|
<widget class="QFrame" name="adjusterWidgetFrame">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWidth">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="margin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -249,14 +308,9 @@
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>EsxView::ProfilesComboBox</class>
|
<class>ContentSelectorView::ProfilesComboBox</class>
|
||||||
<extends>QComboBox</extends>
|
<extends>QComboBox</extends>
|
||||||
<header location="global">components/contentselector/view/profilescombobox.hpp</header>
|
<header>components/contentselector/view/profilescombobox.hpp</header>
|
||||||
</customwidget>
|
|
||||||
<customwidget>
|
|
||||||
<class>EsxView::LineEdit</class>
|
|
||||||
<extends>QLineEdit</extends>
|
|
||||||
<header location="global">components/contentselector/view/lineedit.hpp</header>
|
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in a new issue