diff --git a/cockatrice/CMakeLists.txt b/cockatrice/CMakeLists.txt index e81c6d26..a7d645e0 100644 --- a/cockatrice/CMakeLists.txt +++ b/cockatrice/CMakeLists.txt @@ -95,6 +95,8 @@ SET(cockatrice_SOURCES src/soundengine.cpp src/pending_command.cpp src/shortcutssettings.cpp + src/sequenceEdit/secuenceedit.cpp + src/sequenceEdit/shortcutstab.cpp ${VERSION_STRING_CPP} ) diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index ebf5f44e..2e66b2df 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -1,337 +1,329 @@ - - 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/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/countries/ad.svg - resources/countries/ae.svg - resources/countries/af.svg - resources/countries/ag.svg - resources/countries/ai.svg - resources/countries/al.svg - resources/countries/am.svg - resources/countries/ao.svg - resources/countries/aq.svg - resources/countries/ar.svg - resources/countries/as.svg - resources/countries/at.svg - resources/countries/au.svg - resources/countries/aw.svg - resources/countries/ax.svg - resources/countries/az.svg - resources/countries/ba.svg - resources/countries/bb.svg - resources/countries/bd.svg - resources/countries/be.svg - resources/countries/bf.svg - resources/countries/bg.svg - resources/countries/bh.svg - resources/countries/bi.svg - resources/countries/bj.svg - resources/countries/bl.svg - resources/countries/bm.svg - resources/countries/bn.svg - resources/countries/bo.svg - resources/countries/bq.svg - resources/countries/br.svg - resources/countries/bs.svg - resources/countries/bt.svg - resources/countries/bv.svg - resources/countries/bw.svg - resources/countries/by.svg - resources/countries/bz.svg - resources/countries/ca.svg - resources/countries/cc.svg - resources/countries/cd.svg - resources/countries/cf.svg - resources/countries/cg.svg - resources/countries/ch.svg - resources/countries/ci.svg - resources/countries/ck.svg - resources/countries/cl.svg - resources/countries/cm.svg - resources/countries/cn.svg - resources/countries/co.svg - resources/countries/cr.svg - resources/countries/cu.svg - resources/countries/cv.svg - resources/countries/cw.svg - resources/countries/cx.svg - resources/countries/cy.svg - resources/countries/cz.svg - resources/countries/de.svg - resources/countries/dj.svg - resources/countries/dk.svg - resources/countries/dm.svg - resources/countries/do.svg - resources/countries/dz.svg - resources/countries/ec.svg - resources/countries/ee.svg - resources/countries/eg.svg - resources/countries/eh.svg - resources/countries/er.svg - resources/countries/es.svg - resources/countries/et.svg - resources/countries/fi.svg - resources/countries/fj.svg - resources/countries/fk.svg - resources/countries/fm.svg - resources/countries/fo.svg - resources/countries/fr.svg - resources/countries/ga.svg - resources/countries/gb.svg - resources/countries/gd.svg - resources/countries/ge.svg - resources/countries/gf.svg - resources/countries/gg.svg - resources/countries/gh.svg - resources/countries/gi.svg - resources/countries/gl.svg - resources/countries/gm.svg - resources/countries/gn.svg - resources/countries/gp.svg - resources/countries/gq.svg - resources/countries/gr.svg - resources/countries/gs.svg - resources/countries/gt.svg - resources/countries/gu.svg - resources/countries/gw.svg - resources/countries/gy.svg - resources/countries/hk.svg - resources/countries/hm.svg - resources/countries/hn.svg - resources/countries/hr.svg - resources/countries/ht.svg - resources/countries/hu.svg - resources/countries/id.svg - resources/countries/ie.svg - resources/countries/il.svg - resources/countries/im.svg - resources/countries/in.svg - resources/countries/io.svg - resources/countries/iq.svg - resources/countries/ir.svg - resources/countries/is.svg - resources/countries/it.svg - resources/countries/je.svg - resources/countries/jm.svg - resources/countries/jo.svg - resources/countries/jp.svg - resources/countries/ke.svg - resources/countries/kg.svg - resources/countries/kh.svg - resources/countries/ki.svg - resources/countries/km.svg - resources/countries/kn.svg - resources/countries/kp.svg - resources/countries/kr.svg - resources/countries/kw.svg - resources/countries/ky.svg - resources/countries/kz.svg - resources/countries/la.svg - resources/countries/lb.svg - resources/countries/lc.svg - resources/countries/li.svg - resources/countries/lk.svg - resources/countries/lr.svg - resources/countries/ls.svg - resources/countries/lt.svg - resources/countries/lu.svg - resources/countries/lv.svg - resources/countries/ly.svg - resources/countries/ma.svg - resources/countries/mc.svg - resources/countries/md.svg - resources/countries/me.svg - resources/countries/mf.svg - resources/countries/mg.svg - resources/countries/mh.svg - resources/countries/mk.svg - resources/countries/ml.svg - resources/countries/mm.svg - resources/countries/mn.svg - resources/countries/mo.svg - resources/countries/mp.svg - resources/countries/mq.svg - resources/countries/mr.svg - resources/countries/ms.svg - resources/countries/mt.svg - resources/countries/mu.svg - resources/countries/mv.svg - resources/countries/mw.svg - resources/countries/mx.svg - resources/countries/my.svg - resources/countries/mz.svg - resources/countries/na.svg - resources/countries/nc.svg - resources/countries/ne.svg - resources/countries/nf.svg - resources/countries/ng.svg - resources/countries/ni.svg - resources/countries/nl.svg - resources/countries/no.svg - resources/countries/np.svg - resources/countries/nr.svg - resources/countries/nu.svg - resources/countries/nz.svg - resources/countries/om.svg - resources/countries/pa.svg - resources/countries/pe.svg - resources/countries/pf.svg - resources/countries/pg.svg - resources/countries/ph.svg - resources/countries/pk.svg - resources/countries/pl.svg - resources/countries/pm.svg - resources/countries/pn.svg - resources/countries/pr.svg - resources/countries/ps.svg - resources/countries/pt.svg - resources/countries/pw.svg - resources/countries/py.svg - resources/countries/qa.svg - resources/countries/re.svg - resources/countries/ro.svg - resources/countries/rs.svg - resources/countries/ru.svg - resources/countries/rw.svg - resources/countries/sa.svg - resources/countries/sb.svg - resources/countries/sc.svg - resources/countries/sd.svg - resources/countries/se.svg - resources/countries/sg.svg - resources/countries/sh.svg - resources/countries/si.svg - resources/countries/sj.svg - resources/countries/sk.svg - resources/countries/sl.svg - resources/countries/sm.svg - resources/countries/sn.svg - resources/countries/so.svg - resources/countries/sr.svg - resources/countries/ss.svg - resources/countries/st.svg - resources/countries/sv.svg - resources/countries/sx.svg - resources/countries/sy.svg - resources/countries/sz.svg - resources/countries/tc.svg - resources/countries/td.svg - resources/countries/tf.svg - resources/countries/tg.svg - resources/countries/th.svg - resources/countries/tj.svg - resources/countries/tk.svg - resources/countries/tl.svg - resources/countries/tm.svg - resources/countries/tn.svg - resources/countries/to.svg - resources/countries/tr.svg - resources/countries/tt.svg - resources/countries/tv.svg - resources/countries/tw.svg - resources/countries/tz.svg - resources/countries/ua.svg - resources/countries/ug.svg - resources/countries/um.svg - resources/countries/us.svg - resources/countries/uy.svg - resources/countries/uz.svg - resources/countries/va.svg - resources/countries/vc.svg - resources/countries/ve.svg - resources/countries/vg.svg - resources/countries/vi.svg - resources/countries/vn.svg - resources/countries/vu.svg - resources/countries/wf.svg - resources/countries/ws.svg - resources/countries/ye.svg - resources/countries/yt.svg - 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/userlevels/normal.svg - resources/userlevels/registered.svg - resources/userlevels/registered_buddy.svg - resources/userlevels/moderator.svg - 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/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/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/countries/ad.svg + resources/countries/ae.svg + resources/countries/af.svg + resources/countries/ag.svg + resources/countries/ai.svg + resources/countries/al.svg + resources/countries/am.svg + resources/countries/ao.svg + resources/countries/aq.svg + resources/countries/ar.svg + resources/countries/as.svg + resources/countries/at.svg + resources/countries/au.svg + resources/countries/aw.svg + resources/countries/ax.svg + resources/countries/az.svg + resources/countries/ba.svg + resources/countries/bb.svg + resources/countries/bd.svg + resources/countries/be.svg + resources/countries/bf.svg + resources/countries/bg.svg + resources/countries/bh.svg + resources/countries/bi.svg + resources/countries/bj.svg + resources/countries/bl.svg + resources/countries/bm.svg + resources/countries/bn.svg + resources/countries/bo.svg + resources/countries/bq.svg + resources/countries/br.svg + resources/countries/bs.svg + resources/countries/bt.svg + resources/countries/bv.svg + resources/countries/bw.svg + resources/countries/by.svg + resources/countries/bz.svg + resources/countries/ca.svg + resources/countries/cc.svg + resources/countries/cd.svg + resources/countries/cf.svg + resources/countries/cg.svg + resources/countries/ch.svg + resources/countries/ci.svg + resources/countries/ck.svg + resources/countries/cl.svg + resources/countries/cm.svg + resources/countries/cn.svg + resources/countries/co.svg + resources/countries/cr.svg + resources/countries/cu.svg + resources/countries/cv.svg + resources/countries/cw.svg + resources/countries/cx.svg + resources/countries/cy.svg + resources/countries/cz.svg + resources/countries/de.svg + resources/countries/dj.svg + resources/countries/dk.svg + resources/countries/dm.svg + resources/countries/do.svg + resources/countries/dz.svg + resources/countries/ec.svg + resources/countries/ee.svg + resources/countries/eg.svg + resources/countries/eh.svg + resources/countries/er.svg + resources/countries/es.svg + resources/countries/et.svg + resources/countries/fi.svg + resources/countries/fj.svg + resources/countries/fk.svg + resources/countries/fm.svg + resources/countries/fo.svg + resources/countries/fr.svg + resources/countries/ga.svg + resources/countries/gb.svg + resources/countries/gd.svg + resources/countries/ge.svg + resources/countries/gf.svg + resources/countries/gg.svg + resources/countries/gh.svg + resources/countries/gi.svg + resources/countries/gl.svg + resources/countries/gm.svg + resources/countries/gn.svg + resources/countries/gp.svg + resources/countries/gq.svg + resources/countries/gr.svg + resources/countries/gs.svg + resources/countries/gt.svg + resources/countries/gu.svg + resources/countries/gw.svg + resources/countries/gy.svg + resources/countries/hk.svg + resources/countries/hm.svg + resources/countries/hn.svg + resources/countries/hr.svg + resources/countries/ht.svg + resources/countries/hu.svg + resources/countries/id.svg + resources/countries/ie.svg + resources/countries/il.svg + resources/countries/im.svg + resources/countries/in.svg + resources/countries/io.svg + resources/countries/iq.svg + resources/countries/ir.svg + resources/countries/is.svg + resources/countries/it.svg + resources/countries/je.svg + resources/countries/jm.svg + resources/countries/jo.svg + resources/countries/jp.svg + resources/countries/ke.svg + resources/countries/kg.svg + resources/countries/kh.svg + resources/countries/ki.svg + resources/countries/km.svg + resources/countries/kn.svg + resources/countries/kp.svg + resources/countries/kr.svg + resources/countries/kw.svg + resources/countries/ky.svg + resources/countries/kz.svg + resources/countries/la.svg + resources/countries/lb.svg + resources/countries/lc.svg + resources/countries/li.svg + resources/countries/lk.svg + resources/countries/lr.svg + resources/countries/ls.svg + resources/countries/lt.svg + resources/countries/lu.svg + resources/countries/lv.svg + resources/countries/ly.svg + resources/countries/ma.svg + resources/countries/mc.svg + resources/countries/md.svg + resources/countries/me.svg + resources/countries/mf.svg + resources/countries/mg.svg + resources/countries/mh.svg + resources/countries/mk.svg + resources/countries/ml.svg + resources/countries/mm.svg + resources/countries/mn.svg + resources/countries/mo.svg + resources/countries/mp.svg + resources/countries/mq.svg + resources/countries/mr.svg + resources/countries/ms.svg + resources/countries/mt.svg + resources/countries/mu.svg + resources/countries/mv.svg + resources/countries/mw.svg + resources/countries/mx.svg + resources/countries/my.svg + resources/countries/mz.svg + resources/countries/na.svg + resources/countries/nc.svg + resources/countries/ne.svg + resources/countries/nf.svg + resources/countries/ng.svg + resources/countries/ni.svg + resources/countries/nl.svg + resources/countries/no.svg + resources/countries/np.svg + resources/countries/nr.svg + resources/countries/nu.svg + resources/countries/nz.svg + resources/countries/om.svg + resources/countries/pa.svg + resources/countries/pe.svg + resources/countries/pf.svg + resources/countries/pg.svg + resources/countries/ph.svg + resources/countries/pk.svg + resources/countries/pl.svg + resources/countries/pm.svg + resources/countries/pn.svg + resources/countries/pr.svg + resources/countries/ps.svg + resources/countries/pt.svg + resources/countries/pw.svg + resources/countries/py.svg + resources/countries/qa.svg + resources/countries/re.svg + resources/countries/ro.svg + resources/countries/rs.svg + resources/countries/ru.svg + resources/countries/rw.svg + resources/countries/sa.svg + resources/countries/sb.svg + resources/countries/sc.svg + resources/countries/sd.svg + resources/countries/se.svg + resources/countries/sg.svg + resources/countries/sh.svg + resources/countries/si.svg + resources/countries/sj.svg + resources/countries/sk.svg + resources/countries/sl.svg + resources/countries/sm.svg + resources/countries/sn.svg + resources/countries/so.svg + resources/countries/sr.svg + resources/countries/ss.svg + resources/countries/st.svg + resources/countries/sv.svg + resources/countries/sx.svg + resources/countries/sy.svg + resources/countries/sz.svg + resources/countries/tc.svg + resources/countries/td.svg + resources/countries/tf.svg + resources/countries/tg.svg + resources/countries/th.svg + resources/countries/tj.svg + resources/countries/tk.svg + resources/countries/tl.svg + resources/countries/tm.svg + resources/countries/tn.svg + resources/countries/to.svg + resources/countries/tr.svg + resources/countries/tt.svg + resources/countries/tv.svg + resources/countries/tw.svg + resources/countries/tz.svg + resources/countries/ua.svg + resources/countries/ug.svg + resources/countries/um.svg + resources/countries/us.svg + resources/countries/uy.svg + resources/countries/uz.svg + resources/countries/va.svg + resources/countries/vc.svg + resources/countries/ve.svg + resources/countries/vg.svg + resources/countries/vi.svg + resources/countries/vn.svg + resources/countries/vu.svg + resources/countries/wf.svg + resources/countries/ws.svg + resources/countries/ye.svg + resources/countries/yt.svg + 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/userlevels/normal.svg + resources/userlevels/registered.svg + resources/userlevels/registered_buddy.svg + resources/userlevels/moderator.svg + 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_shorcuts.svg b/cockatrice/resources/icon_config_shorcuts.svg new file mode 100644 index 00000000..d52858cb --- /dev/null +++ b/cockatrice/resources/icon_config_shorcuts.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/cockatrice/src/abstractcounter.cpp b/cockatrice/src/abstractcounter.cpp index 3eb7ae0b..73fc81cb 100644 --- a/cockatrice/src/abstractcounter.cpp +++ b/cockatrice/src/abstractcounter.cpp @@ -67,15 +67,15 @@ void AbstractCounter::setShortcutsActive() { if (name == "life") { aSet->setShortcuts(settingsCache->shortcuts().getShortcut( - "AbstractCounter/aSet", + "Player/aSet", QKeySequence("Ctrl+L"))); aDec->setShortcuts(settingsCache->shortcuts().getShortcut( - "AbstractCounter/aDec", + "Player/aDec", QKeySequence("F11"))); aInc->setShortcuts(settingsCache->shortcuts().getShortcut( - "AbstractCounter/aInc", + "Player/aInc", QKeySequence("F12"))); } } diff --git a/cockatrice/src/dlg_settings.cpp b/cockatrice/src/dlg_settings.cpp index 02e84457..0ea5b5b6 100644 --- a/cockatrice/src/dlg_settings.cpp +++ b/cockatrice/src/dlg_settings.cpp @@ -28,6 +28,7 @@ #include "settingscache.h" #include "priceupdater.h" #include "soundengine.h" +#include "sequenceEdit/shortcutstab.h" #define LINKING_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Custom-Download-URLs" @@ -858,6 +859,7 @@ DlgSettings::DlgSettings(QWidget *parent) pagesWidget->addWidget(new DeckEditorSettingsPage); pagesWidget->addWidget(new MessagesSettingsPage); pagesWidget->addWidget(new SoundSettingsPage); + pagesWidget->addWidget(new ShortcutsTab); createIcons(); contentsWidget->setCurrentRow(0); @@ -912,6 +914,11 @@ void DlgSettings::createIcons() soundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); soundButton->setIcon(QIcon(":/resources/icon_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")); + connect(contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem *))); } @@ -1021,6 +1028,7 @@ void DlgSettings::retranslateUi() deckEditorButton->setText(tr("Deck Editor")); messagesButton->setText(tr("Chat")); soundButton->setText(tr("Sound")); + shortcutsButton->setText(tr("Shortcuts")); for (int i = 0; i < pagesWidget->count(); i++) dynamic_cast(pagesWidget->widget(i))->retranslateUi(); diff --git a/cockatrice/src/dlg_settings.h b/cockatrice/src/dlg_settings.h index e3c8b158..d95ce606 100644 --- a/cockatrice/src/dlg_settings.h +++ b/cockatrice/src/dlg_settings.h @@ -223,6 +223,7 @@ private: QListWidget *contentsWidget; QStackedWidget *pagesWidget; QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *messagesButton, *soundButton; + QListWidgetItem *shortcutsButton; void createIcons(); void retranslateUi(); protected: diff --git a/cockatrice/src/gameview.cpp b/cockatrice/src/gameview.cpp index 9eb2942e..b6495e34 100644 --- a/cockatrice/src/gameview.cpp +++ b/cockatrice/src/gameview.cpp @@ -21,7 +21,7 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent) aCloseMostRecentZoneView = new QAction(this); aCloseMostRecentZoneView->setShortcuts(settingsCache->shortcuts().getShortcut( - "GameView/aCloseMostRecentZoneView", + "Player/aCloseMostRecentZoneView", QKeySequence("Esc"))); connect(aCloseMostRecentZoneView, SIGNAL(triggered()), scene, SLOT(closeMostRecentZoneView())); addAction(aCloseMostRecentZoneView); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index f247f056..1db94781 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -616,6 +616,7 @@ void Player::retranslateUi() { aViewGraveyard->setText(tr("&View graveyard")); aViewRfg->setText(tr("&View exile")); + playerMenu->setTitle(tr("Player \"%1\"").arg(QString::fromStdString(userInfo->name()))); graveMenu->setTitle(tr("&Graveyard")); rfgMenu->setTitle(tr("&Exile")); @@ -682,14 +683,32 @@ void Player::retranslateUi() } aPlay->setText(tr("&Play")); + aPlay->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aPlay", QKeySequence())); + aHide->setText(tr("&Hide")); aPlayFacedown->setText(tr("Play &Face Down")); aTap->setText(tr("&Tap")); + aTap->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aTap", QKeySequence())); + aUntap->setText(tr("&Untap")); + aUntap->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aUntap", QKeySequence())); + aDoesntUntap->setText(tr("Toggle &normal untapping")); + aDoesntUntap->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aDoesntUntap", QKeySequence())); + aFlip->setText(tr("&Flip")); + aFlip->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aFlip", QKeySequence())); + aPeek->setText(tr("&Peek at card face")); + aPeek->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aPeek", QKeySequence())); + aClone->setText(tr("&Clone")); aClone->setShortcuts(settingsCache->shortcuts().getShortcut( "Player/aClone", QKeySequence("Ctrl+J"))); @@ -699,7 +718,12 @@ void Player::retranslateUi() "Player/aAttach", QKeySequence("Ctrl+A"))); aUnattach->setText(tr("Unattac&h")); + aUnattach->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aUnattach", QKeySequence())); + aDrawArrow->setText(tr("&Draw arrow...")); + aDrawArrow->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aDrawArrow", QKeySequence())); aIncP->setText(tr("&Increase power")); aIncP->setShortcuts(settingsCache->shortcuts().getShortcut( @@ -730,24 +754,71 @@ void Player::retranslateUi() "Player/aSetPT", QKeySequence("Ctrl+P"))); aSetAnnotation->setText(tr("&Set annotation...")); + aSetAnnotation->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aSetAnnotation", QKeySequence())); + QStringList counterColors; counterColors.append(tr("Red")); counterColors.append(tr("Yellow")); counterColors.append(tr("Green")); - for (int i = 0; i < aAddCounter.size(); ++i) + + QList addCCShortCuts; + addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aCCRed", QKeySequence())); + addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aCCYellow", QKeySequence())); + addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aCCGreen", QKeySequence())); + + QList removeCCShortCuts; + removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aRCRed", QKeySequence())); + removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aRCYellow", QKeySequence())); + removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aRCGreen", QKeySequence())); + + QList setCCShortCuts; + setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aSCRed", QKeySequence())); + setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aSCYellow", QKeySequence())); + setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut( + "Player/aSCGreen", QKeySequence())); + + for (int i = 0; i < aAddCounter.size(); ++i){ aAddCounter[i]->setText(tr("&Add counter (%1)").arg(counterColors[i])); - for (int i = 0; i < aRemoveCounter.size(); ++i) + aAddCounter[i]->setShortcut(addCCShortCuts[i]); + } + for (int i = 0; i < aRemoveCounter.size(); ++i){ aRemoveCounter[i]->setText(tr("&Remove counter (%1)").arg(counterColors[i])); - for (int i = 0; i < aSetCounter.size(); ++i) + aRemoveCounter[i]->setShortcut(removeCCShortCuts[i]); + } + for (int i = 0; i < aSetCounter.size(); ++i){ aSetCounter[i]->setText(tr("&Set counters (%1)...").arg(counterColors[i])); + aSetCounter[i]->setShortcut(setCCShortCuts[i]); + } + aMoveToTopLibrary->setText(tr("&Top of library")); + aMoveToTopLibrary->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aMoveToTopLibrary", QKeySequence())); + aMoveToBottomLibrary->setText(tr("&Bottom of library")); + aMoveToBottomLibrary->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aMoveToBottomLibrary", QKeySequence())); + aMoveToHand->setText(tr("&Hand")); + aMoveToHand->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aMoveToHand", QKeySequence())); + aMoveToGraveyard->setText(tr("&Graveyard")); aMoveToGraveyard->setShortcuts(settingsCache->shortcuts().getShortcut( "Player/aMoveToGraveyard", QKeySequence("Ctrl+Del"))); + aMoveToExile->setText(tr("&Exile")); - + aMoveToExile->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aMoveToExile", QKeySequence())); + QMapIterator zoneIterator(zones); while (zoneIterator.hasNext()) zoneIterator.next().value()->retranslateUi(); @@ -769,6 +840,9 @@ void Player::setShortcutsActive() aViewGraveyard->setShortcuts(settingsCache->shortcuts().getShortcut( "Player/aViewGraveyard", QKeySequence("F4"))); + aViewRfg->setShortcuts(settingsCache->shortcuts().getShortcut( + "Player/aViewRfg", QKeySequence())); + aDrawCard->setShortcuts(settingsCache->shortcuts().getShortcut( "Player/aDrawCard", QKeySequence("Ctrl+D"))); @@ -838,14 +912,11 @@ void Player::initSayMenu() QSettings settings; settings.beginGroup("messages"); int count = settings.value("count", 0).toInt(); - QString base = settingsCache->shortcuts().getSingleShortcut( - "Player/say", QKeySequence("Ctrl")).toString(); - base = base.append("+"); for (int i = 0; i < count; i++) { QAction *newAction = new QAction(settings.value(QString("msg%1").arg(i)).toString(), this); if (i <= 10){ - newAction->setShortcut(QKeySequence(base + QString::number((i + 1) % 10))); + newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10))); } connect(newAction, SIGNAL(triggered()), this, SLOT(actSayMessage())); sayMenu->addAction(newAction); @@ -861,10 +932,6 @@ void Player::setDeck(const DeckLoader &_deck) predefinedTokens.clear(); InnerDecklistNode *tokenZone = dynamic_cast(deck->getRoot()->findChild("tokens")); - QString base = settingsCache->shortcuts().getSingleShortcut( - "Player/token", QKeySequence("Alt")).toString(); - base = base.append("+"); - if (tokenZone) for (int i = 0; i < tokenZone->size(); ++i) { const QString tokenName = tokenZone->at(i)->getName(); @@ -872,7 +939,7 @@ void Player::setDeck(const DeckLoader &_deck) QAction *a = createPredefinedTokenMenu->addAction(tokenName); if (i < 10) { - a->setShortcut(QKeySequence(base + QString::number((i + 1) % 10))); + a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10))); } connect(a, SIGNAL(triggered()), this, SLOT(actCreatePredefinedToken())); } diff --git a/cockatrice/src/sequenceEdit/secuenceedit.cpp b/cockatrice/src/sequenceEdit/secuenceedit.cpp new file mode 100644 index 00000000..dc8721ec --- /dev/null +++ b/cockatrice/src/sequenceEdit/secuenceedit.cpp @@ -0,0 +1,150 @@ +#include "secuenceedit.h" +#include "../settingscache.h" +#include +#include +#include +#include +#include +#include + +SecuenceEdit::SecuenceEdit(QString name, QWidget *parent) : QWidget(parent) +{ + this->shorcutName = name; + currentKey = 0; + maxKeys = 4; + keys = 0; + valid = false; + + lineEdit = new QLineEdit(this); + clearButton = new QPushButton("", this); + defaultButton = new QPushButton("", this); + + lineEdit->setMinimumWidth(100); + clearButton->setMaximumWidth(lineEdit->height()); + defaultButton->setMaximumWidth(lineEdit->height()); + + clearButton->setIcon(QIcon(":/resources/icon_clearsearch.svg")); + defaultButton->setIcon(QIcon(":/resources/icon_update.png")); + + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setContentsMargins(0,0,0,0); + layout->setSpacing(0); + layout->addWidget(lineEdit); + layout->addWidget(clearButton); + layout->addWidget(defaultButton); + + connect(clearButton,SIGNAL(clicked()),this,SLOT(removeLastShortcut())); + connect(defaultButton,SIGNAL(clicked()),this,SLOT(restoreDefault())); + lineEdit->installEventFilter(this); + + lineEdit->setText(settingsCache->shortcuts().getShortcutString(name)); +} + +QString SecuenceEdit::getSecuence() +{ + return lineEdit->text(); +} + +void SecuenceEdit::removeLastShortcut() +{ + QString secuences = lineEdit->text(); + if(!secuences.isEmpty()) + { + if(secuences.lastIndexOf(";") > 0){ + QString valid = secuences.left(secuences.lastIndexOf(";")); + lineEdit->setText(valid); + } + else + lineEdit->clear(); + updateSettings(); + } +} + +void SecuenceEdit::restoreDefault() +{ + lineEdit->setText(settingsCache->shortcuts().getDefaultShortcutString(shorcutName)); + updateSettings(); +} + +bool SecuenceEdit::eventFilter(QObject *, QEvent * event) +{ + if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) + { + QKeyEvent * keyEvent = (QKeyEvent *) event; + + if(event->type() == QEvent::KeyPress && !keyEvent->isAutoRepeat()) + processKey(keyEvent); + else if (event->type() == QEvent::KeyRelease && !keyEvent->isAutoRepeat()) + finishShortcut(); + return true; + } + return false; +} + +void SecuenceEdit::processKey(QKeyEvent* e) +{ + int key = e->key(); + if(key != Qt::Key_Control && key != Qt::Key_Shift + && key != Qt::Key_Meta && key != Qt::Key_Alt) + { + valid = true; + key |= translateModifiers(e->modifiers(), e->text()); + } + keys = key; + currentKey++; + if(currentKey >= key) + finishShortcut(); +} + +int SecuenceEdit::translateModifiers(Qt::KeyboardModifiers state, const QString &text) +{ + int result = 0; + // The shift modifier only counts when it is not used to type a symbol + // that is only reachable using the shift key anyway + if ((state & Qt::ShiftModifier) && (text.isEmpty() || + !text.at(0).isPrint() || + text.at(0).isLetterOrNumber() || + text.at(0).isSpace())) + result |= Qt::SHIFT; + + if (state & Qt::ControlModifier) + result |= Qt::CTRL; + if (state & Qt::MetaModifier) + result |= Qt::META; + if (state & Qt::AltModifier) + result |= Qt::ALT; + return result; +} + +void SecuenceEdit::finishShortcut() +{ + QKeySequence secuence(keys); + if(!secuence.isEmpty() && valid) + { + QString secuenceString = secuence.toString(); + if(settingsCache->shortcuts().isValid(shorcutName,secuenceString)) + { + if(!lineEdit->text().isEmpty()) + { + if(lineEdit->text().contains(secuenceString)) + return; + lineEdit->setText(lineEdit->text() + ";"); + } + lineEdit->setText(lineEdit->text() + secuenceString); + } + else + { + QToolTip::showText(lineEdit->mapToGlobal(QPoint()), tr("Shortcut already in use")); + } + } + currentKey = 0; + keys = 0; + valid = false; + updateSettings(); +} + +void SecuenceEdit::updateSettings() +{ + settingsCache->shortcuts().setShortcuts(shorcutName,lineEdit->text()); +} + diff --git a/cockatrice/src/sequenceEdit/secuenceedit.h b/cockatrice/src/sequenceEdit/secuenceedit.h new file mode 100644 index 00000000..eef971fb --- /dev/null +++ b/cockatrice/src/sequenceEdit/secuenceedit.h @@ -0,0 +1,40 @@ +#ifndef SECUENCEEDIT_H +#define SECUENCEEDIT_H + +#include +#include + +class QLineEdit; +class QPushButton; +class QEvent; + +class SecuenceEdit : public QWidget +{ + Q_OBJECT +public: + SecuenceEdit(QString shorcutName, QWidget *parent = 0); + QString getSecuence(); +signals: + +private slots: + void removeLastShortcut(); + void restoreDefault(); +protected: + bool eventFilter(QObject *, QEvent *event); +private: + QString shorcutName; + QLineEdit *lineEdit; + QPushButton *clearButton; + QPushButton *defaultButton; + int keys; + int currentKey; + int maxKeys; + bool valid; + + void processKey(QKeyEvent *e); + int translateModifiers(Qt::KeyboardModifiers state, const QString &text); + void finishShortcut(); + void updateSettings(); +}; + +#endif // SECUENCEEDIT_H diff --git a/cockatrice/src/sequenceEdit/shortcutstab.cpp b/cockatrice/src/sequenceEdit/shortcutstab.cpp new file mode 100644 index 00000000..b28a1466 --- /dev/null +++ b/cockatrice/src/sequenceEdit/shortcutstab.cpp @@ -0,0 +1,18 @@ +#include "shortcutstab.h" +#include "ui_shortcutstab.h" + +ShortcutsTab::ShortcutsTab() : + ui(new Ui::shortcutsTab) +{ + ui->setupUi(this); +} + +void ShortcutsTab::retranslateUi() +{ + ui->retranslateUi(this); +} + +ShortcutsTab::~ShortcutsTab() +{ + delete ui; +} diff --git a/cockatrice/src/sequenceEdit/shortcutstab.h b/cockatrice/src/sequenceEdit/shortcutstab.h new file mode 100644 index 00000000..c2e88d39 --- /dev/null +++ b/cockatrice/src/sequenceEdit/shortcutstab.h @@ -0,0 +1,25 @@ +#ifndef SHORTCUTSTAB_H +#define SHORTCUTSTAB_H + +#include + +#include "../dlg_settings.h" + +namespace Ui { +class shortcutsTab; +} + +class ShortcutsTab : public AbstractSettingsPage +{ + Q_OBJECT + +public: + ShortcutsTab(); + void retranslateUi(); + ~ShortcutsTab(); + +private: + Ui::shortcutsTab *ui; +}; + +#endif // SHORTCUTSTAB_H diff --git a/cockatrice/src/shortcutssettings.cpp b/cockatrice/src/shortcutssettings.cpp index 399f9667..38b28bad 100644 --- a/cockatrice/src/shortcutssettings.cpp +++ b/cockatrice/src/shortcutssettings.cpp @@ -1,43 +1,38 @@ #include "shortcutssettings.h" - -#include -QList ShortcutsSettings::parseSecuenceString(QString stringSecuence) -{ - QStringList secuences = stringSecuence.split(";"); - QList secuenceList; - for(QStringList::const_iterator ss = secuences.cbegin(); ss != secuences.cend(); ++ss) - { - secuenceList.append(QKeySequence(*ss, QKeySequence::PortableText)); - } - - return secuenceList; -} +#include ShortcutsSettings::ShortcutsSettings(QString settingsPath, QObject *parent) : QObject(parent) { this->settingsFilePath = settingsPath; this->settingsFilePath.append("shortcuts.ini"); + fillDefaultShorcuts(); + shortCuts = QMap >(defaultShortCuts); + + bool exists = QFile(settingsFilePath).exists(); + QSettings shortCutsFile(settingsFilePath, QSettings::IniFormat); - shortCutsFile.beginGroup("Custom"); - const QStringList customKeys = shortCutsFile.allKeys(); - for(QStringList::const_iterator it = customKeys.cbegin(); it != customKeys.cend(); ++it) - { - QString stringSecuence = shortCutsFile.value(*it).toString(); - QList secuenceList = parseSecuenceString(stringSecuence); - shortCuts.insert(*it, secuenceList); - } - shortCutsFile.endGroup(); + if(exists){ + shortCutsFile.beginGroup("Custom"); + const QStringList customKeys = shortCutsFile.allKeys(); + for(QStringList::const_iterator it = customKeys.cbegin(); it != customKeys.cend(); ++it) + { + QString stringSecuence = shortCutsFile.value(*it).toString(); + QList secuenceList = parseSecuenceString(stringSecuence); + shortCuts.insert(*it, secuenceList); + } + shortCutsFile.endGroup(); - shortCutsFile.beginGroup("Defaults"); - const QStringList defaultKeys = shortCutsFile.allKeys(); - for(QStringList::const_iterator it = defaultKeys.cbegin(); it != defaultKeys.cend(); ++it) - { - QString stringSecuence = shortCutsFile.value(*it).toString(); - QList secuenceList = parseSecuenceString(stringSecuence); - defaultShortCuts.insert(*it, secuenceList); + shortCutsFile.beginGroup("Defaults"); + const QStringList defaultKeys = shortCutsFile.allKeys(); + for(QStringList::const_iterator it = defaultKeys.cbegin(); it != defaultKeys.cend(); ++it) + { + QString stringSecuence = shortCutsFile.value(*it).toString(); + QList secuenceList = parseSecuenceString(stringSecuence); + defaultShortCuts.insert(*it, secuenceList); + } + shortCutsFile.endGroup(); } - shortCutsFile.endGroup(); } QList ShortcutsSettings::getShortcut(QString name, QList defaultShortCut) @@ -66,9 +61,14 @@ QKeySequence ShortcutsSettings::getSingleShortcut(QString name, QKeySequence def return getShortcut(name,defaultShortCut).at(0); } -QList ShortcutsSettings::getDefaultShortCut(QString name) +QString ShortcutsSettings::getDefaultShortcutString(QString name) { - return defaultShortCuts.value(name); + return stringifySecuence(defaultShortCuts.value(name)); +} + +QString ShortcutsSettings::getShortcutString(QString name) +{ + return stringifySecuence(shortCuts.value(name)); } QString ShortcutsSettings::stringifySecuence(QList secuence) const @@ -84,6 +84,18 @@ QString ShortcutsSettings::stringifySecuence(QList secuence) const return stringSecuence; } +QList ShortcutsSettings::parseSecuenceString(QString stringSecuence) +{ + QStringList secuences = stringSecuence.split(";"); + QList secuenceList; + for(QStringList::const_iterator ss = secuences.cbegin(); ss != secuences.cend(); ++ss) + { + secuenceList.append(QKeySequence(*ss, QKeySequence::PortableText)); + } + + return secuenceList; +} + void ShortcutsSettings::setShortcuts(QString name, QList secuence) { shortCuts[name] = secuence; @@ -100,3 +112,136 @@ void ShortcutsSettings::setShortcuts(QString name, QKeySequence secuence) setShortcuts(name, QList() << secuence); } +void ShortcutsSettings::setShortcuts(QString name, QString secuences) +{ + setShortcuts(name,parseSecuenceString(secuences)); +} + +bool ShortcutsSettings::isValid(QString name, QString secuences) +{ + QString checkKey = name.left(name.indexOf("/")); + + QStringList stringSecuences = secuences.split(";"); + + QList allKeys = shortCuts.keys(); + for(int i=0; i < allKeys.size(); i++){ + QString key = allKeys.at(i); + if(key.startsWith(checkKey) || key.startsWith("MainWindow") || checkKey.startsWith("MainWindow")) + { + QString storedSecuence = stringifySecuence(shortCuts.value(key)); + for(int j = 0; j < stringSecuences.size(); j++) + { + if(storedSecuence.contains(stringSecuences.at(j))) + return false; + } + } + } + return true; +} + +void ShortcutsSettings::fillDefaultShorcuts() +{ + defaultShortCuts["MainWindow/aCheckCardUpdates"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aConnect"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aDeckEditor"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aDisconnect"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aExit"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aFullScreen"] = parseSecuenceString("Ctrl+F"); + defaultShortCuts["MainWindow/aRegister"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aSettings"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aSinglePlayer"] = parseSecuenceString(""); + defaultShortCuts["MainWindow/aWatchReplay"] = parseSecuenceString(""); + + defaultShortCuts["TabDeckEditor/aAnalyzeDeck"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aClearFilterAll"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aClearFilterOne"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aClose"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aDecrement"] = parseSecuenceString("-"); + defaultShortCuts["TabDeckEditor/aEditSets"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aEditTokens"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aIncrement"] = parseSecuenceString("+"); + defaultShortCuts["TabDeckEditor/aLoadDeck"] = parseSecuenceString("Ctrl+O"); + defaultShortCuts["TabDeckEditor/aLoadDeckFromClipboard"] = parseSecuenceString("Ctrl+V"); + defaultShortCuts["TabDeckEditor/aNewDeck"] = parseSecuenceString("Ctrl+N"); + defaultShortCuts["TabDeckEditor/aOpenCustomFolder"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aPrintDeck"] = parseSecuenceString("Ctrl+P"); + defaultShortCuts["TabDeckEditor/aRemoveCard"] = parseSecuenceString("Del"); + defaultShortCuts["TabDeckEditor/aResetLayout"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aSaveDeck"] = parseSecuenceString("Ctrl+S"); + defaultShortCuts["TabDeckEditor/aSaveDeckAs"] = parseSecuenceString(""); + defaultShortCuts["TabDeckEditor/aSaveDeckToClipboard"] = parseSecuenceString("Ctrl+C"); + + defaultShortCuts["DeckViewContainer/loadLocalButton"] = parseSecuenceString("Ctrl+O"); + defaultShortCuts["DeckViewContainer/loadRemoteButton"] = parseSecuenceString("Ctrl+Alt+O"); + + defaultShortCuts["Player/aDec"] = parseSecuenceString("F11"); + defaultShortCuts["Player/aInc"] = parseSecuenceString("F12"); + defaultShortCuts["Player/aSet"] = parseSecuenceString("Ctrl+L"); + defaultShortCuts["Player/aCloseMostRecentZoneView"] = parseSecuenceString("Esc"); + defaultShortCuts["Player/IncP"] = parseSecuenceString("Ctrl++"); + defaultShortCuts["Player/aAlwaysRevealTopCard"] = parseSecuenceString("Ctrl+N"); + defaultShortCuts["Player/aAttach"] = parseSecuenceString("Ctrl+A"); + defaultShortCuts["Player/aCCGreen"] = parseSecuenceString(""); + defaultShortCuts["Player/aCCRed"] = parseSecuenceString(""); + defaultShortCuts["Player/aCCYellow"] = parseSecuenceString(""); + defaultShortCuts["Player/aClone"] = parseSecuenceString("Ctrl+J"); + defaultShortCuts["Player/aCreateAnotherToken"] = parseSecuenceString("Ctrl+G"); + defaultShortCuts["Player/aCreateToken"] = parseSecuenceString("Ctrl+T"); + defaultShortCuts["Player/aDecP"] = parseSecuenceString("Ctrl+-"); + defaultShortCuts["Player/aDecPT"] = parseSecuenceString("Ctrl+Alt+-"); + defaultShortCuts["Player/aDecT"] = parseSecuenceString("Alt+-"); + defaultShortCuts["Player/aDoesntUntap"] = parseSecuenceString(""); + defaultShortCuts["Player/aDrawArrow"] = parseSecuenceString(""); + defaultShortCuts["Player/aDrawCard"] = parseSecuenceString("Ctrl+D"); + defaultShortCuts["Player/aDrawCards"] = parseSecuenceString("Ctrl+E"); + defaultShortCuts["Player/aFlip"] = parseSecuenceString(""); + defaultShortCuts["Player/aIncPT"] = parseSecuenceString("Ctrl+Alt++"); + defaultShortCuts["Player/aIncT"] = parseSecuenceString("Alt++"); + defaultShortCuts["Player/aMoveToBottomLibrary"] = parseSecuenceString(""); + defaultShortCuts["Player/aMoveToExile"] = parseSecuenceString(""); + defaultShortCuts["Player/aMoveToGraveyard"] = parseSecuenceString("Ctrl+Del"); + defaultShortCuts["Player/aMoveToHand"] = parseSecuenceString(""); + defaultShortCuts["Player/aMoveToTopLibrary"] = parseSecuenceString(""); + defaultShortCuts["Player/aMulligan"] = parseSecuenceString("Ctrl+M"); + defaultShortCuts["Player/aPeek"] = parseSecuenceString(""); + defaultShortCuts["Player/aPlay"] = parseSecuenceString(""); + defaultShortCuts["Player/aRCGreen"] = parseSecuenceString(""); + defaultShortCuts["Player/aRCRed"] = parseSecuenceString(""); + defaultShortCuts["Player/aRCYellow"] = parseSecuenceString(""); + defaultShortCuts["Player/aRollDie"] = parseSecuenceString("Ctrl+I"); + defaultShortCuts["Player/aSCGreen"] = parseSecuenceString(""); + defaultShortCuts["Player/aSCRed"] = parseSecuenceString(""); + defaultShortCuts["Player/aSCYellow"] = parseSecuenceString(""); + defaultShortCuts["Player/aSetAnnotation"] = parseSecuenceString(""); + defaultShortCuts["Player/aSetPT"] = parseSecuenceString("Ctrl+P"); + defaultShortCuts["Player/aShuffle"] = parseSecuenceString("Ctrl+S"); + defaultShortCuts["Player/aTap"] = parseSecuenceString(""); + defaultShortCuts["Player/aUnattach"] = parseSecuenceString(""); + defaultShortCuts["Player/aUndoDraw"] = parseSecuenceString("Ctrl+Shift+D"); + defaultShortCuts["Player/aUntap"] = parseSecuenceString(""); + defaultShortCuts["Player/aUntapAll"] = parseSecuenceString("Ctrl+U"); + defaultShortCuts["Player/aViewGraveyard"] = parseSecuenceString("F4"); + defaultShortCuts["Player/aViewLibrary"] = parseSecuenceString("F3"); + defaultShortCuts["Player/aViewRfg"] = parseSecuenceString(""); + defaultShortCuts["Player/aViewSideboard"] = parseSecuenceString("Ctrl+F3"); + defaultShortCuts["Player/aViewTopCards"] = parseSecuenceString("Ctrl+W"); + defaultShortCuts["Player/aConcede"] = parseSecuenceString("F2"); + defaultShortCuts["Player/aLeaveGame"] = parseSecuenceString("Ctrl+Q"); + defaultShortCuts["Player/aNextPhase"] = parseSecuenceString("Ctrl+Space;Tab"); + defaultShortCuts["Player/aNextTurn"] = parseSecuenceString("Ctrl+Return;Ctrl+Enter"); + defaultShortCuts["Player/aRemoveLocalArrows"] = parseSecuenceString("Ctrl+R"); + defaultShortCuts["Player/aRotateViewCCW"] = parseSecuenceString("Ctrl+["); + defaultShortCuts["Player/aRotateViewCW"] = parseSecuenceString("Ctrl+]"); + defaultShortCuts["Player/phase0"] = parseSecuenceString("F5"); + defaultShortCuts["Player/phase1"] = parseSecuenceString(""); + defaultShortCuts["Player/phase10"] = parseSecuenceString("F10"); + defaultShortCuts["Player/phase2"] = parseSecuenceString("F6"); + defaultShortCuts["Player/phase3"] = parseSecuenceString("F7"); + defaultShortCuts["Player/phase4"] = parseSecuenceString("F8"); + defaultShortCuts["Player/phase5"] = parseSecuenceString(""); + defaultShortCuts["Player/phase6"] = parseSecuenceString(""); + defaultShortCuts["Player/phase7"] = parseSecuenceString(""); + defaultShortCuts["Player/phase8"] = parseSecuenceString(""); + defaultShortCuts["Player/phase9"] = parseSecuenceString("F9"); +} + diff --git a/cockatrice/src/shortcutssettings.h b/cockatrice/src/shortcutssettings.h index f0aa795d..d986e3b2 100644 --- a/cockatrice/src/shortcutssettings.h +++ b/cockatrice/src/shortcutssettings.h @@ -16,19 +16,20 @@ public: QList getShortcut(QString name, QList defaultShortCut); QList getShortcut(QString name, QKeySequence defaultShortCut); QKeySequence getSingleShortcut(QString name, QKeySequence defaultShortCut); - QList getDefaultShortCut(QString name); + + QString getDefaultShortcutString(QString name); + QString getShortcutString(QString name); void setShortcuts(QString name, QList secuence); void setShortcuts(QString name, QKeySequence secuence); + void setShortcuts(QString name, QString secuences); -signals: - -public slots: - + bool isValid(QString name, QString secuences); private: QString settingsFilePath; QMap > shortCuts; QMap > defaultShortCuts; + void fillDefaultShorcuts(); QString stringifySecuence(QList secuence) const; QList parseSecuenceString(QString stringSecuence); diff --git a/cockatrice/src/tab_deck_editor.cpp b/cockatrice/src/tab_deck_editor.cpp index ab442089..6e5f9270 100644 --- a/cockatrice/src/tab_deck_editor.cpp +++ b/cockatrice/src/tab_deck_editor.cpp @@ -254,26 +254,28 @@ void TabDeckEditor::createFiltersDock() void TabDeckEditor::createMenus() { aNewDeck = new QAction(QString(), this); + connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck())); aNewDeck->setShortcuts(settingsCache->shortcuts().getShortcut( "TabDeckEditor/aNewDeck", QKeySequence::New)); - connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck())); aLoadDeck = new QAction(QString(), this); + connect(aLoadDeck, SIGNAL(triggered()), this, SLOT(actLoadDeck())); aLoadDeck->setShortcuts(settingsCache->shortcuts().getShortcut( "TabDeckEditor/aLoadDeck", QKeySequence::Open)); - connect(aLoadDeck, SIGNAL(triggered()), this, SLOT(actLoadDeck())); aSaveDeck = new QAction(QString(), this); + connect(aSaveDeck, SIGNAL(triggered()), this, SLOT(actSaveDeck())); aSaveDeck->setShortcuts(settingsCache->shortcuts().getShortcut( "TabDeckEditor/aSaveDeck", QKeySequence::Save)); - connect(aSaveDeck, SIGNAL(triggered()), this, SLOT(actSaveDeck())); aSaveDeckAs = new QAction(QString(), this); -// aSaveDeckAs->setShortcuts(QKeySequence::SaveAs); connect(aSaveDeckAs, SIGNAL(triggered()), this, SLOT(actSaveDeckAs())); + aSaveDeckAs->setShortcuts(QKeySequence::SaveAs); + aSaveDeckAs->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aSaveDeckAs", QKeySequence())); aLoadDeckFromClipboard = new QAction(QString(), this); connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard())); @@ -288,24 +290,39 @@ void TabDeckEditor::createMenus() QKeySequence::Copy)); aPrintDeck = new QAction(QString(), this); + connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck())); aPrintDeck->setShortcuts(settingsCache->shortcuts().getShortcut( "TabDeckEditor/aPrintDeck",QKeySequence::Print)); - connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck())); aAnalyzeDeck = new QAction(QString(), this); connect(aAnalyzeDeck, SIGNAL(triggered()), this, SLOT(actAnalyzeDeck())); + aAnalyzeDeck->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aAnalyzeDeck", QKeySequence())); + aClose = new QAction(QString(), this); connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest())); + aClose->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aClose", QKeySequence())); + aOpenCustomFolder = new QAction(QString(), this); connect(aOpenCustomFolder, SIGNAL(triggered()), this, SLOT(actOpenCustomFolder())); + aOpenCustomFolder->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aOpenCustomFolder", QKeySequence())); aEditSets = new QAction(QString(), this); connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets())); + aEditSets->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aEditSets", QKeySequence())); + aEditTokens = new QAction(QString(), this); connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens())); + aEditTokens->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aEditTokens", QKeySequence())); aResetLayout = new QAction(QString(), this); connect(aResetLayout,SIGNAL(triggered()),this,SLOT(restartLayout())); + aResetLayout->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aResetLayout", QKeySequence())); deckMenu = new QMenu(this); deckMenu->addAction(aNewDeck); @@ -328,10 +345,14 @@ void TabDeckEditor::createMenus() aClearFilterAll = new QAction(QString(), this); aClearFilterAll->setIcon(QIcon(":/resources/icon_clearsearch.svg")); connect(aClearFilterAll, SIGNAL(triggered()), this, SLOT(actClearFilterAll())); + aClearFilterAll->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aClearFilterAll", QKeySequence())); aClearFilterOne = new QAction(QString(), this); aClearFilterOne->setIcon(QIcon(":/resources/decrement.svg")); connect(aClearFilterOne, SIGNAL(triggered()), this, SLOT(actClearFilterOne())); + aClearFilterOne->setShortcuts(settingsCache->shortcuts().getShortcut( + "TabDeckEditor/aClearFilterOne", QKeySequence())); dbMenu = new QMenu(this); dbMenu->addAction(aEditSets); diff --git a/cockatrice/src/tab_game.cpp b/cockatrice/src/tab_game.cpp index 83fa5420..6e64a359 100644 --- a/cockatrice/src/tab_game.cpp +++ b/cockatrice/src/tab_game.cpp @@ -473,12 +473,17 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList &_client QAction *temp = new QAction(QString(), this); connect(temp, SIGNAL(triggered()), this, SLOT(actPhaseAction())); switch (i) { - case 0: temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase0" ,QKeySequence("F5"))); break; - case 2: temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase2" ,QKeySequence("F6"))); break; - case 3: temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase3" ,QKeySequence("F7"))); break; - case 4: temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase4" ,QKeySequence("F8"))); break; - case 9: temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase9" ,QKeySequence("F9"))); break; - case 10:temp->setShortcuts(settingsCache->shortcuts().getShortcut("TabGame/phase10" ,QKeySequence("F10"))); break; + case 0: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase0" ,QKeySequence("F5"))); break; + case 1: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase1" ,QKeySequence())); break; + case 2: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase2" ,QKeySequence("F6"))); break; + case 3: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase3" ,QKeySequence("F7"))); break; + case 4: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase4" ,QKeySequence("F8"))); break; + case 5: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase5" ,QKeySequence())); break; + case 6: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase6" ,QKeySequence())); break; + case 7: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase7" ,QKeySequence())); break; + case 8: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase8" ,QKeySequence())); break; + case 9: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase9" ,QKeySequence("F9"))); break; + case 10:temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase10" ,QKeySequence("F10"))); break; default: ; } phasesMenu->addAction(temp); @@ -550,7 +555,7 @@ void TabGame::retranslateUi() if (aNextPhase) { aNextPhase->setText(tr("Next &phase")); aNextPhase->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aNextPhase", + "Player/aNextPhase", QList() << QKeySequence("Ctrl+Space") << QKeySequence("Tab"))); @@ -558,7 +563,7 @@ void TabGame::retranslateUi() if (aNextTurn) { aNextTurn->setText(tr("Next &turn")); aNextTurn->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aNextTurn", + "Player/aNextTurn", QList() << QKeySequence("Ctrl+Return") << QKeySequence("Ctrl+Enter"))); @@ -566,19 +571,19 @@ void TabGame::retranslateUi() if (aRemoveLocalArrows) { aRemoveLocalArrows->setText(tr("&Remove all local arrows")); aRemoveLocalArrows->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aRemoveLocalArrows", + "Player/aRemoveLocalArrows", QKeySequence("Ctrl+R"))); } if (aRotateViewCW) { aRotateViewCW->setText(tr("Rotate View Cl&ockwise")); aRotateViewCW->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aRotateViewCW", + "Player/aRotateViewCW", QKeySequence("Ctrl+]"))); } if (aRotateViewCCW) { aRotateViewCCW->setText(tr("Rotate View Co&unterclockwise")); aRotateViewCCW->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aRotateViewCCW", + "Player/aRotateViewCCW", QKeySequence("Ctrl+["))); } if (aGameInfo) @@ -586,19 +591,19 @@ void TabGame::retranslateUi() if (aConcede) { aConcede->setText(tr("&Concede")); aConcede->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aRotateViewCCW", + "Player/aConcede", QKeySequence("F2"))); } if (aLeaveGame) { aLeaveGame->setText(tr("&Leave game")); aLeaveGame->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aLeaveGame", + "Player/aLeaveGame", QKeySequence("Ctrl+Q"))); } if (aCloseReplay) { aCloseReplay->setText(tr("C&lose replay")); aCloseReplay->setShortcuts(settingsCache->shortcuts().getShortcut( - "TabGame/aCloseReplay", + "Player/aCloseReplay", QKeySequence("Ctrl+Q"))); } diff --git a/cockatrice/src/window_main.cpp b/cockatrice/src/window_main.cpp index 291299fe..25198109 100644 --- a/cockatrice/src/window_main.cpp +++ b/cockatrice/src/window_main.cpp @@ -453,24 +453,54 @@ void MainWindow::retranslateUi() setClientStatusTitle(); aConnect->setText(tr("&Connect...")); + aConnect->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aConnect", QKeySequence())); + aDisconnect->setText(tr("&Disconnect")); + aDisconnect->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aDisconnect", QKeySequence())); + aSinglePlayer->setText(tr("Start &local game...")); + aSinglePlayer->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aSinglePlayer", QKeySequence())); + aWatchReplay->setText(tr("&Watch replay...")); + aWatchReplay->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aWatchReplay", QKeySequence())); + aDeckEditor->setText(tr("&Deck editor")); + aDeckEditor->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aDeckEditor", QKeySequence())); + aFullScreen->setText(tr("&Full screen")); - aFullScreen->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aFullScreen", QKeySequence("Ctrl+F"))); + aFullScreen->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aFullScreen", QKeySequence("Ctrl+F"))); + aRegister->setText(tr("&Register to server...")); + aRegister->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aRegister", QKeySequence())); + aSettings->setText(tr("&Settings...")); + aSettings->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aSettings", QKeySequence())); + aExit->setText(tr("&Exit")); + aExit->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aExit", QKeySequence())); #if defined(__APPLE__) /* For OSX */ cockatriceMenu->setTitle(tr("A&ctions")); #else cockatriceMenu->setTitle(tr("&Cockatrice")); #endif + aAbout->setText(tr("&About Cockatrice")); helpMenu->setTitle(tr("&Help")); + aCheckCardUpdates->setText(tr("Check for card updates...")); + aCheckCardUpdates->setShortcuts(settingsCache->shortcuts().getShortcut( + "MainWindow/aCheckCardUpdates", + QKeySequence())); tabSupervisor->retranslateUi(); }