1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 18:06:43 +00:00

Build objects and connections only once.

This commit is contained in:
cc9cii 2014-09-10 07:14:01 +10:00
parent 5675626482
commit 3a5ed9c5bb
2 changed files with 33 additions and 31 deletions

View file

@ -18,7 +18,7 @@
#include "adjusterwidget.hpp" #include "adjusterwidget.hpp"
CSVDoc::FileDialog::FileDialog(QWidget *parent) : CSVDoc::FileDialog::FileDialog(QWidget *parent) :
QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0) QDialog(parent), mSelector (0), mFileWidget (0), mAdjusterWidget (0), mDialogBuilt(false)
{ {
ui.setupUi (this); ui.setupUi (this);
resize(400, 400); resize(400, 400);
@ -70,11 +70,15 @@ void CSVDoc::FileDialog::showDialog (ContentAction action)
mAdjusterWidget->setFilenameCheck (mAction == ContentAction_New); mAdjusterWidget->setFilenameCheck (mAction == ContentAction_New);
//connections common to both dialog view flavors if(!mDialogBuilt)
connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)), {
this, SLOT (slotUpdateAcceptButton (int))); //connections common to both dialog view flavors
connect (mSelector, SIGNAL (signalCurrentGamefileIndexChanged (int)),
this, SLOT (slotUpdateAcceptButton (int)));
connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected())); connect (ui.projectButtonBox, SIGNAL (rejected()), this, SLOT (slotRejected()));
mDialogBuilt = true;
}
show(); show();
raise(); raise();
@ -85,37 +89,41 @@ void CSVDoc::FileDialog::buildNewFileView()
{ {
setWindowTitle(tr("Create a new addon")); setWindowTitle(tr("Create a new addon"));
QPushButton* createButton = ui.projectButtonBox->button (QDialogButtonBox::Ok); QPushButton* createButton = ui.projectButtonBox->button (QDialogButtonBox::Ok);
createButton->setText ("Create"); createButton->setText ("Create");
createButton->setEnabled (false); createButton->setEnabled (false);
mFileWidget = new FileWidget (this); if(!mFileWidget)
{
mFileWidget = new FileWidget (this);
mFileWidget->setType (true); mFileWidget->setType (true);
mFileWidget->extensionLabelIsVisible(true); mFileWidget->extensionLabelIsVisible(true);
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
mAdjusterWidget, SLOT (setName (const QString&, bool)));
connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)),
this, SLOT (slotUpdateAcceptButton(const QString &, bool)));
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile()));
}
ui.projectGroupBoxLayout->insertWidget (0, mFileWidget); ui.projectGroupBoxLayout->insertWidget (0, mFileWidget);
connect (mFileWidget, SIGNAL (nameChanged (const QString&, bool)),
mAdjusterWidget, SLOT (setName (const QString&, bool)));
connect (mFileWidget, SIGNAL (nameChanged(const QString &, bool)),
this, SLOT (slotUpdateAcceptButton(const QString &, bool)));
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotNewFile()));
} }
void CSVDoc::FileDialog::buildOpenFileView() void CSVDoc::FileDialog::buildOpenFileView()
{ {
setWindowTitle(tr("Open")); setWindowTitle(tr("Open"));
ui.projectGroupBox->setTitle (QString("")); ui.projectGroupBox->setTitle (QString(""));
ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false); ui.projectButtonBox->button(QDialogButtonBox::Ok)->setEnabled (false);
connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int))); if(!mDialogBuilt)
connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int))); {
connect (mSelector, SIGNAL (signalAddonFileSelected (int)), this, SLOT (slotUpdateAcceptButton (int)));
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile())); connect (mSelector, SIGNAL (signalAddonFileUnselected (int)), this, SLOT (slotUpdateAcceptButton (int)));
connect (ui.projectButtonBox, SIGNAL (accepted()), this, SLOT (slotOpenFile()));
}
} }
void CSVDoc::FileDialog::slotUpdateAcceptButton (int) void CSVDoc::FileDialog::slotUpdateAcceptButton (int)
@ -162,10 +170,6 @@ void CSVDoc::FileDialog::slotRejected()
void CSVDoc::FileDialog::slotNewFile() void CSVDoc::FileDialog::slotNewFile()
{ {
emit signalCreateNewFile (mAdjusterWidget->getPath()); emit signalCreateNewFile (mAdjusterWidget->getPath());
mFileWidget->disconnect();
mSelector->disconnect();
ui.projectButtonBox->disconnect();
close(); close();
} }
@ -176,8 +180,5 @@ void CSVDoc::FileDialog::slotOpenFile()
mAdjusterWidget->setName (file->filePath(), !file->isGameFile()); mAdjusterWidget->setName (file->filePath(), !file->isGameFile());
emit signalOpenFiles (mAdjusterWidget->getPath()); emit signalOpenFiles (mAdjusterWidget->getPath());
mSelector->disconnect();
ui.projectButtonBox->disconnect();
close(); close();
} }

View file

@ -37,6 +37,7 @@ namespace CSVDoc
ContentAction mAction; ContentAction mAction;
FileWidget *mFileWidget; FileWidget *mFileWidget;
AdjusterWidget *mAdjusterWidget; AdjusterWidget *mAdjusterWidget;
bool mDialogBuilt;
public: public: