diff --git a/CMakeLists.txt b/CMakeLists.txt index c7ac1eb9..c4d239fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,7 @@ option(WITH_CLIENT "build cockatrice" ON) if(WITH_CLIENT) add_subdirectory(cockatrice) add_subdirectory(sounds) - add_subdirectory(zonebg) + add_subdirectory(themes) SET(CPACK_INSTALL_CMAKE_PROJECTS "cockatrice;cockatrice;ALL;/" ${CPACK_INSTALL_CMAKE_PROJECTS}) endif() diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index 8efc1e0e..2555d66f 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -87,6 +87,7 @@ SET(cockatrice_SOURCES src/playerlistwidget.cpp src/pixmapgenerator.cpp src/settingscache.cpp + src/thememanager.cpp src/localserver.cpp src/localserverinterface.cpp src/localclient.cpp diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 2e66b2df..84a5e651 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -1,57 +1,58 @@ - - resources/back.svg - resources/lock.svg - resources/icon_delete.svg - resources/icon_tab_changed.svg - resources/icon_config_general.svg - resources/icon_config_appearance.svg - resources/icon_config_interface.svg - resources/icon_config_messages.svg - resources/icon_config_deckeditor.svg - resources/icon_config_sound.svg - resources/phases/icon_phase_untap.svg - resources/phases/icon_phase_upkeep.svg - resources/phases/icon_phase_draw.svg - resources/phases/icon_phase_main1.svg - resources/phases/icon_phase_combat_start.svg - resources/phases/icon_phase_combat_attackers.svg - resources/phases/icon_phase_combat_blockers.svg - resources/phases/icon_phase_combat_damage.svg - resources/phases/icon_phase_combat_end.svg - resources/phases/icon_phase_main2.svg - resources/phases/icon_phase_cleanup.svg - resources/phases/icon_phase_nextturn.svg - resources/icon_settings.svg + + resources/back.svg + resources/cockatrice.svg resources/hand.svg - resources/pencil.svg - resources/icon_search_black.svg - resources/icon_clearsearch.svg - resources/icon_update.png - resources/icon_view.svg resources/hr.jpg - resources/cockatrice.svg - resources/add_to_sideboard.svg - resources/decrement.svg - resources/increment.svg - resources/remove_row.svg - resources/arrow_left_green.svg - resources/arrow_right_green.svg - resources/arrow_top_green.svg - resources/arrow_up_green.svg - resources/arrow_down_green.svg - resources/arrow_bottom_green.svg - resources/icon_ready_start.svg - resources/icon_not_ready_start.svg - resources/icon_conceded.svg - resources/icon_player.svg - resources/icon_spectator.svg - resources/replay_start.svg - resources/replay_fastforward.svg - resources/replay_pause.svg - resources/genders/male.svg - resources/genders/female.svg - resources/genders/unknown.svg + + resources/icons/arrow_bottom_green.svg + resources/icons/arrow_down_green.svg + resources/icons/arrow_left_green.svg + resources/icons/arrow_right_blue.svg + resources/icons/arrow_right_green.svg + resources/icons/arrow_top_green.svg + resources/icons/arrow_up_green.svg + resources/icons/clearsearch.svg + resources/icons/conceded.svg + resources/icons/decrement.svg + resources/icons/delete.svg + resources/icons/increment.svg + resources/icons/lock.svg + resources/icons/not_ready_start.svg + resources/icons/pencil.svg + resources/icons/player.svg + resources/icons/ready_start.svg + resources/icons/remove_row.svg + resources/icons/search.svg + resources/icons/settings.svg + resources/icons/spectator.svg + resources/icons/tab_changed.svg + resources/icons/update.png + resources/icons/view.svg + + resources/config/general.svg + resources/config/appearance.svg + resources/config/interface.svg + resources/config/messages.svg + resources/config/deckeditor.svg + resources/config/shorcuts.svg + resources/config/sound.svg + + resources/counters/w.svg + resources/counters/w_highlight.svg + resources/counters/u.svg + resources/counters/u_highlight.svg + resources/counters/b.svg + resources/counters/b_highlight.svg + resources/counters/r.svg + resources/counters/r_highlight.svg + resources/counters/g.svg + resources/counters/g_highlight.svg + resources/counters/storm.svg + resources/counters/storm_highlight.svg + resources/counters/general.svg + resources/counters/general_highlight.svg + resources/countries/ad.svg resources/countries/ae.svg resources/countries/af.svg @@ -301,20 +302,28 @@ resources/countries/za.svg resources/countries/zm.svg resources/countries/zw.svg - resources/counters/w.svg - resources/counters/w_highlight.svg - resources/counters/u.svg - resources/counters/u_highlight.svg - resources/counters/b.svg - resources/counters/b_highlight.svg - resources/counters/r.svg - resources/counters/r_highlight.svg - resources/counters/g.svg - resources/counters/g_highlight.svg - resources/counters/storm.svg - resources/counters/storm_highlight.svg - resources/counters/general.svg - resources/counters/general_highlight.svg + + resources/genders/male.svg + resources/genders/female.svg + resources/genders/unknown.svg + + resources/phases/untap.svg + resources/phases/upkeep.svg + resources/phases/draw.svg + resources/phases/main1.svg + resources/phases/combat_start.svg + resources/phases/combat_attackers.svg + resources/phases/combat_blockers.svg + resources/phases/combat_damage.svg + resources/phases/combat_end.svg + resources/phases/main2.svg + resources/phases/cleanup.svg + resources/phases/nextturn.svg + + resources/replay/start.svg + resources/replay/fastforward.svg + resources/replay/pause.svg + resources/userlevels/normal.svg resources/userlevels/registered.svg resources/userlevels/registered_buddy.svg @@ -322,8 +331,5 @@ resources/userlevels/moderator_buddy.svg resources/userlevels/admin.svg resources/userlevels/admin_buddy.svg - resources/news/exclamation_mark.svg - resources/news/question_mark.svg - resources/icon_config_shorcuts.svg diff --git a/cockatrice/resources/icon_config_appearance.svg b/cockatrice/resources/config/appearance.svg similarity index 100% rename from cockatrice/resources/icon_config_appearance.svg rename to cockatrice/resources/config/appearance.svg diff --git a/cockatrice/resources/icon_config_deckeditor.svg b/cockatrice/resources/config/deckeditor.svg similarity index 100% rename from cockatrice/resources/icon_config_deckeditor.svg rename to cockatrice/resources/config/deckeditor.svg diff --git a/cockatrice/resources/icon_config_general.svg b/cockatrice/resources/config/general.svg similarity index 100% rename from cockatrice/resources/icon_config_general.svg rename to cockatrice/resources/config/general.svg diff --git a/cockatrice/resources/icon_config_interface.svg b/cockatrice/resources/config/interface.svg similarity index 100% rename from cockatrice/resources/icon_config_interface.svg rename to cockatrice/resources/config/interface.svg diff --git a/cockatrice/resources/icon_config_messages.svg b/cockatrice/resources/config/messages.svg similarity index 100% rename from cockatrice/resources/icon_config_messages.svg rename to cockatrice/resources/config/messages.svg diff --git a/cockatrice/resources/icon_config_shorcuts.svg b/cockatrice/resources/config/shorcuts.svg similarity index 100% rename from cockatrice/resources/icon_config_shorcuts.svg rename to cockatrice/resources/config/shorcuts.svg diff --git a/cockatrice/resources/icon_config_sound.svg b/cockatrice/resources/config/sound.svg similarity index 100% rename from cockatrice/resources/icon_config_sound.svg rename to cockatrice/resources/config/sound.svg diff --git a/cockatrice/resources/arrow_bottom_green.svg b/cockatrice/resources/icons/arrow_bottom_green.svg similarity index 100% rename from cockatrice/resources/arrow_bottom_green.svg rename to cockatrice/resources/icons/arrow_bottom_green.svg diff --git a/cockatrice/resources/arrow_down_green.svg b/cockatrice/resources/icons/arrow_down_green.svg similarity index 100% rename from cockatrice/resources/arrow_down_green.svg rename to cockatrice/resources/icons/arrow_down_green.svg diff --git a/cockatrice/resources/arrow_left_green.svg b/cockatrice/resources/icons/arrow_left_green.svg similarity index 100% rename from cockatrice/resources/arrow_left_green.svg rename to cockatrice/resources/icons/arrow_left_green.svg diff --git a/cockatrice/resources/add_to_sideboard.svg b/cockatrice/resources/icons/arrow_right_blue.svg similarity index 100% rename from cockatrice/resources/add_to_sideboard.svg rename to cockatrice/resources/icons/arrow_right_blue.svg diff --git a/cockatrice/resources/arrow_right_green.svg b/cockatrice/resources/icons/arrow_right_green.svg similarity index 100% rename from cockatrice/resources/arrow_right_green.svg rename to cockatrice/resources/icons/arrow_right_green.svg diff --git a/cockatrice/resources/arrow_top_green.svg b/cockatrice/resources/icons/arrow_top_green.svg similarity index 100% rename from cockatrice/resources/arrow_top_green.svg rename to cockatrice/resources/icons/arrow_top_green.svg diff --git a/cockatrice/resources/arrow_up_green.svg b/cockatrice/resources/icons/arrow_up_green.svg similarity index 100% rename from cockatrice/resources/arrow_up_green.svg rename to cockatrice/resources/icons/arrow_up_green.svg diff --git a/cockatrice/resources/icon_clearsearch.svg b/cockatrice/resources/icons/clearsearch.svg similarity index 100% rename from cockatrice/resources/icon_clearsearch.svg rename to cockatrice/resources/icons/clearsearch.svg diff --git a/cockatrice/resources/icon_conceded.svg b/cockatrice/resources/icons/conceded.svg similarity index 100% rename from cockatrice/resources/icon_conceded.svg rename to cockatrice/resources/icons/conceded.svg diff --git a/cockatrice/resources/decrement.svg b/cockatrice/resources/icons/decrement.svg similarity index 100% rename from cockatrice/resources/decrement.svg rename to cockatrice/resources/icons/decrement.svg diff --git a/cockatrice/resources/icon_delete.svg b/cockatrice/resources/icons/delete.svg similarity index 100% rename from cockatrice/resources/icon_delete.svg rename to cockatrice/resources/icons/delete.svg diff --git a/cockatrice/resources/increment.svg b/cockatrice/resources/icons/increment.svg similarity index 100% rename from cockatrice/resources/increment.svg rename to cockatrice/resources/icons/increment.svg diff --git a/cockatrice/resources/lock.svg b/cockatrice/resources/icons/lock.svg similarity index 100% rename from cockatrice/resources/lock.svg rename to cockatrice/resources/icons/lock.svg diff --git a/cockatrice/resources/icon_not_ready_start.svg b/cockatrice/resources/icons/not_ready_start.svg similarity index 100% rename from cockatrice/resources/icon_not_ready_start.svg rename to cockatrice/resources/icons/not_ready_start.svg diff --git a/cockatrice/resources/pencil.svg b/cockatrice/resources/icons/pencil.svg similarity index 100% rename from cockatrice/resources/pencil.svg rename to cockatrice/resources/icons/pencil.svg diff --git a/cockatrice/resources/icon_player.svg b/cockatrice/resources/icons/player.svg similarity index 100% rename from cockatrice/resources/icon_player.svg rename to cockatrice/resources/icons/player.svg diff --git a/cockatrice/resources/icon_ready_start.svg b/cockatrice/resources/icons/ready_start.svg similarity index 100% rename from cockatrice/resources/icon_ready_start.svg rename to cockatrice/resources/icons/ready_start.svg diff --git a/cockatrice/resources/remove_row.svg b/cockatrice/resources/icons/remove_row.svg similarity index 100% rename from cockatrice/resources/remove_row.svg rename to cockatrice/resources/icons/remove_row.svg diff --git a/cockatrice/resources/icon_search_black.svg b/cockatrice/resources/icons/search.svg similarity index 100% rename from cockatrice/resources/icon_search_black.svg rename to cockatrice/resources/icons/search.svg diff --git a/cockatrice/resources/icon_settings.svg b/cockatrice/resources/icons/settings.svg similarity index 100% rename from cockatrice/resources/icon_settings.svg rename to cockatrice/resources/icons/settings.svg diff --git a/cockatrice/resources/icon_spectator.svg b/cockatrice/resources/icons/spectator.svg similarity index 100% rename from cockatrice/resources/icon_spectator.svg rename to cockatrice/resources/icons/spectator.svg diff --git a/cockatrice/resources/icon_tab_changed.svg b/cockatrice/resources/icons/tab_changed.svg similarity index 100% rename from cockatrice/resources/icon_tab_changed.svg rename to cockatrice/resources/icons/tab_changed.svg diff --git a/cockatrice/resources/icon_update.png b/cockatrice/resources/icons/update.png similarity index 100% rename from cockatrice/resources/icon_update.png rename to cockatrice/resources/icons/update.png diff --git a/cockatrice/resources/icon_view.svg b/cockatrice/resources/icons/view.svg similarity index 100% rename from cockatrice/resources/icon_view.svg rename to cockatrice/resources/icons/view.svg diff --git a/cockatrice/resources/news/exclamation_mark.svg b/cockatrice/resources/news/exclamation_mark.svg deleted file mode 100644 index a4994777..00000000 --- a/cockatrice/resources/news/exclamation_mark.svg +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/cockatrice/resources/news/question_mark.svg b/cockatrice/resources/news/question_mark.svg deleted file mode 100644 index 9272381f..00000000 --- a/cockatrice/resources/news/question_mark.svg +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - ? - - diff --git a/cockatrice/resources/phases/icon_phase_cleanup.svg b/cockatrice/resources/phases/cleanup.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_cleanup.svg rename to cockatrice/resources/phases/cleanup.svg diff --git a/cockatrice/resources/phases/icon_phase_combat_attackers.svg b/cockatrice/resources/phases/combat_attackers.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_combat_attackers.svg rename to cockatrice/resources/phases/combat_attackers.svg diff --git a/cockatrice/resources/phases/icon_phase_combat_blockers.svg b/cockatrice/resources/phases/combat_blockers.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_combat_blockers.svg rename to cockatrice/resources/phases/combat_blockers.svg diff --git a/cockatrice/resources/phases/icon_phase_combat_damage.svg b/cockatrice/resources/phases/combat_damage.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_combat_damage.svg rename to cockatrice/resources/phases/combat_damage.svg diff --git a/cockatrice/resources/phases/icon_phase_combat_end.svg b/cockatrice/resources/phases/combat_end.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_combat_end.svg rename to cockatrice/resources/phases/combat_end.svg diff --git a/cockatrice/resources/phases/icon_phase_combat_start.svg b/cockatrice/resources/phases/combat_start.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_combat_start.svg rename to cockatrice/resources/phases/combat_start.svg diff --git a/cockatrice/resources/phases/icon_phase_draw.svg b/cockatrice/resources/phases/draw.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_draw.svg rename to cockatrice/resources/phases/draw.svg diff --git a/cockatrice/resources/phases/icon_phase_main1.svg b/cockatrice/resources/phases/main1.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_main1.svg rename to cockatrice/resources/phases/main1.svg diff --git a/cockatrice/resources/phases/icon_phase_main2.svg b/cockatrice/resources/phases/main2.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_main2.svg rename to cockatrice/resources/phases/main2.svg diff --git a/cockatrice/resources/phases/icon_phase_nextturn.svg b/cockatrice/resources/phases/nextturn.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_nextturn.svg rename to cockatrice/resources/phases/nextturn.svg diff --git a/cockatrice/resources/phases/icon_phase_untap.svg b/cockatrice/resources/phases/untap.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_untap.svg rename to cockatrice/resources/phases/untap.svg diff --git a/cockatrice/resources/phases/icon_phase_upkeep.svg b/cockatrice/resources/phases/upkeep.svg similarity index 100% rename from cockatrice/resources/phases/icon_phase_upkeep.svg rename to cockatrice/resources/phases/upkeep.svg diff --git a/cockatrice/resources/replay_fastforward.svg b/cockatrice/resources/replay/fastforward.svg similarity index 100% rename from cockatrice/resources/replay_fastforward.svg rename to cockatrice/resources/replay/fastforward.svg diff --git a/cockatrice/resources/replay_pause.svg b/cockatrice/resources/replay/pause.svg similarity index 100% rename from cockatrice/resources/replay_pause.svg rename to cockatrice/resources/replay/pause.svg diff --git a/cockatrice/resources/replay_start.svg b/cockatrice/resources/replay/start.svg similarity index 100% rename from cockatrice/resources/replay_start.svg rename to cockatrice/resources/replay/start.svg diff --git a/cockatrice/resources/replay_stop.svg b/cockatrice/resources/replay_stop.svg deleted file mode 100644 index 8791b3c0..00000000 --- a/cockatrice/resources/replay_stop.svg +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - diff --git a/cockatrice/src/carddatabase.cpp b/cockatrice/src/carddatabase.cpp index 0f80a7a1..8978e70c 100644 --- a/cockatrice/src/carddatabase.cpp +++ b/cockatrice/src/carddatabase.cpp @@ -1,5 +1,7 @@ #include "carddatabase.h" #include "settingscache.h" +#include "thememanager.h" + #include #include #include @@ -642,7 +644,7 @@ void CardInfo::loadPixmap(QPixmap &pixmap) pixmap = QPixmap(); if (getName().isEmpty()) { - pixmap.load(settingsCache->getCardBackPicturePath()); + pixmap = themeManager->getCardBackPixmap(); return; } @@ -672,15 +674,15 @@ void CardInfo::getPixmap(QSize size, QPixmap &pixmap) QPixmap bigPixmap; loadPixmap(bigPixmap); if (bigPixmap.isNull()) { - if (!getName().isEmpty()) { - pixmap = QPixmap(); // null - return; - } else { - QSvgRenderer svg(QString(":/back.svg")); + if (getName().isEmpty()) { + QSvgRenderer svg(QString("theme:back.svg")); bigPixmap = QPixmap(svg.defaultSize()); bigPixmap.fill(Qt::transparent); QPainter painter(&bigPixmap); svg.render(&painter); + } else { + pixmap = QPixmap(); // null + return; } } @@ -808,7 +810,7 @@ CardDatabase::CardDatabase(QObject *parent) noCard = new CardInfo(this); QPixmap tmp; noCard->loadPixmap(tmp); // cache pixmap for card back - connect(settingsCache, SIGNAL(cardBackPicturePathChanged()), noCard, SLOT(updatePixmapCache())); + connect(themeManager, SIGNAL(themeChanged()), noCard, SLOT(updatePixmapCache())); } CardDatabase::~CardDatabase() diff --git a/cockatrice/src/decklistmodel.cpp b/cockatrice/src/decklistmodel.cpp index 3b04bf06..d2f1319e 100644 --- a/cockatrice/src/decklistmodel.cpp +++ b/cockatrice/src/decklistmodel.cpp @@ -469,7 +469,7 @@ void DeckListModel::printDeckList(QPrinter *printer) cursor.insertBlock(headerBlockFormat, headerCharFormat); for (int i = 0; i < root->size(); i++) { - cursor.insertHtml("
"); + cursor.insertHtml("
"); //cursor.insertHtml("
"); cursor.insertBlock(headerBlockFormat, headerCharFormat); diff --git a/cockatrice/src/deckview.cpp b/cockatrice/src/deckview.cpp index 9cda1524..cd5d1022 100644 --- a/cockatrice/src/deckview.cpp +++ b/cockatrice/src/deckview.cpp @@ -5,6 +5,7 @@ #include "decklist.h" #include "carddatabase.h" #include "settingscache.h" +#include "thememanager.h" #include "main.h" DeckViewCardDragItem::DeckViewCardDragItem(DeckViewCard *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag) @@ -128,10 +129,6 @@ void DeckViewCard::hoverEnterEvent(QGraphicsSceneHoverEvent *event) DeckViewCardContainer::DeckViewCardContainer(const QString &_name) : QGraphicsItem(), name(_name), width(0), height(0) { - QString bgPath = settingsCache->getTableBgPath(); - if (!bgPath.isEmpty()) - bgPixmap.load(bgPath); - setCacheMode(DeviceCoordinateCache); } @@ -144,17 +141,7 @@ void DeckViewCardContainer::paint(QPainter *painter, const QStyleOptionGraphicsI { qreal totalTextWidth = getCardTypeTextWidth(); - if (bgPixmap.isNull()) { - QLinearGradient grad1(0, 0, 1, 0); - grad1.setCoordinateMode(QGradient::ObjectBoundingMode); - grad1.setColorAt(0, QColor(30, 30, 30)); - grad1.setColorAt(1, QColor(80, 80, 80)); - painter->fillRect(QRectF(0, 0, width, height), QBrush(grad1)); - - painter->fillRect(boundingRect(), QColor(0, 0, 0, 80)); - } - else - painter->fillRect(boundingRect(), QBrush(bgPixmap)); + painter->fillRect(boundingRect(), themeManager->getTableBgBrush()); painter->setPen(QColor(255, 255, 255, 100)); painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY)); diff --git a/cockatrice/src/deckview.h b/cockatrice/src/deckview.h index cc064ef6..080f80c1 100644 --- a/cockatrice/src/deckview.h +++ b/cockatrice/src/deckview.h @@ -53,7 +53,6 @@ private: QMultiMap cardsByType; QList > currentRowsAndCols; qreal width, height; - QPixmap bgPixmap; int getCardTypeTextWidth() const; public: enum { Type = typeDeckViewCardContainer }; diff --git a/cockatrice/src/dlg_edit_tokens.cpp b/cockatrice/src/dlg_edit_tokens.cpp index 4f2b6372..9f024ed5 100644 --- a/cockatrice/src/dlg_edit_tokens.cpp +++ b/cockatrice/src/dlg_edit_tokens.cpp @@ -83,10 +83,10 @@ DlgEditTokens::DlgEditTokens(CardDatabaseModel *_cardDatabaseModel, QWidget *par connect(chooseTokenView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(tokenSelectionChanged(QModelIndex, QModelIndex))); QAction *aAddToken = new QAction(tr("Add token"), this); - aAddToken->setIcon(QIcon(":/resources/increment.svg")); + aAddToken->setIcon(QIcon("theme:icons/increment.svg")); connect(aAddToken, SIGNAL(triggered()), this, SLOT(actAddToken())); QAction *aRemoveToken = new QAction(tr("Remove token"), this); - aRemoveToken->setIcon(QIcon(":/resources/decrement.svg")); + aRemoveToken->setIcon(QIcon("theme:icons/decrement.svg")); connect(aRemoveToken, SIGNAL(triggered()), this, SLOT(actRemoveToken())); QToolBar *databaseToolBar = new QToolBar; diff --git a/cockatrice/src/dlg_edit_user.cpp b/cockatrice/src/dlg_edit_user.cpp index 932dfa12..fd5df607 100644 --- a/cockatrice/src/dlg_edit_user.cpp +++ b/cockatrice/src/dlg_edit_user.cpp @@ -19,9 +19,9 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString cou genderLabel = new QLabel(tr("Pronouns:")); genderEdit = new QComboBox(); genderLabel->setBuddy(genderEdit); - genderEdit->insertItem(0, QIcon(":/resources/genders/unknown.svg"), tr("Neutral")); - genderEdit->insertItem(1, QIcon(":/resources/genders/male.svg"), tr("Masculine")); - genderEdit->insertItem(2, QIcon(":/resources/genders/female.svg"), tr("Feminine")); + genderEdit->insertItem(0, QIcon("theme:genders/unknown.svg"), tr("Neutral")); + genderEdit->insertItem(1, QIcon("theme:genders/male.svg"), tr("Masculine")); + genderEdit->insertItem(2, QIcon("theme:genders/female.svg"), tr("Feminine")); genderEdit->setCurrentIndex(gender + 1); countryLabel = new QLabel(tr("Country:")); @@ -34,7 +34,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString cou int i = 1; foreach(QString c, countries) { - countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c); + countryEdit->addItem(QPixmap("theme:countries/" + c.toLower() + ".svg"), c); if (c == country) countryEdit->setCurrentIndex(i); diff --git a/cockatrice/src/dlg_register.cpp b/cockatrice/src/dlg_register.cpp index bda76b48..97f47c9d 100644 --- a/cockatrice/src/dlg_register.cpp +++ b/cockatrice/src/dlg_register.cpp @@ -50,19 +50,268 @@ DlgRegister::DlgRegister(QWidget *parent) genderLabel = new QLabel(tr("Pronouns:")); genderEdit = new QComboBox(); genderLabel->setBuddy(genderEdit); - genderEdit->insertItem(0, QIcon(":/resources/genders/unknown.svg"), tr("Neutral")); - genderEdit->insertItem(1, QIcon(":/resources/genders/male.svg"), tr("Masculine")); - genderEdit->insertItem(2, QIcon(":/resources/genders/female.svg"), tr("Feminine")); + genderEdit->insertItem(0, QIcon("theme:genders/unknown.svg"), tr("Neutral")); + genderEdit->insertItem(1, QIcon("theme:genders/male.svg"), tr("Masculine")); + genderEdit->insertItem(2, QIcon("theme:genders/female.svg"), tr("Feminine")); genderEdit->setCurrentIndex(0); countryLabel = new QLabel(tr("Country:")); countryEdit = new QComboBox(); countryLabel->setBuddy(countryEdit); countryEdit->insertItem(0, tr("Undefined")); + countryEdit->addItem(QPixmap("theme:countries/ad.svg"), "ad"); + countryEdit->addItem(QIcon("theme:countries/ae.svg"), "ae"); + countryEdit->addItem(QIcon("theme:countries/af.svg"), "af"); + countryEdit->addItem(QIcon("theme:countries/ag.svg"), "ag"); + countryEdit->addItem(QIcon("theme:countries/ai.svg"), "ai"); + countryEdit->addItem(QIcon("theme:countries/al.svg"), "al"); + countryEdit->addItem(QIcon("theme:countries/am.svg"), "am"); + countryEdit->addItem(QIcon("theme:countries/ao.svg"), "ao"); + countryEdit->addItem(QIcon("theme:countries/aq.svg"), "aq"); + countryEdit->addItem(QIcon("theme:countries/ar.svg"), "ar"); + countryEdit->addItem(QIcon("theme:countries/as.svg"), "as"); + countryEdit->addItem(QIcon("theme:countries/at.svg"), "at"); + countryEdit->addItem(QIcon("theme:countries/au.svg"), "au"); + countryEdit->addItem(QIcon("theme:countries/aw.svg"), "aw"); + countryEdit->addItem(QIcon("theme:countries/ax.svg"), "ax"); + countryEdit->addItem(QIcon("theme:countries/az.svg"), "az"); + countryEdit->addItem(QIcon("theme:countries/ba.svg"), "ba"); + countryEdit->addItem(QIcon("theme:countries/bb.svg"), "bb"); + countryEdit->addItem(QIcon("theme:countries/bd.svg"), "bd"); + countryEdit->addItem(QIcon("theme:countries/be.svg"), "be"); + countryEdit->addItem(QIcon("theme:countries/bf.svg"), "bf"); + countryEdit->addItem(QIcon("theme:countries/bg.svg"), "bg"); + countryEdit->addItem(QIcon("theme:countries/bh.svg"), "bh"); + countryEdit->addItem(QIcon("theme:countries/bi.svg"), "bi"); + countryEdit->addItem(QIcon("theme:countries/bj.svg"), "bj"); + countryEdit->addItem(QIcon("theme:countries/bl.svg"), "bl"); + countryEdit->addItem(QIcon("theme:countries/bm.svg"), "bm"); + countryEdit->addItem(QIcon("theme:countries/bn.svg"), "bn"); + countryEdit->addItem(QIcon("theme:countries/bo.svg"), "bo"); + countryEdit->addItem(QIcon("theme:countries/bq.svg"), "bq"); + countryEdit->addItem(QIcon("theme:countries/br.svg"), "br"); + countryEdit->addItem(QIcon("theme:countries/bs.svg"), "bs"); + countryEdit->addItem(QIcon("theme:countries/bt.svg"), "bt"); + countryEdit->addItem(QIcon("theme:countries/bv.svg"), "bv"); + countryEdit->addItem(QIcon("theme:countries/bw.svg"), "bw"); + countryEdit->addItem(QIcon("theme:countries/by.svg"), "by"); + countryEdit->addItem(QIcon("theme:countries/bz.svg"), "bz"); + countryEdit->addItem(QIcon("theme:countries/ca.svg"), "ca"); + countryEdit->addItem(QIcon("theme:countries/cc.svg"), "cc"); + countryEdit->addItem(QIcon("theme:countries/cd.svg"), "cd"); + countryEdit->addItem(QIcon("theme:countries/cf.svg"), "cf"); + countryEdit->addItem(QIcon("theme:countries/cg.svg"), "cg"); + countryEdit->addItem(QIcon("theme:countries/ch.svg"), "ch"); + countryEdit->addItem(QIcon("theme:countries/ci.svg"), "ci"); + countryEdit->addItem(QIcon("theme:countries/ck.svg"), "ck"); + countryEdit->addItem(QIcon("theme:countries/cl.svg"), "cl"); + countryEdit->addItem(QIcon("theme:countries/cm.svg"), "cm"); + countryEdit->addItem(QIcon("theme:countries/cn.svg"), "cn"); + countryEdit->addItem(QIcon("theme:countries/co.svg"), "co"); + countryEdit->addItem(QIcon("theme:countries/cr.svg"), "cr"); + countryEdit->addItem(QIcon("theme:countries/cu.svg"), "cu"); + countryEdit->addItem(QIcon("theme:countries/cv.svg"), "cv"); + countryEdit->addItem(QIcon("theme:countries/cw.svg"), "cw"); + countryEdit->addItem(QIcon("theme:countries/cx.svg"), "cx"); + countryEdit->addItem(QIcon("theme:countries/cy.svg"), "cy"); + countryEdit->addItem(QIcon("theme:countries/cz.svg"), "cz"); + countryEdit->addItem(QIcon("theme:countries/de.svg"), "de"); + countryEdit->addItem(QIcon("theme:countries/dj.svg"), "dj"); + countryEdit->addItem(QIcon("theme:countries/dk.svg"), "dk"); + countryEdit->addItem(QIcon("theme:countries/dm.svg"), "dm"); + countryEdit->addItem(QIcon("theme:countries/do.svg"), "do"); + countryEdit->addItem(QIcon("theme:countries/dz.svg"), "dz"); + countryEdit->addItem(QIcon("theme:countries/ec.svg"), "ec"); + countryEdit->addItem(QIcon("theme:countries/ee.svg"), "ee"); + countryEdit->addItem(QIcon("theme:countries/eg.svg"), "eg"); + countryEdit->addItem(QIcon("theme:countries/eh.svg"), "eh"); + countryEdit->addItem(QIcon("theme:countries/er.svg"), "er"); + countryEdit->addItem(QIcon("theme:countries/es.svg"), "es"); + countryEdit->addItem(QIcon("theme:countries/et.svg"), "et"); + countryEdit->addItem(QIcon("theme:countries/fi.svg"), "fi"); + countryEdit->addItem(QIcon("theme:countries/fj.svg"), "fj"); + countryEdit->addItem(QIcon("theme:countries/fk.svg"), "fk"); + countryEdit->addItem(QIcon("theme:countries/fm.svg"), "fm"); + countryEdit->addItem(QIcon("theme:countries/fo.svg"), "fo"); + countryEdit->addItem(QIcon("theme:countries/fr.svg"), "fr"); + countryEdit->addItem(QIcon("theme:countries/ga.svg"), "ga"); + countryEdit->addItem(QIcon("theme:countries/gb.svg"), "gb"); + countryEdit->addItem(QIcon("theme:countries/gd.svg"), "gd"); + countryEdit->addItem(QIcon("theme:countries/ge.svg"), "ge"); + countryEdit->addItem(QIcon("theme:countries/gf.svg"), "gf"); + countryEdit->addItem(QIcon("theme:countries/gg.svg"), "gg"); + countryEdit->addItem(QIcon("theme:countries/gh.svg"), "gh"); + countryEdit->addItem(QIcon("theme:countries/gi.svg"), "gi"); + countryEdit->addItem(QIcon("theme:countries/gl.svg"), "gl"); + countryEdit->addItem(QIcon("theme:countries/gm.svg"), "gm"); + countryEdit->addItem(QIcon("theme:countries/gn.svg"), "gn"); + countryEdit->addItem(QIcon("theme:countries/gp.svg"), "gp"); + countryEdit->addItem(QIcon("theme:countries/gq.svg"), "gq"); + countryEdit->addItem(QIcon("theme:countries/gr.svg"), "gr"); + countryEdit->addItem(QIcon("theme:countries/gs.svg"), "gs"); + countryEdit->addItem(QIcon("theme:countries/gt.svg"), "gt"); + countryEdit->addItem(QIcon("theme:countries/gu.svg"), "gu"); + countryEdit->addItem(QIcon("theme:countries/gw.svg"), "gw"); + countryEdit->addItem(QIcon("theme:countries/gy.svg"), "gy"); + countryEdit->addItem(QIcon("theme:countries/hk.svg"), "hk"); + countryEdit->addItem(QIcon("theme:countries/hm.svg"), "hm"); + countryEdit->addItem(QIcon("theme:countries/hn.svg"), "hn"); + countryEdit->addItem(QIcon("theme:countries/hr.svg"), "hr"); + countryEdit->addItem(QIcon("theme:countries/ht.svg"), "ht"); + countryEdit->addItem(QIcon("theme:countries/hu.svg"), "hu"); + countryEdit->addItem(QIcon("theme:countries/id.svg"), "id"); + countryEdit->addItem(QIcon("theme:countries/ie.svg"), "ie"); + countryEdit->addItem(QIcon("theme:countries/il.svg"), "il"); + countryEdit->addItem(QIcon("theme:countries/im.svg"), "im"); + countryEdit->addItem(QIcon("theme:countries/in.svg"), "in"); + countryEdit->addItem(QIcon("theme:countries/io.svg"), "io"); + countryEdit->addItem(QIcon("theme:countries/iq.svg"), "iq"); + countryEdit->addItem(QIcon("theme:countries/ir.svg"), "ir"); + countryEdit->addItem(QIcon("theme:countries/is.svg"), "is"); + countryEdit->addItem(QIcon("theme:countries/it.svg"), "it"); + countryEdit->addItem(QIcon("theme:countries/je.svg"), "je"); + countryEdit->addItem(QIcon("theme:countries/jm.svg"), "jm"); + countryEdit->addItem(QIcon("theme:countries/jo.svg"), "jo"); + countryEdit->addItem(QIcon("theme:countries/jp.svg"), "jp"); + countryEdit->addItem(QIcon("theme:countries/ke.svg"), "ke"); + countryEdit->addItem(QIcon("theme:countries/kg.svg"), "kg"); + countryEdit->addItem(QIcon("theme:countries/kh.svg"), "kh"); + countryEdit->addItem(QIcon("theme:countries/ki.svg"), "ki"); + countryEdit->addItem(QIcon("theme:countries/km.svg"), "km"); + countryEdit->addItem(QIcon("theme:countries/kn.svg"), "kn"); + countryEdit->addItem(QIcon("theme:countries/kp.svg"), "kp"); + countryEdit->addItem(QIcon("theme:countries/kr.svg"), "kr"); + countryEdit->addItem(QIcon("theme:countries/kw.svg"), "kw"); + countryEdit->addItem(QIcon("theme:countries/ky.svg"), "ky"); + countryEdit->addItem(QIcon("theme:countries/kz.svg"), "kz"); + countryEdit->addItem(QIcon("theme:countries/la.svg"), "la"); + countryEdit->addItem(QIcon("theme:countries/lb.svg"), "lb"); + countryEdit->addItem(QIcon("theme:countries/lc.svg"), "lc"); + countryEdit->addItem(QIcon("theme:countries/li.svg"), "li"); + countryEdit->addItem(QIcon("theme:countries/lk.svg"), "lk"); + countryEdit->addItem(QIcon("theme:countries/lr.svg"), "lr"); + countryEdit->addItem(QIcon("theme:countries/ls.svg"), "ls"); + countryEdit->addItem(QIcon("theme:countries/lt.svg"), "lt"); + countryEdit->addItem(QIcon("theme:countries/lu.svg"), "lu"); + countryEdit->addItem(QIcon("theme:countries/lv.svg"), "lv"); + countryEdit->addItem(QIcon("theme:countries/ly.svg"), "ly"); + countryEdit->addItem(QIcon("theme:countries/ma.svg"), "ma"); + countryEdit->addItem(QIcon("theme:countries/mc.svg"), "mc"); + countryEdit->addItem(QIcon("theme:countries/md.svg"), "md"); + countryEdit->addItem(QIcon("theme:countries/me.svg"), "me"); + countryEdit->addItem(QIcon("theme:countries/mf.svg"), "mf"); + countryEdit->addItem(QIcon("theme:countries/mg.svg"), "mg"); + countryEdit->addItem(QIcon("theme:countries/mh.svg"), "mh"); + countryEdit->addItem(QIcon("theme:countries/mk.svg"), "mk"); + countryEdit->addItem(QIcon("theme:countries/ml.svg"), "ml"); + countryEdit->addItem(QIcon("theme:countries/mm.svg"), "mm"); + countryEdit->addItem(QIcon("theme:countries/mn.svg"), "mn"); + countryEdit->addItem(QIcon("theme:countries/mo.svg"), "mo"); + countryEdit->addItem(QIcon("theme:countries/mp.svg"), "mp"); + countryEdit->addItem(QIcon("theme:countries/mq.svg"), "mq"); + countryEdit->addItem(QIcon("theme:countries/mr.svg"), "mr"); + countryEdit->addItem(QIcon("theme:countries/ms.svg"), "ms"); + countryEdit->addItem(QIcon("theme:countries/mt.svg"), "mt"); + countryEdit->addItem(QIcon("theme:countries/mu.svg"), "mu"); + countryEdit->addItem(QIcon("theme:countries/mv.svg"), "mv"); + countryEdit->addItem(QIcon("theme:countries/mw.svg"), "mw"); + countryEdit->addItem(QIcon("theme:countries/mx.svg"), "mx"); + countryEdit->addItem(QIcon("theme:countries/my.svg"), "my"); + countryEdit->addItem(QIcon("theme:countries/mz.svg"), "mz"); + countryEdit->addItem(QIcon("theme:countries/na.svg"), "na"); + countryEdit->addItem(QIcon("theme:countries/nc.svg"), "nc"); + countryEdit->addItem(QIcon("theme:countries/ne.svg"), "ne"); + countryEdit->addItem(QIcon("theme:countries/nf.svg"), "nf"); + countryEdit->addItem(QIcon("theme:countries/ng.svg"), "ng"); + countryEdit->addItem(QIcon("theme:countries/ni.svg"), "ni"); + countryEdit->addItem(QIcon("theme:countries/nl.svg"), "nl"); + countryEdit->addItem(QIcon("theme:countries/no.svg"), "no"); + countryEdit->addItem(QIcon("theme:countries/np.svg"), "np"); + countryEdit->addItem(QIcon("theme:countries/nr.svg"), "nr"); + countryEdit->addItem(QIcon("theme:countries/nu.svg"), "nu"); + countryEdit->addItem(QIcon("theme:countries/nz.svg"), "nz"); + countryEdit->addItem(QIcon("theme:countries/om.svg"), "om"); + countryEdit->addItem(QIcon("theme:countries/pa.svg"), "pa"); + countryEdit->addItem(QIcon("theme:countries/pe.svg"), "pe"); + countryEdit->addItem(QIcon("theme:countries/pf.svg"), "pf"); + countryEdit->addItem(QIcon("theme:countries/pg.svg"), "pg"); + countryEdit->addItem(QIcon("theme:countries/ph.svg"), "ph"); + countryEdit->addItem(QIcon("theme:countries/pk.svg"), "pk"); + countryEdit->addItem(QIcon("theme:countries/pl.svg"), "pl"); + countryEdit->addItem(QIcon("theme:countries/pm.svg"), "pm"); + countryEdit->addItem(QIcon("theme:countries/pn.svg"), "pn"); + countryEdit->addItem(QIcon("theme:countries/pr.svg"), "pr"); + countryEdit->addItem(QIcon("theme:countries/ps.svg"), "ps"); + countryEdit->addItem(QIcon("theme:countries/pt.svg"), "pt"); + countryEdit->addItem(QIcon("theme:countries/pw.svg"), "pw"); + countryEdit->addItem(QIcon("theme:countries/py.svg"), "py"); + countryEdit->addItem(QIcon("theme:countries/qa.svg"), "qa"); + countryEdit->addItem(QIcon("theme:countries/re.svg"), "re"); + countryEdit->addItem(QIcon("theme:countries/ro.svg"), "ro"); + countryEdit->addItem(QIcon("theme:countries/rs.svg"), "rs"); + countryEdit->addItem(QIcon("theme:countries/ru.svg"), "ru"); + countryEdit->addItem(QIcon("theme:countries/rw.svg"), "rw"); + countryEdit->addItem(QIcon("theme:countries/sa.svg"), "sa"); + countryEdit->addItem(QIcon("theme:countries/sb.svg"), "sb"); + countryEdit->addItem(QIcon("theme:countries/sc.svg"), "sc"); + countryEdit->addItem(QIcon("theme:countries/sd.svg"), "sd"); + countryEdit->addItem(QIcon("theme:countries/se.svg"), "se"); + countryEdit->addItem(QIcon("theme:countries/sg.svg"), "sg"); + countryEdit->addItem(QIcon("theme:countries/sh.svg"), "sh"); + countryEdit->addItem(QIcon("theme:countries/si.svg"), "si"); + countryEdit->addItem(QIcon("theme:countries/sj.svg"), "sj"); + countryEdit->addItem(QIcon("theme:countries/sk.svg"), "sk"); + countryEdit->addItem(QIcon("theme:countries/sl.svg"), "sl"); + countryEdit->addItem(QIcon("theme:countries/sm.svg"), "sm"); + countryEdit->addItem(QIcon("theme:countries/sn.svg"), "sn"); + countryEdit->addItem(QIcon("theme:countries/so.svg"), "so"); + countryEdit->addItem(QIcon("theme:countries/sr.svg"), "sr"); + countryEdit->addItem(QIcon("theme:countries/ss.svg"), "ss"); + countryEdit->addItem(QIcon("theme:countries/st.svg"), "st"); + countryEdit->addItem(QIcon("theme:countries/sv.svg"), "sv"); + countryEdit->addItem(QIcon("theme:countries/sx.svg"), "sx"); + countryEdit->addItem(QIcon("theme:countries/sy.svg"), "sy"); + countryEdit->addItem(QIcon("theme:countries/sz.svg"), "sz"); + countryEdit->addItem(QIcon("theme:countries/tc.svg"), "tc"); + countryEdit->addItem(QIcon("theme:countries/td.svg"), "td"); + countryEdit->addItem(QIcon("theme:countries/tf.svg"), "tf"); + countryEdit->addItem(QIcon("theme:countries/tg.svg"), "tg"); + countryEdit->addItem(QIcon("theme:countries/th.svg"), "th"); + countryEdit->addItem(QIcon("theme:countries/tj.svg"), "tj"); + countryEdit->addItem(QIcon("theme:countries/tk.svg"), "tk"); + countryEdit->addItem(QIcon("theme:countries/tl.svg"), "tl"); + countryEdit->addItem(QIcon("theme:countries/tm.svg"), "tm"); + countryEdit->addItem(QIcon("theme:countries/tn.svg"), "tn"); + countryEdit->addItem(QIcon("theme:countries/to.svg"), "to"); + countryEdit->addItem(QIcon("theme:countries/tr.svg"), "tr"); + countryEdit->addItem(QIcon("theme:countries/tt.svg"), "tt"); + countryEdit->addItem(QIcon("theme:countries/tv.svg"), "tv"); + countryEdit->addItem(QIcon("theme:countries/tw.svg"), "tw"); + countryEdit->addItem(QIcon("theme:countries/tz.svg"), "tz"); + countryEdit->addItem(QIcon("theme:countries/ua.svg"), "ua"); + countryEdit->addItem(QIcon("theme:countries/ug.svg"), "ug"); + countryEdit->addItem(QIcon("theme:countries/um.svg"), "um"); + countryEdit->addItem(QIcon("theme:countries/us.svg"), "us"); + countryEdit->addItem(QIcon("theme:countries/uy.svg"), "uy"); + countryEdit->addItem(QIcon("theme:countries/uz.svg"), "uz"); + countryEdit->addItem(QIcon("theme:countries/va.svg"), "va"); + countryEdit->addItem(QIcon("theme:countries/vc.svg"), "vc"); + countryEdit->addItem(QIcon("theme:countries/ve.svg"), "ve"); + countryEdit->addItem(QIcon("theme:countries/vg.svg"), "vg"); + countryEdit->addItem(QIcon("theme:countries/vi.svg"), "vi"); + countryEdit->addItem(QIcon("theme:countries/vn.svg"), "vn"); + countryEdit->addItem(QIcon("theme:countries/vu.svg"), "vu"); + countryEdit->addItem(QIcon("theme:countries/wf.svg"), "wf"); + countryEdit->addItem(QIcon("theme:countries/ws.svg"), "ws"); + countryEdit->addItem(QIcon("theme:countries/ye.svg"), "ye"); + countryEdit->addItem(QIcon("theme:countries/yt.svg"), "yt"); + countryEdit->addItem(QIcon("theme:countries/za.svg"), "za"); + countryEdit->addItem(QIcon("theme:countries/zm.svg"), "zm"); + countryEdit->addItem(QIcon("theme:countries/zw.svg"), "zw"); countryEdit->setCurrentIndex(0); QStringList countries = settingsCache->getCountries(); foreach(QString c, countries) - countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c); + countryEdit->addItem(QPixmap("theme:countries/" + c.toLower() + ".svg"), c); realnameLabel = new QLabel(tr("Real name:")); realnameEdit = new QLineEdit(); diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index da47aa8d..5b18f7ed 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -26,6 +26,7 @@ #include "dlg_settings.h" #include "main.h" #include "settingscache.h" +#include "thememanager.h" #include "priceupdater.h" #include "soundengine.h" #include "sequenceEdit/shortcutstab.h" @@ -255,67 +256,23 @@ void GeneralSettingsPage::setEnabledStatus(bool status) AppearanceSettingsPage::AppearanceSettingsPage() { - QIcon deleteIcon(":/resources/icon_delete.svg"); - - handBgEdit = new QLineEdit(settingsCache->getHandBgPath()); - handBgEdit->setReadOnly(true); - QPushButton *handBgClearButton = new QPushButton(deleteIcon, QString()); - connect(handBgClearButton, SIGNAL(clicked()), this, SLOT(handBgClearButtonClicked())); - QPushButton *handBgButton = new QPushButton("..."); - connect(handBgButton, SIGNAL(clicked()), this, SLOT(handBgButtonClicked())); - - stackBgEdit = new QLineEdit(settingsCache->getStackBgPath()); - stackBgEdit->setReadOnly(true); - QPushButton *stackBgClearButton = new QPushButton(deleteIcon, QString()); - connect(stackBgClearButton, SIGNAL(clicked()), this, SLOT(stackBgClearButtonClicked())); - QPushButton *stackBgButton = new QPushButton("..."); - connect(stackBgButton, SIGNAL(clicked()), this, SLOT(stackBgButtonClicked())); + QString themeName = settingsCache->getThemeName(); - tableBgEdit = new QLineEdit(settingsCache->getTableBgPath()); - tableBgEdit->setReadOnly(true); - QPushButton *tableBgClearButton = new QPushButton(deleteIcon, QString()); - connect(tableBgClearButton, SIGNAL(clicked()), this, SLOT(tableBgClearButtonClicked())); - QPushButton *tableBgButton = new QPushButton("..."); - connect(tableBgButton, SIGNAL(clicked()), this, SLOT(tableBgButtonClicked())); - - playerAreaBgEdit = new QLineEdit(settingsCache->getPlayerBgPath()); - playerAreaBgEdit->setReadOnly(true); - QPushButton *playerAreaBgClearButton = new QPushButton(deleteIcon, QString()); - connect(playerAreaBgClearButton, SIGNAL(clicked()), this, SLOT(playerAreaBgClearButtonClicked())); - QPushButton *playerAreaBgButton = new QPushButton("..."); - connect(playerAreaBgButton, SIGNAL(clicked()), this, SLOT(playerAreaBgButtonClicked())); - - cardBackPicturePathEdit = new QLineEdit(settingsCache->getCardBackPicturePath()); - cardBackPicturePathEdit->setReadOnly(true); - QPushButton *cardBackPicturePathClearButton = new QPushButton(deleteIcon, QString()); - connect(cardBackPicturePathClearButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathClearButtonClicked())); - QPushButton *cardBackPicturePathButton = new QPushButton("..."); - connect(cardBackPicturePathButton, SIGNAL(clicked()), this, SLOT(cardBackPicturePathButtonClicked())); - - QGridLayout *zoneBgGrid = new QGridLayout; - zoneBgGrid->addWidget(&handBgLabel, 0, 0); - zoneBgGrid->addWidget(handBgEdit, 0, 1); - zoneBgGrid->addWidget(handBgClearButton, 0, 2); - zoneBgGrid->addWidget(handBgButton, 0, 3); - zoneBgGrid->addWidget(&stackBgLabel, 1, 0); - zoneBgGrid->addWidget(stackBgEdit, 1, 1); - zoneBgGrid->addWidget(stackBgClearButton, 1, 2); - zoneBgGrid->addWidget(stackBgButton, 1, 3); - zoneBgGrid->addWidget(&tableBgLabel, 2, 0); - zoneBgGrid->addWidget(tableBgEdit, 2, 1); - zoneBgGrid->addWidget(tableBgClearButton, 2, 2); - zoneBgGrid->addWidget(tableBgButton, 2, 3); - zoneBgGrid->addWidget(&playerAreaBgLabel, 3, 0); - zoneBgGrid->addWidget(playerAreaBgEdit, 3, 1); - zoneBgGrid->addWidget(playerAreaBgClearButton, 3, 2); - zoneBgGrid->addWidget(playerAreaBgButton, 3, 3); - zoneBgGrid->addWidget(&cardBackPicturePathLabel, 4, 0); - zoneBgGrid->addWidget(cardBackPicturePathEdit, 4, 1); - zoneBgGrid->addWidget(cardBackPicturePathClearButton, 4, 2); - zoneBgGrid->addWidget(cardBackPicturePathButton, 4, 3); + QStringList themeDirs = themeManager->getAvailableThemes().keys(); + for (int i = 0; i < themeDirs.size(); i++) { + themeBox.addItem(themeDirs[i]); + if (themeDirs[i] == themeName) + themeBox.setCurrentIndex(i); + } - zoneBgGroupBox = new QGroupBox; - zoneBgGroupBox->setLayout(zoneBgGrid); + connect(&themeBox, SIGNAL(currentIndexChanged(int)), this, SLOT(themeBoxChanged(int))); + + QGridLayout *themeGrid = new QGridLayout; + themeGrid->addWidget(&themeLabel, 0, 0); + themeGrid->addWidget(&themeBox, 0, 1); + + themeGroupBox = new QGroupBox; + themeGroupBox->setLayout(themeGrid); displayCardNamesCheckBox.setChecked(settingsCache->getDisplayCardNames()); connect(&displayCardNamesCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setDisplayCardNames(int))); @@ -360,7 +317,7 @@ AppearanceSettingsPage::AppearanceSettingsPage() tableGroupBox->setLayout(tableGrid); QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addWidget(zoneBgGroupBox); + mainLayout->addWidget(themeGroupBox); mainLayout->addWidget(cardsGroupBox); mainLayout->addWidget(handGroupBox); mainLayout->addWidget(tableGroupBox); @@ -368,14 +325,17 @@ AppearanceSettingsPage::AppearanceSettingsPage() setLayout(mainLayout); } +void AppearanceSettingsPage::themeBoxChanged(int index) +{ + QStringList themeDirs = themeManager->getAvailableThemes().keys(); + if(index >= 0 && index < themeDirs.count()) + settingsCache->setThemeName(themeDirs.at(index)); +} + void AppearanceSettingsPage::retranslateUi() { - zoneBgGroupBox->setTitle(tr("Zone background pictures")); - handBgLabel.setText(tr("Hand background:")); - stackBgLabel.setText(tr("Stack background:")); - tableBgLabel.setText(tr("Table background:")); - playerAreaBgLabel.setText(tr("Player info background:")); - cardBackPicturePathLabel.setText(tr("Card back:")); + themeGroupBox->setTitle(tr("Theme settings")); + themeLabel.setText(tr("Current theme:")); cardsGroupBox->setTitle(tr("Card rendering")); displayCardNamesCheckBox.setText(tr("Display card names on cards having a picture")); @@ -390,86 +350,6 @@ void AppearanceSettingsPage::retranslateUi() minPlayersForMultiColumnLayoutLabel.setText(tr("Minimum player count for multi-column layout:")); } -void AppearanceSettingsPage::handBgClearButtonClicked() -{ - handBgEdit->setText(QString()); - settingsCache->setHandBgPath(QString()); -} - -void AppearanceSettingsPage::handBgButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - - handBgEdit->setText(path); - settingsCache->setHandBgPath(path); -} - -void AppearanceSettingsPage::stackBgClearButtonClicked() -{ - stackBgEdit->setText(QString()); - settingsCache->setStackBgPath(QString()); -} - -void AppearanceSettingsPage::stackBgButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - - stackBgEdit->setText(path); - settingsCache->setStackBgPath(path); -} - -void AppearanceSettingsPage::tableBgClearButtonClicked() -{ - tableBgEdit->setText(QString()); - settingsCache->setTableBgPath(QString()); -} - -void AppearanceSettingsPage::tableBgButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - - tableBgEdit->setText(path); - settingsCache->setTableBgPath(path); -} - -void AppearanceSettingsPage::playerAreaBgClearButtonClicked() -{ - playerAreaBgEdit->setText(QString()); - settingsCache->setPlayerBgPath(QString()); -} - -void AppearanceSettingsPage::playerAreaBgButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - - playerAreaBgEdit->setText(path); - settingsCache->setPlayerBgPath(path); -} - -void AppearanceSettingsPage::cardBackPicturePathClearButtonClicked() -{ - cardBackPicturePathEdit->setText(QString()); - settingsCache->setCardBackPicturePath(QString()); -} - -void AppearanceSettingsPage::cardBackPicturePathButtonClicked() -{ - QString path = QFileDialog::getOpenFileName(this, tr("Choose path")); - if (path.isEmpty()) - return; - - cardBackPicturePathEdit->setText(path); - settingsCache->setCardBackPicturePath(path); -} - UserInterfaceSettingsPage::UserInterfaceSettingsPage() { notificationsEnabledCheckBox.setChecked(settingsCache->getNotificationsEnabled()); @@ -640,10 +520,10 @@ MessagesSettingsPage::MessagesSettingsPage() messageList->addItem(settings.value(QString("msg%1").arg(i)).toString()); aAdd = new QAction(this); - aAdd->setIcon(QIcon(":/resources/increment.svg")); + aAdd->setIcon(QIcon("theme:icons/increment.svg")); connect(aAdd, SIGNAL(triggered()), this, SLOT(actAdd())); aRemove = new QAction(this); - aRemove->setIcon(QIcon(":/resources/decrement.svg")); + aRemove->setIcon(QIcon("theme:icons/decrement.svg")); connect(aRemove, SIGNAL(triggered()), this, SLOT(actRemove())); QToolBar *messageToolBar = new QToolBar; @@ -755,7 +635,7 @@ void MessagesSettingsPage::retranslateUi() SoundSettingsPage::SoundSettingsPage() { - QIcon deleteIcon(":/resources/icon_delete.svg"); + QIcon deleteIcon("theme:icons/delete.svg"); soundEnabledCheckBox.setChecked(settingsCache->getSoundEnabled()); connect(&soundEnabledCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setSoundEnabled(int))); @@ -892,37 +772,37 @@ void DlgSettings::createIcons() generalButton = new QListWidgetItem(contentsWidget); generalButton->setTextAlignment(Qt::AlignHCenter); generalButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - generalButton->setIcon(QIcon(":/resources/icon_config_general.svg")); + generalButton->setIcon(QIcon("theme:config/general.svg")); appearanceButton = new QListWidgetItem(contentsWidget); appearanceButton->setTextAlignment(Qt::AlignHCenter); appearanceButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - appearanceButton->setIcon(QIcon(":/resources/icon_config_appearance.svg")); + appearanceButton->setIcon(QIcon("theme:config/appearance.svg")); userInterfaceButton = new QListWidgetItem(contentsWidget); userInterfaceButton->setTextAlignment(Qt::AlignHCenter); userInterfaceButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - userInterfaceButton->setIcon(QIcon(":/resources/icon_config_interface.svg")); + userInterfaceButton->setIcon(QIcon("theme:config/interface.svg")); deckEditorButton = new QListWidgetItem(contentsWidget); deckEditorButton->setTextAlignment(Qt::AlignHCenter); deckEditorButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - deckEditorButton->setIcon(QIcon(":/resources/icon_config_deckeditor.svg")); + deckEditorButton->setIcon(QIcon("theme:config/deckeditor.svg")); messagesButton = new QListWidgetItem(contentsWidget); messagesButton->setTextAlignment(Qt::AlignHCenter); messagesButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - messagesButton->setIcon(QIcon(":/resources/icon_config_messages.svg")); + messagesButton->setIcon(QIcon("theme:config/messages.svg")); soundButton = new QListWidgetItem(contentsWidget); soundButton->setTextAlignment(Qt::AlignHCenter); soundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - soundButton->setIcon(QIcon(":/resources/icon_config_sound.svg")); + soundButton->setIcon(QIcon("theme:config/sound.svg")); shortcutsButton = new QListWidgetItem(contentsWidget); shortcutsButton->setTextAlignment(Qt::AlignHCenter); shortcutsButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - shortcutsButton->setIcon(QIcon(":/resources/icon_config_shorcuts.svg")); + shortcutsButton->setIcon(QIcon("theme:config/shorcuts.svg")); connect(contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem *))); } diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index 208c9b63..2bceda71 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -75,40 +75,17 @@ private: class AppearanceSettingsPage : public AbstractSettingsPage { Q_OBJECT private slots: - void handBgClearButtonClicked(); - void handBgButtonClicked(); - void stackBgClearButtonClicked(); - void stackBgButtonClicked(); - void tableBgClearButtonClicked(); - void tableBgButtonClicked(); - void playerAreaBgClearButtonClicked(); - void playerAreaBgButtonClicked(); - void cardBackPicturePathClearButtonClicked(); - void cardBackPicturePathButtonClicked(); -signals: - void handBgChanged(const QString &path); - void stackBgChanged(const QString &path); - void tableBgChanged(const QString &path); - void playerAreaBgChanged(const QString &path); - void cardBackPicturePathChanged(const QString &path); + void themeBoxChanged(int index); private: - QLabel handBgLabel; - QLabel stackBgLabel; - QLabel tableBgLabel; - QLabel playerAreaBgLabel; - QLabel cardBackPicturePathLabel; + QLabel themeLabel; + QComboBox themeBox; QLabel minPlayersForMultiColumnLayoutLabel; - QLineEdit *handBgEdit; - QLineEdit *stackBgEdit; - QLineEdit *tableBgEdit; - QLineEdit *playerAreaBgEdit; - QLineEdit *cardBackPicturePathEdit; QCheckBox displayCardNamesCheckBox; QCheckBox cardScalingCheckBox; QCheckBox horizontalHandCheckBox; QCheckBox leftJustifiedHandCheckBox; QCheckBox invertVerticalCoordinateCheckBox; - QGroupBox *zoneBgGroupBox; + QGroupBox *themeGroupBox; QGroupBox *cardsGroupBox; QGroupBox *handGroupBox; QGroupBox *tableGroupBox; diff --git a/cockatrice/src/filterbuilder.cpp b/cockatrice/src/filterbuilder.cpp index b6e33ff6..a07e40c5 100644 --- a/cockatrice/src/filterbuilder.cpp +++ b/cockatrice/src/filterbuilder.cpp @@ -26,7 +26,7 @@ FilterBuilder::FilterBuilder(QWidget *parent) QVariant(i) ); - QPushButton *ok = new QPushButton(QIcon(":/resources/increment.svg"), QString()); + QPushButton *ok = new QPushButton(QIcon("theme:icons/increment.svg"), QString()); ok->setObjectName("ok"); ok->setMaximumSize(20, 20); diff --git a/cockatrice/src/gameselector.cpp b/cockatrice/src/gameselector.cpp index 06b46c3e..6c58b842 100644 --- a/cockatrice/src/gameselector.cpp +++ b/cockatrice/src/gameselector.cpp @@ -60,10 +60,10 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup gameListView->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); #endif filterButton = new QPushButton; - filterButton->setIcon(QIcon(":/resources/icon_search_black.svg")); + filterButton->setIcon(QIcon("theme:icons/search.svg")); connect(filterButton, SIGNAL(clicked()), this, SLOT(actSetFilter())); clearFilterButton = new QPushButton; - clearFilterButton->setIcon(QIcon(":/resources/icon_clearsearch.svg")); + clearFilterButton->setIcon(QIcon("theme:icons/clearsearch.svg")); clearFilterButton->setEnabled(true); connect(clearFilterButton, SIGNAL(clicked()), this, SLOT(actClearFilter())); diff --git a/cockatrice/src/handcounter.cpp b/cockatrice/src/handcounter.cpp index 4aa33d69..3b7ba1d9 100644 --- a/cockatrice/src/handcounter.cpp +++ b/cockatrice/src/handcounter.cpp @@ -36,7 +36,7 @@ void HandCounter::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op #else if (!QPixmapCache::find("handCounter" + QString::number(translatedSize.width()), cachedPixmap)) { #endif - QSvgRenderer svg(QString(":/resources/hand.svg")); + QSvgRenderer svg(QString("theme:hand.svg")); cachedPixmap = QPixmap(translatedSize); cachedPixmap.fill(Qt::transparent); QPainter painter(&cachedPixmap); diff --git a/cockatrice/src/handzone.cpp b/cockatrice/src/handzone.cpp index 80e1194c..0db67f13 100644 --- a/cockatrice/src/handzone.cpp +++ b/cockatrice/src/handzone.cpp @@ -1,6 +1,7 @@ #include #include "handzone.h" #include "settingscache.h" +#include "thememanager.h" #include "player.h" #include "carddragitem.h" #include "carditem.h" @@ -10,16 +11,13 @@ HandZone::HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent) : SelectZone(_p, "hand", false, false, _contentsKnown, parent), zoneHeight(_zoneHeight) { - connect(settingsCache, SIGNAL(handBgPathChanged()), this, SLOT(updateBgPixmap())); - updateBgPixmap(); + connect(themeManager, SIGNAL(themeChanged()), this, SLOT(updateBg())); + updateBg(); setCacheMode(DeviceCoordinateCache); } -void HandZone::updateBgPixmap() +void HandZone::updateBg() { - QString bgPath = settingsCache->getHandBgPath(); - if (!bgPath.isEmpty()) - bgPixmap.load(bgPath); update(); } @@ -77,10 +75,7 @@ QRectF HandZone::boundingRect() const void HandZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - if (bgPixmap.isNull()) - painter->fillRect(boundingRect(), QColor(30, 30, 30)); - else - painter->fillRect(boundingRect(), QBrush(bgPixmap)); + painter->fillRect(boundingRect(), themeManager->getHandBgBrush()); } void HandZone::reorganizeCards() diff --git a/cockatrice/src/handzone.h b/cockatrice/src/handzone.h index 66245c50..47fb5075 100644 --- a/cockatrice/src/handzone.h +++ b/cockatrice/src/handzone.h @@ -7,9 +7,8 @@ class HandZone : public SelectZone { Q_OBJECT private: qreal width, zoneHeight; - QPixmap bgPixmap; private slots: - void updateBgPixmap(); + void updateBg(); public slots: void updateOrientation(); public: diff --git a/cockatrice/src/main.cpp b/cockatrice/src/main.cpp index 5bd07ef9..d691659a 100644 --- a/cockatrice/src/main.cpp +++ b/cockatrice/src/main.cpp @@ -40,6 +40,7 @@ #include "dlg_settings.h" #include "carddatabase.h" #include "settingscache.h" +#include "thememanager.h" #include "pixmapgenerator.h" #include "rng_sfmt.h" #include "soundengine.h" @@ -52,7 +53,7 @@ SettingsCache *settingsCache; RNG_Abstract *rng; SoundEngine *soundEngine; QSystemTrayIcon *trayIcon; - +ThemeManager *themeManager; const QString translationPrefix = "cockatrice"; #ifdef TRANSLATION_PATH @@ -147,6 +148,7 @@ int main(int argc, char *argv[]) rng = new RNG_SFMT; settingsCache = new SettingsCache; + themeManager = new ThemeManager; db = new CardDatabase; qtTranslator = new QTranslator; @@ -210,13 +212,14 @@ int main(int argc, char *argv[]) if (settingsValid()) { qDebug("main(): starting main program"); + soundEngine = new SoundEngine; qDebug("main(): SoundEngine constructor finished"); MainWindow ui; qDebug("main(): MainWindow constructor finished"); - QIcon icon(":/resources/appicon.svg"); + QIcon icon("theme:cockatrice.svg"); ui.setWindowIcon(icon); settingsCache->setClientID(generateClientID()); diff --git a/cockatrice/src/pixmapgenerator.cpp b/cockatrice/src/pixmapgenerator.cpp index 17d576c9..dd324037 100644 --- a/cockatrice/src/pixmapgenerator.cpp +++ b/cockatrice/src/pixmapgenerator.cpp @@ -16,7 +16,7 @@ QPixmap PhasePixmapGenerator::generatePixmap(int height, QString name) if (pmCache.contains(key)) return pmCache.value(key); - QSvgRenderer svg(QString(":/resources/phases/icon_phase_" + name + ".svg")); + QSvgRenderer svg(QString("theme:phases/" + name + ".svg")); QPixmap pixmap(height, height); pixmap.fill(Qt::transparent); @@ -36,13 +36,13 @@ QPixmap CounterPixmapGenerator::generatePixmap(int height, QString name, bool hi if (pmCache.contains(key)) return pmCache.value(key); - QSvgRenderer svg(QString(":/resources/counters/" + name + ".svg")); + QSvgRenderer svg(QString("theme:counters/" + name + ".svg")); if (!svg.isValid()) { name = "general"; if (highlight) name.append("_highlight"); - svg.load(QString(":/resources/counters/" + name + ".svg")); + svg.load(QString("theme:counters/" + name + ".svg")); } int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); @@ -98,7 +98,7 @@ QPixmap GenderPixmapGenerator::generatePixmap(int height, int _gender) default: genderStr = "unknown"; }; - QSvgRenderer svg(QString(":/resources/genders/" + genderStr + ".svg")); + QSvgRenderer svg(QString("theme:genders/" + genderStr + ".svg")); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); QPixmap pixmap(width, height); pixmap.fill(Qt::transparent); @@ -119,7 +119,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr if (pmCache.contains(key)) return pmCache.value(key); - QSvgRenderer svg(QString(":/resources/countries/" + countryCode.toLower() + ".svg")); + QSvgRenderer svg(QString("theme:countries/" + countryCode.toLower() + ".svg")); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); QPixmap pixmap(width, height); pixmap.fill(Qt::transparent); @@ -154,7 +154,7 @@ QPixmap UserLevelPixmapGenerator::generatePixmap(int height, UserLevelFlags user if (isBuddy) levelString.append("_buddy"); - QSvgRenderer svg(QString(":/resources/userlevels/" + levelString + ".svg")); + QSvgRenderer svg(QString("theme:userlevels/" + levelString + ".svg")); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); QPixmap pixmap(width, height); pixmap.fill(Qt::transparent); @@ -175,7 +175,7 @@ QPixmap LockPixmapGenerator::generatePixmap(int height) if (pmCache.contains(key)) return pmCache.value(key); - QSvgRenderer svg(QString(":/resources/lock.svg")); + QSvgRenderer svg(QString("theme:icons/lock.svg")); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); QPixmap pixmap(width, height); pixmap.fill(Qt::transparent); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 1caeba45..e1d68aa2 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -15,6 +15,7 @@ #include "tab_game.h" #include "gamescene.h" #include "settingscache.h" +#include "thememanager.h" #include "dlg_create_token.h" #include "carddatabase.h" #include "color.h" @@ -69,25 +70,18 @@ PlayerArea::PlayerArea(QGraphicsItem *parentItem) : QObject(), QGraphicsItem(parentItem) { setCacheMode(DeviceCoordinateCache); - connect(settingsCache, SIGNAL(playerBgPathChanged()), this, SLOT(updateBgPixmap())); - updateBgPixmap(); + connect(themeManager, SIGNAL(themeChanged()), this, SLOT(updateBg())); + updateBg(); } -void PlayerArea::updateBgPixmap() +void PlayerArea::updateBg() { - QString bgPath = settingsCache->getPlayerBgPath(); - if (bgPath.isEmpty()) - bgPixmapBrush = QBrush(QColor(200, 200, 200)); - else { - qDebug() << "loading" << bgPath; - bgPixmapBrush = QBrush(QPixmap(bgPath)); - } update(); } void PlayerArea::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - painter->fillRect(bRect, bgPixmapBrush); + painter->fillRect(bRect, themeManager->getPlayerBgBrush()); } void PlayerArea::setSize(qreal width, qreal height) diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 5eb1a57f..db13d7f8 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -60,10 +60,9 @@ class PlayerArea : public QObject, public QGraphicsItem { Q_OBJECT Q_INTERFACES(QGraphicsItem) private: - QBrush bgPixmapBrush; QRectF bRect; private slots: - void updateBgPixmap(); + void updateBg(); public: enum { Type = typeOther }; int type() const { return Type; } diff --git a/cockatrice/src/playerlistwidget.cpp b/cockatrice/src/playerlistwidget.cpp index 6aac922d..1d780ce3 100644 --- a/cockatrice/src/playerlistwidget.cpp +++ b/cockatrice/src/playerlistwidget.cpp @@ -50,12 +50,12 @@ bool PlayerListTWI::operator<(const QTreeWidgetItem &other) const PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient *_client, TabGame *_game, QWidget *parent) : QTreeWidget(parent), tabSupervisor(_tabSupervisor), client(_client), game(_game), gameStarted(false) { - readyIcon = QIcon(":/resources/icon_ready_start.svg"); - notReadyIcon = QIcon(":/resources/icon_not_ready_start.svg"); - concededIcon = QIcon(":/resources/icon_conceded.svg"); - playerIcon = QIcon(":/resources/icon_player.svg"); - spectatorIcon = QIcon(":/resources/icon_spectator.svg"); - lockIcon = QIcon(":/resources/lock.svg"); + readyIcon = QIcon("theme:icons/ready_start.svg"); + notReadyIcon = QIcon("theme:icons/not_ready_start.svg"); + concededIcon = QIcon("theme:icons/conceded.svg"); + playerIcon = QIcon("theme:icons/player.svg"); + spectatorIcon = QIcon("theme:icons/spectator.svg"); + lockIcon = QIcon("theme:icons/lock.svg"); if (tabSupervisor) { itemDelegate = new PlayerListItemDelegate(this); diff --git a/cockatrice/src/remotereplaylist_treewidget.cpp b/cockatrice/src/remotereplaylist_treewidget.cpp index 5357596f..fa6a2e98 100644 --- a/cockatrice/src/remotereplaylist_treewidget.cpp +++ b/cockatrice/src/remotereplaylist_treewidget.cpp @@ -35,7 +35,7 @@ RemoteReplayList_TreeModel::RemoteReplayList_TreeModel(AbstractClient *_client, QFileIconProvider fip; dirIcon = fip.icon(QFileIconProvider::Folder); fileIcon = fip.icon(QFileIconProvider::File); - lockIcon = QIcon(":/resources/lock.svg"); + lockIcon = QIcon("theme:icons/lock.svg"); refreshTree(); } diff --git a/cockatrice/src/sequenceEdit/sequenceedit.cpp b/cockatrice/src/sequenceEdit/sequenceedit.cpp index 1056b576..f3b5d0de 100644 --- a/cockatrice/src/sequenceEdit/sequenceedit.cpp +++ b/cockatrice/src/sequenceEdit/sequenceedit.cpp @@ -25,8 +25,8 @@ SequenceEdit::SequenceEdit(QString _shorcutName, QWidget *parent) : QWidget(pare clearButton->setMaximumHeight(lineEdit->height()); defaultButton->setMaximumHeight(lineEdit->height()); - clearButton->setIcon(QIcon(":/resources/icon_clearsearch.svg")); - defaultButton->setIcon(QIcon(":/resources/icon_update.png")); + clearButton->setIcon(QIcon("theme:icons/clearsearch.svg")); + defaultButton->setIcon(QIcon("theme:icons/update.png")); clearButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); defaultButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); diff --git a/cockatrice/src/settingscache.cpp b/cockatrice/src/settingscache.cpp index a640e5f6..9a3fb54d 100644 --- a/cockatrice/src/settingscache.cpp +++ b/cockatrice/src/settingscache.cpp @@ -36,11 +36,7 @@ SettingsCache::SettingsCache() cardDatabasePath = settings->value("paths/carddatabase").toString(); tokenDatabasePath = settings->value("paths/tokendatabase").toString(); - handBgPath = settings->value("zonebg/hand").toString(); - stackBgPath = settings->value("zonebg/stack").toString(); - tableBgPath = settings->value("zonebg/table").toString(); - playerBgPath = settings->value("zonebg/playerarea").toString(); - cardBackPicturePath = settings->value("paths/cardbackpicture").toString(); + themeName = settings->value("theme/name").toString(); // we only want to reset the cache once, then its up to the user bool updateCache = settings->value("revert/pixmapCacheSize", false).toBool(); @@ -210,39 +206,11 @@ void SettingsCache::setTokenDatabasePath(const QString &_tokenDatabasePath) emit tokenDatabasePathChanged(); } -void SettingsCache::setHandBgPath(const QString &_handBgPath) +void SettingsCache::setThemeName(const QString &_themeName) { - handBgPath = _handBgPath; - settings->setValue("zonebg/hand", handBgPath); - emit handBgPathChanged(); -} - -void SettingsCache::setStackBgPath(const QString &_stackBgPath) -{ - stackBgPath = _stackBgPath; - settings->setValue("zonebg/stack", stackBgPath); - emit stackBgPathChanged(); -} - -void SettingsCache::setTableBgPath(const QString &_tableBgPath) -{ - tableBgPath = _tableBgPath; - settings->setValue("zonebg/table", tableBgPath); - emit tableBgPathChanged(); -} - -void SettingsCache::setPlayerBgPath(const QString &_playerBgPath) -{ - playerBgPath = _playerBgPath; - settings->setValue("zonebg/playerarea", playerBgPath); - emit playerBgPathChanged(); -} - -void SettingsCache::setCardBackPicturePath(const QString &_cardBackPicturePath) -{ - cardBackPicturePath = _cardBackPicturePath; - settings->setValue("paths/cardbackpicture", cardBackPicturePath); - emit cardBackPicturePathChanged(); + themeName = _themeName; + settings->setValue("theme/name", themeName); + emit themeChanged(); } void SettingsCache::setPicDownload(int _picDownload) diff --git a/cockatrice/src/settingscache.h b/cockatrice/src/settingscache.h index 3670bc09..6e439ca1 100644 --- a/cockatrice/src/settingscache.h +++ b/cockatrice/src/settingscache.h @@ -25,11 +25,7 @@ signals: void picsPathChanged(); void cardDatabasePathChanged(); void tokenDatabasePathChanged(); - void handBgPathChanged(); - void stackBgPathChanged(); - void tableBgPathChanged(); - void playerBgPathChanged(); - void cardBackPicturePathChanged(); + void themeChanged(); void picDownloadChanged(); void picDownloadHqChanged(); void displayCardNamesChanged(); @@ -50,8 +46,7 @@ private: ShortcutsSettings *shortcutsSettings; QByteArray mainWindowGeometry; QString lang; - QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath; - QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath; + QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath, themeName; bool picDownload; bool picDownloadHq; bool notificationsEnabled; @@ -117,11 +112,7 @@ public: QString getPicsPath() const { return picsPath; } QString getCardDatabasePath() const { return cardDatabasePath; } QString getTokenDatabasePath() const { return tokenDatabasePath; } - QString getHandBgPath() const { return handBgPath; } - QString getStackBgPath() const { return stackBgPath; } - QString getTableBgPath() const { return tableBgPath; } - QString getPlayerBgPath() const { return playerBgPath; } - QString getCardBackPicturePath() const { return cardBackPicturePath; } + QString getThemeName() const { return themeName; } QString getChatMentionColor() const { return chatMentionColor; } QString getChatHighlightColor() const { return chatHighlightColor; } bool getPicDownload() const { return picDownload; } @@ -203,11 +194,7 @@ public slots: void setPicsPath(const QString &_picsPath); void setCardDatabasePath(const QString &_cardDatabasePath); void setTokenDatabasePath(const QString &_tokenDatabasePath); - void setHandBgPath(const QString &_handBgPath); - void setStackBgPath(const QString &_stackBgPath); - void setTableBgPath(const QString &_tableBgPath); - void setPlayerBgPath(const QString &_playerBgPath); - void setCardBackPicturePath(const QString &_cardBackPicturePath); + void setThemeName(const QString &_themeName); void setChatMentionColor(const QString &_chatMentionColor); void setChatHighlightColor(const QString &_chatHighlightColor); void setPicDownload(int _picDownload); diff --git a/cockatrice/src/stackzone.cpp b/cockatrice/src/stackzone.cpp index a60c4037..4b4b6b52 100644 --- a/cockatrice/src/stackzone.cpp +++ b/cockatrice/src/stackzone.cpp @@ -3,6 +3,7 @@ #include "arrowitem.h" #include "stackzone.h" #include "settingscache.h" +#include "thememanager.h" #include "player.h" #include "carddragitem.h" #include "carditem.h" @@ -12,16 +13,13 @@ StackZone::StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent) : SelectZone(_p, "stack", false, false, true, parent), zoneHeight(_zoneHeight) { - connect(settingsCache, SIGNAL(stackBgPathChanged()), this, SLOT(updateBgPixmap())); - updateBgPixmap(); + connect(themeManager, SIGNAL(themeChanged()), this, SLOT(updateBg())); + updateBg(); setCacheMode(DeviceCoordinateCache); } -void StackZone::updateBgPixmap() +void StackZone::updateBg() { - QString bgPath = settingsCache->getStackBgPath(); - if (!bgPath.isEmpty()) - bgPixmap.load(bgPath); update(); } @@ -48,10 +46,7 @@ QRectF StackZone::boundingRect() const void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - if (bgPixmap.isNull()) - painter->fillRect(boundingRect(), QColor(113, 43, 43)); - else - painter->fillRect(boundingRect(), QBrush(bgPixmap)); + painter->fillRect(boundingRect(), themeManager->getStackBgBrush()); } void StackZone::handleDropEvent(const QList &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/) diff --git a/cockatrice/src/stackzone.h b/cockatrice/src/stackzone.h index 948d3bcb..05fb2d24 100644 --- a/cockatrice/src/stackzone.h +++ b/cockatrice/src/stackzone.h @@ -7,9 +7,8 @@ class StackZone : public SelectZone { Q_OBJECT private: qreal zoneHeight; - QPixmap bgPixmap; private slots: - void updateBgPixmap(); + void updateBg(); public: StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0); void handleDropEvent(const QList &dragItems, CardZone *startZone, const QPoint &dropPoint); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index 52c24995..0bef8e7a 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -53,21 +53,21 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event) void TabDeckEditor::createShowHideDocksButtons() { - btnFilter = new QPushButton(QIcon("://resources/icon_view.svg"),QString()); + btnFilter = new QPushButton(QIcon("theme:icons/view.svg"),QString()); btnFilter->setObjectName("btnFilter"); btnFilter->setCheckable(true); btnFilter->setChecked(true); btnFilter->setMaximumWidth(30); searchLayout->addWidget(btnFilter); - btnDeck = new QPushButton(QIcon("://resources/hand.svg"),QString()); + btnDeck = new QPushButton(QIcon("theme:hand.svg"),QString()); btnDeck->setObjectName("btnDeck"); btnDeck->setCheckable(true); btnDeck->setChecked(true); btnDeck->setMaximumWidth(30); searchLayout->addWidget(btnDeck); - btnCard = new QPushButton(QIcon("://back.svg"),QString()); + btnCard = new QPushButton(QIcon("theme:back.svg"),QString()); btnCard->setObjectName("btnCard"); btnCard->setCheckable(true); btnCard->setChecked(true); @@ -134,7 +134,7 @@ void TabDeckEditor::createDeckDock() /* Update price aUpdatePrices = new QAction(QString(), this); - aUpdatePrices->setIcon(QIcon(":/resources/icon_update.png")); + aUpdatePrices->setIcon(QIcon("theme:icons/update.png")); connect(aUpdatePrices, SIGNAL(triggered()), this, SLOT(actUpdatePrices())); if (!settingsCache->getPriceTagFeature()) aUpdatePrices->setVisible(false); @@ -316,11 +316,11 @@ void TabDeckEditor::createMenus() addTabMenu(deckMenu); aClearFilterAll = new QAction(QString(), this); - aClearFilterAll->setIcon(QIcon(":/resources/icon_clearsearch.svg")); + aClearFilterAll->setIcon(QIcon("theme:icons/clearsearch.svg")); connect(aClearFilterAll, SIGNAL(triggered()), this, SLOT(actClearFilterAll())); aClearFilterOne = new QAction(QString(), this); - aClearFilterOne->setIcon(QIcon(":/resources/decrement.svg")); + aClearFilterOne->setIcon(QIcon("theme:icons/decrement.svg")); connect(aClearFilterOne, SIGNAL(triggered()), this, SLOT(actClearFilterOne())); dbMenu = new QMenu(this); @@ -342,7 +342,7 @@ void TabDeckEditor::createCentralFrame() searchEdit = new SearchLineEdit; searchEdit->setObjectName("searchEdit"); #if QT_VERSION >= 0x050300 - searchEdit->addAction(QIcon(":/resources/icon_search_black.svg"), QLineEdit::LeadingPosition); + searchEdit->addAction(QIcon("theme:icons/search.svg"), QLineEdit::LeadingPosition); #endif setFocusProxy(searchEdit); @@ -381,19 +381,19 @@ void TabDeckEditor::createCentralFrame() searchEdit->setTreeView(databaseView); aAddCard = new QAction(QString(), this); - aAddCard->setIcon(QIcon(":/resources/arrow_right_green.svg")); + aAddCard->setIcon(QIcon("theme:icons/arrow_right_green.svg")); connect(aAddCard, SIGNAL(triggered()), this, SLOT(actAddCard())); aAddCardToSideboard = new QAction(QString(), this); - aAddCardToSideboard->setIcon(QIcon(":/resources/add_to_sideboard.svg")); + aAddCardToSideboard->setIcon(QIcon("theme:icons/arrow_right_blue.svg")); connect(aAddCardToSideboard, SIGNAL(triggered()), this, SLOT(actAddCardToSideboard())); aRemoveCard = new QAction(QString(), this); - aRemoveCard->setIcon(QIcon(":/resources/remove_row.svg")); + aRemoveCard->setIcon(QIcon("theme:icons/remove_row.svg")); connect(aRemoveCard, SIGNAL(triggered()), this, SLOT(actRemoveCard())); aIncrement = new QAction(QString(), this); - aIncrement->setIcon(QIcon(":/resources/increment.svg")); + aIncrement->setIcon(QIcon("theme:icons/increment.svg")); connect(aIncrement, SIGNAL(triggered()), this, SLOT(actIncrement())); aDecrement = new QAction(QString(), this); - aDecrement->setIcon(QIcon(":/resources/decrement.svg")); + aDecrement->setIcon(QIcon("theme:icons/decrement.svg")); connect(aDecrement, SIGNAL(triggered()), this, SLOT(actDecrement())); QToolBar *deckEditToolBar = new QToolBar; diff --git a/cockatrice/src/tab_deck_storage.cpp b/cockatrice/src/tab_deck_storage.cpp index 9898c9ee..fa30ff0b 100644 --- a/cockatrice/src/tab_deck_storage.cpp +++ b/cockatrice/src/tab_deck_storage.cpp @@ -80,25 +80,25 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c hbox->addWidget(rightGroupBox); aOpenLocalDeck = new QAction(this); - aOpenLocalDeck->setIcon(QIcon(":/resources/pencil.svg")); + aOpenLocalDeck->setIcon(QIcon("theme:icons/pencil.svg")); connect(aOpenLocalDeck, SIGNAL(triggered()), this, SLOT(actOpenLocalDeck())); aUpload = new QAction(this); - aUpload->setIcon(QIcon(":/resources/arrow_right_green.svg")); + aUpload->setIcon(QIcon("theme:icons/arrow_right_green.svg")); connect(aUpload, SIGNAL(triggered()), this, SLOT(actUpload())); aDeleteLocalDeck = new QAction(this); - aDeleteLocalDeck->setIcon(QIcon(":/resources/remove_row.svg")); + aDeleteLocalDeck->setIcon(QIcon("theme:icons/remove_row.svg")); connect(aDeleteLocalDeck, SIGNAL(triggered()), this, SLOT(actDeleteLocalDeck())); aOpenRemoteDeck = new QAction(this); - aOpenRemoteDeck->setIcon(QIcon(":/resources/pencil.svg")); + aOpenRemoteDeck->setIcon(QIcon("theme:icons/pencil.svg")); connect(aOpenRemoteDeck, SIGNAL(triggered()), this, SLOT(actOpenRemoteDeck())); aDownload = new QAction(this); - aDownload->setIcon(QIcon(":/resources/arrow_left_green.svg")); + aDownload->setIcon(QIcon("theme:icons/arrow_left_green.svg")); connect(aDownload, SIGNAL(triggered()), this, SLOT(actDownload())); aNewFolder = new QAction(this); aNewFolder->setIcon(qApp->style()->standardIcon(QStyle::SP_FileDialogNewFolder)); connect(aNewFolder, SIGNAL(triggered()), this, SLOT(actNewFolder())); aDeleteRemoteDeck = new QAction(this); - aDeleteRemoteDeck->setIcon(QIcon(":/resources/remove_row.svg")); + aDeleteRemoteDeck->setIcon(QIcon("theme:icons/remove_row.svg")); connect(aDeleteRemoteDeck, SIGNAL(triggered()), this, SLOT(actDeleteRemoteDeck())); leftToolBar->addAction(aOpenLocalDeck); diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 53ba95c3..36a20ff9 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -363,17 +363,17 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay) replayStartButton = new QToolButton; replayStartButton->setIconSize(QSize(32, 32)); - replayStartButton->setIcon(QIcon(":/resources/replay_start.svg")); + replayStartButton->setIcon(QIcon("theme:replay/start.svg")); connect(replayStartButton, SIGNAL(clicked()), this, SLOT(replayStartButtonClicked())); replayPauseButton = new QToolButton; replayPauseButton->setIconSize(QSize(32, 32)); replayPauseButton->setEnabled(false); - replayPauseButton->setIcon(QIcon(":/resources/replay_pause.svg")); + replayPauseButton->setIcon(QIcon("theme:replay/pause.svg")); connect(replayPauseButton, SIGNAL(clicked()), this, SLOT(replayPauseButtonClicked())); replayFastForwardButton = new QToolButton; replayFastForwardButton->setIconSize(QSize(32, 32)); replayFastForwardButton->setEnabled(false); - replayFastForwardButton->setIcon(QIcon(":/resources/replay_fastforward.svg")); + replayFastForwardButton->setIcon(QIcon("theme:replay/fastforward.svg")); replayFastForwardButton->setCheckable(true); connect(replayFastForwardButton, SIGNAL(toggled(bool)), this, SLOT(replayFastForwardButtonToggled(bool))); diff --git a/cockatrice/src/tab_replays.cpp b/cockatrice/src/tab_replays.cpp index d0e507d0..3947ca08 100644 --- a/cockatrice/src/tab_replays.cpp +++ b/cockatrice/src/tab_replays.cpp @@ -78,24 +78,24 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client) hbox->addWidget(rightGroupBox); aOpenLocalReplay = new QAction(this); - aOpenLocalReplay->setIcon(QIcon(":/resources/icon_view.svg")); + aOpenLocalReplay->setIcon(QIcon("theme:icons/view.svg")); connect(aOpenLocalReplay, SIGNAL(triggered()), this, SLOT(actOpenLocalReplay())); connect(localDirView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actOpenLocalReplay())); aDeleteLocalReplay = new QAction(this); - aDeleteLocalReplay->setIcon(QIcon(":/resources/remove_row.svg")); + aDeleteLocalReplay->setIcon(QIcon("theme:icons/remove_row.svg")); connect(aDeleteLocalReplay, SIGNAL(triggered()), this, SLOT(actDeleteLocalReplay())); aOpenRemoteReplay = new QAction(this); - aOpenRemoteReplay->setIcon(QIcon(":/resources/icon_view.svg")); + aOpenRemoteReplay->setIcon(QIcon("theme:icons/view.svg")); connect(aOpenRemoteReplay, SIGNAL(triggered()), this, SLOT(actOpenRemoteReplay())); connect(serverDirView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actOpenRemoteReplay())); aDownload = new QAction(this); - aDownload->setIcon(QIcon(":/resources/arrow_left_green.svg")); + aDownload->setIcon(QIcon("theme:icons/arrow_left_green.svg")); connect(aDownload, SIGNAL(triggered()), this, SLOT(actDownload())); aKeep = new QAction(this); - aKeep->setIcon(QIcon(":/resources/lock.svg")); + aKeep->setIcon(QIcon("theme:icons/lock.svg")); connect(aKeep, SIGNAL(triggered()), this, SLOT(actKeepRemoteReplay())); aDeleteRemoteReplay = new QAction(this); - aDeleteRemoteReplay->setIcon(QIcon(":/resources/remove_row.svg")); + aDeleteRemoteReplay->setIcon(QIcon("theme:icons/remove_row.svg")); connect(aDeleteRemoteReplay, SIGNAL(triggered()), this, SLOT(actDeleteRemoteReplay())); leftToolBar->addAction(aOpenLocalReplay); diff --git a/cockatrice/src/tab_room.cpp b/cockatrice/src/tab_room.cpp index bdf19192..e7e37171 100644 --- a/cockatrice/src/tab_room.cpp +++ b/cockatrice/src/tab_room.cpp @@ -71,7 +71,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings())); QToolButton *chatSettingsButton = new QToolButton; - chatSettingsButton->setIcon(QIcon(":/resources/icon_settings.svg")); + chatSettingsButton->setIcon(QIcon("theme:icons/settings.svg")); chatSettingsButton->setMenu(chatSettingsMenu); chatSettingsButton->setPopupMode(QToolButton::InstantPopup); diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index 9bde53b2..015d9267 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -80,7 +80,7 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/) TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent) : QTabWidget(parent), userInfo(0), client(_client), tabServer(0), tabUserLists(0), tabDeckStorage(0), tabReplays(0), tabAdmin(0) { - tabChangedIcon = new QIcon(":/resources/icon_tab_changed.svg"); + tabChangedIcon = new QIcon("theme:icons/tab_changed.svg"); setElideMode(Qt::ElideRight); setMovable(true); setIconSize(QSize(15, 15)); diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index cfaa6e5f..eebae0f3 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -8,6 +8,7 @@ #include "tablezone.h" #include "player.h" #include "settingscache.h" +#include "thememanager.h" #include "arrowitem.h" #include "carddragitem.h" #include "carddatabase.h" @@ -16,20 +17,18 @@ #include "pb/command_move_card.pb.h" #include "pb/command_set_card_attr.pb.h" - const QColor TableZone::BACKGROUND_COLOR = QColor(100, 100, 100); const QColor TableZone::FADE_MASK = QColor(0, 0, 0, 80); const QColor TableZone::GRADIENT_COLOR = QColor(255, 255, 255, 150); const QColor TableZone::GRADIENT_COLORLESS = QColor(255, 255, 255, 0); - TableZone::TableZone(Player *_p, QGraphicsItem *parent) : SelectZone(_p, "table", true, false, true, parent), active(false) { - connect(settingsCache, SIGNAL(tableBgPathChanged()), this, SLOT(updateBgPixmap())); + connect(themeManager, SIGNAL(themeChanged()), this, SLOT(updateBg())); connect(settingsCache, SIGNAL(invertVerticalCoordinateChanged()), this, SLOT(reorganizeCards())); - updateBgPixmap(); + updateBg(); height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS-1) * PADDING_Y; width = MIN_WIDTH; @@ -44,11 +43,8 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent) } -void TableZone::updateBgPixmap() +void TableZone::updateBg() { - QString bgPath = settingsCache->getTableBgPath(); - if (!bgPath.isEmpty()) - backgroundPixelMap.load(bgPath); update(); } @@ -67,11 +63,7 @@ bool TableZone::isInverted() const void TableZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, QWidget * /*widget*/) { - // if no custom background is provided then use the default color - if (backgroundPixelMap.isNull()) - painter->fillRect(boundingRect(), BACKGROUND_COLOR); - else - painter->fillRect(boundingRect(), QBrush(backgroundPixelMap)); + painter->fillRect(boundingRect(), themeManager->getTableBgBrush()); if (active) { paintZoneOutline(painter); diff --git a/cockatrice/src/tablezone.h b/cockatrice/src/tablezone.h index 2094a48f..55b12b8b 100644 --- a/cockatrice/src/tablezone.h +++ b/cockatrice/src/tablezone.h @@ -49,7 +49,7 @@ private: static const int BOX_LINE_WIDTH = 10; /* - Default background color, inactive mask and boarder gradient + Default inactive mask and border gradient */ static const QColor BACKGROUND_COLOR; static const QColor FADE_MASK; @@ -84,7 +84,7 @@ private slots: /** Loads in any found custom background and updates */ - void updateBgPixmap(); + void updateBg(); public slots: /** diff --git a/cockatrice/src/thememanager.cpp b/cockatrice/src/thememanager.cpp new file mode 100644 index 00000000..0e2bb996 --- /dev/null +++ b/cockatrice/src/thememanager.cpp @@ -0,0 +1,144 @@ +#include "thememanager.h" +#include "settingscache.h" +#include +#include +#include +#include +#if QT_VERSION < 0x050000 + #include +#else + #include +#endif + +#define DEFAULT_THEME_NAME "Default" +#define STYLE_CSS_NAME "style.css" +#define HANDZONE_BG_NAME "handzone" +#define PLAYERZONE_BG_NAME "playerzone" +#define STACKZONE_BG_NAME "stackzone" +#define TABLEZONE_BG_NAME "tablezone" +#define CARD_BACK_NAME "cardback" + +ThemeManager::ThemeManager(QObject *parent) + :QObject(parent) +{ + ensureThemeDirectoryExists(); + connect(settingsCache, SIGNAL(themeChanged()), this, SLOT(themeChangedSlot())); + themeChangedSlot(); +} + +void ThemeManager::ensureThemeDirectoryExists() +{ + if(settingsCache->getThemeName().isEmpty() || + !getAvailableThemes().contains(settingsCache->getThemeName())) + { + qDebug() << "Theme name not set, setting default value"; + settingsCache->setThemeName(DEFAULT_THEME_NAME); + } +} + +QStringMap & ThemeManager::getAvailableThemes() +{ + QDir dir; + availableThemes.clear(); + + // load themes from user profile dir + dir = +#if QT_VERSION < 0x050000 + QDesktopServices::storageLocation(QDesktopServices::DataLocation) + +#else + QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() + +#endif + "/themes"; + + foreach(QString themeName, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) + { + if(!availableThemes.contains(themeName)) + availableThemes.insert(themeName, dir.absoluteFilePath(themeName)); + } + + // load themes from cockatrice system dir +#ifdef Q_OS_MAC + dir = qApp->applicationDirPath() + "/../Resources/themes"; +#elif defined(Q_OS_WIN) + dir = qApp->applicationDirPath() + "/themes"; +#else // linux + dir = qApp->applicationDirPath() + "/../share/cockatrice/themes"; +#endif + foreach(QString themeName, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name)) + { + if(!availableThemes.contains(themeName)) + availableThemes.insert(themeName, dir.absoluteFilePath(themeName)); + } + + return availableThemes; +} + +QBrush ThemeManager::loadBrush(QDir dir, QString fileName, QColor fallbackColor) +{ + QBrush brush; + QPixmap tmp; + QStringList exts; + exts << ".png" << ".jpg" << ".jpeg" << ".gif" << ".bmp"; + + brush.setColor(fallbackColor); + brush.setStyle(Qt::SolidPattern); + + foreach (const QString &ext, exts) { + if (dir.exists(fileName + ext)) { + tmp.load(dir.absoluteFilePath(fileName + ext)); + if(!tmp.isNull()) + brush.setTexture(tmp); + break; + } + } + + return brush; +} + +QPixmap ThemeManager::loadPixmap(QDir dir, QString fileName) +{ + QPixmap pix; + QStringList exts; + exts << ".png" << ".jpg" << ".jpeg" << ".gif" << ".bmp"; + + foreach (const QString &ext, exts) { + if (dir.exists(fileName + ext)) { + pix.load(dir.absoluteFilePath(fileName + ext)); + break; + } + } + + return pix; +} + +void ThemeManager::themeChangedSlot() +{ + QString themeName = settingsCache->getThemeName(); + qDebug() << "Theme changed:" << themeName; + + QDir dir = getAvailableThemes().value(themeName); + + // css + if(dir.exists(STYLE_CSS_NAME)) + + qApp->setStyleSheet("file:///" + dir.absoluteFilePath(STYLE_CSS_NAME)); + else + qApp->setStyleSheet(""); + + // card background + cardBackPixmap = loadPixmap(dir, CARD_BACK_NAME); + + // zones bg + dir.cd("zones"); + handBgBrush = loadBrush(dir, HANDZONE_BG_NAME, QColor(80, 100, 50)); + tableBgBrush = loadBrush(dir, TABLEZONE_BG_NAME, QColor(70, 50, 100)); + playerBgBrush = loadBrush(dir, PLAYERZONE_BG_NAME, QColor(200, 200, 200)); + stackBgBrush = loadBrush(dir, STACKZONE_BG_NAME, QColor(113, 43, 43)); + + // resources + QStringList resources; + resources << dir.absolutePath() << ":/resources"; + QDir::setSearchPaths("theme", resources); + + emit themeChanged(); +} \ No newline at end of file diff --git a/cockatrice/src/thememanager.h b/cockatrice/src/thememanager.h new file mode 100644 index 00000000..19cb19c5 --- /dev/null +++ b/cockatrice/src/thememanager.h @@ -0,0 +1,42 @@ +#ifndef THEMEMANAGER_H +#define THEMEMANAGER_H + +#include +#include +#include +#include +#include +#include + +typedef QMap QStringMap; + +class QApplication; + +class ThemeManager : public QObject { + Q_OBJECT +public: + ThemeManager(QObject *parent = 0); +private: + QBrush handBgBrush, stackBgBrush, tableBgBrush, playerBgBrush; + QPixmap cardBackPixmap; + QStringMap availableThemes; +protected: + void ensureThemeDirectoryExists(); + QBrush loadBrush(QDir dir, QString fileName, QColor fallbackColor); + QPixmap loadPixmap(QDir dir, QString fileName); +public: + QBrush &getHandBgBrush() { return handBgBrush; } + QBrush &getStackBgBrush() { return stackBgBrush; } + QBrush &getTableBgBrush() { return tableBgBrush; } + QBrush &getPlayerBgBrush() { return playerBgBrush; } + QPixmap &getCardBackPixmap() { return cardBackPixmap; } + QStringMap &getAvailableThemes(); +protected slots: + void themeChangedSlot(); +signals: + void themeChanged(); +}; + +extern ThemeManager * themeManager; + +#endif diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 219f1dbe..812fc1df 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -100,7 +100,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event) { serverShutdownMessageBox.setInformativeText(tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason()))); - serverShutdownMessageBox.setIconPixmap(QPixmap(":/resources/appicon.svg").scaled(64, 64)); + serverShutdownMessageBox.setIconPixmap(QPixmap("theme:appicon.svg").scaled(64, 64)); serverShutdownMessageBox.setText(tr("Scheduled server shutdown")); serverShutdownMessageBox.setWindowModality(Qt::ApplicationModal); serverShutdownMessageBox.setVisible(true); @@ -618,7 +618,7 @@ void MainWindow::createTrayIcon() { trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu); - trayIcon->setIcon(QIcon(":/resources/appicon.svg")); + trayIcon->setIcon(QIcon("theme:cockatrice.svg")); trayIcon->show(); connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this, diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index 890688cf..4668c55d 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -24,28 +24,28 @@ WndSets::WndSets(QWidget *parent) setsEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); aTop = new QAction(QString(), this); - aTop->setIcon(QIcon(":/resources/arrow_top_green.svg")); + aTop->setIcon(QIcon("theme:icons/arrow_top_green.svg")); aTop->setToolTip(tr("Move selected set to the top")); aTop->setEnabled(false); connect(aTop, SIGNAL(triggered()), this, SLOT(actTop())); setsEditToolBar->addAction(aTop); aUp = new QAction(QString(), this); - aUp->setIcon(QIcon(":/resources/arrow_up_green.svg")); + aUp->setIcon(QIcon("theme:icons/arrow_up_green.svg")); aUp->setToolTip(tr("Move selected set up")); aUp->setEnabled(false); connect(aUp, SIGNAL(triggered()), this, SLOT(actUp())); setsEditToolBar->addAction(aUp); aDown = new QAction(QString(), this); - aDown->setIcon(QIcon(":/resources/arrow_down_green.svg")); + aDown->setIcon(QIcon("theme:icons/arrow_down_green.svg")); aDown->setToolTip(tr("Move selected set down")); aDown->setEnabled(false); connect(aDown, SIGNAL(triggered()), this, SLOT(actDown())); setsEditToolBar->addAction(aDown); aBottom = new QAction(QString(), this); - aBottom->setIcon(QIcon(":/resources/arrow_bottom_green.svg")); + aBottom->setIcon(QIcon("theme:icons/arrow_bottom_green.svg")); aBottom->setToolTip(tr("Move selected set to the bottom")); aBottom->setEnabled(false); connect(aBottom, SIGNAL(triggered()), this, SLOT(actBottom())); diff --git a/cockatrice/src/zoneviewwidget.cpp b/cockatrice/src/zoneviewwidget.cpp index ccb36af1..6cc8a092 100644 --- a/cockatrice/src/zoneviewwidget.cpp +++ b/cockatrice/src/zoneviewwidget.cpp @@ -250,5 +250,5 @@ void ZoneViewWidget::zoneDeleted() void ZoneViewWidget::initStyleOption(QStyleOption *option) const { QStyleOptionTitleBar *titleBar = qstyleoption_cast(option); if (titleBar) - titleBar->icon = QIcon(":/resources/appicon.svg"); + titleBar->icon = QIcon("theme:cockatrice.svg"); } diff --git a/oracle/CMakeLists.txt b/oracle/CMakeLists.txt index c91e958e..08fdfabb 100644 --- a/oracle/CMakeLists.txt +++ b/oracle/CMakeLists.txt @@ -14,6 +14,7 @@ SET(oracle_SOURCES ../cockatrice/src/carddatabase.cpp ../cockatrice/src/settingscache.cpp ../cockatrice/src/shortcutssettings.cpp + ../cockatrice/src/thememanager.cpp ../cockatrice/src/qt-json/json.cpp ) diff --git a/oracle/src/main.cpp b/oracle/src/main.cpp index 9b462dd8..60e5e8d9 100644 --- a/oracle/src/main.cpp +++ b/oracle/src/main.cpp @@ -7,9 +7,11 @@ #include "main.h" #include "oraclewizard.h" #include "settingscache.h" +#include "thememanager.h" QTranslator *translator, *qtTranslator; SettingsCache *settingsCache; +ThemeManager *themeManager; const QString translationPrefix = "oracle"; #ifdef TRANSLATION_PATH @@ -51,6 +53,7 @@ int main(int argc, char *argv[]) } settingsCache = new SettingsCache; + themeManager = new ThemeManager; qtTranslator = new QTranslator; translator = new QTranslator; @@ -58,7 +61,7 @@ int main(int argc, char *argv[]) OracleWizard wizard; - QIcon icon(":/resources/appicon.svg"); + QIcon icon("theme:appicon.svg"); wizard.setWindowIcon(icon); wizard.show(); diff --git a/themes/CMakeLists.txt b/themes/CMakeLists.txt new file mode 100644 index 00000000..dc3b9b50 --- /dev/null +++ b/themes/CMakeLists.txt @@ -0,0 +1,22 @@ +# CMakeLists for themes directory +# +# add themes subfolders + +SET(defthemes + Default + Fabric + Leather + Plasma + VelvetMarble +) + +if(UNIX) + if(APPLE) + INSTALL(DIRECTORY ${defthemes} DESTINATION cockatrice.app/Contents/Resources/themes/) + else() + # Assume linux + INSTALL(DIRECTORY ${defthemes} DESTINATION share/cockatrice/themes/) + endif() +elseif(WIN32) + INSTALL(DIRECTORY ${defthemes} DESTINATION themes/) +endif() diff --git a/zonebg/fabric_green.png b/themes/Fabric/zones/handzone.png similarity index 100% rename from zonebg/fabric_green.png rename to themes/Fabric/zones/handzone.png diff --git a/zonebg/fabric_gray.png b/themes/Fabric/zones/playerzone.png similarity index 100% rename from zonebg/fabric_gray.png rename to themes/Fabric/zones/playerzone.png diff --git a/zonebg/fabric_red.png b/themes/Fabric/zones/stackzone.png similarity index 100% rename from zonebg/fabric_red.png rename to themes/Fabric/zones/stackzone.png diff --git a/zonebg/fabric_blue.png b/themes/Fabric/zones/tablezone.png similarity index 100% rename from zonebg/fabric_blue.png rename to themes/Fabric/zones/tablezone.png diff --git a/zonebg/leather_green.png b/themes/Leather/zones/handzone.png similarity index 100% rename from zonebg/leather_green.png rename to themes/Leather/zones/handzone.png diff --git a/zonebg/leather_gray.png b/themes/Leather/zones/playerzone.png similarity index 100% rename from zonebg/leather_gray.png rename to themes/Leather/zones/playerzone.png diff --git a/zonebg/leather_red.png b/themes/Leather/zones/stackzone.png similarity index 100% rename from zonebg/leather_red.png rename to themes/Leather/zones/stackzone.png diff --git a/zonebg/leather_blue.png b/themes/Leather/zones/tablezone.png similarity index 100% rename from zonebg/leather_blue.png rename to themes/Leather/zones/tablezone.png diff --git a/zonebg/plasma_green.png b/themes/Plasma/zones/handzone.png similarity index 100% rename from zonebg/plasma_green.png rename to themes/Plasma/zones/handzone.png diff --git a/zonebg/plasma_gray.png b/themes/Plasma/zones/playerzone.png similarity index 100% rename from zonebg/plasma_gray.png rename to themes/Plasma/zones/playerzone.png diff --git a/zonebg/plasma_red.png b/themes/Plasma/zones/stackzone.png similarity index 100% rename from zonebg/plasma_red.png rename to themes/Plasma/zones/stackzone.png diff --git a/zonebg/plasma_blue.png b/themes/Plasma/zones/tablezone.png similarity index 100% rename from zonebg/plasma_blue.png rename to themes/Plasma/zones/tablezone.png diff --git a/zonebg/VelvetMarble_HorizontalHand_Hand.jpg b/themes/VelvetMarble/zones/handzone.jpg similarity index 100% rename from zonebg/VelvetMarble_HorizontalHand_Hand.jpg rename to themes/VelvetMarble/zones/handzone.jpg diff --git a/zonebg/VelvetMarble_Table.jpg b/themes/VelvetMarble/zones/playerzone.jpg similarity index 100% rename from zonebg/VelvetMarble_Table.jpg rename to themes/VelvetMarble/zones/playerzone.jpg diff --git a/zonebg/VelvetMarble_Stack.jpg b/themes/VelvetMarble/zones/stackzone.jpg similarity index 100% rename from zonebg/VelvetMarble_Stack.jpg rename to themes/VelvetMarble/zones/stackzone.jpg diff --git a/zonebg/VelvetMarble_HorizontalHand_Player.jpg b/themes/VelvetMarble/zones/tablezone.jpg similarity index 100% rename from zonebg/VelvetMarble_HorizontalHand_Player.jpg rename to themes/VelvetMarble/zones/tablezone.jpg diff --git a/zonebg/CMakeLists.txt b/zonebg/CMakeLists.txt deleted file mode 100644 index b250a44b..00000000 --- a/zonebg/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# CMakeLists for zonebg/ directory -# -# Installs default "zone background" files - -FILE(GLOB zonebg "${CMAKE_CURRENT_SOURCE_DIR}/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/*.jpg") - -if(UNIX) - if(APPLE) - INSTALL(FILES ${zonebg} DESTINATION cockatrice.app/Contents/Resources/zonebg/) - else() - # Assume linux - INSTALL(FILES ${zonebg} DESTINATION share/cockatrice/zonebg/) - endif() -elseif(WIN32) - INSTALL(FILES ${zonebg} DESTINATION zonebg/) -endif() \ No newline at end of file diff --git a/zonebg/VelvetMarble_VerticalHand_Hand.jpg b/zonebg/VelvetMarble_VerticalHand_Hand.jpg deleted file mode 100644 index 83e8915a..00000000 Binary files a/zonebg/VelvetMarble_VerticalHand_Hand.jpg and /dev/null differ diff --git a/zonebg/VelvetMarble_VerticalHand_Player.jpg b/zonebg/VelvetMarble_VerticalHand_Player.jpg deleted file mode 100644 index d86987bf..00000000 Binary files a/zonebg/VelvetMarble_VerticalHand_Player.jpg and /dev/null differ