inheriting Merge from QWidget instead of QDialog, because QDialog is bloody useless for non-modal dialogues (which makes the class completely useless, since modal dialogues are the spawn of Satan)

sceneinput
Marc Zinnschlag 10 years ago
parent 904ad94952
commit e2377396a7

@ -379,4 +379,6 @@ void CS::Editor::mergeDocument (CSMDoc::Document *document)
{ {
mMerge.configure (document); mMerge.configure (document);
mMerge.show(); mMerge.show();
mMerge.raise();
mMerge.activateWindow();
} }

@ -7,14 +7,26 @@
#include <QPushButton> #include <QPushButton>
#include <QListWidget> #include <QListWidget>
#include <QLabel> #include <QLabel>
#include <QKeyEvent>
#include "../../model/doc/document.hpp" #include "../../model/doc/document.hpp"
#include "../doc/filewidget.hpp" #include "../doc/filewidget.hpp"
#include "../doc/adjusterwidget.hpp" #include "../doc/adjusterwidget.hpp"
void CSVTools::Merge::keyPressEvent (QKeyEvent *event)
{
if (event->key()==Qt::Key_Escape)
{
event->accept();
cancel();
}
else
QWidget::keyPressEvent (event);
}
CSVTools::Merge::Merge (QWidget *parent) CSVTools::Merge::Merge (QWidget *parent)
: QDialog (parent), mDocument (0) : QWidget (parent), mDocument (0)
{ {
setWindowTitle ("Merge Content Files into a new Game File"); setWindowTitle ("Merge Content Files into a new Game File");
@ -65,7 +77,7 @@ CSVTools::Merge::Merge (QWidget *parent)
// buttons // buttons
QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this); QDialogButtonBox *buttons = new QDialogButtonBox (QDialogButtonBox::Cancel, Qt::Horizontal, this);
connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (reject())); connect (buttons->button (QDialogButtonBox::Cancel), SIGNAL (clicked()), this, SLOT (cancel()));
mOkay = new QPushButton ("Merge", this); mOkay = new QPushButton ("Merge", this);
connect (mOkay, SIGNAL (clicked()), this, SLOT (accept())); connect (mOkay, SIGNAL (clicked()), this, SLOT (accept()));
@ -110,8 +122,6 @@ void CSVTools::Merge::cancel()
void CSVTools::Merge::accept() void CSVTools::Merge::accept()
{ {
QDialog::accept();
if ((mDocument->getState() & CSMDoc::State_Merging)==0) if ((mDocument->getState() & CSMDoc::State_Merging)==0)
{ {
mDocument->runMerge (mAdjuster->getPath()); mDocument->runMerge (mAdjuster->getPath());
@ -119,12 +129,6 @@ void CSVTools::Merge::accept()
} }
} }
void CSVTools::Merge::reject()
{
QDialog::reject();
cancel();
}
void CSVTools::Merge::stateChanged (bool valid) void CSVTools::Merge::stateChanged (bool valid)
{ {
mOkay->setEnabled (valid); mOkay->setEnabled (valid);

@ -1,7 +1,7 @@
#ifndef CSV_TOOLS_REPORTTABLE_H #ifndef CSV_TOOLS_REPORTTABLE_H
#define CSV_TOOLS_REPORTTABLE_H #define CSV_TOOLS_REPORTTABLE_H
#include <QDialog> #include <QWidget>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
@ -21,7 +21,7 @@ namespace CSVDoc
namespace CSVTools namespace CSVTools
{ {
class Merge : public QDialog class Merge : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -31,6 +31,8 @@ namespace CSVTools
CSVDoc::FileWidget *mNewFile; CSVDoc::FileWidget *mNewFile;
CSVDoc::AdjusterWidget *mAdjuster; CSVDoc::AdjusterWidget *mAdjuster;
void keyPressEvent (QKeyEvent *event);
public: public:
Merge (QWidget *parent = 0); Merge (QWidget *parent = 0);
@ -42,18 +44,15 @@ namespace CSVTools
CSMDoc::Document *getDocument() const; CSMDoc::Document *getDocument() const;
void cancel();
public slots: public slots:
virtual void accept(); void cancel();
virtual void reject();
private slots: private slots:
void stateChanged (bool valid); void accept();
void stateChanged (bool valid);
}; };
} }

Loading…
Cancel
Save