Added Qt version to Mussagl about box.
[mussa.git] / qui / MussaWindow.cpp
index 2342ee783fbfc75bb06673923f5eed26ef3c69eb..39d25f9db598bf69223ac14f05eb3d15cd37d411 100644 (file)
@@ -32,6 +32,14 @@ namespace fs = boost::filesystem;
 
 using namespace std;
 
+static void init_resources() {
+  static bool resources_loaded = false;
+  if (not resources_loaded) {
+    Q_INIT_RESOURCE(icons);
+    resources_loaded = true;
+  }
+}
+
 MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   QMainWindow(parent),
   analysis(analysis_),
@@ -60,6 +68,7 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   viewMussaAlignmentAction(0),
   manualAssistant(0)
 {
+  init_resources();
   setupWidgets();
   setupActions();
   setupAssistant();
@@ -199,9 +208,11 @@ void MussaWindow::setupActions()
 
   //Save pixel map action
   saveBrowserPixmapAction = new QAction(tr("Save to image..."), this);
-  connect(saveBrowserPixmapAction, (SIGNAL(triggered())),
-         browser, SLOT(promptSaveBrowserPixmap()));
-  saveBrowserPixmapAction->setIcon(QIcon(":/icons/image2.png"));
+  if (browser) {
+    connect(saveBrowserPixmapAction, (SIGNAL(triggered())),
+            browser, SLOT(promptSaveBrowserPixmap()));
+    saveBrowserPixmapAction->setIcon(QIcon(":/icons/image2.png"));
+  }
 
   viewMussaAlignmentAction = new QAction(tr("View sequence alignment"), this);
   connect(viewMussaAlignmentAction, SIGNAL(triggered()),
@@ -248,10 +259,10 @@ void MussaWindow::setupMainMenu()
 
   newMenu = menuBar()->addMenu(tr("&Edit"));
   newMenu->addAction(editMotifsAction);
-  newMenu->addAction(browser->getCopySelectedSequenceAsStringAction());
-  newMenu->addAction(browser->getCopySelectedSequenceAsFastaAction());
+  if (browser) newMenu->addAction(browser->getCopySelectedSequenceAsStringAction());
+  if (browser) newMenu->addAction(browser->getCopySelectedSequenceAsFastaAction());
   newMenu->addAction(createSubAnalysisAction);
-  newMenu->addAction(browser->getEditSequencePropertiesAction());
+  if (browser) newMenu->addAction(browser->getEditSequencePropertiesAction());
  
   newMenu = menuBar()->addMenu(tr("&View"));
   newMenu->addAction(viewMussaAlignmentAction);
@@ -264,10 +275,12 @@ void MussaWindow::setupMainMenu()
   newMenu->addAction(aboutAction);
 
   // add some extra features to the context menu
-  QMenu *popupMenu = browser->getPopupMenu();
-  if (popupMenu) {
-    popupMenu->addAction(viewMussaAlignmentAction);
-    popupMenu->addAction(createSubAnalysisAction);
+  if (browser) {
+    QMenu *popupMenu = browser->getPopupMenu();
+    if (popupMenu) {
+      popupMenu->addAction(viewMussaAlignmentAction);
+      popupMenu->addAction(createSubAnalysisAction);
+    }
   }
 }
 
@@ -303,6 +316,9 @@ void MussaWindow::about()
   msg += "Version: ";
   msg += mussa_version;
   msg += "\n";
+  msg += "Qt: ";
+  msg += qVersion();
+  msg += "\n";
   msg += "OpenGL: ";
   msg += (char *)glGetString(GL_VERSION);
   msg += "\n";
@@ -311,6 +327,11 @@ void MussaWindow::about()
 
 void MussaWindow::clear()
 {
+  if (motif_editor != 0) {
+    motif_editor->hide();
+    delete motif_editor;
+  }
+  
   aligned_windows.clear();
   browser->clear();
 }
@@ -446,13 +467,11 @@ bool MussaWindow::isClearingAnalysisSafe()
 
 void MussaWindow::editMotifs()
 {
-  if (motif_editor != 0) {
-    motif_editor->hide();
-    delete motif_editor;
+  if (not motif_editor) {
+    motif_editor = new MotifEditor(analysis);
+    connect(motif_editor, SIGNAL(changedMotifs()), 
+            this, SLOT(updateAnnotations()));
   }
-  motif_editor = new MotifEditor(analysis);
-  connect(motif_editor, SIGNAL(changedMotifs()), 
-          this, SLOT(updateAnnotations()));
   motif_editor->show();
 }