From 4aef34b78122f104fdf19729d3422236b5676658 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Tue, 28 Mar 2006 01:33:52 +0000 Subject: [PATCH] use qt resources for icons 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 | 2 ++ icons.qrc | 15 +++++++++++++++ mussagl.cpp | 1 + mussagl.pro | 1 + qui/MussaWindow.cpp | 22 +++++++++++----------- 5 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 icons.qrc diff --git a/.boring b/.boring index 7ef83f1..74a300b 100644 --- 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 index 0000000..4777b84 --- /dev/null +++ b/icons.qrc @@ -0,0 +1,15 @@ + + + + icons/exit.png + icons/filenew.png + icons/fileopen.png + icons/filesave.png + icons/help.png + icons/image2.png + icons/info.png + icons/lock.png + icons/motif_icon.png + icons/viewmag.png + + diff --git a/mussagl.cpp b/mussagl.cpp index 008b888..656c9a2 100644 --- a/mussagl.cpp +++ b/mussagl.cpp @@ -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) { diff --git a/mussagl.pro b/mussagl.pro index 551dec9..e569115 100644 --- a/mussagl.pro +++ b/mussagl.pro @@ -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 diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index a132f33..7abf8f3 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -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")); } -- 2.30.2