X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;ds=inline;f=src%2Fplugins%2FSdiWindow%2Fsdiwindow.cpp;h=aba9ce2041502ac51fed5f2a5aa04d9cc4be01bf;hb=ad70660919cd7b0e821e35548b6d1f5efa181c4c;hp=b63ab978606f0b27329b7302f1f33673992eaf21;hpb=06f9c5336ba8a2200b68f636520707693eb5ada7;p=evaf
diff --git a/src/plugins/SdiWindow/sdiwindow.cpp b/src/plugins/SdiWindow/sdiwindow.cpp
index b63ab97..aba9ce2 100644
--- a/src/plugins/SdiWindow/sdiwindow.cpp
+++ b/src/plugins/SdiWindow/sdiwindow.cpp
@@ -22,6 +22,7 @@
#include
#include
+#include
#include
@@ -53,6 +54,7 @@ using namespace eVaf::SdiWindow::Internal;
MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
: QWidget(parent, flags)
+ , mReady(false)
{
setObjectName(QString("%1-%2").arg(VER_MODULE_NAME_STR).arg(__FUNCTION__));
@@ -62,21 +64,37 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags flags)
// Apply the size specified in a) properties; or b) on the command line
setWindowSize();
+ // Create the default layout
+ mLayout = new QVBoxLayout;
+ setLayout(mLayout);
+
+ mSdiWindow = this;
+
EVAF_INFO("%s created", qPrintable(objectName()));
}
MainWindow::~MainWindow()
{
+ mSdiWindow = 0;
+
// Save geometry
saveSettings();
EVAF_INFO("%s destroyed", qPrintable(objectName()));
}
-bool MainWindow::init()
+bool MainWindow::init(QString const & args)
{
+ Q_UNUSED(args);
+
+ Common::iRegistry::instance()->registerInterface("iSdiWindow", this);
+
+ setWindowTitle(Common::iApp::instance()->name());
+
show();
+ mReady = true;
+
EVAF_INFO("%s initialized", qPrintable(objectName()));
return true;
@@ -84,15 +102,36 @@ bool MainWindow::init()
void MainWindow::done()
{
+ mReady = false;
+
close();
+ // Delete all the items added to the main window
+ while (mItemsAdded.count() > 0) {
+ QWeakPointer item = mItemsAdded.takeAt(0);
+ if (!item.isNull())
+ delete item.data();
+ }
+
EVAF_INFO("%s finalized", qPrintable(objectName()));
}
+void MainWindow::addWidget(QWidget * widget)
+{
+ mLayout->addWidget(widget);
+ mItemsAdded.append(widget);
+}
+
+void MainWindow::addLayout(QLayout * layout)
+{
+ mLayout->addLayout(layout);
+ mItemsAdded.append(layout);
+}
+
void MainWindow::saveSettings()
{
static int ver[4] = {VER_FILE_VERSION};
- QSettings settings(VER_COMPANY_NAME_STR, VER_PRODUCT_NAME_STR);
+ QSettings settings(VER_COMPANY_NAME_STR, Common::iApp::instance()->name());
settings.setValue(QString("%1/version/major").arg(objectName()), ver[0]);
settings.setValue(QString("%1/version/minor").arg(objectName()), ver[1]);
settings.setValue(QString("%1/geometry").arg(objectName()), saveGeometry());
@@ -101,7 +140,7 @@ void MainWindow::saveSettings()
void MainWindow::restoreSettings()
{
static int ver[4] = {VER_FILE_VERSION};
- QSettings settings(VER_COMPANY_NAME_STR, VER_PRODUCT_NAME_STR);
+ QSettings settings(VER_COMPANY_NAME_STR, Common::iApp::instance()->name());
// Ignore saved settings if the version number is not the same
// More intelligent checks can be implemented to allow upgrading from previous versions
@@ -152,56 +191,6 @@ void MainWindow::setWindowSize()
}
-//-------------------------------------------------------------------
-
-SdiWindowImpl::SdiWindowImpl()
- : iSdiWindow()
- , mReady(false)
-{
- setObjectName(QString("%1.iSdiWindow").arg(VER_MODULE_NAME_STR));
-
- mSdiWindow = this;
-
- wWindow = new MainWindow;
-
- Common::iRegistry::instance()->registerInterface("iSdiWindow", this);
-
- EVAF_INFO("%s created", qPrintable(objectName()));
-}
-
-SdiWindowImpl::~SdiWindowImpl()
-{
- delete wWindow;
-
- mSdiWindow = 0;
-
- EVAF_INFO("%s destroyed", qPrintable(objectName()));
-}
-
-bool SdiWindowImpl::init(const QString & args)
-{
- Q_UNUSED(args);
-
- if (!wWindow->init())
- return false;
-
- mReady = true;
-
- EVAF_INFO("%s initialized", qPrintable(objectName()));
-
- return true;
-}
-
-void SdiWindowImpl::done()
-{
- mReady = false;
-
- wWindow->done();
-
- EVAF_INFO("%s finalized", qPrintable(objectName()));
-}
-
-
//-------------------------------------------------------------------
SdiWindowPlugin::SdiWindowPlugin()
@@ -209,7 +198,7 @@ SdiWindowPlugin::SdiWindowPlugin()
{
setObjectName(VER_MODULE_NAME_STR);
- mWindow = new SdiWindowImpl;
+ mWindow = new MainWindow;
EVAF_INFO("%s created", qPrintable(objectName()));
}