# HG changeset patch # User Santeri Piippo # Date 1367630343 -10800 # Node ID 499286fcbf37f791dd238dd8182696cdd328cbc3 # Parent 635da3135bd4cdd9d6d43e8687e926ca38a699e0 Compile the icon resources to a QRC file, so that they are embedded in the application diff -r 635da3135bd4 -r 499286fcbf37 gldraw.cpp --- a/gldraw.cpp Sat May 04 02:52:33 2013 +0300 +++ b/gldraw.cpp Sat May 04 04:19:03 2013 +0300 @@ -101,11 +101,11 @@ // Init camera icons for (const GLRenderer::Camera cam : g_Cameras) { - str path; - path.format ("./icons/camera-%s.png", str (g_CameraNames[cam]).tolower ().chars ()); + str iconname; + iconname.format ("camera-%s", str (g_CameraNames[cam]).tolower ().chars ()); CameraIcon* info = &g_CameraIcons[cam]; - info->img = new QPixmap (path); + info->img = new QPixmap (getIcon (iconname)); info->cam = cam; } diff -r 635da3135bd4 -r 499286fcbf37 gui.cpp --- a/gui.cpp Sat May 04 02:52:33 2013 +0300 +++ b/gui.cpp Sat May 04 04:19:03 2013 +0300 @@ -146,7 +146,7 @@ slot_selectionChanged (); setStatusBar (new QStatusBar); - setWindowIcon (QIcon ("icons/ldforge.png")); + setWindowIcon (getIcon ("ldforge")); setTitle (); setMinimumSize (320, 200); resize (800, 600); @@ -955,8 +955,8 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -QIcon getIcon (const char* sIconName) { - return (QIcon (format ("./icons/%s.png", sIconName))); +QPixmap getIcon (const char* sIconName) { + return (QPixmap (format (":/icons/%s.png", sIconName))); } // ============================================================================= diff -r 635da3135bd4 -r 499286fcbf37 gui.h --- a/gui.h Sat May 04 02:52:33 2013 +0300 +++ b/gui.h Sat May 04 04:19:03 2013 +0300 @@ -182,7 +182,7 @@ // ----------------------------------------------------------------------------- // Other GUI-related stuff not directly part of ForgeWindow: -QIcon getIcon (const char* sIconName); +QPixmap getIcon (const char* sIconName); std::vector parseQuickColorMeta (); bool confirm (str title, str msg); bool confirm (str msg); diff -r 635da3135bd4 -r 499286fcbf37 ldforge.pro --- a/ldforge.pro Sat May 04 02:52:33 2013 +0300 +++ b/ldforge.pro Sat May 04 04:19:03 2013 +0300 @@ -8,6 +8,7 @@ INCLUDEPATH += . OBJECTS_DIR = build/ RC_FILE = ldforge.rc +RESOURCES = ldforge.qrc # Input HEADERS += bbox.h \ diff -r 635da3135bd4 -r 499286fcbf37 ldforge.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ldforge.qrc Sat May 04 04:19:03 2013 +0300 @@ -0,0 +1,89 @@ + + + + ./icons/add-bfc.png + ./icons/add-comment.png + ./icons/add-condline.png + ./icons/add-line.png + ./icons/add-quad.png + ./icons/add-radial.png + ./icons/add-subfile.png + ./icons/add-triangle.png + ./icons/add-vertex.png + ./icons/arrow-down.png + ./icons/arrow-left.png + ./icons/arrow-right.png + ./icons/arrow-up.png + ./icons/axes.png + ./icons/bfc.png + ./icons/brick-new.png + ./icons/brick.png + ./icons/camera-back.png + ./icons/camera-bottom.png + ./icons/camera-free.png + ./icons/camera-front.png + ./icons/camera-left.png + ./icons/camera-right.png + ./icons/camera-top.png + ./icons/checkerboard.png + ./icons/colorcursor.png + ./icons/colorselect.png + ./icons/comment.png + ./icons/condline.png + ./icons/copy.png + ./icons/corner-verts.png + ./icons/cut.png + ./icons/delete.png + ./icons/del-line.png + ./icons/empty.png + ./icons/error.png + ./icons/exit.png + ./icons/file-new.png + ./icons/file-open.png + ./icons/file.png + ./icons/file-save-as.png + ./icons/file-save.png + ./icons/folder.png + ./icons/grid-coarse.png + ./icons/grid-fine.png + ./icons/grid-medium.png + ./icons/help.png + ./icons/history.png + ./icons/inline-deep.png + ./icons/inline.png + ./icons/ldforge.ico + ./icons/ldforge.png + ./icons/line.png + ./icons/mail.png + ./icons/make-borders.png + ./icons/move-x-neg.png + ./icons/move-x-pos.png + ./icons/move-y-neg.png + ./icons/move-y-pos.png + ./icons/move-z-neg.png + ./icons/move-z-pos.png + ./icons/open-recent.png + ./icons/palette.png + ./icons/paste.png + ./icons/qt.png + ./icons/quad.png + ./icons/quad-split.png + ./icons/radial.png + ./icons/redo.png + ./icons/round-coords.png + ./icons/screencap.png + ./icons/select-all.png + ./icons/select-color.png + ./icons/select-type.png + ./icons/set-contents.png + ./icons/settings.png + ./icons/subfile.png + ./icons/triangle.png + ./icons/uncolorize.png + ./icons/undo.png + ./icons/vertex.png + ./docs/test2.html + ./docs/test.html + LICENSE + + diff -r 635da3135bd4 -r 499286fcbf37 mkqrc.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mkqrc.sh Sat May 04 04:19:03 2013 +0300 @@ -0,0 +1,12 @@ +#!/bin/bash + +QRCFILE=ldforge.qrc +printf "" > $QRCFILE + +printf "\n\n\n" >> $QRCFILE + +for img in ./icons/*.* ./docs/*.* LICENSE; do + printf "\t$img\n" >> $QRCFILE +done + +printf "\n\n" >> $QRCFILE \ No newline at end of file diff -r 635da3135bd4 -r 499286fcbf37 zz_aboutDialog.cpp --- a/zz_aboutDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_aboutDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -34,7 +34,7 @@ // Application icon - in full 64 x 64 glory. QLabel* icon = new QLabel; - icon->setPixmap (QPixmap ("icons/ldforge.png")); + icon->setPixmap (getIcon ("ldforge")); // Heading - application label and copyright information QLabel* title = new QLabel (format ("" APPNAME_DISPLAY " v%d.%d
" diff -r 635da3135bd4 -r 499286fcbf37 zz_addObjectDialog.cpp --- a/zz_addObjectDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_addObjectDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -49,11 +49,11 @@ QDialog (parent) { short coordCount = 0; - str iconName = format ("icons/add-%s.png", g_saObjTypeIcons[type]); + QPixmap icon = getIcon (format ("add-%s", g_saObjTypeIcons[type])); LDObject* defaults = LDObject::getDefault (type); lb_typeIcon = new QLabel; - lb_typeIcon->setPixmap (QPixmap (iconName)); + lb_typeIcon->setPixmap (icon); switch (type) { case OBJ_Comment: @@ -274,7 +274,7 @@ setWindowTitle (format (APPNAME_DISPLAY ": New %s", g_saObjTypeNames[type]).chars()); - setWindowIcon (QIcon (iconName.chars ())); + setWindowIcon (icon); delete defaults; } @@ -282,7 +282,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void AddObjectDialog::setButtonBackground (QPushButton* button, short color) { - button->setIcon (QIcon ("icons/palette.png")); + button->setIcon (getIcon ("palette")); button->setAutoFillBackground (true); button->setStyleSheet ( format ("background-color: %s", getColor (color)->zColorString.chars()).chars() diff -r 635da3135bd4 -r 499286fcbf37 zz_colorSelectDialog.cpp --- a/zz_colorSelectDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_colorSelectDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -53,7 +53,7 @@ selColor = dDefault; // not really an icon but eh - gs_scene->setBackgroundBrush (QPixmap ("icons/checkerboard.png")); + gs_scene->setBackgroundBrush (getIcon ("checkerboard")); gs_scene->setSceneRect (0, 0, g_lWidth, g_lMaxHeight); gv_view->setSceneRect (0, 0, g_lWidth, g_lMaxHeight); @@ -86,8 +86,8 @@ qLayout->addWidget (bbx_buttons); setLayout (qLayout); - setWindowIcon (QIcon ("icons/palette.png")); - setWindowTitle (APPNAME_DISPLAY " - choose a color"); + setWindowIcon (getIcon ("palette")); + setWindowTitle (APPNAME_DISPLAY); } // ============================================================================= @@ -125,7 +125,7 @@ if (i == selColor) { QGraphicsPixmapItem* qCursorPic; - qCursorPic = gs_scene->addPixmap (QPixmap ("icons/colorcursor.png")); + qCursorPic = gs_scene->addPixmap (getIcon ("colorcursor")); qCursorPic->setPos (x, y); } } diff -r 635da3135bd4 -r 499286fcbf37 zz_configDialog.cpp --- a/zz_configDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_configDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -70,7 +70,7 @@ setLayout (layout); setWindowTitle (APPNAME_DISPLAY " - Settings"); - setWindowIcon (QIcon ("icons/settings.png")); + setWindowIcon (getIcon ("settings")); } // ============================================================================= @@ -87,7 +87,7 @@ le_LDrawPath->setText (io_ldpath.value.chars()); pb_findLDrawPath = new QPushButton; - pb_findLDrawPath->setIcon (QIcon ("icons/folder.png")); + pb_findLDrawPath->setIcon (getIcon ("folder")); connect (pb_findLDrawPath, SIGNAL (clicked ()), this, SLOT (slot_findLDrawPath ())); @@ -286,7 +286,7 @@ for (int i = 0; i < g_NumGrids; ++i) { // Icon lb_gridIcons[i] = new QLabel; - lb_gridIcons[i]->setPixmap (QPixmap (format ("icons/grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); + lb_gridIcons[i]->setPixmap (getIcon (format ("grid-%s", str (g_GridInfo[i].name).tolower ().chars ()))); // Text label lb_gridLabels[i] = new QLabel (format ("%s:", g_GridInfo[i].name)); @@ -478,7 +478,7 @@ // ============================================================================= void ConfigDialog::pickColor (strconfig& cfg, QPushButton* qButton) { QColorDialog dlg (QColor (cfg.value.chars())); - dlg.setWindowIcon (QIcon ("icons/colorselect.png")); + dlg.setWindowIcon (getIcon ("colorselect")); if (dlg.exec ()) { uchar r = dlg.currentColor ().red (), @@ -501,7 +501,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ConfigDialog::setButtonBackground (QPushButton* qButton, str zValue) { - qButton->setIcon (QIcon ("icons/colorselect.png")); + qButton->setIcon (getIcon ("colorselect")); qButton->setAutoFillBackground (true); qButton->setStyleSheet ( format ("background-color: %s", zValue.chars()).chars() diff -r 635da3135bd4 -r 499286fcbf37 zz_newPartDialog.cpp --- a/zz_newPartDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_newPartDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -39,7 +39,7 @@ // ============================================================================= NewPartDialog::NewPartDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { lb_brickIcon = new QLabel; - lb_brickIcon->setPixmap (QPixmap ("icons/brick.png")); + lb_brickIcon->setPixmap (getIcon ("brick")); lb_name = new QLabel ("Name:"); le_name = new QLineEdit; @@ -76,8 +76,8 @@ layout->addWidget (bbx_buttons, 3, 2); setLayout (layout); - setWindowIcon (QIcon ("icons/brick.png")); - setWindowTitle (APPNAME_DISPLAY " - new part"); + setWindowIcon (getIcon ("brick")); + setWindowTitle (APPNAME_DISPLAY ": New Part"); } // ============================================================================= diff -r 635da3135bd4 -r 499286fcbf37 zz_setContentsDialog.cpp --- a/zz_setContentsDialog.cpp Sat May 04 02:52:33 2013 +0300 +++ b/zz_setContentsDialog.cpp Sat May 04 04:19:03 2013 +0300 @@ -45,7 +45,7 @@ lb_error->setText (format ("%s", static_cast (obj)->zReason.chars())); - QPixmap qErrorPixmap = QPixmap ("icons/error.png").scaledToHeight (16); + QPixmap qErrorPixmap = getIcon ("error").scaledToHeight (16); lb_errorIcon = new QLabel; lb_errorIcon->setPixmap (qErrorPixmap); @@ -68,8 +68,8 @@ layout->addLayout (layout2); setLayout (layout); - setWindowTitle (APPNAME_DISPLAY " - setting contents"); - setWindowIcon (QIcon ("icons/set-contents.png")); + setWindowTitle (APPNAME_DISPLAY ": Set Contents"); + setWindowIcon (getIcon ("set-contents")); } // =============================================================================