use qt resources for icons
authorDiane Trout <diane@caltech.edu>
Tue, 28 Mar 2006 01:33:52 +0000 (01:33 +0000)
committerDiane Trout <diane@caltech.edu>
Tue, 28 Mar 2006 01:33:52 +0000 (01:33 +0000)
WARNING: Seems to need qt 4.1.1 to work correctly
This uses QT resources to link the icons directly into the application, so
they'll always show up, even when not being run from the source directory.

Of course in practice it seems like qt 4.1.0 has a bug so the resource
feature doesn't quite work right.

.boring
icons.qrc [new file with mode: 0644]
mussagl.cpp
mussagl.pro
qui/MussaWindow.cpp

diff --git a/.boring b/.boring
index 7ef83f1da1c5113dbc0b721800f72a981cec8cac..74a300b2ec9101d719da61462e763358c40080b5 100644 (file)
--- a/.boring
+++ b/.boring
@@ -5,6 +5,8 @@
 \.d$
 # qt
 moc_.*\.cpp$
+qrc_(^|/)*$
+(^|/)mussagl.app($|/)
 # mussa specific thingies
 \.museq$
 \.muway$
diff --git a/icons.qrc b/icons.qrc
new file mode 100644 (file)
index 0000000..4777b84
--- /dev/null
+++ b/icons.qrc
@@ -0,0 +1,15 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+<qresource>
+   <file>icons/exit.png</file>
+   <file>icons/filenew.png</file>
+   <file>icons/fileopen.png</file>
+   <file>icons/filesave.png</file>
+   <file>icons/help.png</file>
+   <file>icons/image2.png</file>
+   <file>icons/info.png</file>
+   <file>icons/lock.png</file>
+   <file>icons/motif_icon.png</file>
+   <file>icons/viewmag.png</file>
+</qresource>
+</RCC>
index 008b888fbcca15dc70da33367248d5b9fc296dbd..656c9a2de45f9340efad2f6d9db0942a9d0f32b2 100644 (file)
@@ -6,6 +6,7 @@
 int main(int argc, char **argv)
 {
   QApplication app(argc, argv);
+  Q_INIT_RESOURCE(icons);
   Mussa *analysis = initialize_mussa(argc, argv);
 
   if (analysis == 0) {
index 551dec9eece883ebf0ff36277a80149dd9a47369..e569115b490cb8bbd3cb8797c19beebe21a46ffe 100644 (file)
@@ -72,6 +72,7 @@ SOURCES += mussagl.cpp \
            alg/nway_paths.cpp \
            alg/parse_options.cpp \
            alg/sequence.cpp 
+RESOURCES = icons.qrc
 
 LIBS += -lm 
 QT += opengl
index a132f33401b007274fd7895c3f5c6b554a373aa1..7abf8f3d34451e1fb6b64da2777bf2cd5f910b24 100644 (file)
@@ -43,7 +43,7 @@ MussaWindow::MussaWindow(Mussa *analysis_, QWidget *parent) :
 
   mussaViewTB.addAction(toggleMotifsAction);
   
-  zoomLabel.setPixmap(QIcon("icons/viewmag.png").pixmap(16, 16));
+  zoomLabel.setPixmap(QIcon(":/icons/viewmag.png").pixmap(16, 16));
   zoomLabel.setToolTip(tr("Zoom"));
   zoomLabel.setWhatsThis(tr("Zoom magnification factor"));
   mussaViewTB.addWidget(&zoomLabel);
@@ -89,18 +89,18 @@ void MussaWindow::setupActions()
   // the ever popular about box
   aboutAction = new QAction(tr("&About"), this);
   connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
-  aboutAction->setIcon(QIcon("icons/info.png"));
+  aboutAction->setIcon(QIcon(":/icons/info.png"));
 
   // add exit
   closeAction = new QAction(tr("&Close"), this);
   closeAction->setStatusTip(tr("Close this window"));
   connect(closeAction, SIGNAL(triggered()), this, SLOT(close()));
-  closeAction->setIcon(QIcon("icons/exit.png"));
+  closeAction->setIcon(QIcon(":/icons/exit.png"));
   
   createNewAnalysisAction = new QAction(tr("Define Analysis"), this);
   connect(createNewAnalysisAction, SIGNAL(triggered()), 
           this, SLOT(createNewAnalysis()));
-  createNewAnalysisAction->setIcon(QIcon("icons/filenew.png"));
+  createNewAnalysisAction->setIcon(QIcon(":/icons/filenew.png"));
   
   createSubAnalysisAction = new QAction(tr("Define SubAnalysis"), this);
   connect(createSubAnalysisAction, SIGNAL(triggered()), 
@@ -112,22 +112,22 @@ void MussaWindow::setupActions()
   loadMotifListAction = new QAction(tr("Load Motif List"), this);
   connect(loadMotifListAction, SIGNAL(triggered()), 
           this, SLOT(loadMotifList()));
-  loadMotifListAction->setIcon(QIcon("icons/fileopen.png"));
+  loadMotifListAction->setIcon(QIcon(":/icons/fileopen.png"));
   
   loadMupaAction = new QAction(tr("Load Mussa Parameters"), this);
   connect(loadMupaAction, SIGNAL(triggered()), 
           this, SLOT(loadMupa()));
-  loadMupaAction->setIcon(QIcon("icons/fileopen.png"));
+  loadMupaAction->setIcon(QIcon(":/icons/fileopen.png"));
 
   loadSavedAnalysisAction = new QAction(tr("Load &Analysis"), this);
   connect(loadSavedAnalysisAction, SIGNAL(triggered()), 
           this, SLOT(loadSavedAnalysis()));
-  loadSavedAnalysisAction->setIcon(QIcon("icons/fileopen.png"));
+  loadSavedAnalysisAction->setIcon(QIcon(":/icons/fileopen.png"));
 
   saveMotifListAction = new QAction(tr("Save Motifs"), this);
   connect(saveMotifListAction, SIGNAL(triggered()), 
           this, SLOT(saveMotifList()));
-  saveMotifListAction->setIcon(QIcon("icons/filesave.png"));
+  saveMotifListAction->setIcon(QIcon(":/icons/filesave.png"));
 
   showMussaViewToolbarAction = new QAction(tr("Show Toolbar"), this);
   connect(showMussaViewToolbarAction, SIGNAL(triggered()), 
@@ -139,7 +139,7 @@ void MussaWindow::setupActions()
   connect(toggleMotifsAction, SIGNAL(triggered()), 
           this, SLOT(toggleMotifs()));
   toggleMotifsAction->setCheckable(true);
-  toggleMotifsAction->setIcon(QIcon("icons/motif_icon.png"));
+  toggleMotifsAction->setIcon(QIcon(":/icons/motif_icon.png"));
   toggleMotifsAction->setWhatsThis(tr("Toggle motif annotations on/off\n\n"
                                   "You can load motif annotations via "
                                   "'File->Load Motif List' menu option."));
@@ -148,7 +148,7 @@ void MussaWindow::setupActions()
   saveBrowserPixmapAction = new QAction(tr("Save to image..."), this);
   connect(saveBrowserPixmapAction, (SIGNAL(triggered())),
          &browser, SLOT(promptSaveBrowserPixmap()));
-  saveBrowserPixmapAction->setIcon(QIcon("icons/image2.png"));
+  saveBrowserPixmapAction->setIcon(QIcon(":/icons/image2.png"));
 
   viewMussaAlignmentAction = new QAction(tr("View mussa alignment"), this);
   connect(viewMussaAlignmentAction, SIGNAL(triggered()),
@@ -158,7 +158,7 @@ void MussaWindow::setupActions()
                                             "defined paths"));
 
   whatsThisAction = QWhatsThis::createAction(this);
-  whatsThisAction->setIcon(QIcon("icons/help.png"));
+  whatsThisAction->setIcon(QIcon(":/icons/help.png"));
 
 }