merged with master
This commit is contained in:
commit
5cfb034452
416 changed files with 65983 additions and 19400 deletions
12
.dockerignore
Normal file
12
.dockerignore
Normal file
|
@ -0,0 +1,12 @@
|
|||
.git/
|
||||
CONTRIBUTING.md
|
||||
Dockerfile
|
||||
TODO.md
|
||||
build/
|
||||
cockatrice/
|
||||
doc/
|
||||
oracle/
|
||||
sounds/
|
||||
travis-compile.sh
|
||||
travis-dependencies.sh
|
||||
zonebg/
|
41
Dockerfile
Normal file
41
Dockerfile
Normal file
|
@ -0,0 +1,41 @@
|
|||
FROM ubuntu:trusty
|
||||
MAINTAINER Gavin Bisesi <Daenyth@gmail.com>
|
||||
|
||||
RUN apt-get update && apt-get install -y software-properties-common
|
||||
RUN apt-add-repository ppa:ubuntu-sdk-team/ppa
|
||||
RUN apt-get update && apt-get install -y\
|
||||
cmake\
|
||||
git\
|
||||
libprotobuf-dev\
|
||||
libqt5sql5-mysql\
|
||||
libqt5svg5-dev\
|
||||
libqt5webkit5-dev\
|
||||
libsqlite3-dev\
|
||||
protobuf-compiler\
|
||||
qt5-default\
|
||||
qtbase5-dev\
|
||||
qtdeclarative5-dev\
|
||||
qtmultimedia5-dev\
|
||||
qttools5-dev-tools\
|
||||
qttools5-dev
|
||||
|
||||
ENV dir /home/servatrice/code
|
||||
WORKDIR $dir
|
||||
RUN mkdir oracle
|
||||
COPY COPYING COPYING
|
||||
COPY CMakeLists.txt CMakeLists.txt
|
||||
COPY cmake/ cmake/
|
||||
COPY common/ common/
|
||||
COPY servatrice/ servatrice/
|
||||
COPY README.md README.md
|
||||
|
||||
WORKDIR build
|
||||
RUN cmake .. -DWITH_QT4=0 -DWITH_SERVER=1 -DWITH_CLIENT=0 -DWITH_ORACLE=0 &&\
|
||||
make &&\
|
||||
make install
|
||||
|
||||
WORKDIR /home/servatrice
|
||||
|
||||
EXPOSE 4747
|
||||
|
||||
ENTRYPOINT [ "servatrice" ]
|
38
README.md
38
README.md
|
@ -1,18 +1,29 @@
|
|||
<p align='center'><img src=https://cloud.githubusercontent.com/assets/9874850/7516775/b00b8e36-f4d1-11e4-8da4-3df294d01f86.png></p>
|
||||
|
||||
---
|
||||
|
||||
**Table of Contents** [Cockatrice](#cockatrice) | [Get Involved] (#get-involved-) | [Community](#community-resources) | [Translation](#translation-status-) | [Building](#building-) | [Running](#running) | [License](#license)
|
||||
|
||||
---
|
||||
|
||||
# Cockatrice
|
||||
|
||||
Cockatrice is an open-source multiplatform software for playing card games,
|
||||
such as Magic: The Gathering, over a network. It is fully client-server based
|
||||
to prevent any kind of cheating, though it supports single-player games without
|
||||
a network interface as well. Both client and server are written in Qt, supporting both Qt4 and Qt5.
|
||||
a network interface as well. Both client and server are written in Qt, supporting both Qt4 and Qt5.<br>
|
||||
|
||||
|
||||
# Get Involved [](https://gitter.im/Cockatrice/Cockatrice)
|
||||
|
||||
Chat with the Cockatrice developers on Gitter. Come here to talk about the application, features, or just to hang out. For support regarding specific servers, please contact that server's admin or forum for support rather than asking here.
|
||||
Chat with the Cockatrice developers on Gitter. Come here to talk about the application, features, or just to hang out. For support regarding specific servers, please contact that server's admin or forum for support rather than asking here.<br>
|
||||
|
||||
|
||||
# Community Resources
|
||||
- [reddit r/Cockatrice](http://reddit.com/r/cockatrice)
|
||||
- [Woogerworks Server & Forums](http://www.woogerworks.com)
|
||||
- [Cockatrice Official Wiki](https://github.com/Cockatrice/Cockatrice/wiki)
|
||||
- [reddit r/Cockatrice](http://reddit.com/r/cockatrice)
|
||||
- [Woogerworks](http://www.woogerworks.com) / [Chickatrice] (http://www.chickatrice.net/) / [Poixen](http://www.poixen.com/) (incomplete Serverlist)<br>
|
||||
|
||||
|
||||
# Translation Status [](https://www.transifex.com/projects/p/cockatrice/)
|
||||
|
||||
|
@ -23,26 +34,25 @@ Language statistics for `Cockatrice` *(on the left)* and `Oracle` *(on the right
|
|||
|
||||
[](https://www.transifex.com/projects/p/cockatrice/resource/cockatrice/) [](https://www.transifex.com/projects/p/cockatrice/resource/oracle/)
|
||||
|
||||
Check out our [Translator FAQ](https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ) for more information!
|
||||
Check out our [Translator FAQ](https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ) for more information!<br>
|
||||
|
||||
|
||||
# Building [](https://travis-ci.org/Cockatrice/Cockatrice)
|
||||
|
||||
**Detailed installation instructions are on the Cockatrice wiki under [Installing Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Installing-Cockatrice)**
|
||||
**Detailed compiling instructions are on the Cockatrice wiki under [Compiling Cockatrice](https://github.com/Cockatrice/Cockatrice/wiki/Compiling-Cockatrice)**
|
||||
|
||||
Dependencies:
|
||||
|
||||
- [Qt](http://qt-project.org/)
|
||||
- [protobuf](http://code.google.com/p/protobuf/)
|
||||
- [CMake](http://www.cmake.org/)
|
||||
|
||||
Oracle can optionally use zlib to load zipped files:
|
||||
|
||||
- [zlib](http://www.zlib.net/)
|
||||
|
||||
The server requires an additional dependency when compiled under Qt4:
|
||||
|
||||
- [libgcrypt](http://www.gnu.org/software/libgcrypt/)
|
||||
|
||||
|
||||
To compile:
|
||||
|
||||
mkdir build
|
||||
|
@ -60,12 +70,18 @@ The following flags can be passed to `cmake`:
|
|||
- `-DCMAKE_BUILD_TYPE=Debug` Compile in debug mode. Enables extra logging output, debug symbols, and much more verbose compiler warnings.
|
||||
- `-DUPDATE_TRANSLATIONS=1` Configure `make` to update the translation .ts files for new strings in the source code. Note: Running `make clean` will remove the .ts files.
|
||||
|
||||
#### Building servatrice Docker container
|
||||
`docker build -t servatrice .`<br>
|
||||
|
||||
|
||||
# Running
|
||||
|
||||
`oracle` fetches card data
|
||||
`cockatrice` is the game client
|
||||
`servatrice` is the server
|
||||
`servatrice` is the server<br>
|
||||
|
||||
|
||||
# License
|
||||
|
||||
Cockatrice is free software, licensed under the GPLv2; see COPYING for details.
|
||||
Cockatrice is free software, licensed under the GPLv2; see COPYING for details.<br>
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ InstallDir "$PROGRAMFILES\Cockatrice"
|
|||
!insertmacro MUI_PAGE_FINISH
|
||||
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_COMPONENTS
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
!insertmacro MUI_UNPAGE_FINISH
|
||||
|
||||
|
@ -54,8 +55,10 @@ SectionEnd
|
|||
Section "Update configuration" SecUpdateConfig
|
||||
SetShellVarContext current
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "carddatabase" "$LOCALAPPDATA\Cockatrice\cards.xml"
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "tokendatabase" "$LOCALAPPDATA\Cockatrice\tokens.xml"
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "decks" "$LOCALAPPDATA\Cockatrice\decks"
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\paths" "pics" "$LOCALAPPDATA\Cockatrice\pics"
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\replays" "pics" "$LOCALAPPDATA\Cockatrice\replays"
|
||||
WriteRegStr HKCU "Software\Cockatrice\Cockatrice\sound" "path" "$INSTDIR\sounds"
|
||||
SectionEnd
|
||||
|
||||
|
@ -68,7 +71,7 @@ Section "Start menu item" SecStartMenu
|
|||
createShortCut "$SMPROGRAMS\Cockatrice\Usermanual.lnk" "$INSTDIR\Usermanual.pdf"
|
||||
SectionEnd
|
||||
|
||||
Section Uninstall
|
||||
Section "un.Application" UnSecApplication
|
||||
SetShellVarContext all
|
||||
RMDir /r "$INSTDIR\zonebg"
|
||||
RMDir /r "$INSTDIR\plugins"
|
||||
|
@ -94,9 +97,14 @@ Section Uninstall
|
|||
RMDir "$SMPROGRAMS\Cockatrice"
|
||||
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice"
|
||||
SectionEnd
|
||||
|
||||
; unselected because it is /o
|
||||
Section /o "un.Configurations, decks, cards, pics" UnSecConfiguration
|
||||
SetShellVarContext current
|
||||
DeleteRegKey HKCU "Software\Cockatrice"
|
||||
|
||||
RMDir /r "$LOCALAPPDATA\Cockatrice"
|
||||
SectionEnd
|
||||
|
||||
LangString DESC_SecApplication ${LANG_ENGLISH} "Cockatrice program files"
|
||||
|
@ -108,6 +116,14 @@ LangString DESC_SecStartMenu ${LANG_ENGLISH} "Create start menu items for Cockat
|
|||
!insertmacro MUI_DESCRIPTION_TEXT ${SecStartMenu} $(DESC_SecStartMenu)
|
||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||
|
||||
LangString DESC_UnSecApplication ${LANG_ENGLISH} "Cockatrice program files and start menu items"
|
||||
LangString DESC_UnSecConfiguration ${LANG_ENGLISH} "Configurations, decks, card database, pictures"
|
||||
!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecApplication} $(DESC_UnSecApplication)
|
||||
!insertmacro MUI_DESCRIPTION_TEXT ${UnSecConfiguration} $(DESC_UnSecConfiguration)
|
||||
!insertmacro MUI_UNFUNCTION_DESCRIPTION_END
|
||||
|
||||
|
||||
Function .onInit
|
||||
SetShellVarContext all
|
||||
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Cockatrice" "UninstallString"
|
||||
|
|
|
@ -11,7 +11,10 @@ SET(cockatrice_SOURCES
|
|||
src/dlg_filter_games.cpp
|
||||
src/dlg_connect.cpp
|
||||
src/dlg_create_token.cpp
|
||||
src/dlg_edit_avatar.cpp
|
||||
src/dlg_edit_password.cpp
|
||||
src/dlg_edit_tokens.cpp
|
||||
src/dlg_edit_user.cpp
|
||||
src/dlg_register.cpp
|
||||
src/abstractclient.cpp
|
||||
src/remoteclient.cpp
|
||||
|
@ -92,6 +95,10 @@ SET(cockatrice_SOURCES
|
|||
src/qt-json/json.cpp
|
||||
src/soundengine.cpp
|
||||
src/pending_command.cpp
|
||||
src/shortcutssettings.cpp
|
||||
src/sequenceEdit/sequenceedit.cpp
|
||||
src/sequenceEdit/shortcutstab.cpp
|
||||
src/lineeditcompleter.cpp
|
||||
${VERSION_STRING_CPP}
|
||||
)
|
||||
|
||||
|
@ -220,6 +227,8 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
|
|||
|
||||
# Build cockatrice binary and link it
|
||||
ADD_EXECUTABLE(cockatrice WIN32 MACOSX_BUNDLE ${cockatrice_SOURCES} ${cockatrice_QM} ${cockatrice_RESOURCES_RCC} ${cockatrice_MOC_SRCS})
|
||||
set_property(TARGET cockatrice PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET cockatrice PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(Qt4_FOUND)
|
||||
if(MSVC)
|
||||
|
@ -318,4 +327,4 @@ Data = Resources\")
|
|||
if(WIN32SSLRUNTIME_FOUND)
|
||||
install(FILES ${WIN32SSLRUNTIME_LIBRARIES} DESTINATION ./)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<RCC>
|
||||
<<<<<<< HEAD
|
||||
<qresource prefix="/" >
|
||||
<file>resources/back.svg</file>
|
||||
<file>resources/cockatrice.svg</file>
|
||||
|
@ -331,4 +332,333 @@
|
|||
<file>resources/userlevels/admin.svg</file>
|
||||
<file>resources/userlevels/admin_buddy.svg</file>
|
||||
</qresource>
|
||||
=======
|
||||
<qresource prefix="/">
|
||||
<file alias="back.svg">resources/back.svg</file>
|
||||
<file>resources/lock.svg</file>
|
||||
<file>resources/icon_delete.svg</file>
|
||||
<file>resources/icon_tab_changed.svg</file>
|
||||
<file>resources/icon_config_general.svg</file>
|
||||
<file>resources/icon_config_appearance.svg</file>
|
||||
<file>resources/icon_config_interface.svg</file>
|
||||
<file>resources/icon_config_messages.svg</file>
|
||||
<file>resources/icon_config_deckeditor.svg</file>
|
||||
<file>resources/icon_config_sound.svg</file>
|
||||
<file>resources/phases/icon_phase_untap.svg</file>
|
||||
<file>resources/phases/icon_phase_upkeep.svg</file>
|
||||
<file>resources/phases/icon_phase_draw.svg</file>
|
||||
<file>resources/phases/icon_phase_main1.svg</file>
|
||||
<file>resources/phases/icon_phase_combat_start.svg</file>
|
||||
<file>resources/phases/icon_phase_combat_attackers.svg</file>
|
||||
<file>resources/phases/icon_phase_combat_blockers.svg</file>
|
||||
<file>resources/phases/icon_phase_combat_damage.svg</file>
|
||||
<file>resources/phases/icon_phase_combat_end.svg</file>
|
||||
<file>resources/phases/icon_phase_main2.svg</file>
|
||||
<file>resources/phases/icon_phase_cleanup.svg</file>
|
||||
<file>resources/phases/icon_phase_nextturn.svg</file>
|
||||
<file>resources/icon_settings.svg</file>
|
||||
<file>resources/hand.svg</file>
|
||||
<file>resources/pencil.svg</file>
|
||||
<file>resources/icon_search_black.svg</file>
|
||||
<file>resources/icon_clearsearch.svg</file>
|
||||
<file>resources/icon_update.png</file>
|
||||
<file>resources/icon_view.svg</file>
|
||||
<file>resources/hr.jpg</file>
|
||||
<file alias="resources/appicon.svg">resources/cockatrice.svg</file>
|
||||
<file>resources/add_to_sideboard.svg</file>
|
||||
<file>resources/decrement.svg</file>
|
||||
<file>resources/increment.svg</file>
|
||||
<file>resources/remove_row.svg</file>
|
||||
<file>resources/arrow_left_green.svg</file>
|
||||
<file>resources/arrow_right_green.svg</file>
|
||||
<file>resources/arrow_top_green.svg</file>
|
||||
<file>resources/arrow_up_green.svg</file>
|
||||
<file>resources/arrow_down_green.svg</file>
|
||||
<file>resources/arrow_bottom_green.svg</file>
|
||||
<file>resources/icon_ready_start.svg</file>
|
||||
<file>resources/icon_not_ready_start.svg</file>
|
||||
<file>resources/icon_conceded.svg</file>
|
||||
<file>resources/icon_player.svg</file>
|
||||
<file>resources/icon_spectator.svg</file>
|
||||
<file>resources/replay_start.svg</file>
|
||||
<file>resources/replay_fastforward.svg</file>
|
||||
<file>resources/replay_pause.svg</file>
|
||||
<file>resources/genders/male.svg</file>
|
||||
<file>resources/genders/female.svg</file>
|
||||
<file>resources/genders/unknown.svg</file>
|
||||
<file>resources/countries/ad.svg</file>
|
||||
<file>resources/countries/ae.svg</file>
|
||||
<file>resources/countries/af.svg</file>
|
||||
<file>resources/countries/ag.svg</file>
|
||||
<file>resources/countries/ai.svg</file>
|
||||
<file>resources/countries/al.svg</file>
|
||||
<file>resources/countries/am.svg</file>
|
||||
<file>resources/countries/ao.svg</file>
|
||||
<file>resources/countries/aq.svg</file>
|
||||
<file>resources/countries/ar.svg</file>
|
||||
<file>resources/countries/as.svg</file>
|
||||
<file>resources/countries/at.svg</file>
|
||||
<file>resources/countries/au.svg</file>
|
||||
<file>resources/countries/aw.svg</file>
|
||||
<file>resources/countries/ax.svg</file>
|
||||
<file>resources/countries/az.svg</file>
|
||||
<file>resources/countries/ba.svg</file>
|
||||
<file>resources/countries/bb.svg</file>
|
||||
<file>resources/countries/bd.svg</file>
|
||||
<file>resources/countries/be.svg</file>
|
||||
<file>resources/countries/bf.svg</file>
|
||||
<file>resources/countries/bg.svg</file>
|
||||
<file>resources/countries/bh.svg</file>
|
||||
<file>resources/countries/bi.svg</file>
|
||||
<file>resources/countries/bj.svg</file>
|
||||
<file>resources/countries/bl.svg</file>
|
||||
<file>resources/countries/bm.svg</file>
|
||||
<file>resources/countries/bn.svg</file>
|
||||
<file>resources/countries/bo.svg</file>
|
||||
<file>resources/countries/bq.svg</file>
|
||||
<file>resources/countries/br.svg</file>
|
||||
<file>resources/countries/bs.svg</file>
|
||||
<file>resources/countries/bt.svg</file>
|
||||
<file>resources/countries/bv.svg</file>
|
||||
<file>resources/countries/bw.svg</file>
|
||||
<file>resources/countries/by.svg</file>
|
||||
<file>resources/countries/bz.svg</file>
|
||||
<file>resources/countries/ca.svg</file>
|
||||
<file>resources/countries/cc.svg</file>
|
||||
<file>resources/countries/cd.svg</file>
|
||||
<file>resources/countries/cf.svg</file>
|
||||
<file>resources/countries/cg.svg</file>
|
||||
<file>resources/countries/ch.svg</file>
|
||||
<file>resources/countries/ci.svg</file>
|
||||
<file>resources/countries/ck.svg</file>
|
||||
<file>resources/countries/cl.svg</file>
|
||||
<file>resources/countries/cm.svg</file>
|
||||
<file>resources/countries/cn.svg</file>
|
||||
<file>resources/countries/co.svg</file>
|
||||
<file>resources/countries/cr.svg</file>
|
||||
<file>resources/countries/cu.svg</file>
|
||||
<file>resources/countries/cv.svg</file>
|
||||
<file>resources/countries/cw.svg</file>
|
||||
<file>resources/countries/cx.svg</file>
|
||||
<file>resources/countries/cy.svg</file>
|
||||
<file>resources/countries/cz.svg</file>
|
||||
<file>resources/countries/de.svg</file>
|
||||
<file>resources/countries/dj.svg</file>
|
||||
<file>resources/countries/dk.svg</file>
|
||||
<file>resources/countries/dm.svg</file>
|
||||
<file>resources/countries/do.svg</file>
|
||||
<file>resources/countries/dz.svg</file>
|
||||
<file>resources/countries/ec.svg</file>
|
||||
<file>resources/countries/ee.svg</file>
|
||||
<file>resources/countries/eg.svg</file>
|
||||
<file>resources/countries/eh.svg</file>
|
||||
<file>resources/countries/er.svg</file>
|
||||
<file>resources/countries/es.svg</file>
|
||||
<file>resources/countries/et.svg</file>
|
||||
<file>resources/countries/fi.svg</file>
|
||||
<file>resources/countries/fj.svg</file>
|
||||
<file>resources/countries/fk.svg</file>
|
||||
<file>resources/countries/fm.svg</file>
|
||||
<file>resources/countries/fo.svg</file>
|
||||
<file>resources/countries/fr.svg</file>
|
||||
<file>resources/countries/ga.svg</file>
|
||||
<file>resources/countries/gb.svg</file>
|
||||
<file>resources/countries/gd.svg</file>
|
||||
<file>resources/countries/ge.svg</file>
|
||||
<file>resources/countries/gf.svg</file>
|
||||
<file>resources/countries/gg.svg</file>
|
||||
<file>resources/countries/gh.svg</file>
|
||||
<file>resources/countries/gi.svg</file>
|
||||
<file>resources/countries/gl.svg</file>
|
||||
<file>resources/countries/gm.svg</file>
|
||||
<file>resources/countries/gn.svg</file>
|
||||
<file>resources/countries/gp.svg</file>
|
||||
<file>resources/countries/gq.svg</file>
|
||||
<file>resources/countries/gr.svg</file>
|
||||
<file>resources/countries/gs.svg</file>
|
||||
<file>resources/countries/gt.svg</file>
|
||||
<file>resources/countries/gu.svg</file>
|
||||
<file>resources/countries/gw.svg</file>
|
||||
<file>resources/countries/gy.svg</file>
|
||||
<file>resources/countries/hk.svg</file>
|
||||
<file>resources/countries/hm.svg</file>
|
||||
<file>resources/countries/hn.svg</file>
|
||||
<file>resources/countries/hr.svg</file>
|
||||
<file>resources/countries/ht.svg</file>
|
||||
<file>resources/countries/hu.svg</file>
|
||||
<file>resources/countries/id.svg</file>
|
||||
<file>resources/countries/ie.svg</file>
|
||||
<file>resources/countries/il.svg</file>
|
||||
<file>resources/countries/im.svg</file>
|
||||
<file>resources/countries/in.svg</file>
|
||||
<file>resources/countries/io.svg</file>
|
||||
<file>resources/countries/iq.svg</file>
|
||||
<file>resources/countries/ir.svg</file>
|
||||
<file>resources/countries/is.svg</file>
|
||||
<file>resources/countries/it.svg</file>
|
||||
<file>resources/countries/je.svg</file>
|
||||
<file>resources/countries/jm.svg</file>
|
||||
<file>resources/countries/jo.svg</file>
|
||||
<file>resources/countries/jp.svg</file>
|
||||
<file>resources/countries/ke.svg</file>
|
||||
<file>resources/countries/kg.svg</file>
|
||||
<file>resources/countries/kh.svg</file>
|
||||
<file>resources/countries/ki.svg</file>
|
||||
<file>resources/countries/km.svg</file>
|
||||
<file>resources/countries/kn.svg</file>
|
||||
<file>resources/countries/kp.svg</file>
|
||||
<file>resources/countries/kr.svg</file>
|
||||
<file>resources/countries/kw.svg</file>
|
||||
<file>resources/countries/ky.svg</file>
|
||||
<file>resources/countries/kz.svg</file>
|
||||
<file>resources/countries/la.svg</file>
|
||||
<file>resources/countries/lb.svg</file>
|
||||
<file>resources/countries/lc.svg</file>
|
||||
<file>resources/countries/li.svg</file>
|
||||
<file>resources/countries/lk.svg</file>
|
||||
<file>resources/countries/lr.svg</file>
|
||||
<file>resources/countries/ls.svg</file>
|
||||
<file>resources/countries/lt.svg</file>
|
||||
<file>resources/countries/lu.svg</file>
|
||||
<file>resources/countries/lv.svg</file>
|
||||
<file>resources/countries/ly.svg</file>
|
||||
<file>resources/countries/ma.svg</file>
|
||||
<file>resources/countries/mc.svg</file>
|
||||
<file>resources/countries/md.svg</file>
|
||||
<file>resources/countries/me.svg</file>
|
||||
<file>resources/countries/mf.svg</file>
|
||||
<file>resources/countries/mg.svg</file>
|
||||
<file>resources/countries/mh.svg</file>
|
||||
<file>resources/countries/mk.svg</file>
|
||||
<file>resources/countries/ml.svg</file>
|
||||
<file>resources/countries/mm.svg</file>
|
||||
<file>resources/countries/mn.svg</file>
|
||||
<file>resources/countries/mo.svg</file>
|
||||
<file>resources/countries/mp.svg</file>
|
||||
<file>resources/countries/mq.svg</file>
|
||||
<file>resources/countries/mr.svg</file>
|
||||
<file>resources/countries/ms.svg</file>
|
||||
<file>resources/countries/mt.svg</file>
|
||||
<file>resources/countries/mu.svg</file>
|
||||
<file>resources/countries/mv.svg</file>
|
||||
<file>resources/countries/mw.svg</file>
|
||||
<file>resources/countries/mx.svg</file>
|
||||
<file>resources/countries/my.svg</file>
|
||||
<file>resources/countries/mz.svg</file>
|
||||
<file>resources/countries/na.svg</file>
|
||||
<file>resources/countries/nc.svg</file>
|
||||
<file>resources/countries/ne.svg</file>
|
||||
<file>resources/countries/nf.svg</file>
|
||||
<file>resources/countries/ng.svg</file>
|
||||
<file>resources/countries/ni.svg</file>
|
||||
<file>resources/countries/nl.svg</file>
|
||||
<file>resources/countries/no.svg</file>
|
||||
<file>resources/countries/np.svg</file>
|
||||
<file>resources/countries/nr.svg</file>
|
||||
<file>resources/countries/nu.svg</file>
|
||||
<file>resources/countries/nz.svg</file>
|
||||
<file>resources/countries/om.svg</file>
|
||||
<file>resources/countries/pa.svg</file>
|
||||
<file>resources/countries/pe.svg</file>
|
||||
<file>resources/countries/pf.svg</file>
|
||||
<file>resources/countries/pg.svg</file>
|
||||
<file>resources/countries/ph.svg</file>
|
||||
<file>resources/countries/pk.svg</file>
|
||||
<file>resources/countries/pl.svg</file>
|
||||
<file>resources/countries/pm.svg</file>
|
||||
<file>resources/countries/pn.svg</file>
|
||||
<file>resources/countries/pr.svg</file>
|
||||
<file>resources/countries/ps.svg</file>
|
||||
<file>resources/countries/pt.svg</file>
|
||||
<file>resources/countries/pw.svg</file>
|
||||
<file>resources/countries/py.svg</file>
|
||||
<file>resources/countries/qa.svg</file>
|
||||
<file>resources/countries/re.svg</file>
|
||||
<file>resources/countries/ro.svg</file>
|
||||
<file>resources/countries/rs.svg</file>
|
||||
<file>resources/countries/ru.svg</file>
|
||||
<file>resources/countries/rw.svg</file>
|
||||
<file>resources/countries/sa.svg</file>
|
||||
<file>resources/countries/sb.svg</file>
|
||||
<file>resources/countries/sc.svg</file>
|
||||
<file>resources/countries/sd.svg</file>
|
||||
<file>resources/countries/se.svg</file>
|
||||
<file>resources/countries/sg.svg</file>
|
||||
<file>resources/countries/sh.svg</file>
|
||||
<file>resources/countries/si.svg</file>
|
||||
<file>resources/countries/sj.svg</file>
|
||||
<file>resources/countries/sk.svg</file>
|
||||
<file>resources/countries/sl.svg</file>
|
||||
<file>resources/countries/sm.svg</file>
|
||||
<file>resources/countries/sn.svg</file>
|
||||
<file>resources/countries/so.svg</file>
|
||||
<file>resources/countries/sr.svg</file>
|
||||
<file>resources/countries/ss.svg</file>
|
||||
<file>resources/countries/st.svg</file>
|
||||
<file>resources/countries/sv.svg</file>
|
||||
<file>resources/countries/sx.svg</file>
|
||||
<file>resources/countries/sy.svg</file>
|
||||
<file>resources/countries/sz.svg</file>
|
||||
<file>resources/countries/tc.svg</file>
|
||||
<file>resources/countries/td.svg</file>
|
||||
<file>resources/countries/tf.svg</file>
|
||||
<file>resources/countries/tg.svg</file>
|
||||
<file>resources/countries/th.svg</file>
|
||||
<file>resources/countries/tj.svg</file>
|
||||
<file>resources/countries/tk.svg</file>
|
||||
<file>resources/countries/tl.svg</file>
|
||||
<file>resources/countries/tm.svg</file>
|
||||
<file>resources/countries/tn.svg</file>
|
||||
<file>resources/countries/to.svg</file>
|
||||
<file>resources/countries/tr.svg</file>
|
||||
<file>resources/countries/tt.svg</file>
|
||||
<file>resources/countries/tv.svg</file>
|
||||
<file>resources/countries/tw.svg</file>
|
||||
<file>resources/countries/tz.svg</file>
|
||||
<file>resources/countries/ua.svg</file>
|
||||
<file>resources/countries/ug.svg</file>
|
||||
<file>resources/countries/um.svg</file>
|
||||
<file>resources/countries/us.svg</file>
|
||||
<file>resources/countries/uy.svg</file>
|
||||
<file>resources/countries/uz.svg</file>
|
||||
<file>resources/countries/va.svg</file>
|
||||
<file>resources/countries/vc.svg</file>
|
||||
<file>resources/countries/ve.svg</file>
|
||||
<file>resources/countries/vg.svg</file>
|
||||
<file>resources/countries/vi.svg</file>
|
||||
<file>resources/countries/vn.svg</file>
|
||||
<file>resources/countries/vu.svg</file>
|
||||
<file>resources/countries/wf.svg</file>
|
||||
<file>resources/countries/ws.svg</file>
|
||||
<file>resources/countries/ye.svg</file>
|
||||
<file>resources/countries/yt.svg</file>
|
||||
<file>resources/countries/za.svg</file>
|
||||
<file>resources/countries/zm.svg</file>
|
||||
<file>resources/countries/zw.svg</file>
|
||||
<file>resources/counters/w.svg</file>
|
||||
<file>resources/counters/w_highlight.svg</file>
|
||||
<file>resources/counters/u.svg</file>
|
||||
<file>resources/counters/u_highlight.svg</file>
|
||||
<file>resources/counters/b.svg</file>
|
||||
<file>resources/counters/b_highlight.svg</file>
|
||||
<file>resources/counters/r.svg</file>
|
||||
<file>resources/counters/r_highlight.svg</file>
|
||||
<file>resources/counters/g.svg</file>
|
||||
<file>resources/counters/g_highlight.svg</file>
|
||||
<file>resources/counters/storm.svg</file>
|
||||
<file>resources/counters/storm_highlight.svg</file>
|
||||
<file>resources/counters/general.svg</file>
|
||||
<file>resources/counters/general_highlight.svg</file>
|
||||
<file>resources/userlevels/normal.svg</file>
|
||||
<file>resources/userlevels/registered.svg</file>
|
||||
<file>resources/userlevels/registered_buddy.svg</file>
|
||||
<file>resources/userlevels/moderator.svg</file>
|
||||
<file>resources/userlevels/moderator_buddy.svg</file>
|
||||
<file>resources/userlevels/admin.svg</file>
|
||||
<file>resources/userlevels/admin_buddy.svg</file>
|
||||
<file>resources/news/exclamation_mark.svg</file>
|
||||
<file>resources/news/question_mark.svg</file>
|
||||
<file>resources/icon_config_shorcuts.svg</file>
|
||||
</qresource>
|
||||
>>>>>>> master
|
||||
</RCC>
|
||||
|
|
161
cockatrice/resources/icon_config_shorcuts.svg
Normal file
161
cockatrice/resources/icon_config_shorcuts.svg
Normal file
|
@ -0,0 +1,161 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="500"
|
||||
height="500"
|
||||
id="svg2"
|
||||
version="1.1"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="icon_config_shorcuts.svg">
|
||||
<defs
|
||||
id="defs4">
|
||||
<inkscape:path-effect
|
||||
effect="bend_path"
|
||||
id="path-effect3618"
|
||||
is_visible="true"
|
||||
bendpath="m 142.49072,814.69439 c 81.91729,17.90777 153.31508,14.77655 218.89021,0"
|
||||
prop_scale="1"
|
||||
scale_y_rel="false"
|
||||
vertical="false"
|
||||
bendpath-nodetypes="cc" />
|
||||
<inkscape:perspective
|
||||
sodipodi:type="inkscape:persp3d"
|
||||
inkscape:vp_x="0 : 526.18109 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_z="744.09448 : 526.18109 : 1"
|
||||
inkscape:persp3d-origin="372.04724 : 350.78739 : 1"
|
||||
id="perspective10" />
|
||||
<inkscape:perspective
|
||||
id="perspective4226"
|
||||
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
|
||||
inkscape:vp_z="1 : 0.5 : 1"
|
||||
inkscape:vp_y="0 : 1000 : 0"
|
||||
inkscape:vp_x="0 : 0.5 : 1"
|
||||
sodipodi:type="inkscape:persp3d" />
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient6464"
|
||||
id="linearGradient6470"
|
||||
x1="32.090908"
|
||||
y1="1.8181819"
|
||||
x2="31.09091"
|
||||
y2="62.909088"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="translate(0,-0.1818182)" />
|
||||
<linearGradient
|
||||
id="linearGradient6464">
|
||||
<stop
|
||||
style="stop-color:#0061ff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6466" />
|
||||
<stop
|
||||
style="stop-color:#001c4c;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop6468" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient6482"
|
||||
id="linearGradient6488"
|
||||
x1="32.18182"
|
||||
y1="3.2835093"
|
||||
x2="32.18182"
|
||||
y2="13.02554"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.0281354,0,0,1.0429299,-0.9963584,-0.6864152)" />
|
||||
<linearGradient
|
||||
id="linearGradient6482">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop6484" />
|
||||
<stop
|
||||
style="stop-color:#00ff00;stop-opacity:0;"
|
||||
offset="1"
|
||||
id="stop6486" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
y2="13.02554"
|
||||
x2="32.18182"
|
||||
y1="3.2835093"
|
||||
x1="32.18182"
|
||||
gradientTransform="matrix(1.0281354,0,0,1.0429299,-0.9963584,-0.6864152)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
id="linearGradient4241"
|
||||
xlink:href="#linearGradient6482"
|
||||
inkscape:collect="always" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.42293617"
|
||||
inkscape:cx="401.93458"
|
||||
inkscape:cy="251.13063"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1280"
|
||||
inkscape:window-height="745"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata7">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Ebene 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-552.36218)">
|
||||
<g
|
||||
transform="matrix(7.8163235,0,0,7.8163235,-0.83292805,550.81868)"
|
||||
id="g4214">
|
||||
<rect
|
||||
ry="5.6363635"
|
||||
y="1.6363637"
|
||||
x="1.2727273"
|
||||
height="61.090908"
|
||||
width="61.636364"
|
||||
id="rect6462"
|
||||
style="fill:url(#linearGradient6470);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-opacity:1" />
|
||||
<rect
|
||||
ry="4.7325583"
|
||||
y="2.7380548"
|
||||
x="2.1926003"
|
||||
height="13.251164"
|
||||
width="59.796619"
|
||||
id="rect6472"
|
||||
style="fill:url(#linearGradient4241);fill-opacity:1;fill-rule:nonzero;stroke:none" />
|
||||
</g>
|
||||
<image
|
||||
width="330.20697"
|
||||
height="335.80368"
|
||||
preserveAspectRatio="none"
|
||||
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAAB4CAYAAAAnrQZhAAAABmJLR0QA/wD/AP+gvaeTAAALCklE QVR4nO2dbWgcZR7Af/Oyu91umlfTNtFYxabVbg4xGmkqGAiUXoViWq4UvFMOPxz4wfOoekhR6CEn fqig/eCHgyLY3kXxgzmLePZDvdpcyhlSriW2tmI0TXurl43ZtG422ezO3Ic44+xm9mWyEyedPD94 2Hl2Zp59dn77f55nXleiPCLANmAtUAtUlbmewD2mgQQwAZwBJhdbUAD4LfBPYBbQRVo2KQP8G/gD sNpenz17gG+WwRcQqXT6H/A7QLIKzMkwH6V/YT5SF6AoCqtWrUKWZbvZBZFlGVVVkWXZ8bp26Lpe cRlLUZZd2Zqmoes62Wy24s9KpVJkMplCs/8B7AOuQ65YFegFfmVduq6ujnvuuYeWlhaqq6vLroQs y2zfvp27774bVVWd1N8WYwOVSj/Hck4IhUI0NDSwbt06rl27xuDgIMPDwyXLURQFVVXNFAgEUFWV VCrF119/zeDgIFeuXMlfrR/4JZC0iv0zcMBaoW3btrFx40ZHXwSgra2NHTt2OF6vGDerWANJkmhq auKuu+7i22+/5Z133iEWi5nzDZGGwPxXu+mLFy/y1ltvMTExYf2ovwK/McT+AhhivikmEomwa9cu 1qxZ4/gLdHV10dHR4XoTd7OLNaiurqatrQ1d1+nt7WV0dLSkwPxp6+v09DQvvPACIyMj1o/ZaYg9 Bvwa5pvQ3bt3U19f77jSnZ2dPPTQQ0vSb/lFLEBVVRXt7e1omsb7779PPB4vKdCuWTZeJycn2bt3 L9evXzc+4l8KsAY4wo/RGo1G2bRpk+PK1tbWsnv37iWRCuUPcrxazgnpdJq5uTkaGxu58847icVi rF69mqqqKqqqqohEIkQiEXO60HvhcJhgMEhNTQ3BYJD+/n7jI1pUoB3LvtDmzZsXVdk9e/agaVrF X3qlEIvFuPXWW4lEIrS3tzM6Olq0Xw0EAkhS/k7MTzz66KMcOnTIGDVLKrDBmCnLMnV1dY4rGQqF qK+vX7Jo9SO6rnPt2jU2bdpES0sLyWQSRVFypBYTmU9NTQ1NTU2MjY0BIAM1xsxQKOSoMIOtW7cK qYsgHo+j6zqqqrJ+/Xqqq6sJh8Mlo7MQDQ0N5nTlRwuADRs2lF5IsIB0Os3s7CwAwWCw4vKsPwZX xK5e7ehwpcCCIVZRFFfLdUWsG0eWVipzc3MArhxqteJuaYJlgxDrU4RYnyLE+hQh1qcsq+Gspmmc Pn2agYEBhoaGiMfjfP/99yiKQm1tLa2trdx3333s3LmT5uZmr6u7rFk2Yk+cOMHrr7+ef/rJJJVK EYvF+PTTTzl8+DAPP/wwzz77LLfffvvPXNObA8/FZrNZXn31VY4ePZrzfnV1NdFo1Dx9GI/HuXTp EolEAl3XOXXqFAMDA3z88ceLOr7tdzwXe/DgQd577z0z39HRwdNPP80DDzyQs9OuaRrZbJbz58/z 9ttvc+LECebm5swdfEEung6e+vr6cqQ+9dRTHD16lAcffND2SIwsy9x7770cOnSI3t5eWlpafs7q 3lR4FrHpdJrXXnvNzPf09PDMM8+Uvf6WLVt49913XT/G6hc8E9vX18f4+DgA4XCYAwcOlFhjIZFI xLXLVfyGZ03xyZMnzeldu3Y5urRVUBpPxGqaxtDQkJnv7Oz0ohq+xhOx4+Pj3Lhxw8xHo1EvquFr PBGbSCRy8rW1tV5Uw9d4IjaZTObkI5GIF9XwNZ6IzReZL1pQOZ6IzW9685tmQeV4IraxsTHnvqDP P//ci2r4Gk/EyrLM/fffb+bPnDnjRTV8jWcHKLq7u83p48ePW28oEriAZ2J7enq45ZZbgPlzra+8 8orjMpLJpHldriAXz8QGg0Gee+45M9/X18fhw4fLXv/ChQvs27dPDLwK4Olpu56eHvbu3Wvm33zz TZ544gkGBwdt79zTNI1z587x/PPP89hjj5k3IAkWsixOtIdCIY4dOwbAZ599xuOPP05NTQ3RaNS8 OmJiYoIvvvgiJ0JDoZAr97z4Ec/FKorCiy++SEdHB2+88YZ5zdPU1BQDAwO268iyTHd3N/v376eu rk6ctrPBc7EGO3bsYPv27Zw+fZr+/n7Onj3L+Pg4iUTCvG+3tbWV9vZ2HnnkEdavXy/OxRZh2YiF +Ujs6uqiq6trwbyleBaEnxEXjPsUIdanCLE+RYj1KUKsTxFifYoQ61OEWJ8ixPoUIdanCLE+RYj1 KUKsTxFifYoQ61OEWJ8ixPoUIdanCLE+RYj1KUKsTxFifYoQ61OEWJ8ixPoUIdanCLE+RYj1KUKs TxFifYoQ61OEWJ8ixPoUIdanCLE+RYj1KUKsTxFifYorYiVJcqMYgYu4InZmZsaNYlYkoVAImP/z RjdxRewPP/zgRjErkmUtdnh42I1iVhxVVVXmQz7dbvUqFitJEpcuXRL97CIwHsS9FH+XWrFY4+9A L1++XHFlVhLBYND8m9R4PE4mk3G1/IrEyrJsplOnTokHVzrgjjvuQFEUkskkU1NTZLNZV+UuWqwk STliNU2jr69PNMll0NTURHNzM7Ozs4yMjJhSs9msa4OoRYu1SjVSIpHgk08+EXKL0NzcTGtrK8lk kosXL5JOp02pmUyGTCZj+9h8pyxKrKIotmJlWebq1at88MEHpFIpIdhCKBRiy5YtbNy4katXr3L2 7FmSyWSOVCNis9lsxd2a4wdR5zfBdml6epoPP/yQ2267jba2NtasWbMi+99AIEBNTQ21tbWEw2HG x8cZHh4mnU4TCARQVRVJknISYE6r6uKfE+5oTUmSikZrfvruu++Ix+MoioKiKKxatcocRS8li/0R uf3j03WdK1eukMlkUFXVlBkIBBYItUvAouU6WssQ5lSwIXOlHXq0dkXZbLakRGve2M7GtnZK2WKt kpxKlWV5RTbFVjRNKyk3X7Lxaoh2Qlli7fpVJ1ErmKccsdZILSS9HMoSayerXKliZJxLJpNxFKnW 5KS/LblkKXGlBIP7g5KbBV3XbX/YxeSWSuX2t0XFltq1KTVfYI+u6zlyofDAqVBzXYqiYsuNVruo FU3wPIWiVtO0HLnWbVasOZYkydxdKkZBseWOdgtFreAnCsktd5RcSG4xbMWWamJL9bH5X0pQGEMu 5EZqqea41GDKdo7TfVTrrk/+L1OSJCG3CLquF4xcKNwclxpMLRDrVGp+1NpVXFAca39bTqTmi7fb 7q6IFf1qaQr1swZWuVA6Uu1G0FZcEyuonEoGU/n9bU7OyaBJ7No4p1TUgnO5YH/BvisRK3CPYoOp Us2x9coLFbhuZGZnZx1HrcAZ5URtOWeCYOGBjMnJSbMMFRgzMtlslqmpKRobG0UT7DFOzwRNT08T i8XM9WXgLGCeAb9w4YKI1mVC/vVQ+Re9Wa+T+uijj3IuOpeBBHDceGNoaIhEIuGKVLEPa4+T7VJI rlXwxMQER44csa42aBy2+AZ4EpA1TWNkZIRoNEo4HDavV7ImEa3uUG5Xlt8vW5vjmZkZXnrpJcbG xqyr/N4Q+1+gHtgKkEqlGB4eZt26daxdu3aBWIE7OBFrLG8dPH355Ze8/PLLjIyMWBfvAw5aSw4B fwd2WJfasGEDnZ2dbN68mYaGBkcDJtEUF8fp4FNVVVKpFF999RX9/f2cP38+fxv/B+gGJvNLDgN/ A3rsCg6Hw0QikbIqIaSWhxO5MzMzxe5FHmDe23ixMp78cQFdpGWfbgB/BMruIyPAfuAcoC2DLyBS broM/AlosJNXbjuwDugC1jIvXOANKWAC6AdGiy34f92AFnOZ6uyjAAAAAElFTkSuQmCC "
|
||||
id="image4221"
|
||||
x="89.958641"
|
||||
y="628.24109" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 8.6 KiB |
|
@ -123,7 +123,7 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
} else {
|
||||
painter->save();
|
||||
transformPainter(painter, translatedSize, angle);
|
||||
painter->drawPixmap(QPointF(0, angle ? -1 : 0), translatedPixmap);
|
||||
painter->drawPixmap(QPointF(1, 1), translatedPixmap);
|
||||
painter->restore();
|
||||
}
|
||||
painter->setBrush(bgColor);
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "pb/event_server_shutdown.pb.h"
|
||||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_user_message.pb.h"
|
||||
#include "pb/event_notify_user.pb.h"
|
||||
#include "pb/event_list_rooms.pb.h"
|
||||
#include "pb/event_add_to_list.pb.h"
|
||||
#include "pb/event_remove_from_list.pb.h"
|
||||
|
@ -40,6 +41,7 @@ AbstractClient::AbstractClient(QObject *parent)
|
|||
qRegisterMetaType<Event_ListRooms>("Event_ListRooms");
|
||||
qRegisterMetaType<Event_GameJoined>("Event_GameJoined");
|
||||
qRegisterMetaType<Event_UserMessage>("Event_UserMessage");
|
||||
qRegisterMetaType<Event_NotifyUser>("Event_NotifyUser");
|
||||
qRegisterMetaType<ServerInfo_User>("ServerInfo_User");
|
||||
qRegisterMetaType<QList<ServerInfo_User> >("QList<ServerInfo_User>");
|
||||
qRegisterMetaType<Event_ReplayAdded>("Event_ReplayAdded");
|
||||
|
@ -75,6 +77,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
|
|||
case SessionEvent::SERVER_SHUTDOWN: emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext)); break;
|
||||
case SessionEvent::CONNECTION_CLOSED: emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext)); break;
|
||||
case SessionEvent::USER_MESSAGE: emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext)); break;
|
||||
case SessionEvent::NOTIFY_USER: emit notifyUserEventReceived(event.GetExtension(Event_NotifyUser::ext)); break;
|
||||
case SessionEvent::LIST_ROOMS: emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext)); break;
|
||||
case SessionEvent::ADD_TO_LIST: emit addToListEventReceived(event.GetExtension(Event_AddToList::ext)); break;
|
||||
case SessionEvent::REMOVE_FROM_LIST: emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext)); break;
|
||||
|
|
|
@ -21,6 +21,7 @@ class Event_ServerMessage;
|
|||
class Event_ListRooms;
|
||||
class Event_GameJoined;
|
||||
class Event_UserMessage;
|
||||
class Event_NotifyUser;
|
||||
class Event_ConnectionClosed;
|
||||
class Event_ServerShutdown;
|
||||
class Event_ReplayAdded;
|
||||
|
@ -56,6 +57,7 @@ signals:
|
|||
void listRoomsEventReceived(const Event_ListRooms &event);
|
||||
void gameJoinedEventReceived(const Event_GameJoined &event);
|
||||
void userMessageEventReceived(const Event_UserMessage &event);
|
||||
void notifyUserEventReceived(const Event_NotifyUser &event);
|
||||
void userInfoChanged(const ServerInfo_User &userInfo);
|
||||
void buddyListReceived(const QList<ServerInfo_User> &buddyList);
|
||||
void ignoreListReceived(const QList<ServerInfo_User> &ignoreList);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "abstractcounter.h"
|
||||
#include "player.h"
|
||||
#include "settingscache.h"
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
@ -17,6 +18,8 @@ AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name,
|
|||
setAcceptHoverEvents(true);
|
||||
#endif
|
||||
|
||||
shortcutActive = false;
|
||||
|
||||
if (player->getLocal()) {
|
||||
menu = new QMenu(name);
|
||||
aSet = new QAction(this);
|
||||
|
@ -39,6 +42,8 @@ AbstractCounter::AbstractCounter(Player *_player, int _id, const QString &_name,
|
|||
} else
|
||||
menu = 0;
|
||||
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
|
@ -65,14 +70,16 @@ void AbstractCounter::retranslateUi()
|
|||
void AbstractCounter::setShortcutsActive()
|
||||
{
|
||||
if (name == "life") {
|
||||
aSet->setShortcut(QKeySequence("Ctrl+L"));
|
||||
aDec->setShortcut(QKeySequence("F11"));
|
||||
aInc->setShortcut(QKeySequence("F12"));
|
||||
shortcutActive = true;
|
||||
aSet->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aSet"));
|
||||
aDec->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDec"));
|
||||
aInc->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aInc"));
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractCounter::setShortcutsInactive()
|
||||
{
|
||||
shortcutActive = false;
|
||||
if (name == "life") {
|
||||
aSet->setShortcut(QKeySequence());
|
||||
aDec->setShortcut(QKeySequence());
|
||||
|
@ -80,6 +87,12 @@ void AbstractCounter::setShortcutsInactive()
|
|||
}
|
||||
}
|
||||
|
||||
void AbstractCounter::refreshShortcuts()
|
||||
{
|
||||
if(shortcutActive)
|
||||
setShortcutsActive();
|
||||
}
|
||||
|
||||
void AbstractCounter::setValue(int _value)
|
||||
{
|
||||
value = _value;
|
||||
|
|
|
@ -26,6 +26,7 @@ private:
|
|||
bool dialogSemaphore, deleteAfterDialog;
|
||||
bool shownInCounterArea;
|
||||
private slots:
|
||||
void refreshShortcuts();
|
||||
void incrementCounter();
|
||||
void setCounter();
|
||||
public:
|
||||
|
@ -44,6 +45,7 @@ public:
|
|||
|
||||
void setShortcutsActive();
|
||||
void setShortcutsInactive();
|
||||
bool shortcutActive;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,15 +17,7 @@ void AbstractGraphicsItem::paintNumberEllipse(int number, int fontSize, const QC
|
|||
w = h;
|
||||
|
||||
painter->setPen(QColor(255, 255, 255, 0));
|
||||
QRadialGradient grad(QPointF(0.5, 0.5), 0.5);
|
||||
grad.setCoordinateMode(QGradient::ObjectBoundingMode);
|
||||
QColor color1(color), color2(color);
|
||||
color1.setAlpha(255);
|
||||
color2.setAlpha(0);
|
||||
grad.setColorAt(0, color1);
|
||||
grad.setColorAt(0.8, color1);
|
||||
grad.setColorAt(1, color2);
|
||||
painter->setBrush(QBrush(grad));
|
||||
painter->setBrush(QBrush(QColor(color)));
|
||||
|
||||
QRectF textRect;
|
||||
if (position == -1)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "carddatabase.h"
|
||||
#include "settingscache.h"
|
||||
#include "thememanager.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
#include <QDir>
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
|
@ -92,7 +94,7 @@ void CardSet::setIsKnown(bool _isknown)
|
|||
settings.setValue("isknown", isknown);
|
||||
}
|
||||
|
||||
class SetList::CompareFunctor {
|
||||
class SetList::KeyCompareFunctor {
|
||||
public:
|
||||
inline bool operator()(CardSet *a, CardSet *b) const
|
||||
{
|
||||
|
@ -102,7 +104,39 @@ public:
|
|||
|
||||
void SetList::sortByKey()
|
||||
{
|
||||
qSort(begin(), end(), CompareFunctor());
|
||||
qSort(begin(), end(), KeyCompareFunctor());
|
||||
}
|
||||
|
||||
class SetList::EnabledAndKeyCompareFunctor {
|
||||
public:
|
||||
inline bool operator()(CardSet *a, CardSet *b) const
|
||||
{
|
||||
if(a->getEnabled())
|
||||
{
|
||||
if(b->getEnabled())
|
||||
{
|
||||
// both enabled: sort by key
|
||||
return a->getSortKey() < b->getSortKey();
|
||||
} else {
|
||||
// only a enabled
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if(b->getEnabled())
|
||||
{
|
||||
// only b enabled
|
||||
return false;
|
||||
} else {
|
||||
// both disabled: sort by key
|
||||
return a->getSortKey() < b->getSortKey();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void SetList::sortByEnabledAndKey()
|
||||
{
|
||||
qSort(begin(), end(), EnabledAndKeyCompareFunctor());
|
||||
}
|
||||
|
||||
int SetList::getEnabledSetsNum()
|
||||
|
@ -185,7 +219,7 @@ PictureToLoad::PictureToLoad(CardInfo *_card, bool _hq)
|
|||
{
|
||||
if (card) {
|
||||
sortedSets = card->getSets();
|
||||
sortedSets.sortByKey();
|
||||
sortedSets.sortByEnabledAndKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,6 +247,9 @@ CardSet *PictureToLoad::getCurrentSet() const
|
|||
return 0;
|
||||
}
|
||||
|
||||
QStringList PictureLoader::md5Blacklist = QStringList()
|
||||
<< "db0c48db407a907c16ade38de048a441"; // card back returned by gatherer when card is not found
|
||||
|
||||
PictureLoader::PictureLoader(const QString &__picsPath, bool _picDownload, bool _picDownloadHq, QObject *parent)
|
||||
: QObject(parent),
|
||||
_picsPath(__picsPath), picDownload(_picDownload), picDownloadHq(_picDownloadHq),
|
||||
|
@ -338,16 +375,26 @@ QString PictureLoader::getPicUrl()
|
|||
picUrl = picDownloadHq ? settingsCache->getPicUrlHqFallback() : settingsCache->getPicUrlFallback();
|
||||
|
||||
picUrl.replace("!name!", QUrl::toPercentEncoding(card->getCorrectedName()));
|
||||
picUrl.replace("!name_lower!", QUrl::toPercentEncoding(card->getCorrectedName().toLower()));
|
||||
picUrl.replace("!cardid!", QUrl::toPercentEncoding(QString::number(muid)));
|
||||
if (set) {
|
||||
if (set)
|
||||
{
|
||||
picUrl.replace("!setcode!", QUrl::toPercentEncoding(set->getShortName()));
|
||||
picUrl.replace("!setcode_lower!", QUrl::toPercentEncoding(set->getShortName().toLower()));
|
||||
picUrl.replace("!setname!", QUrl::toPercentEncoding(set->getLongName()));
|
||||
picUrl.replace("!setname_lower!", QUrl::toPercentEncoding(set->getLongName().toLower()));
|
||||
}
|
||||
|
||||
if (picUrl.contains("!name!") ||
|
||||
picUrl.contains("!setcode!") ||
|
||||
picUrl.contains("!setname!") ||
|
||||
picUrl.contains("!cardid!")) {
|
||||
if (
|
||||
picUrl.contains("!name!") ||
|
||||
picUrl.contains("!name_lower!") ||
|
||||
picUrl.contains("!setcode!") ||
|
||||
picUrl.contains("!setcode_lower!") ||
|
||||
picUrl.contains("!setname!") ||
|
||||
picUrl.contains("!setname_lower!") ||
|
||||
picUrl.contains("!cardid!")
|
||||
)
|
||||
{
|
||||
qDebug() << "Insufficient card data to download" << card->getName() << "Url:" << picUrl;
|
||||
return QString("");
|
||||
}
|
||||
|
@ -403,7 +450,28 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
|||
qDebug() << "Download failed:" << reply->errorString();
|
||||
}
|
||||
|
||||
int statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||
if (statusCode == 301 || statusCode == 302) {
|
||||
QUrl redirectUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
QNetworkRequest req(redirectUrl);
|
||||
qDebug() << "following redirect:" << cardBeingDownloaded.getCard()->getName() << "Url:" << req.url();
|
||||
networkManager->get(req);
|
||||
return;
|
||||
}
|
||||
|
||||
const QByteArray &picData = reply->peek(reply->size()); //peek is used to keep the data in the buffer for use by QImageReader
|
||||
|
||||
// check if the image is blacklisted
|
||||
QString md5sum = QCryptographicHash::hash(picData, QCryptographicHash::Md5).toHex();
|
||||
if(md5Blacklist.contains(md5sum))
|
||||
{
|
||||
qDebug() << "Picture downloaded, but blacklisted (" << md5sum << "), will consider it as not found";
|
||||
picDownloadFailed();
|
||||
reply->deleteLater();
|
||||
startNextPicDownload();
|
||||
return;
|
||||
}
|
||||
|
||||
QImage testImage;
|
||||
|
||||
QImageReader imgReader;
|
||||
|
@ -483,13 +551,16 @@ CardInfo::CardInfo(CardDatabase *_db,
|
|||
const QString &_powtough,
|
||||
const QString &_text,
|
||||
const QStringList &_colors,
|
||||
const QStringList &_relatedCards,
|
||||
bool _upsideDownArt,
|
||||
int _loyalty,
|
||||
bool _cipt,
|
||||
int _tableRow,
|
||||
const SetList &_sets,
|
||||
const QStringMap &_customPicURLs,
|
||||
const QStringMap &_customPicURLsHq,
|
||||
MuidMap _muIds)
|
||||
MuidMap _muIds
|
||||
)
|
||||
: db(_db),
|
||||
name(_name),
|
||||
isToken(_isToken),
|
||||
|
@ -500,6 +571,8 @@ CardInfo::CardInfo(CardDatabase *_db,
|
|||
powtough(_powtough),
|
||||
text(_text),
|
||||
colors(_colors),
|
||||
relatedCards(_relatedCards),
|
||||
upsideDownArt(_upsideDownArt),
|
||||
loyalty(_loyalty),
|
||||
customPicURLs(_customPicURLs),
|
||||
customPicURLsHq(_customPicURLsHq),
|
||||
|
@ -581,7 +654,13 @@ void CardInfo::loadPixmap(QPixmap &pixmap)
|
|||
void CardInfo::imageLoaded(const QImage &image)
|
||||
{
|
||||
if (!image.isNull()) {
|
||||
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(image));
|
||||
if(upsideDownArt)
|
||||
{
|
||||
QImage mirrorImage = image.mirrored(true, true);
|
||||
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(mirrorImage));
|
||||
} else {
|
||||
QPixmapCache::insert(pixmapCacheKey, QPixmap::fromImage(image));
|
||||
}
|
||||
emit pixmapUpdated();
|
||||
}
|
||||
}
|
||||
|
@ -686,6 +765,10 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
|||
for (int i = 0; i < colors.size(); i++)
|
||||
xml.writeTextElement("color", colors[i]);
|
||||
|
||||
const QStringList &related = info->getRelatedCards();
|
||||
for (int i = 0; i < related.size(); i++)
|
||||
xml.writeTextElement("related", related[i]);
|
||||
|
||||
xml.writeTextElement("manacost", info->getManaCost());
|
||||
xml.writeTextElement("cmc", info->getCmc());
|
||||
xml.writeTextElement("type", info->getCardType());
|
||||
|
@ -699,6 +782,8 @@ static QXmlStreamWriter &operator<<(QXmlStreamWriter &xml, const CardInfo *info)
|
|||
xml.writeTextElement("cipt", "1");
|
||||
if (info->getIsToken())
|
||||
xml.writeTextElement("token", "1");
|
||||
if (info->getUpsideDownArt())
|
||||
xml.writeTextElement("upsidedown", "1");
|
||||
xml.writeEndElement(); // card
|
||||
|
||||
return xml;
|
||||
|
@ -815,6 +900,8 @@ void CardDatabase::clearPixmapCache()
|
|||
}
|
||||
if (noCard)
|
||||
noCard->clearPixmapCache();
|
||||
|
||||
QPixmapCache::clear();
|
||||
}
|
||||
|
||||
void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||
|
@ -853,7 +940,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
|||
break;
|
||||
if (xml.name() == "card") {
|
||||
QString name, manacost, cmc, type, pt, text;
|
||||
QStringList colors;
|
||||
QStringList colors, relatedCards;
|
||||
QStringMap customPicURLs, customPicURLsHq;
|
||||
MuidMap muids;
|
||||
SetList sets;
|
||||
|
@ -861,6 +948,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
|||
int loyalty = 0;
|
||||
bool cipt = false;
|
||||
bool isToken = false;
|
||||
bool upsideDown = false;
|
||||
while (!xml.atEnd()) {
|
||||
if (xml.readNext() == QXmlStreamReader::EndElement)
|
||||
break;
|
||||
|
@ -891,10 +979,14 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
|||
}
|
||||
} else if (xml.name() == "color")
|
||||
colors << xml.readElementText();
|
||||
else if (xml.name() == "related")
|
||||
relatedCards << xml.readElementText();
|
||||
else if (xml.name() == "tablerow")
|
||||
tableRow = xml.readElementText().toInt();
|
||||
else if (xml.name() == "cipt")
|
||||
cipt = (xml.readElementText() == "1");
|
||||
else if (xml.name() == "upsidedown")
|
||||
upsideDown = (xml.readElementText() == "1");
|
||||
else if (xml.name() == "loyalty")
|
||||
loyalty = xml.readElementText().toInt();
|
||||
else if (xml.name() == "token")
|
||||
|
@ -902,7 +994,7 @@ void CardDatabase::loadCardsFromXml(QXmlStreamReader &xml, bool tokens)
|
|||
}
|
||||
|
||||
if (isToken == tokens) {
|
||||
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
|
||||
addCard(new CardInfo(this, name, isToken, manacost, cmc, type, pt, text, colors, relatedCards, upsideDown, loyalty, cipt, tableRow, sets, customPicURLs, customPicURLsHq, muids));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,10 @@ public:
|
|||
|
||||
class SetList : public QList<CardSet *> {
|
||||
private:
|
||||
class CompareFunctor;
|
||||
class KeyCompareFunctor;
|
||||
class EnabledAndKeyCompareFunctor;
|
||||
public:
|
||||
void sortByEnabledAndKey();
|
||||
void sortByKey();
|
||||
void guessSortKeys();
|
||||
void enableAllUnknown();
|
||||
|
@ -94,6 +96,7 @@ private:
|
|||
bool picDownload, picDownloadHq, downloadRunning, loadQueueRunning;
|
||||
void startNextPicDownload();
|
||||
QString getPicUrl();
|
||||
static QStringList md5Blacklist;
|
||||
public:
|
||||
PictureLoader(const QString &__picsPath, bool _picDownload, bool _picDownloadHq, QObject *parent = 0);
|
||||
~PictureLoader();
|
||||
|
@ -132,6 +135,8 @@ private:
|
|||
QString powtough;
|
||||
QString text;
|
||||
QStringList colors;
|
||||
QStringList relatedCards;
|
||||
bool upsideDownArt;
|
||||
int loyalty;
|
||||
QStringMap customPicURLs, customPicURLsHq;
|
||||
MuidMap muIds;
|
||||
|
@ -148,13 +153,16 @@ public:
|
|||
const QString &_powtough = QString(),
|
||||
const QString &_text = QString(),
|
||||
const QStringList &_colors = QStringList(),
|
||||
const QStringList &_relatedCards = QStringList(),
|
||||
bool _upsideDownArt = false,
|
||||
int _loyalty = 0,
|
||||
bool _cipt = false,
|
||||
int _tableRow = 0,
|
||||
const SetList &_sets = SetList(),
|
||||
const QStringMap &_customPicURLs = QStringMap(),
|
||||
const QStringMap &_customPicURLsHq = QStringMap(),
|
||||
MuidMap muids = MuidMap());
|
||||
MuidMap muids = MuidMap()
|
||||
);
|
||||
~CardInfo();
|
||||
const QString &getName() const { return name; }
|
||||
const QString &getSimpleName() const { return simpleName; }
|
||||
|
@ -174,6 +182,8 @@ public:
|
|||
void setText(const QString &_text) { text = _text; emit cardInfoChanged(this); }
|
||||
void setColors(const QStringList &_colors) { colors = _colors; emit cardInfoChanged(this); }
|
||||
const QStringList &getColors() const { return colors; }
|
||||
const QStringList &getRelatedCards() const { return relatedCards; }
|
||||
bool getUpsideDownArt() const { return upsideDownArt; }
|
||||
QString getCustomPicURL(const QString &set) const { return customPicURLs.value(set); }
|
||||
QString getCustomPicURLHq(const QString &set) const { return customPicURLsHq.value(set); }
|
||||
int getMuId(const QString &set) const { return muIds.value(set); }
|
||||
|
|
|
@ -7,42 +7,52 @@
|
|||
#include "cardinfotext.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
#include <QSplitter>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
CardFrame::CardFrame(int width, int height,
|
||||
const QString &cardName, QWidget *parent)
|
||||
: QTabWidget(parent)
|
||||
, info(0)
|
||||
, cardTextOnly(false)
|
||||
CardFrame::CardFrame(const QString &cardName, QWidget *parent)
|
||||
: QTabWidget(parent), info(0), cardTextOnly(false)
|
||||
{
|
||||
setMaximumWidth(width);
|
||||
setMinimumWidth(width);
|
||||
setMinimumHeight(height);
|
||||
|
||||
pic = new CardInfoPicture(width);
|
||||
setContentsMargins(3, 3, 3, 3);
|
||||
pic = new CardInfoPicture();
|
||||
pic->setObjectName("pic");
|
||||
text = new CardInfoText();
|
||||
text->setObjectName("text");
|
||||
|
||||
tab1 = new QWidget(this);
|
||||
tab2 = new QWidget(this);
|
||||
tab3 = new QWidget(this);
|
||||
|
||||
tab1->setObjectName("tab1");
|
||||
tab2->setObjectName("tab2");
|
||||
tab3->setObjectName("tab3");
|
||||
|
||||
insertTab(ImageOnlyView, tab1, QString());
|
||||
insertTab(TextOnlyView, tab2, QString());
|
||||
insertTab(ImageAndTextView, tab3, QString());
|
||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(setViewMode(int)));
|
||||
|
||||
tab1Layout = new QVBoxLayout();
|
||||
tab1Layout->setObjectName("tab1Layout");
|
||||
tab1Layout->setContentsMargins(0, 0, 0, 0);
|
||||
tab1Layout->setSpacing(0);
|
||||
tab1->setLayout(tab1Layout);
|
||||
|
||||
tab2Layout = new QVBoxLayout();
|
||||
tab2Layout->setObjectName("tab2Layout");
|
||||
tab2Layout->setContentsMargins(0, 0, 0, 0);
|
||||
tab2Layout->setSpacing(0);
|
||||
tab2->setLayout(tab2Layout);
|
||||
|
||||
splitter = new QSplitter();
|
||||
splitter->setObjectName("splitter");
|
||||
splitter->setOrientation(Qt::Vertical);
|
||||
|
||||
tab3Layout = new QVBoxLayout();
|
||||
tab3Layout->setObjectName("tab3Layout");
|
||||
tab3Layout->setContentsMargins(0, 0, 0, 0);
|
||||
tab3Layout->setSpacing(0);
|
||||
tab3Layout->addWidget(splitter);
|
||||
tab3->setLayout(tab3Layout);
|
||||
|
||||
setViewMode(settingsCache->getCardInfoViewMode());
|
||||
|
@ -70,8 +80,8 @@ void CardFrame::setViewMode(int mode)
|
|||
tab2Layout->addWidget(text);
|
||||
break;
|
||||
case ImageAndTextView:
|
||||
tab3Layout->addWidget(pic);
|
||||
tab3Layout->addWidget(text);
|
||||
splitter->addWidget(pic);
|
||||
splitter->addWidget(text);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ class CardInfo;
|
|||
class CardInfoPicture;
|
||||
class CardInfoText;
|
||||
class QVBoxLayout;
|
||||
class QSplitter;
|
||||
|
||||
class CardFrame : public QTabWidget {
|
||||
Q_OBJECT
|
||||
|
@ -19,11 +20,11 @@ private:
|
|||
bool cardTextOnly;
|
||||
QWidget *tab1, *tab2, *tab3;
|
||||
QVBoxLayout *tab1Layout, *tab2Layout, *tab3Layout;
|
||||
|
||||
QSplitter *splitter;
|
||||
public:
|
||||
enum ViewMode { ImageOnlyView, TextOnlyView, ImageAndTextView };
|
||||
|
||||
CardFrame(int width, int height, const QString &cardName = QString(),
|
||||
CardFrame(const QString &cardName = QString(),
|
||||
QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
public slots:
|
||||
|
|
|
@ -1,25 +1,19 @@
|
|||
#include "cardinfopicture.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QStyle>
|
||||
|
||||
#include "carditem.h"
|
||||
#include "carddatabase.h"
|
||||
#include "main.h"
|
||||
|
||||
CardInfoPicture::CardInfoPicture(int maximumWidth, QWidget *parent)
|
||||
: QLabel(parent)
|
||||
, info(0)
|
||||
, noPicture(true)
|
||||
CardInfoPicture::CardInfoPicture(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
info(0),
|
||||
pixmapDirty(true)
|
||||
{
|
||||
setAlignment(Qt::AlignCenter);
|
||||
setMaximumWidth(maximumWidth);
|
||||
}
|
||||
|
||||
void CardInfoPicture::setNoPicture(bool status)
|
||||
{
|
||||
if (noPicture != status) {
|
||||
noPicture = status;
|
||||
emit hasPictureChanged();
|
||||
}
|
||||
setMinimumHeight(100);
|
||||
}
|
||||
|
||||
void CardInfoPicture::setCard(CardInfo *card)
|
||||
|
@ -32,26 +26,37 @@ void CardInfoPicture::setCard(CardInfo *card)
|
|||
updatePixmap();
|
||||
}
|
||||
|
||||
void CardInfoPicture::resizeEvent(QResizeEvent * /* e */)
|
||||
void CardInfoPicture::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updatePixmap();
|
||||
}
|
||||
|
||||
void CardInfoPicture::updatePixmap()
|
||||
{
|
||||
if (info == 0 || width() == 0 || height() == 0) {
|
||||
setNoPicture(true);
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap resizedPixmap;
|
||||
info->getPixmap(size(), resizedPixmap);
|
||||
|
||||
if (resizedPixmap.isNull()) {
|
||||
setNoPicture(true);
|
||||
db->getCard()->getPixmap(size(), resizedPixmap);
|
||||
} else {
|
||||
setNoPicture(false);
|
||||
}
|
||||
this->setPixmap(resizedPixmap);
|
||||
pixmapDirty = true;
|
||||
update();
|
||||
}
|
||||
|
||||
void CardInfoPicture::loadPixmap()
|
||||
{
|
||||
if(info)
|
||||
info->getPixmap(size(), resizedPixmap);
|
||||
else
|
||||
resizedPixmap = QPixmap();
|
||||
|
||||
|
||||
if (resizedPixmap.isNull())
|
||||
db->getCard()->getPixmap(size(), resizedPixmap);
|
||||
}
|
||||
|
||||
void CardInfoPicture::paintEvent(QPaintEvent *)
|
||||
{
|
||||
if (width() == 0 || height() == 0)
|
||||
return;
|
||||
|
||||
if(pixmapDirty)
|
||||
loadPixmap();
|
||||
|
||||
QPainter painter(this);
|
||||
style()->drawItemPixmap(&painter, rect(), Qt::AlignHCenter, resizedPixmap);
|
||||
}
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
#ifndef CARDINFOPICTURE_H
|
||||
#define CARDINFOPICTURE_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
|
||||
class AbstractCardItem;
|
||||
class CardInfo;
|
||||
|
||||
class CardInfoPicture : public QLabel {
|
||||
class CardInfoPicture : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
signals:
|
||||
void hasPictureChanged();
|
||||
|
||||
private:
|
||||
CardInfo *info;
|
||||
bool noPicture;
|
||||
QPixmap resizedPixmap;
|
||||
bool pixmapDirty;
|
||||
|
||||
public:
|
||||
CardInfoPicture(int maximumWidth, QWidget *parent = 0);
|
||||
bool hasPicture() const { return !noPicture; }
|
||||
private:
|
||||
void setNoPicture(bool status);
|
||||
CardInfoPicture(QWidget *parent = 0);
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
||||
void paintEvent(QPaintEvent *);
|
||||
void loadPixmap();
|
||||
public slots:
|
||||
void setCard(CardInfo *card);
|
||||
void updatePixmap();
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
#include "main.h"
|
||||
|
||||
CardInfoText::CardInfoText(QWidget *parent)
|
||||
: QFrame(parent)
|
||||
, info(0)
|
||||
: QFrame(parent), info(0)
|
||||
{
|
||||
nameLabel1 = new QLabel;
|
||||
nameLabel2 = new QLabel;
|
||||
|
@ -17,6 +16,9 @@ CardInfoText::CardInfoText(QWidget *parent)
|
|||
manacostLabel1 = new QLabel;
|
||||
manacostLabel2 = new QLabel;
|
||||
manacostLabel2->setWordWrap(true);
|
||||
colorLabel1 = new QLabel;
|
||||
colorLabel2 = new QLabel;
|
||||
colorLabel2->setWordWrap(true);
|
||||
cardtypeLabel1 = new QLabel;
|
||||
cardtypeLabel2 = new QLabel;
|
||||
cardtypeLabel2->setWordWrap(true);
|
||||
|
@ -34,6 +36,8 @@ CardInfoText::CardInfoText(QWidget *parent)
|
|||
grid->addWidget(nameLabel2, row++, 1);
|
||||
grid->addWidget(manacostLabel1, row, 0);
|
||||
grid->addWidget(manacostLabel2, row++, 1);
|
||||
grid->addWidget(colorLabel1, row, 0);
|
||||
grid->addWidget(colorLabel2, row++, 1);
|
||||
grid->addWidget(cardtypeLabel1, row, 0);
|
||||
grid->addWidget(cardtypeLabel2, row++, 1);
|
||||
grid->addWidget(powtoughLabel1, row, 0);
|
||||
|
@ -51,6 +55,7 @@ void CardInfoText::setCard(CardInfo *card)
|
|||
{
|
||||
nameLabel2->setText(card->getName());
|
||||
manacostLabel2->setText(card->getManaCost());
|
||||
colorLabel2->setText(card->getColors().join(""));
|
||||
cardtypeLabel2->setText(card->getCardType());
|
||||
powtoughLabel2->setText(card->getPowTough());
|
||||
loyaltyLabel2->setText(card->getLoyalty() > 0 ? QString::number(card->getLoyalty()) : QString());
|
||||
|
@ -61,6 +66,7 @@ void CardInfoText::retranslateUi()
|
|||
{
|
||||
nameLabel1->setText(tr("Name:"));
|
||||
manacostLabel1->setText(tr("Mana cost:"));
|
||||
colorLabel1->setText(tr("Color(s):"));
|
||||
cardtypeLabel1->setText(tr("Card type:"));
|
||||
powtoughLabel1->setText(tr("P / T:"));
|
||||
loyaltyLabel1->setText(tr("Loyalty:"));
|
||||
|
|
|
@ -13,6 +13,7 @@ class CardInfoText : public QFrame {
|
|||
private:
|
||||
QLabel *nameLabel1, *nameLabel2;
|
||||
QLabel *manacostLabel1, *manacostLabel2;
|
||||
QLabel *colorLabel1, *colorLabel2;
|
||||
QLabel *cardtypeLabel1, *cardtypeLabel2;
|
||||
QLabel *powtoughLabel1, *powtoughLabel2;
|
||||
QLabel *loyaltyLabel1, *loyaltyLabel2;
|
||||
|
|
|
@ -39,6 +39,9 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidge
|
|||
manacostLabel1 = new QLabel;
|
||||
manacostLabel2 = new QLabel;
|
||||
manacostLabel2->setWordWrap(true);
|
||||
colorLabel1 = new QLabel;
|
||||
colorLabel2 = new QLabel;
|
||||
colorLabel2->setWordWrap(true);
|
||||
cardtypeLabel1 = new QLabel;
|
||||
cardtypeLabel2 = new QLabel;
|
||||
cardtypeLabel2->setWordWrap(true);
|
||||
|
@ -59,6 +62,8 @@ CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidge
|
|||
grid->addWidget(nameLabel2, row++, 1);
|
||||
grid->addWidget(manacostLabel1, row, 0);
|
||||
grid->addWidget(manacostLabel2, row++, 1);
|
||||
grid->addWidget(colorLabel1, row, 0);
|
||||
grid->addWidget(colorLabel2, row++, 1);
|
||||
grid->addWidget(cardtypeLabel1, row, 0);
|
||||
grid->addWidget(cardtypeLabel2, row++, 1);
|
||||
grid->addWidget(powtoughLabel1, row, 0);
|
||||
|
@ -94,14 +99,12 @@ void CardInfoWidget::minimizeClicked(int newMinimized)
|
|||
|
||||
bool CardInfoWidget::shouldShowPowTough()
|
||||
{
|
||||
// return (!info->getPowTough().isEmpty() && (minimized != 0));
|
||||
return (minimized != 0);
|
||||
return !info->getPowTough().isEmpty();
|
||||
}
|
||||
|
||||
bool CardInfoWidget::shouldShowLoyalty()
|
||||
{
|
||||
// return ((info->getLoyalty() > 0) && (minimized != 0));
|
||||
return (minimized != 0);
|
||||
return (info->getLoyalty() > 0);
|
||||
}
|
||||
|
||||
void CardInfoWidget::setMinimized(int _minimized)
|
||||
|
@ -117,6 +120,8 @@ void CardInfoWidget::setMinimized(int _minimized)
|
|||
nameLabel2->setVisible(showAll);
|
||||
manacostLabel1->setVisible(showAll);
|
||||
manacostLabel2->setVisible(showAll);
|
||||
colorLabel1->setVisible(showAll);
|
||||
colorLabel2->setVisible(showAll);
|
||||
cardtypeLabel1->setVisible(showAll);
|
||||
cardtypeLabel2->setVisible(showAll);
|
||||
powtoughLabel1->setVisible(showPowTough);
|
||||
|
@ -153,6 +158,7 @@ void CardInfoWidget::setCard(CardInfo *card)
|
|||
updatePixmap();
|
||||
nameLabel2->setText(card->getName());
|
||||
manacostLabel2->setText(card->getManaCost());
|
||||
colorLabel2->setText(card->getColors().join(""));
|
||||
cardtypeLabel2->setText(card->getCardType());
|
||||
powtoughLabel2->setText(card->getPowTough());
|
||||
loyaltyLabel2->setText(card->getLoyalty() > 0 ? QString::number(card->getLoyalty()) : QString());
|
||||
|
@ -200,6 +206,7 @@ void CardInfoWidget::retranslateUi()
|
|||
{
|
||||
nameLabel1->setText(tr("Name:"));
|
||||
manacostLabel1->setText(tr("Mana cost:"));
|
||||
colorLabel1->setText(tr("Color(s):"));
|
||||
cardtypeLabel1->setText(tr("Card type:"));
|
||||
powtoughLabel1->setText(tr("P / T:"));
|
||||
loyaltyLabel1->setText(tr("Loyalty:"));
|
||||
|
|
|
@ -31,6 +31,7 @@ private:
|
|||
QLabel *cardPicture;
|
||||
QLabel *nameLabel1, *nameLabel2;
|
||||
QLabel *manacostLabel1, *manacostLabel2;
|
||||
QLabel *colorLabel1, *colorLabel2;
|
||||
QLabel *cardtypeLabel1, *cardtypeLabel2;
|
||||
QLabel *powtoughLabel1, *powtoughLabel2;
|
||||
QLabel *loyaltyLabel1, *loyaltyLabel2;
|
||||
|
|
|
@ -110,7 +110,7 @@ void CardItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
QStringList ptDbSplit = db->getCard(name)->getPowTough().split("/");
|
||||
QStringList ptSplit = pt.split("/");
|
||||
|
||||
if (ptDbSplit.at(0) != ptSplit.at(0) || ptDbSplit.at(1) != ptSplit.at(1))
|
||||
if (getFaceDown() || ptDbSplit.at(0) != ptSplit.at(0) || ptDbSplit.at(1) != ptSplit.at(1))
|
||||
painter->setPen(QColor(255, 150, 0));
|
||||
else
|
||||
painter->setPen(Qt::white);
|
||||
|
@ -358,7 +358,7 @@ void CardItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (settingsCache->getDoubleClickToPlay()) {
|
||||
if (settingsCache->getDoubleClickToPlay() && event->buttons() == Qt::LeftButton) {
|
||||
if (revealedCard)
|
||||
zone->removeCard(this);
|
||||
else
|
||||
|
|
|
@ -53,14 +53,15 @@ QTextCursor ChatView::prepareBlock(bool same)
|
|||
|
||||
QTextCursor cursor(document()->lastBlock());
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
if (!same) {
|
||||
if (same) {
|
||||
cursor.insertHtml("<br>");
|
||||
} else {
|
||||
QTextBlockFormat blockFormat;
|
||||
if ((evenNumber = !evenNumber))
|
||||
blockFormat.setBackground(palette().alternateBase());
|
||||
blockFormat.setBottomMargin(4);
|
||||
cursor.insertBlock(blockFormat);
|
||||
} else
|
||||
cursor.insertHtml("<br>");
|
||||
}
|
||||
|
||||
return cursor;
|
||||
}
|
||||
|
@ -73,10 +74,16 @@ void ChatView::appendHtml(const QString &html)
|
|||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void ChatView::appendHtmlServerMessage(const QString &html)
|
||||
void ChatView::appendHtmlServerMessage(const QString &html, bool optionalIsBold, QString optionalFontColor)
|
||||
{
|
||||
bool atBottom = verticalScrollBar()->value() >= verticalScrollBar()->maximum();
|
||||
prepareBlock().insertHtml("<font color=" + SERVER_MESSAGE_COLOR + ">" + html + "</font>");
|
||||
|
||||
QString htmlText = "<font color=" + ((optionalFontColor.size() > 0) ? optionalFontColor : SERVER_MESSAGE_COLOR) + ">" + html + "</font>";
|
||||
|
||||
if (optionalIsBold)
|
||||
htmlText = "<b>" + htmlText + "</b>";
|
||||
|
||||
prepareBlock().insertHtml(htmlText);
|
||||
if (atBottom)
|
||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
|
@ -120,6 +127,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
QTextCursor cursor = prepareBlock(sameSender);
|
||||
lastSender = sender;
|
||||
|
||||
// timestamp
|
||||
if (showTimestamps && !sameSender) {
|
||||
QTextCharFormat timeFormat;
|
||||
timeFormat.setForeground(QColor(SERVER_MESSAGE_COLOR));
|
||||
|
@ -128,7 +136,8 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
cursor.setCharFormat(timeFormat);
|
||||
cursor.insertText(QDateTime::currentDateTime().toString("[hh:mm:ss] "));
|
||||
}
|
||||
|
||||
|
||||
// nickname
|
||||
QTextCharFormat senderFormat;
|
||||
if (tabSupervisor && tabSupervisor->getUserInfo() && (sender == QString::fromStdString(tabSupervisor->getUserInfo()->name()))) {
|
||||
senderFormat.setForeground(QBrush(getCustomMentionColor()));
|
||||
|
@ -140,7 +149,9 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
}
|
||||
senderFormat.setAnchor(true);
|
||||
senderFormat.setAnchorHref("user://" + QString::number(userLevel) + "_" + sender);
|
||||
if (!sameSender) {
|
||||
if (sameSender) {
|
||||
cursor.insertText(" ");
|
||||
} else {
|
||||
if (!sender.isEmpty() && tabSupervisor->getUserListsTab()) {
|
||||
const int pixelSize = QFontInfo(cursor.charFormat().font()).pixelSize();
|
||||
QMap<QString, UserListTWI *> buddyList = tabSupervisor->getUserListsTab()->getBuddyList()->getUsers();
|
||||
|
@ -151,142 +162,48 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
if (!sender.isEmpty())
|
||||
sender.append(": ");
|
||||
cursor.insertText(sender);
|
||||
} else
|
||||
cursor.insertText(" ");
|
||||
|
||||
QTextCharFormat messageFormat;
|
||||
if (sender.isEmpty()) {
|
||||
messageFormat.setForeground(Qt::darkGreen);
|
||||
messageFormat.setFontWeight(QFont::Bold);
|
||||
}
|
||||
cursor.setCharFormat(messageFormat);
|
||||
|
||||
int index = -1, bracketFirstIndex = -1, mentionFirstIndex = -1, urlFirstIndex = -1;
|
||||
|
||||
// use different color for server messages
|
||||
defaultFormat = QTextCharFormat();
|
||||
if (sender.isEmpty()) {
|
||||
defaultFormat.setForeground(Qt::darkGreen);
|
||||
defaultFormat.setFontWeight(QFont::Bold);
|
||||
}
|
||||
cursor.setCharFormat(defaultFormat);
|
||||
|
||||
bool mentionEnabled = settingsCache->getChatMention();
|
||||
highlightedWords = settingsCache->getHighlightWords().split(' ', QString::SkipEmptyParts);
|
||||
|
||||
// parse the message
|
||||
while (message.size())
|
||||
{
|
||||
// search for the first [ or @
|
||||
bracketFirstIndex = message.indexOf('[');
|
||||
mentionFirstIndex = mentionEnabled ? message.indexOf('@') : -1;
|
||||
urlFirstIndex = message.indexOf(QRegExp("https?://|www."));
|
||||
if(bracketFirstIndex == -1) {
|
||||
if(mentionFirstIndex == -1) {
|
||||
if (urlFirstIndex == -1) {
|
||||
// quick way out
|
||||
cursor.insertText(message);
|
||||
break;
|
||||
} else {
|
||||
// url
|
||||
index = urlFirstIndex;
|
||||
}
|
||||
} else {
|
||||
if (urlFirstIndex == -1) {
|
||||
// mention
|
||||
index = mentionFirstIndex;
|
||||
} else {
|
||||
index = std::min(urlFirstIndex, mentionFirstIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mentionFirstIndex == -1) {
|
||||
// bracket
|
||||
index = bracketFirstIndex;
|
||||
} else {
|
||||
// both, pick up the first one
|
||||
index = std::min(bracketFirstIndex, mentionFirstIndex);
|
||||
}
|
||||
if(urlFirstIndex != -1) {
|
||||
index = std::min(index, urlFirstIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// insert the message text up to the [ / @ / https://
|
||||
if(index > 0)
|
||||
QChar c = message.at(0);
|
||||
switch(c.toLatin1())
|
||||
{
|
||||
cursor.insertText(message.left(index), defaultFormat);
|
||||
message = message.mid(index);
|
||||
}
|
||||
|
||||
if(index == bracketFirstIndex)
|
||||
{
|
||||
if (message.startsWith("[card]")) {
|
||||
message = message.mid(6);
|
||||
int closeTagIndex = message.indexOf("[/card]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 7);
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
} else if (message.startsWith("[[")) {
|
||||
message = message.mid(2);
|
||||
int closeTagIndex = message.indexOf("]]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 2);
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
} else if (message.startsWith("[url]")) {
|
||||
message = message.mid(5);
|
||||
int closeTagIndex = message.indexOf("[/url]");
|
||||
QString url = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 6);
|
||||
|
||||
appendUrlTag(cursor, url);
|
||||
} else {
|
||||
// not a recognized [tag]
|
||||
cursor.insertText("[", defaultFormat);
|
||||
case '[':
|
||||
checkTag(cursor, message);
|
||||
break;
|
||||
case '@':
|
||||
if(mentionEnabled) {
|
||||
checkMention(cursor, message, sender, userLevel);
|
||||
} else {
|
||||
cursor.insertText(c, defaultFormat);
|
||||
message = message.mid(1);
|
||||
}
|
||||
break;
|
||||
case ' ':
|
||||
cursor.insertText(c, defaultFormat);
|
||||
message = message.mid(1);
|
||||
}
|
||||
} else if (index == urlFirstIndex) {
|
||||
int urlEndIndex = message.indexOf(QRegExp("\\s"), 0);
|
||||
if (urlEndIndex == -1)
|
||||
urlEndIndex = message.size();
|
||||
QString urlText = message.left(urlEndIndex);
|
||||
QUrl qUrl(urlText);
|
||||
if (qUrl.isValid())
|
||||
appendUrlTag(cursor, urlText);
|
||||
else
|
||||
cursor.insertText(urlText);
|
||||
if (urlEndIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(urlEndIndex);
|
||||
} else {
|
||||
if (message.startsWith(mention, Qt::CaseInsensitive)) {
|
||||
// you have been mentioned
|
||||
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white):QBrush(Qt::black));
|
||||
cursor.insertText(mention, mentionFormat);
|
||||
message = message.mid(mention.size());
|
||||
QApplication::alert(this);
|
||||
if (settingsCache->getShowMentionPopup() && shouldShowSystemPopup()) {
|
||||
QString ref = sender.left(sender.length() - 2);
|
||||
showSystemPopup(ref);
|
||||
break;
|
||||
default:
|
||||
if(c.isLetterOrNumber()) {
|
||||
checkWord(cursor, message);
|
||||
} else {
|
||||
cursor.insertText(c, defaultFormat);
|
||||
message = message.mid(1);
|
||||
}
|
||||
} else {
|
||||
int mentionEndIndex = message.indexOf(QRegExp("\\s"), 1);// from 1 as @ is non-char
|
||||
if (mentionEndIndex == -1)
|
||||
mentionEndIndex = message.size(); // there is no text after the mention
|
||||
QString userMention = message.left(mentionEndIndex);
|
||||
QString userName = userMention.right(userMention.size()-1).normalized(QString::NormalizationForm_D);
|
||||
QMap<QString, UserListTWI *> userList = tabSupervisor->getUserListsTab()->getAllUsersList()->getUsers();
|
||||
QString correctUserName = getNameFromUserList(userList, userName);
|
||||
if (!correctUserName.isEmpty()) {
|
||||
UserListTWI *vlu = userList.value(correctUserName);
|
||||
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(vlu->getUserInfo().user_level()) + "_" + correctUserName);
|
||||
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
|
||||
} else
|
||||
cursor.insertText("@" + userName, defaultFormat);
|
||||
message = message.mid(userName.size() + 1);
|
||||
}
|
||||
cursor.setCharFormat(defaultFormat); // reset format after each iteration
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,6 +211,207 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
|
|||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||
}
|
||||
|
||||
void ChatView::checkTag(QTextCursor &cursor, QString &message)
|
||||
{
|
||||
if (message.startsWith("[card]"))
|
||||
{
|
||||
message = message.mid(6);
|
||||
int closeTagIndex = message.indexOf("[/card]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 7);
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.startsWith("[["))
|
||||
{
|
||||
message = message.mid(2);
|
||||
int closeTagIndex = message.indexOf("]]");
|
||||
QString cardName = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 2);
|
||||
|
||||
appendCardTag(cursor, cardName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.startsWith("[url]"))
|
||||
{
|
||||
message = message.mid(5);
|
||||
int closeTagIndex = message.indexOf("[/url]");
|
||||
QString url = message.left(closeTagIndex);
|
||||
if (closeTagIndex == -1)
|
||||
message.clear();
|
||||
else
|
||||
message = message.mid(closeTagIndex + 6);
|
||||
|
||||
appendUrlTag(cursor, url);
|
||||
return;
|
||||
}
|
||||
|
||||
// no valid tag found
|
||||
checkWord(cursor, message);
|
||||
}
|
||||
|
||||
void ChatView::checkMention(QTextCursor &cursor, QString &message, QString &sender, UserLevelFlags userLevel)
|
||||
{
|
||||
const QRegExp notALetterOrNumber = QRegExp("[^a-zA-Z0-9]");
|
||||
|
||||
int firstSpace = message.indexOf(' ');
|
||||
QString fullMentionUpToSpaceOrEnd = (firstSpace == -1) ? message.mid(1) : message.mid(1, firstSpace - 1);
|
||||
QString mentionIntact = fullMentionUpToSpaceOrEnd;
|
||||
|
||||
QMap<QString, UserListTWI *> userList = tabSupervisor->getUserListsTab()->getAllUsersList()->getUsers();
|
||||
|
||||
while (fullMentionUpToSpaceOrEnd.size())
|
||||
{
|
||||
if (isFullMentionAValidUser(userList, fullMentionUpToSpaceOrEnd)) // Is there a user online named this?
|
||||
{
|
||||
if (userName.toLower() == fullMentionUpToSpaceOrEnd.toLower()) // Is this user you?
|
||||
{
|
||||
// You have received a valid mention!!
|
||||
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
cursor.insertText(mention, mentionFormat);
|
||||
message = message.mid(mention.size());
|
||||
QApplication::alert(this);
|
||||
if (settingsCache->getShowMentionPopup() && shouldShowSystemPopup())
|
||||
{
|
||||
QString ref = sender.left(sender.length() - 2);
|
||||
showSystemPopup(ref);
|
||||
}
|
||||
} else {
|
||||
QString correctUserName = getNameFromUserList(userList, fullMentionUpToSpaceOrEnd);
|
||||
UserListTWI *vlu = userList.value(correctUserName);
|
||||
mentionFormatOtherUser.setAnchorHref("user://" + QString::number(vlu->getUserInfo().user_level()) + "_" + correctUserName);
|
||||
cursor.insertText("@" + correctUserName, mentionFormatOtherUser);
|
||||
|
||||
message = message.mid(correctUserName.size() + 1);
|
||||
}
|
||||
|
||||
cursor.setCharFormat(defaultFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isModeratorSendingGlobal(userLevel, fullMentionUpToSpaceOrEnd)) {
|
||||
// Moderator Sending Global Message
|
||||
mentionFormat.setBackground(QBrush(getCustomMentionColor()));
|
||||
mentionFormat.setForeground(settingsCache->getChatMentionForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
cursor.insertText("@" + fullMentionUpToSpaceOrEnd, mentionFormat);
|
||||
message = message.mid(fullMentionUpToSpaceOrEnd.size() + 1);
|
||||
QApplication::alert(this);
|
||||
if (settingsCache->getShowMentionPopup() && shouldShowSystemPopup())
|
||||
{
|
||||
QString ref = sender.left(sender.length() - 2);
|
||||
showSystemPopup(ref);
|
||||
}
|
||||
|
||||
cursor.setCharFormat(defaultFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
if (fullMentionUpToSpaceOrEnd.right(1).indexOf(notALetterOrNumber) == -1 || fullMentionUpToSpaceOrEnd.size() < 2)
|
||||
{
|
||||
cursor.insertText("@" + mentionIntact, defaultFormat);
|
||||
message = message.mid(mentionIntact.size() + 1);
|
||||
cursor.setCharFormat(defaultFormat);
|
||||
return;
|
||||
}
|
||||
|
||||
fullMentionUpToSpaceOrEnd.chop(1);
|
||||
}
|
||||
|
||||
// no valid mention found
|
||||
checkWord(cursor, message);
|
||||
}
|
||||
|
||||
void ChatView::checkWord(QTextCursor &cursor, QString &message)
|
||||
{
|
||||
// extract the first word
|
||||
QString rest;
|
||||
QString fullWordUpToSpaceOrEnd = extractNextWord(message, rest);
|
||||
|
||||
// check urls
|
||||
if (fullWordUpToSpaceOrEnd.startsWith("http://", Qt::CaseInsensitive) ||
|
||||
fullWordUpToSpaceOrEnd.startsWith("https://", Qt::CaseInsensitive) ||
|
||||
fullWordUpToSpaceOrEnd.startsWith("www.", Qt::CaseInsensitive))
|
||||
{
|
||||
QUrl qUrl(fullWordUpToSpaceOrEnd);
|
||||
if (qUrl.isValid())
|
||||
{
|
||||
appendUrlTag(cursor, fullWordUpToSpaceOrEnd);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check word mentions
|
||||
foreach (QString word, highlightedWords)
|
||||
{
|
||||
if (fullWordUpToSpaceOrEnd.compare(word, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
// You have received a valid mention of custom word!!
|
||||
highlightFormat.setBackground(QBrush(getCustomHighlightColor()));
|
||||
highlightFormat.setForeground(settingsCache->getChatHighlightForeground() ? QBrush(Qt::white) : QBrush(Qt::black));
|
||||
cursor.insertText(fullWordUpToSpaceOrEnd, highlightFormat);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
QApplication::alert(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// not a special word; just print it
|
||||
cursor.insertText(fullWordUpToSpaceOrEnd + rest, defaultFormat);
|
||||
}
|
||||
|
||||
QString ChatView::extractNextWord(QString &message, QString &rest)
|
||||
{
|
||||
// get the first next space and extract the word
|
||||
QString word;
|
||||
int firstSpace = message.indexOf(' ');
|
||||
if(firstSpace == -1)
|
||||
{
|
||||
word = message;
|
||||
message.clear();
|
||||
} else {
|
||||
word = message.mid(0, firstSpace);
|
||||
message = message.mid(firstSpace);
|
||||
}
|
||||
|
||||
// remove any punctution from the end and pass it separately
|
||||
for (int len = word.size() - 1; len >= 0; --len)
|
||||
{
|
||||
if(word.at(len).isLetterOrNumber())
|
||||
{
|
||||
rest = word.mid(len + 1);
|
||||
return word.mid(0, len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
rest = word;
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
bool ChatView::isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message)
|
||||
{
|
||||
int userLevel = QString::number(userLevelFlag).toInt();
|
||||
|
||||
QStringList getAttentionList;
|
||||
getAttentionList << "/all"; // Send a message to all users
|
||||
|
||||
if (getAttentionList.contains(message) && (userLevel & ServerInfo_User::IsModerator || userLevel & ServerInfo_User::IsAdmin))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatView::actMessageClicked() {
|
||||
emit messageClickedSignal();
|
||||
}
|
||||
|
@ -306,13 +424,18 @@ void ChatView::showSystemPopup(QString &sender) {
|
|||
emit showMentionPopup(sender);
|
||||
}
|
||||
|
||||
|
||||
QColor ChatView::getCustomMentionColor() {
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatMentionColor());
|
||||
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
|
||||
}
|
||||
|
||||
QColor ChatView::getCustomHighlightColor() {
|
||||
QColor customColor;
|
||||
customColor.setNamedColor("#" + settingsCache->getChatHighlightColor());
|
||||
return customColor.isValid() ? customColor : DEFAULT_MENTION_COLOR;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the correct case version of the provided username, if no correct casing version
|
||||
was found then the provided name is not available and will return an empty QString.
|
||||
|
@ -327,6 +450,18 @@ QString ChatView::getNameFromUserList(QMap<QString, UserListTWI *> &userList, QS
|
|||
return QString();
|
||||
}
|
||||
|
||||
bool ChatView::isFullMentionAValidUser(QMap<QString, UserListTWI *> &userList, QString userNameToMatch)
|
||||
{
|
||||
QString userNameToMatchLower = userNameToMatch.toLower();
|
||||
QMap<QString, UserListTWI *>::iterator i;
|
||||
|
||||
for (i = userList.begin(); i != userList.end(); ++i)
|
||||
if (i.key().toLower() == userNameToMatchLower)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatView::clearChat() {
|
||||
document()->clear();
|
||||
lastSender = "";
|
||||
|
|
|
@ -27,8 +27,10 @@ private:
|
|||
QString userName;
|
||||
QString mention;
|
||||
QTextCharFormat mentionFormat;
|
||||
QTextCharFormat highlightFormat;
|
||||
QTextCharFormat mentionFormatOtherUser;
|
||||
QTextCharFormat defaultFormat;
|
||||
QStringList highlightedWords;
|
||||
bool evenNumber;
|
||||
bool showTimestamps;
|
||||
HoveredItemType hoveredItemType;
|
||||
|
@ -39,9 +41,16 @@ private:
|
|||
void appendCardTag(QTextCursor &cursor, const QString &cardName);
|
||||
void appendUrlTag(QTextCursor &cursor, QString url);
|
||||
QString getNameFromUserList(QMap<QString, UserListTWI *> &userList, QString &userName);
|
||||
bool isFullMentionAValidUser(QMap<QString, UserListTWI *> &userList, QString userNameToMatch);
|
||||
QColor getCustomMentionColor();
|
||||
QColor getCustomHighlightColor();
|
||||
bool shouldShowSystemPopup();
|
||||
void showSystemPopup(QString &sender);
|
||||
bool isModeratorSendingGlobal(QFlags<ServerInfo_User::UserLevelFlag> userLevelFlag, QString message);
|
||||
void checkTag(QTextCursor &cursor, QString &message);
|
||||
void checkMention(QTextCursor &cursor, QString &message, QString &sender, UserLevelFlags userLevel);
|
||||
void checkWord(QTextCursor &cursor, QString &message);
|
||||
QString extractNextWord(QString &message, QString &rest);
|
||||
private slots:
|
||||
void openLink(const QUrl &link);
|
||||
void actMessageClicked();
|
||||
|
@ -49,7 +58,7 @@ public:
|
|||
ChatView(const TabSupervisor *_tabSupervisor, TabGame *_game, bool _showTimestamps, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
void appendHtml(const QString &html);
|
||||
void appendHtmlServerMessage(const QString &html);
|
||||
void appendHtmlServerMessage(const QString &html, bool optionalIsBold = false, QString optionalFontColor = QString());
|
||||
void appendMessage(QString message, QString sender = QString(), UserLevelFlags userLevel = UserLevelFlags(), bool playerBold = false);
|
||||
void clearChat();
|
||||
protected:
|
||||
|
|
|
@ -108,6 +108,9 @@ QVariant DeckListModel::data(const QModelIndex &index, int role) const
|
|||
int color = 90 + 60 * node->depth();
|
||||
return QBrush(QColor(color, 255, color));
|
||||
}
|
||||
case Qt::ForegroundRole: {
|
||||
return QBrush(QColor(0 ,0 ,0));
|
||||
}
|
||||
default: return QVariant();
|
||||
}
|
||||
} else {
|
||||
|
@ -125,6 +128,9 @@ QVariant DeckListModel::data(const QModelIndex &index, int role) const
|
|||
int color = 255 - (index.row() % 2) * 30;
|
||||
return QBrush(QColor(color, color, color));
|
||||
}
|
||||
case Qt::ForegroundRole: {
|
||||
return QBrush(QColor(0 ,0 ,0));
|
||||
}
|
||||
default: return QVariant();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -228,6 +228,13 @@ QSizeF DeckViewCardContainer::calculateBoundingRect(const QList<QPair<int, int>
|
|||
return QSizeF(getCardTypeTextWidth() + totalWidth, totalHeight + separatorY + paddingY);
|
||||
}
|
||||
|
||||
bool DeckViewCardContainer::sortCardsByName(DeckViewCard * c1, DeckViewCard * c2)
|
||||
{
|
||||
if (c1 && c2)
|
||||
return c1->getName() < c2->getName();
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAndCols)
|
||||
{
|
||||
currentRowsAndCols = rowsAndCols;
|
||||
|
@ -244,6 +251,7 @@ void DeckViewCardContainer::rearrangeItems(const QList<QPair<int, int> > &rowsAn
|
|||
|
||||
QList<QString> cardTypeList = cardsByType.uniqueKeys();
|
||||
QList<DeckViewCard *> row = cardsByType.values(cardTypeList[i]);
|
||||
qSort( row.begin(), row.end(), DeckViewCardContainer::sortCardsByName);
|
||||
for (int j = 0; j < row.size(); ++j) {
|
||||
DeckViewCard *card = row[j];
|
||||
card->setPos(x + (j % tempCols) * CARD_WIDTH, yUntilNow + (j / tempCols) * CARD_HEIGHT);
|
||||
|
|
|
@ -46,6 +46,7 @@ class DeckViewCardContainer : public QGraphicsItem {
|
|||
private:
|
||||
static const int separatorY = 20;
|
||||
static const int paddingY = 10;
|
||||
static bool sortCardsByName(DeckViewCard * c1, DeckViewCard * c2);
|
||||
|
||||
QString name;
|
||||
QList<DeckViewCard *> cards;
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
#include <QSettings>
|
||||
#include <QLabel>
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QRadioButton>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDebug>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <iostream>
|
||||
#include "dlg_connect.h"
|
||||
|
||||
|
@ -14,8 +18,24 @@ DlgConnect::DlgConnect(QWidget *parent)
|
|||
QSettings settings;
|
||||
settings.beginGroup("server");
|
||||
|
||||
previousHostButton = new QRadioButton(tr("Previous Host"), this);
|
||||
|
||||
previousHosts = new QComboBox(this);
|
||||
previousHosts->installEventFilter(new DeleteHighlightedItemWhenShiftDelPressedEventFilter);
|
||||
QStringList previousHostList = settings.value("previoushosts").toStringList();
|
||||
if (previousHostList.isEmpty()) {
|
||||
previousHostList << "cockatrice.woogerworks.com";
|
||||
previousHostList << "vps.poixen.com";
|
||||
previousHostList << "chickatrice.net";
|
||||
}
|
||||
previousHosts->addItems(previousHostList);
|
||||
previousHosts->setCurrentIndex(settings.value("previoushostindex").toInt());
|
||||
|
||||
newHostButton = new QRadioButton(tr("New Host"), this);
|
||||
|
||||
hostLabel = new QLabel(tr("&Host:"));
|
||||
hostEdit = new QLineEdit(settings.value("hostname", "cockatrice.woogerworks.com").toString());
|
||||
hostEdit = new QLineEdit();
|
||||
hostEdit->setPlaceholderText(tr("Enter host name"));
|
||||
hostLabel->setBuddy(hostEdit);
|
||||
|
||||
portLabel = new QLabel(tr("&Port:"));
|
||||
|
@ -48,16 +68,19 @@ DlgConnect::DlgConnect(QWidget *parent)
|
|||
connect(savePasswordCheckBox, SIGNAL(stateChanged(int)), this, SLOT(passwordSaved(int)));
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(hostLabel, 0, 0);
|
||||
grid->addWidget(hostEdit, 0, 1);
|
||||
grid->addWidget(portLabel, 1, 0);
|
||||
grid->addWidget(portEdit, 1, 1);
|
||||
grid->addWidget(playernameLabel, 2, 0);
|
||||
grid->addWidget(playernameEdit, 2, 1);
|
||||
grid->addWidget(passwordLabel, 3, 0);
|
||||
grid->addWidget(passwordEdit, 3, 1);
|
||||
grid->addWidget(savePasswordCheckBox, 4, 0, 1, 2);
|
||||
grid->addWidget(autoConnectCheckBox, 5, 0, 1, 2);
|
||||
grid->addWidget(previousHostButton, 0, 1);
|
||||
grid->addWidget(previousHosts, 1, 1);
|
||||
grid->addWidget(newHostButton, 2, 1);
|
||||
grid->addWidget(hostLabel, 3, 0);
|
||||
grid->addWidget(hostEdit, 3, 1);
|
||||
grid->addWidget(portLabel, 4, 0);
|
||||
grid->addWidget(portEdit, 4, 1);
|
||||
grid->addWidget(playernameLabel, 5, 0);
|
||||
grid->addWidget(playernameEdit, 5, 1);
|
||||
grid->addWidget(passwordLabel, 6, 0);
|
||||
grid->addWidget(passwordEdit, 6, 1);
|
||||
grid->addWidget(savePasswordCheckBox, 7, 0, 1, 2);
|
||||
grid->addWidget(autoConnectCheckBox, 8, 0, 1, 2);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||
|
@ -71,8 +94,32 @@ DlgConnect::DlgConnect(QWidget *parent)
|
|||
setWindowTitle(tr("Connect to server"));
|
||||
setFixedHeight(sizeHint().height());
|
||||
setMinimumWidth(300);
|
||||
|
||||
connect(previousHostButton, SIGNAL(toggled(bool)), this, SLOT(previousHostSelected(bool)));
|
||||
connect(newHostButton, SIGNAL(toggled(bool)), this, SLOT(newHostSelected(bool)));
|
||||
|
||||
if (settings.value("previoushostlogin", 1).toInt())
|
||||
previousHostButton->setChecked(true);
|
||||
else
|
||||
newHostButton->setChecked(true);
|
||||
}
|
||||
|
||||
|
||||
void DlgConnect::previousHostSelected(bool state) {
|
||||
if (state) {
|
||||
hostEdit->setDisabled(true);
|
||||
previousHosts->setDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DlgConnect::newHostSelected(bool state) {
|
||||
if (state) {
|
||||
hostEdit->setDisabled(false);
|
||||
previousHosts->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DlgConnect::passwordSaved(int state)
|
||||
{
|
||||
Q_UNUSED(state);
|
||||
|
@ -88,17 +135,34 @@ void DlgConnect::actOk()
|
|||
{
|
||||
QSettings settings;
|
||||
settings.beginGroup("server");
|
||||
settings.setValue("hostname", hostEdit->text());
|
||||
settings.setValue("port", portEdit->text());
|
||||
settings.setValue("playername", playernameEdit->text());
|
||||
settings.setValue("password", savePasswordCheckBox->isChecked() ? passwordEdit->text() : QString());
|
||||
settings.setValue("save_password", savePasswordCheckBox->isChecked() ? 1 : 0);
|
||||
settings.setValue("auto_connect", autoConnectCheckBox->isChecked() ? 1 : 0);
|
||||
settings.setValue("previoushostlogin", previousHostButton->isChecked() ? 1 : 0);
|
||||
|
||||
QStringList hostList;
|
||||
if (newHostButton->isChecked())
|
||||
if (!hostEdit->text().trimmed().isEmpty())
|
||||
hostList << hostEdit->text();
|
||||
|
||||
for (int i = 0; i < previousHosts->count(); i++)
|
||||
if(!previousHosts->itemText(i).trimmed().isEmpty())
|
||||
hostList << previousHosts->itemText(i);
|
||||
|
||||
settings.setValue("previoushosts", hostList);
|
||||
settings.setValue("previoushostindex", previousHosts->currentIndex());
|
||||
settings.endGroup();
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
|
||||
QString DlgConnect::getHost() const {
|
||||
return previousHostButton->isChecked() ? previousHosts->currentText() : hostEdit->text();
|
||||
}
|
||||
|
||||
void DlgConnect::actCancel()
|
||||
{
|
||||
QSettings settings;
|
||||
|
@ -109,3 +173,17 @@ void DlgConnect::actCancel()
|
|||
|
||||
reject();
|
||||
}
|
||||
|
||||
|
||||
bool DeleteHighlightedItemWhenShiftDelPressedEventFilter::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
||||
if (keyEvent->key() == Qt::Key_Delete) {
|
||||
QComboBox* combobox = reinterpret_cast<QComboBox *>(obj);
|
||||
combobox->removeItem(combobox->currentIndex());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,22 @@
|
|||
class QLabel;
|
||||
class QPushButton;
|
||||
class QCheckBox;
|
||||
class QComboBox;
|
||||
class QRadioButton;
|
||||
|
||||
class DeleteHighlightedItemWhenShiftDelPressedEventFilter : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
};
|
||||
|
||||
|
||||
class DlgConnect : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgConnect(QWidget *parent = 0);
|
||||
QString getHost() const { return hostEdit->text(); }
|
||||
QString getHost() const;
|
||||
int getPort() const { return portEdit->text().toInt(); }
|
||||
QString getPlayerName() const { return playernameEdit->text(); }
|
||||
QString getPassword() const { return passwordEdit->text(); }
|
||||
|
@ -20,10 +30,14 @@ private slots:
|
|||
void actOk();
|
||||
void actCancel();
|
||||
void passwordSaved(int state);
|
||||
void previousHostSelected(bool state);
|
||||
void newHostSelected(bool state);
|
||||
private:
|
||||
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel;
|
||||
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit;
|
||||
QCheckBox *savePasswordCheckBox, *autoConnectCheckBox;
|
||||
QComboBox *previousHosts;
|
||||
QRadioButton *newHostButton, *previousHostButton;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
#include <QTreeView>
|
||||
#include <QRadioButton>
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "decklist.h"
|
||||
#include "dlg_create_token.h"
|
||||
#include "carddatabasemodel.h"
|
||||
#include "main.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
DlgCreateToken::DlgCreateToken(const QStringList &_predefinedTokens, QWidget *parent)
|
||||
: QDialog(parent), predefinedTokens(_predefinedTokens)
|
||||
|
@ -136,7 +138,8 @@ void DlgCreateToken::tokenSelectionChanged(const QModelIndex ¤t, const QMo
|
|||
const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
|
||||
colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
|
||||
ptEdit->setText(cardInfo->getPowTough());
|
||||
annotationEdit->setText(cardInfo->getText());
|
||||
if(settingsCache->getAnnotateTokens())
|
||||
annotationEdit->setText(cardInfo->getText());
|
||||
}
|
||||
|
||||
void DlgCreateToken::actChooseTokenFromAll(bool checked)
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <QSet>
|
||||
#include "dlg_creategame.h"
|
||||
#include "tab_room.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
@ -20,6 +21,7 @@
|
|||
|
||||
void DlgCreateGame::sharedCtor()
|
||||
{
|
||||
rememberGameSettings = new QCheckBox(tr("Re&member settings"));
|
||||
descriptionLabel = new QLabel(tr("&Description:"));
|
||||
descriptionEdit = new QLineEdit;
|
||||
descriptionLabel->setBuddy(descriptionEdit);
|
||||
|
@ -37,6 +39,7 @@ void DlgCreateGame::sharedCtor()
|
|||
generalGrid->addWidget(descriptionEdit, 0, 1);
|
||||
generalGrid->addWidget(maxPlayersLabel, 1, 0);
|
||||
generalGrid->addWidget(maxPlayersEdit, 1, 1);
|
||||
generalGrid->addWidget(rememberGameSettings, 2, 0);
|
||||
|
||||
QVBoxLayout *gameTypeLayout = new QVBoxLayout;
|
||||
QMapIterator<int, QString> gameTypeIterator(gameTypes);
|
||||
|
@ -45,6 +48,7 @@ void DlgCreateGame::sharedCtor()
|
|||
QCheckBox *gameTypeCheckBox = new QCheckBox(gameTypeIterator.value());
|
||||
gameTypeLayout->addWidget(gameTypeCheckBox);
|
||||
gameTypeCheckBoxes.insert(gameTypeIterator.key(), gameTypeCheckBox);
|
||||
gameTypeCheckBoxes[gameTypeIterator.key()]->setChecked((settingsCache->getGameTypes().contains(gameTypeIterator.value() + ", ") ? true : false));
|
||||
}
|
||||
QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type"));
|
||||
gameTypeGroupBox->setLayout(gameTypeLayout);
|
||||
|
@ -109,8 +113,31 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
|
|||
{
|
||||
sharedCtor();
|
||||
|
||||
rememberGameSettings->setChecked(settingsCache->getRememberGameSettings());
|
||||
descriptionEdit->setText(settingsCache->getGameDescription());
|
||||
maxPlayersEdit->setValue(settingsCache->getMaxPlayers());
|
||||
onlyBuddiesCheckBox->setChecked(settingsCache->getOnlyBuddies());
|
||||
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)
|
||||
{
|
||||
onlyRegisteredCheckBox->setChecked(settingsCache->getOnlyRegistered());
|
||||
} else {
|
||||
onlyBuddiesCheckBox->setEnabled(false);
|
||||
onlyRegisteredCheckBox->setEnabled(false);
|
||||
}
|
||||
spectatorsAllowedCheckBox->setChecked(settingsCache->getSpectatorsAllowed());
|
||||
spectatorsNeedPasswordCheckBox->setChecked(settingsCache->getSpectatorsNeedPassword());
|
||||
spectatorsCanTalkCheckBox->setChecked(settingsCache->getSpectatorsCanTalk());
|
||||
spectatorsSeeEverythingCheckBox->setChecked(settingsCache->getSpectatorsCanSeeEverything());
|
||||
|
||||
if (!rememberGameSettings->isChecked()){
|
||||
actReset();
|
||||
}
|
||||
|
||||
clearButton = new QPushButton(tr("&Clear"));
|
||||
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOK()));
|
||||
connect(clearButton, SIGNAL(clicked()), this, SLOT(actReset()));
|
||||
|
||||
setWindowTitle(tr("Create game"));
|
||||
}
|
||||
|
@ -120,6 +147,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
{
|
||||
sharedCtor();
|
||||
|
||||
rememberGameSettings->setEnabled(false);
|
||||
descriptionEdit->setEnabled(false);
|
||||
maxPlayersEdit->setEnabled(false);
|
||||
passwordEdit->setEnabled(false);
|
||||
|
@ -157,6 +185,30 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
setWindowTitle(tr("Game information"));
|
||||
}
|
||||
|
||||
void DlgCreateGame::actReset()
|
||||
{
|
||||
descriptionEdit->setText("");
|
||||
maxPlayersEdit->setValue(2);
|
||||
|
||||
passwordEdit->setText("");
|
||||
onlyBuddiesCheckBox->setChecked(false);
|
||||
onlyRegisteredCheckBox->setChecked(true);
|
||||
|
||||
spectatorsAllowedCheckBox->setChecked(true);
|
||||
spectatorsNeedPasswordCheckBox->setChecked(false);
|
||||
spectatorsCanTalkCheckBox->setChecked(false);
|
||||
spectatorsSeeEverythingCheckBox->setChecked(false);
|
||||
|
||||
QMapIterator<int, QCheckBox *> gameTypeCheckBoxIterator(gameTypeCheckBoxes);
|
||||
while (gameTypeCheckBoxIterator.hasNext()) {
|
||||
gameTypeCheckBoxIterator.next();
|
||||
gameTypeCheckBoxIterator.value()->setChecked(false);
|
||||
}
|
||||
|
||||
descriptionEdit->setFocus();
|
||||
}
|
||||
|
||||
|
||||
void DlgCreateGame::actOK()
|
||||
{
|
||||
Command_CreateGame cmd;
|
||||
|
@ -170,13 +222,28 @@ void DlgCreateGame::actOK()
|
|||
cmd.set_spectators_can_talk(spectatorsCanTalkCheckBox->isChecked());
|
||||
cmd.set_spectators_see_everything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
|
||||
QString gameTypes = QString();
|
||||
QMapIterator<int, QCheckBox *> gameTypeCheckBoxIterator(gameTypeCheckBoxes);
|
||||
while (gameTypeCheckBoxIterator.hasNext()) {
|
||||
gameTypeCheckBoxIterator.next();
|
||||
if (gameTypeCheckBoxIterator.value()->isChecked())
|
||||
if (gameTypeCheckBoxIterator.value()->isChecked()) {
|
||||
cmd.add_game_type_ids(gameTypeCheckBoxIterator.key());
|
||||
gameTypes += gameTypeCheckBoxIterator.value()->text() + ", ";
|
||||
}
|
||||
}
|
||||
|
||||
settingsCache->setRememberGameSettings(rememberGameSettings->isChecked());
|
||||
if (rememberGameSettings->isChecked()){
|
||||
settingsCache->setGameDescription(descriptionEdit->text());
|
||||
settingsCache->setMaxPlayers(maxPlayersEdit->value());
|
||||
settingsCache->setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
|
||||
settingsCache->setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
|
||||
settingsCache->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
settingsCache->setGameTypes(gameTypes);
|
||||
}
|
||||
PendingCommand *pend = room->prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
|
||||
room->sendRoomCommand(pend);
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
DlgCreateGame(const ServerInfo_Game &game, const QMap<int, QString> &_gameTypes, QWidget *parent = 0);
|
||||
private slots:
|
||||
void actOK();
|
||||
void actReset();
|
||||
void checkResponse(const Response &response);
|
||||
void spectatorsAllowedChanged(int state);
|
||||
private:
|
||||
|
@ -37,6 +38,8 @@ private:
|
|||
QCheckBox *onlyBuddiesCheckBox, *onlyRegisteredCheckBox;
|
||||
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
|
||||
QDialogButtonBox *buttonBox;
|
||||
QPushButton *clearButton;
|
||||
QCheckBox *rememberGameSettings;
|
||||
|
||||
void sharedCtor();
|
||||
};
|
||||
|
|
91
cockatrice/src/dlg_edit_avatar.cpp
Normal file
91
cockatrice/src/dlg_edit_avatar.cpp
Normal file
|
@ -0,0 +1,91 @@
|
|||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QImageReader>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "dlg_edit_avatar.h"
|
||||
|
||||
DlgEditAvatar::DlgEditAvatar(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
imageLabel = new QLabel(tr("No image chosen."));
|
||||
imageLabel->setFixedSize(400, 200);
|
||||
imageLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
imageLabel->setStyleSheet("border: 1px solid #000");
|
||||
|
||||
textLabel = new QLabel(tr("To change your avatar, choose a new image.\nTo remove your current avatar, confirm without choosing a new image."));
|
||||
browseButton = new QPushButton(tr("Browse..."));
|
||||
connect(browseButton, SIGNAL(clicked()), this, SLOT(actBrowse()));
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(imageLabel, 0, 0, 1, 2);
|
||||
grid->addWidget(textLabel, 1, 0);
|
||||
grid->addWidget(browseButton, 1, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(actCancel()));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(grid);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("Change avatar"));
|
||||
setFixedHeight(sizeHint().height());
|
||||
setMinimumWidth(300);
|
||||
}
|
||||
|
||||
void DlgEditAvatar::actOk()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
||||
void DlgEditAvatar::actCancel()
|
||||
{
|
||||
reject();
|
||||
}
|
||||
|
||||
void DlgEditAvatar::actBrowse()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open Image"), QDir::homePath(), tr("Image Files (*.png *.jpg *.bmp)"));
|
||||
if(fileName.isEmpty())
|
||||
{
|
||||
imageLabel->setText(tr("No image chosen."));
|
||||
return;
|
||||
}
|
||||
|
||||
QImage image;
|
||||
QImageReader imgReader;
|
||||
imgReader.setDecideFormatFromContent(true);
|
||||
imgReader.setFileName(fileName);
|
||||
if(!imgReader.read(&image))
|
||||
{
|
||||
qDebug() << "Avatar image loading failed for file:" << fileName;
|
||||
imageLabel->setText(tr("Invalid image chosen."));
|
||||
return;
|
||||
}
|
||||
imageLabel->setPixmap(QPixmap::fromImage(image).scaled(400, 200, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
}
|
||||
|
||||
QByteArray DlgEditAvatar::getImage()
|
||||
{
|
||||
const QPixmap *pix = imageLabel->pixmap();
|
||||
if(!pix || pix->isNull())
|
||||
return QByteArray();
|
||||
|
||||
QImage image = pix->toImage();
|
||||
if(image.isNull())
|
||||
return QByteArray();
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
image.save(&buffer, "JPG");
|
||||
return ba;
|
||||
}
|
26
cockatrice/src/dlg_edit_avatar.h
Normal file
26
cockatrice/src/dlg_edit_avatar.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef DLG_EDITAVATAR_H
|
||||
#define DLG_EDITAVATAR_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QCheckBox;
|
||||
|
||||
class DlgEditAvatar : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgEditAvatar(QWidget *parent = 0);
|
||||
QByteArray getImage();
|
||||
private slots:
|
||||
void actOk();
|
||||
void actCancel();
|
||||
void actBrowse();
|
||||
private:
|
||||
QLabel *textLabel, *imageLabel;
|
||||
QPushButton *browseButton;
|
||||
};
|
||||
|
||||
#endif
|
77
cockatrice/src/dlg_edit_password.cpp
Normal file
77
cockatrice/src/dlg_edit_password.cpp
Normal file
|
@ -0,0 +1,77 @@
|
|||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
#include <QSettings>
|
||||
|
||||
#include "dlg_edit_password.h"
|
||||
|
||||
DlgEditPassword::DlgEditPassword(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.beginGroup("server");
|
||||
|
||||
oldPasswordLabel = new QLabel(tr("Old password:"));
|
||||
oldPasswordEdit = new QLineEdit();
|
||||
|
||||
if(settings.value("save_password", 1).toInt())
|
||||
oldPasswordEdit->setText(settings.value("password").toString());
|
||||
|
||||
oldPasswordLabel->setBuddy(oldPasswordEdit);
|
||||
oldPasswordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
newPasswordLabel = new QLabel(tr("New password:"));
|
||||
newPasswordEdit = new QLineEdit();
|
||||
newPasswordLabel->setBuddy(newPasswordLabel);
|
||||
newPasswordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
newPasswordLabel2 = new QLabel(tr("Confirm new password:"));
|
||||
newPasswordEdit2 = new QLineEdit();
|
||||
newPasswordLabel2->setBuddy(newPasswordLabel2);
|
||||
newPasswordEdit2->setEchoMode(QLineEdit::Password);
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(oldPasswordLabel, 0, 0);
|
||||
grid->addWidget(oldPasswordEdit, 0, 1);
|
||||
grid->addWidget(newPasswordLabel, 1, 0);
|
||||
grid->addWidget(newPasswordEdit, 1, 1);
|
||||
grid->addWidget(newPasswordLabel2, 2, 0);
|
||||
grid->addWidget(newPasswordEdit2, 2, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(actCancel()));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(grid);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("Change password"));
|
||||
setFixedHeight(sizeHint().height());
|
||||
setMinimumWidth(300);
|
||||
}
|
||||
|
||||
void DlgEditPassword::actOk()
|
||||
{
|
||||
if(newPasswordEdit->text() != newPasswordEdit2->text())
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("The new passwords don't match."));
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup("server");
|
||||
// always save the password so it will be picked up by the connect dialog
|
||||
settings.setValue("password", newPasswordEdit->text());
|
||||
settings.endGroup();
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
void DlgEditPassword::actCancel()
|
||||
{
|
||||
reject();
|
||||
}
|
26
cockatrice/src/dlg_edit_password.h
Normal file
26
cockatrice/src/dlg_edit_password.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef DLG_EDITPASSWORD_H
|
||||
#define DLG_EDITPASSWORD_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QCheckBox;
|
||||
|
||||
class DlgEditPassword : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgEditPassword(QWidget *parent = 0);
|
||||
QString getOldPassword() const { return oldPasswordEdit->text(); }
|
||||
QString getNewPassword() const { return newPasswordEdit->text(); }
|
||||
private slots:
|
||||
void actOk();
|
||||
void actCancel();
|
||||
private:
|
||||
QLabel *oldPasswordLabel, *newPasswordLabel, *newPasswordLabel2;
|
||||
QLineEdit *oldPasswordEdit, *newPasswordEdit, *newPasswordEdit2;
|
||||
};
|
||||
|
||||
#endif
|
81
cockatrice/src/dlg_edit_user.cpp
Normal file
81
cockatrice/src/dlg_edit_user.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include <QSettings>
|
||||
#include <QLabel>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "dlg_edit_user.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString country, QString realName)
|
||||
: QDialog(parent)
|
||||
{
|
||||
emailLabel = new QLabel(tr("Email:"));
|
||||
emailEdit = new QLineEdit();
|
||||
emailLabel->setBuddy(emailEdit);
|
||||
emailEdit->setText(email);
|
||||
|
||||
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->setCurrentIndex(gender + 1);
|
||||
|
||||
countryLabel = new QLabel(tr("Country:"));
|
||||
countryEdit = new QComboBox();
|
||||
countryLabel->setBuddy(countryEdit);
|
||||
countryEdit->insertItem(0, tr("Undefined"));
|
||||
countryEdit->setCurrentIndex(0);
|
||||
|
||||
QStringList countries = settingsCache->getCountries();
|
||||
int i = 1;
|
||||
foreach(QString c, countries)
|
||||
{
|
||||
countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c);
|
||||
if (c == country)
|
||||
countryEdit->setCurrentIndex(i);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
realnameEdit = new QLineEdit();
|
||||
realnameLabel->setBuddy(realnameEdit);
|
||||
realnameEdit->setText(realName);
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(emailLabel, 0, 0);
|
||||
grid->addWidget(emailEdit, 0, 1);
|
||||
grid->addWidget(genderLabel, 1, 0);
|
||||
grid->addWidget(genderEdit, 1, 1);
|
||||
grid->addWidget(countryLabel, 2, 0);
|
||||
grid->addWidget(countryEdit, 2, 1);
|
||||
grid->addWidget(realnameLabel, 3, 0);
|
||||
grid->addWidget(realnameEdit, 3, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(actCancel()));
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(grid);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
setLayout(mainLayout);
|
||||
|
||||
setWindowTitle(tr("Edit user profile"));
|
||||
setFixedHeight(sizeHint().height());
|
||||
setMinimumWidth(300);
|
||||
}
|
||||
|
||||
void DlgEditUser::actOk()
|
||||
{
|
||||
accept();
|
||||
}
|
||||
|
||||
void DlgEditUser::actCancel()
|
||||
{
|
||||
reject();
|
||||
}
|
29
cockatrice/src/dlg_edit_user.h
Normal file
29
cockatrice/src/dlg_edit_user.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#ifndef DLG_EDITUSER_H
|
||||
#define DLG_EDITUSER_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
|
||||
class QLabel;
|
||||
class QPushButton;
|
||||
class QCheckBox;
|
||||
|
||||
class DlgEditUser : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DlgEditUser(QWidget *parent = 0, QString email = QString(), int gender = -1, QString country = QString(), QString realName = QString());
|
||||
QString getEmail() const { return emailEdit->text(); }
|
||||
int getGender() const { return genderEdit->currentIndex() - 1; }
|
||||
QString getCountry() const { return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
|
||||
QString getRealName() const { return realnameEdit->text(); }
|
||||
private slots:
|
||||
void actOk();
|
||||
void actCancel();
|
||||
private:
|
||||
QLabel *emailLabel, *genderLabel, *countryLabel, *realnameLabel;
|
||||
QLineEdit *emailEdit, *realnameEdit;
|
||||
QComboBox *genderEdit, *countryEdit;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -10,6 +10,7 @@
|
|||
#include <QMessageBox>
|
||||
#include "dlg_load_deck_from_clipboard.h"
|
||||
#include "deck_loader.h"
|
||||
#include "settingscache.h"
|
||||
|
||||
DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent)
|
||||
: QDialog(parent), deckList(0)
|
||||
|
@ -17,7 +18,6 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent)
|
|||
contentsEdit = new QPlainTextEdit;
|
||||
|
||||
refreshButton = new QPushButton(tr("&Refresh"));
|
||||
refreshButton->setShortcut(QKeySequence("F5"));
|
||||
connect(refreshButton, SIGNAL(clicked()), this, SLOT(actRefresh()));
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
@ -35,6 +35,8 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent)
|
|||
resize(500, 500);
|
||||
|
||||
actRefresh();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
}
|
||||
|
||||
void DlgLoadDeckFromClipboard::actRefresh()
|
||||
|
@ -42,13 +44,31 @@ void DlgLoadDeckFromClipboard::actRefresh()
|
|||
contentsEdit->setPlainText(QApplication::clipboard()->text());
|
||||
}
|
||||
|
||||
void DlgLoadDeckFromClipboard::refreshShortcuts()
|
||||
{
|
||||
refreshButton->setShortcut(settingsCache->shortcuts().getSingleShortcut("DlgLoadDeckFromClipboard/refreshButton"));
|
||||
}
|
||||
|
||||
void DlgLoadDeckFromClipboard::actOK()
|
||||
{
|
||||
QString buffer = contentsEdit->toPlainText();
|
||||
QTextStream stream(&buffer);
|
||||
|
||||
DeckLoader *l = new DeckLoader;
|
||||
if (l->loadFromStream_Plain(stream)) {
|
||||
if (buffer.contains("<cockatrice_deck version=\"1\">"))
|
||||
{
|
||||
if (l->loadFromString_Native(buffer))
|
||||
{
|
||||
deckList = l;
|
||||
accept();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid deck list."));
|
||||
delete l;
|
||||
}
|
||||
}
|
||||
else if (l->loadFromStream_Plain(stream)) {
|
||||
deckList = l;
|
||||
accept();
|
||||
} else {
|
||||
|
|
|
@ -12,6 +12,7 @@ class DlgLoadDeckFromClipboard : public QDialog {
|
|||
private slots:
|
||||
void actOK();
|
||||
void actRefresh();
|
||||
void refreshShortcuts();
|
||||
private:
|
||||
DeckLoader *deckList;
|
||||
public:
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "dlg_register.h"
|
||||
#include "settingscache.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
|
||||
DlgRegister::DlgRegister(QWidget *parent)
|
||||
|
@ -32,16 +34,25 @@ DlgRegister::DlgRegister(QWidget *parent)
|
|||
passwordLabel->setBuddy(passwordEdit);
|
||||
passwordEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
passwordConfirmationLabel = new QLabel(tr("Password (again):"));
|
||||
passwordConfirmationEdit = new QLineEdit();
|
||||
passwordConfirmationLabel->setBuddy(passwordConfirmationEdit);
|
||||
passwordConfirmationEdit->setEchoMode(QLineEdit::Password);
|
||||
|
||||
emailLabel = new QLabel(tr("Email:"));
|
||||
emailEdit = new QLineEdit();
|
||||
emailLabel->setBuddy(emailEdit);
|
||||
|
||||
genderLabel = new QLabel(tr("Gender:"));
|
||||
emailConfirmationLabel = new QLabel(tr("Email (again):"));
|
||||
emailConfirmationEdit = new QLineEdit();
|
||||
emailConfirmationLabel->setBuddy(emailConfirmationEdit);
|
||||
|
||||
genderLabel = new QLabel(tr("Pronouns:"));
|
||||
genderEdit = new QComboBox();
|
||||
genderLabel->setBuddy(genderEdit);
|
||||
genderEdit->insertItem(0, QIcon("theme:genders/unknown.svg"), tr("Undefined"));
|
||||
genderEdit->insertItem(1, QIcon("theme:genders/male.svg"), tr("Male"));
|
||||
genderEdit->insertItem(2, QIcon("theme:genders/female.svg"), tr("Female"));
|
||||
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:"));
|
||||
|
@ -298,6 +309,9 @@ DlgRegister::DlgRegister(QWidget *parent)
|
|||
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);
|
||||
|
||||
realnameLabel = new QLabel(tr("Real name:"));
|
||||
realnameEdit = new QLineEdit();
|
||||
|
@ -312,14 +326,18 @@ DlgRegister::DlgRegister(QWidget *parent)
|
|||
grid->addWidget(playernameEdit, 2, 1);
|
||||
grid->addWidget(passwordLabel, 3, 0);
|
||||
grid->addWidget(passwordEdit, 3, 1);
|
||||
grid->addWidget(emailLabel, 4, 0);
|
||||
grid->addWidget(emailEdit, 4, 1);
|
||||
grid->addWidget(genderLabel, 5, 0);
|
||||
grid->addWidget(genderEdit, 5, 1);
|
||||
grid->addWidget(countryLabel, 6, 0);
|
||||
grid->addWidget(countryEdit, 6, 1);
|
||||
grid->addWidget(realnameLabel, 7, 0);
|
||||
grid->addWidget(realnameEdit, 7, 1);
|
||||
grid->addWidget(passwordConfirmationLabel, 4, 0);
|
||||
grid->addWidget(passwordConfirmationEdit, 4, 1);
|
||||
grid->addWidget(emailLabel, 5, 0);
|
||||
grid->addWidget(emailEdit, 5, 1);
|
||||
grid->addWidget(emailConfirmationLabel, 6, 0);
|
||||
grid->addWidget(emailConfirmationEdit, 6, 1);
|
||||
grid->addWidget(genderLabel, 7, 0);
|
||||
grid->addWidget(genderEdit, 7, 1);
|
||||
grid->addWidget(countryLabel, 8, 0);
|
||||
grid->addWidget(countryEdit, 8, 1);
|
||||
grid->addWidget(realnameLabel, 9, 0);
|
||||
grid->addWidget(realnameEdit, 9, 1);
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOk()));
|
||||
|
@ -337,6 +355,17 @@ DlgRegister::DlgRegister(QWidget *parent)
|
|||
|
||||
void DlgRegister::actOk()
|
||||
{
|
||||
if (passwordEdit->text() != passwordConfirmationEdit->text())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Registration Warning"), tr("Your passwords do not match, please try again."));
|
||||
return;
|
||||
}
|
||||
else if (emailConfirmationEdit->text() != emailEdit->text())
|
||||
{
|
||||
QMessageBox::critical(this, tr("Registration Warning"), tr("Your email addresses do not match, please try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup("server");
|
||||
settings.setValue("hostname", hostEdit->text());
|
||||
|
|
|
@ -19,14 +19,14 @@ public:
|
|||
QString getPassword() const { return passwordEdit->text(); }
|
||||
QString getEmail() const { return emailEdit->text(); }
|
||||
int getGender() const { return genderEdit->currentIndex() - 1; }
|
||||
QString getCountry() const { return genderEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
|
||||
QString getCountry() const { return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
|
||||
QString getRealName() const { return realnameEdit->text(); }
|
||||
private slots:
|
||||
void actOk();
|
||||
void actCancel();
|
||||
private:
|
||||
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *emailLabel, *genderLabel, *countryLabel, *realnameLabel;
|
||||
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit, *emailEdit, *realnameEdit;
|
||||
QLabel *hostLabel, *portLabel, *playernameLabel, *passwordLabel, *passwordConfirmationLabel, *emailLabel, *emailConfirmationLabel, *genderLabel, *countryLabel, *realnameLabel;
|
||||
QLineEdit *hostEdit, *portEdit, *playernameEdit, *passwordEdit, *passwordConfirmationEdit, *emailEdit, *emailConfirmationEdit, *realnameEdit;
|
||||
QComboBox *genderEdit, *countryEdit;
|
||||
};
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#include "thememanager.h"
|
||||
#include "priceupdater.h"
|
||||
#include "soundengine.h"
|
||||
#include "sequenceEdit/shortcutstab.h"
|
||||
|
||||
#define LINKING_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Custom-Download-URLs"
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPage()
|
||||
{
|
||||
|
@ -52,12 +55,17 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
pixmapCacheEdit.setSuffix(" MB");
|
||||
picDownloadHqCheckBox.setChecked(settingsCache->getPicDownloadHq());
|
||||
picDownloadCheckBox.setChecked(settingsCache->getPicDownload());
|
||||
|
||||
highQualityURLEdit = new QLineEdit(settingsCache->getPicUrlHq());
|
||||
highQualityURLEdit->setEnabled(settingsCache->getPicDownloadHq());
|
||||
|
||||
connect(&clearDownloadedPicsButton, SIGNAL(clicked()), this, SLOT(clearDownloadedPicsButtonClicked()));
|
||||
connect(&languageBox, SIGNAL(currentIndexChanged(int)), this, SLOT(languageBoxChanged(int)));
|
||||
connect(&picDownloadCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownload(int)));
|
||||
connect(&picDownloadHqCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPicDownloadHq(int)));
|
||||
connect(&pixmapCacheEdit, SIGNAL(valueChanged(int)), settingsCache, SLOT(setPixmapCacheSize(int)));
|
||||
connect(&picDownloadHqCheckBox, SIGNAL(clicked(bool)), this, SLOT(setEnabledStatus(bool)));
|
||||
connect(highQualityURLEdit, SIGNAL(textChanged(QString)), settingsCache, SLOT(setPicUrlHq(QString)));
|
||||
|
||||
QGridLayout *personalGrid = new QGridLayout;
|
||||
personalGrid->addWidget(&languageLabel, 0, 0);
|
||||
|
@ -67,6 +75,12 @@ GeneralSettingsPage::GeneralSettingsPage()
|
|||
personalGrid->addWidget(&picDownloadCheckBox, 2, 0, 1, 2);
|
||||
personalGrid->addWidget(&picDownloadHqCheckBox, 3, 0, 1, 2);
|
||||
personalGrid->addWidget(&clearDownloadedPicsButton, 4, 0, 1, 1);
|
||||
personalGrid->addWidget(&highQualityURLLabel, 5, 0, 1, 1);
|
||||
personalGrid->addWidget(highQualityURLEdit, 5, 1, 1, 1);
|
||||
personalGrid->addWidget(&highQualityURLLinkLabel, 6, 1, 1, 1);
|
||||
|
||||
highQualityURLLinkLabel.setTextInteractionFlags(Qt::LinksAccessibleByMouse);
|
||||
highQualityURLLinkLabel.setOpenExternalLinks(true);
|
||||
|
||||
personalGroupBox = new QGroupBox;
|
||||
personalGroupBox->setLayout(personalGrid);
|
||||
|
@ -222,7 +236,7 @@ void GeneralSettingsPage::retranslateUi()
|
|||
personalGroupBox->setTitle(tr("Personal settings"));
|
||||
languageLabel.setText(tr("Language:"));
|
||||
picDownloadCheckBox.setText(tr("Download card pictures on the fly"));
|
||||
picDownloadHqCheckBox.setText(tr("Download high-quality card pictures"));
|
||||
picDownloadHqCheckBox.setText(tr("Download card pictures from a custom URL"));
|
||||
pathsGroupBox->setTitle(tr("Paths"));
|
||||
deckPathLabel.setText(tr("Decks directory:"));
|
||||
replaysPathLabel.setText(tr("Replays directory:"));
|
||||
|
@ -230,9 +244,16 @@ void GeneralSettingsPage::retranslateUi()
|
|||
cardDatabasePathLabel.setText(tr("Card database:"));
|
||||
tokenDatabasePathLabel.setText(tr("Token database:"));
|
||||
pixmapCacheLabel.setText(tr("Picture cache size:"));
|
||||
highQualityURLLabel.setText(tr("Custom Card Download URL:"));
|
||||
highQualityURLLinkLabel.setText(QString("<a href='%1'>%2</a>").arg(LINKING_FAQ_URL).arg(tr("Linking FAQ")));
|
||||
clearDownloadedPicsButton.setText(tr("Reset/Clear Downloaded Pictures"));
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setEnabledStatus(bool status)
|
||||
{
|
||||
highQualityURLEdit->setEnabled(status);
|
||||
}
|
||||
|
||||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
{
|
||||
QString themeName = settingsCache->getThemeName();
|
||||
|
@ -344,12 +365,16 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
|
||||
playToStackCheckBox.setChecked(settingsCache->getPlayToStack());
|
||||
connect(&playToStackCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPlayToStack(int)));
|
||||
|
||||
|
||||
annotateTokensCheckBox.setChecked(settingsCache->getAnnotateTokens());
|
||||
connect(&annotateTokensCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setAnnotateTokens(int)));
|
||||
|
||||
QGridLayout *generalGrid = new QGridLayout;
|
||||
generalGrid->addWidget(¬ificationsEnabledCheckBox, 0, 0);
|
||||
generalGrid->addWidget(&specNotificationsEnabledCheckBox, 1, 0);
|
||||
generalGrid->addWidget(&doubleClickToPlayCheckBox, 2, 0);
|
||||
generalGrid->addWidget(&playToStackCheckBox, 3, 0);
|
||||
generalGrid->addWidget(&annotateTokensCheckBox, 4, 0);
|
||||
|
||||
generalGroupBox = new QGroupBox;
|
||||
generalGroupBox->setLayout(generalGrid);
|
||||
|
@ -381,6 +406,7 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
specNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar for game events while you are spectating"));
|
||||
doubleClickToPlayCheckBox.setText(tr("&Double-click cards to play them (instead of single-click)"));
|
||||
playToStackCheckBox.setText(tr("&Play all nonlands onto the stack (not the battlefield) by default"));
|
||||
annotateTokensCheckBox.setText(tr("Annotate card text on tokens"));
|
||||
animationGroupBox->setTitle(tr("Animation settings"));
|
||||
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
||||
}
|
||||
|
@ -391,7 +417,7 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
|||
//priceTagsCheckBox.setChecked(settingsCache->getPriceTagFeature());
|
||||
//connect(&priceTagsCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setPriceTagFeature(int)));
|
||||
|
||||
connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int)));
|
||||
//connect(this, SIGNAL(priceTagSourceChanged(int)), settingsCache, SLOT(setPriceTagSource(int)));
|
||||
|
||||
QGridLayout *generalGrid = new QGridLayout;
|
||||
//generalGrid->addWidget(&priceTagsCheckBox, 0, 0);
|
||||
|
@ -428,6 +454,9 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
{
|
||||
chatMentionCheckBox.setChecked(settingsCache->getChatMention());
|
||||
connect(&chatMentionCheckBox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMention(int)));
|
||||
|
||||
chatMentionCompleterCheckbox.setChecked(settingsCache->getChatMentionCompleter());
|
||||
connect(&chatMentionCompleterCheckbox, SIGNAL(stateChanged(int)), settingsCache, SLOT(setChatMentionCompleter(int)));
|
||||
|
||||
ignoreUnregUsersMainChat.setChecked(settingsCache->getIgnoreUnregisteredUsers());
|
||||
ignoreUnregUserMessages.setChecked(settingsCache->getIgnoreUnregisteredUserMessages());
|
||||
|
@ -437,6 +466,9 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
invertMentionForeground.setChecked(settingsCache->getChatMentionForeground());
|
||||
connect(&invertMentionForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextColor(int)));
|
||||
|
||||
invertHighlightForeground.setChecked(settingsCache->getChatHighlightForeground());
|
||||
connect(&invertHighlightForeground, SIGNAL(stateChanged(int)), this, SLOT(updateTextHighlightColor(int)));
|
||||
|
||||
mentionColor = new QLineEdit();
|
||||
mentionColor->setText(settingsCache->getChatMentionColor());
|
||||
updateMentionPreview();
|
||||
|
@ -448,17 +480,37 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
mentionPopups.setChecked(settingsCache->getShowMentionPopup());
|
||||
connect(&mentionPopups, SIGNAL(stateChanged(int)), settingsCache, SLOT(setShowMentionPopups(int)));
|
||||
|
||||
customAlertString = new QLineEdit();
|
||||
customAlertString->setPlaceholderText("Word1 Word2 Word3");
|
||||
customAlertString->setText(settingsCache->getHighlightWords());
|
||||
connect(customAlertString, SIGNAL(textChanged(QString)), settingsCache, SLOT(setHighlightWords(QString)));
|
||||
|
||||
QGridLayout *chatGrid = new QGridLayout;
|
||||
chatGrid->addWidget(&chatMentionCheckBox, 0, 0);
|
||||
chatGrid->addWidget(&invertMentionForeground, 0, 1);
|
||||
chatGrid->addWidget(mentionColor, 0, 2);
|
||||
chatGrid->addWidget(&ignoreUnregUsersMainChat, 1, 0);
|
||||
chatGrid->addWidget(&chatMentionCompleterCheckbox, 1, 0);
|
||||
chatGrid->addWidget(&ignoreUnregUsersMainChat, 2, 0);
|
||||
chatGrid->addWidget(&hexLabel, 1, 2);
|
||||
chatGrid->addWidget(&ignoreUnregUserMessages, 2, 0);
|
||||
chatGrid->addWidget(&messagePopups, 3, 0);
|
||||
chatGrid->addWidget(&mentionPopups, 4, 0);
|
||||
chatGrid->addWidget(&ignoreUnregUserMessages, 3, 0);
|
||||
chatGrid->addWidget(&messagePopups, 4, 0);
|
||||
chatGrid->addWidget(&mentionPopups, 5, 0);
|
||||
chatGroupBox = new QGroupBox;
|
||||
chatGroupBox->setLayout(chatGrid);
|
||||
|
||||
highlightColor = new QLineEdit();
|
||||
highlightColor->setText(settingsCache->getChatHighlightColor());
|
||||
updateHighlightPreview();
|
||||
connect(highlightColor, SIGNAL(textChanged(QString)), this, SLOT(updateHighlightColor(QString)));
|
||||
|
||||
QGridLayout *highlightNotice = new QGridLayout;
|
||||
highlightNotice->addWidget(highlightColor, 0, 2);
|
||||
highlightNotice->addWidget(&invertHighlightForeground, 0, 1);
|
||||
highlightNotice->addWidget(&hexHighlightLabel, 1, 2);
|
||||
highlightNotice->addWidget(customAlertString, 0, 0);
|
||||
highlightNotice->addWidget(&customAlertStringLabel, 1, 0);
|
||||
highlightGroupBox = new QGroupBox;
|
||||
highlightGroupBox->setLayout(highlightNotice);
|
||||
|
||||
QSettings settings;
|
||||
messageList = new QListWidget;
|
||||
|
@ -485,11 +537,12 @@ MessagesSettingsPage::MessagesSettingsPage()
|
|||
|
||||
messageShortcuts = new QGroupBox;
|
||||
messageShortcuts->setLayout(messageListLayout);
|
||||
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
|
||||
|
||||
mainLayout->addWidget(messageShortcuts);
|
||||
mainLayout->addWidget(chatGroupBox);
|
||||
mainLayout->addWidget(highlightGroupBox);
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
||||
|
@ -505,16 +558,35 @@ void MessagesSettingsPage::updateColor(const QString &value) {
|
|||
}
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::updateHighlightColor(const QString &value) {
|
||||
QColor colorToSet;
|
||||
colorToSet.setNamedColor("#" + value);
|
||||
if (colorToSet.isValid()) {
|
||||
settingsCache->setChatHighlightColor(value);
|
||||
updateHighlightPreview();
|
||||
}
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::updateTextColor(int value) {
|
||||
settingsCache->setChatMentionForeground(value);
|
||||
updateMentionPreview();
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::updateTextHighlightColor(int value) {
|
||||
settingsCache->setChatHighlightForeground(value);
|
||||
updateHighlightPreview();
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::updateMentionPreview() {
|
||||
mentionColor->setStyleSheet("QLineEdit{background:#" + settingsCache->getChatMentionColor() +
|
||||
";color: " + (settingsCache->getChatMentionForeground() ? "white" : "black") + ";}");
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::updateHighlightPreview() {
|
||||
highlightColor->setStyleSheet("QLineEdit{background:#" + settingsCache->getChatHighlightColor() +
|
||||
";color: " + (settingsCache->getChatHighlightForeground() ? "white" : "black") + ";}");
|
||||
}
|
||||
|
||||
void MessagesSettingsPage::storeSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
@ -545,15 +617,19 @@ void MessagesSettingsPage::actRemove()
|
|||
void MessagesSettingsPage::retranslateUi()
|
||||
{
|
||||
chatGroupBox->setTitle(tr("Chat settings"));
|
||||
highlightGroupBox->setTitle(tr("Custom alert words"));
|
||||
chatMentionCheckBox.setText(tr("Enable chat mentions"));
|
||||
chatMentionCompleterCheckbox.setText(tr("Enable mention completer"));
|
||||
messageShortcuts->setTitle(tr("In-game message macros"));
|
||||
ignoreUnregUsersMainChat.setText(tr("Ignore unregistered users in main chat"));
|
||||
ignoreUnregUsersMainChat.setText(tr("Ignore chat room messages sent by unregistered users."));
|
||||
ignoreUnregUserMessages.setText(tr("Ignore private messages sent by unregistered users."));
|
||||
ignoreUnregUsersMainChat.setText(tr("Ignore chat room messages sent by unregistered users"));
|
||||
ignoreUnregUserMessages.setText(tr("Ignore private messages sent by unregistered users"));
|
||||
invertMentionForeground.setText(tr("Invert text color"));
|
||||
messagePopups.setText(tr("Enable desktop notifications for private messages."));
|
||||
invertHighlightForeground.setText(tr("Invert text color"));
|
||||
messagePopups.setText(tr("Enable desktop notifications for private messages"));
|
||||
mentionPopups.setText(tr("Enable desktop notification for mentions."));
|
||||
hexLabel.setText(tr("(Color is hexadecimal)"));
|
||||
hexHighlightLabel.setText(tr("(Color is hexadecimal)"));
|
||||
customAlertStringLabel.setText(tr("Separate words with a space, alphanumeric characters only"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -668,6 +744,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);
|
||||
|
@ -722,6 +799,11 @@ void DlgSettings::createIcons()
|
|||
soundButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
|
||||
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"));
|
||||
|
||||
connect(contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWidgetItem *)));
|
||||
}
|
||||
|
||||
|
@ -831,6 +913,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<AbstractSettingsPage *>(pagesWidget->widget(i))->retranslateUi();
|
||||
|
|
|
@ -44,6 +44,7 @@ private slots:
|
|||
void cardDatabasePathButtonClicked();
|
||||
void tokenDatabasePathButtonClicked();
|
||||
void languageBoxChanged(int index);
|
||||
void setEnabledStatus(bool);
|
||||
private:
|
||||
QStringList findQmFiles();
|
||||
QString languageName(const QString &qmFile);
|
||||
|
@ -52,6 +53,7 @@ private:
|
|||
QLineEdit *picsPathEdit;
|
||||
QLineEdit *cardDatabasePathEdit;
|
||||
QLineEdit *tokenDatabasePathEdit;
|
||||
QLineEdit *highQualityURLEdit;
|
||||
QSpinBox pixmapCacheEdit;
|
||||
QGroupBox *personalGroupBox;
|
||||
QGroupBox *pathsGroupBox;
|
||||
|
@ -65,6 +67,8 @@ private:
|
|||
QLabel picsPathLabel;
|
||||
QLabel cardDatabasePathLabel;
|
||||
QLabel tokenDatabasePathLabel;
|
||||
QLabel highQualityURLLabel;
|
||||
QLabel highQualityURLLinkLabel;
|
||||
QPushButton clearDownloadedPicsButton;
|
||||
};
|
||||
|
||||
|
@ -100,6 +104,7 @@ private:
|
|||
QCheckBox specNotificationsEnabledCheckBox;
|
||||
QCheckBox doubleClickToPlayCheckBox;
|
||||
QCheckBox playToStackCheckBox;
|
||||
QCheckBox annotateTokensCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
QGroupBox *generalGroupBox;
|
||||
QGroupBox *animationGroupBox;
|
||||
|
@ -132,24 +137,34 @@ private slots:
|
|||
void actAdd();
|
||||
void actRemove();
|
||||
void updateColor(const QString &value);
|
||||
void updateHighlightColor(const QString &value);
|
||||
void updateTextColor(int value);
|
||||
void updateTextHighlightColor(int value);
|
||||
private:
|
||||
QListWidget *messageList;
|
||||
QAction *aAdd;
|
||||
QAction *aRemove;
|
||||
QCheckBox chatMentionCheckBox;
|
||||
QCheckBox chatMentionCompleterCheckbox;
|
||||
QCheckBox invertMentionForeground;
|
||||
QCheckBox invertHighlightForeground;
|
||||
QCheckBox ignoreUnregUsersMainChat;
|
||||
QCheckBox ignoreUnregUserMessages;
|
||||
QCheckBox messagePopups;
|
||||
QCheckBox mentionPopups;
|
||||
QGroupBox *chatGroupBox;
|
||||
QGroupBox *highlightGroupBox;
|
||||
QGroupBox *messageShortcuts;
|
||||
QLineEdit *mentionColor;
|
||||
QLineEdit *highlightColor;
|
||||
QLineEdit *customAlertString;
|
||||
QLabel hexLabel;
|
||||
QLabel hexHighlightLabel;
|
||||
QLabel customAlertStringLabel;
|
||||
|
||||
void storeSettings();
|
||||
void updateMentionPreview();
|
||||
void updateHighlightPreview();
|
||||
};
|
||||
|
||||
class SoundSettingsPage : public AbstractSettingsPage {
|
||||
|
@ -186,6 +201,7 @@ private:
|
|||
QListWidget *contentsWidget;
|
||||
QStackedWidget *pagesWidget;
|
||||
QListWidgetItem *generalButton, *appearanceButton, *userInterfaceButton, *deckEditorButton, *messagesButton, *soundButton;
|
||||
QListWidgetItem *shortcutsButton;
|
||||
void createIcons();
|
||||
void retranslateUi();
|
||||
protected:
|
||||
|
|
|
@ -11,6 +11,7 @@ FilterBuilder::FilterBuilder(QWidget *parent)
|
|||
: QWidget(parent)
|
||||
{
|
||||
filterCombo = new QComboBox;
|
||||
filterCombo->setObjectName("filterCombo");
|
||||
for (int i = 0; i < CardFilter::AttrEnd; i++)
|
||||
filterCombo->addItem(
|
||||
tr(CardFilter::attrName(static_cast<CardFilter::Attr>(i))),
|
||||
|
@ -18,6 +19,7 @@ FilterBuilder::FilterBuilder(QWidget *parent)
|
|||
);
|
||||
|
||||
typeCombo = new QComboBox;
|
||||
typeCombo->setObjectName("typeCombo");
|
||||
for (int i = 0; i < CardFilter::TypeEnd; i++)
|
||||
typeCombo->addItem(
|
||||
tr(CardFilter::typeName(static_cast<CardFilter::Type>(i))),
|
||||
|
@ -25,12 +27,15 @@ FilterBuilder::FilterBuilder(QWidget *parent)
|
|||
);
|
||||
|
||||
QPushButton *ok = new QPushButton(QIcon("theme:icons/increment.svg"), QString());
|
||||
ok->setObjectName("ok");
|
||||
ok->setMaximumSize(20, 20);
|
||||
|
||||
edit = new QLineEdit;
|
||||
edit->setObjectName("edit");
|
||||
edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
|
||||
QGridLayout *layout = new QGridLayout;
|
||||
layout->setObjectName("layout");
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
layout->addWidget(typeCombo, 0, 0, 1, 2);
|
||||
|
|
|
@ -11,9 +11,13 @@
|
|||
#include <QSet>
|
||||
#include <QBasicTimer>
|
||||
#include <QGraphicsView>
|
||||
#include <QDebug>
|
||||
|
||||
GameScene::GameScene(PhasesToolbar *_phasesToolbar, QObject *parent)
|
||||
: QGraphicsScene(parent), phasesToolbar(_phasesToolbar), viewSize(QSize())
|
||||
: QGraphicsScene(parent),
|
||||
phasesToolbar(_phasesToolbar),
|
||||
viewSize(QSize()),
|
||||
playerRotation(0)
|
||||
{
|
||||
animationTimer = new QBasicTimer;
|
||||
addItem(phasesToolbar);
|
||||
|
@ -35,7 +39,7 @@ void GameScene::retranslateUi()
|
|||
|
||||
void GameScene::addPlayer(Player *player)
|
||||
{
|
||||
qDebug("GameScene::addPlayer");
|
||||
qDebug() << "GameScene::addPlayer name=" << player->getName();
|
||||
players << player;
|
||||
addItem(player);
|
||||
connect(player, SIGNAL(sizeChanged()), this, SLOT(rearrange()));
|
||||
|
@ -44,39 +48,63 @@ void GameScene::addPlayer(Player *player)
|
|||
|
||||
void GameScene::removePlayer(Player *player)
|
||||
{
|
||||
qDebug("GameScene::removePlayer");
|
||||
qDebug() << "GameScene::removePlayer name=" << player->getName();
|
||||
players.removeAt(players.indexOf(player));
|
||||
removeItem(player);
|
||||
rearrange();
|
||||
}
|
||||
|
||||
void GameScene::adjustPlayerRotation(int rotationAdjustment)
|
||||
{
|
||||
playerRotation += rotationAdjustment;
|
||||
rearrange();
|
||||
}
|
||||
|
||||
void GameScene::rearrange()
|
||||
{
|
||||
playersByColumn.clear();
|
||||
|
||||
// Create the list of players playing, noting the first player's index.
|
||||
QList<Player *> playersPlaying;
|
||||
int firstPlayer = -1;
|
||||
for (int i = 0; i < players.size(); ++i)
|
||||
if (!players[i]->getConceded()) {
|
||||
playersPlaying.append(players[i]);
|
||||
if ((firstPlayer == -1) && (players[i]->getLocal()))
|
||||
firstPlayer = playersPlaying.size() - 1;
|
||||
int firstPlayerIndex = 0;
|
||||
bool firstPlayerFound = false;
|
||||
QListIterator<Player *> playersIter(players);
|
||||
while (playersIter.hasNext()) {
|
||||
Player *p = playersIter.next();
|
||||
if (!p->getConceded()) {
|
||||
playersPlaying.append(p);
|
||||
if (!firstPlayerFound && (p->getLocal())) {
|
||||
firstPlayerIndex = playersPlaying.size() - 1;
|
||||
firstPlayerFound = true;
|
||||
}
|
||||
}
|
||||
if (firstPlayer == -1)
|
||||
firstPlayer = 0;
|
||||
}
|
||||
|
||||
// Rotate the players playing list so that first player is first, then
|
||||
// adjust by the additional rotation setting.
|
||||
if (!playersPlaying.isEmpty()) {
|
||||
int totalRotation = firstPlayerIndex + playerRotation;
|
||||
while (totalRotation < 0)
|
||||
totalRotation += playersPlaying.size();
|
||||
for (int i = 0; i < totalRotation; ++i) {
|
||||
playersPlaying.append(playersPlaying.takeFirst());
|
||||
}
|
||||
}
|
||||
|
||||
const int playersCount = playersPlaying.size();
|
||||
const int columns = playersCount < settingsCache->getMinPlayersForMultiColumnLayout() ? 1 : 2;
|
||||
const int rows = ceil((qreal) playersCount / columns);
|
||||
qreal sceneHeight = 0, sceneWidth = -playerAreaSpacing;
|
||||
QList<int> columnWidth;
|
||||
int firstPlayerOfColumn = firstPlayer;
|
||||
|
||||
QListIterator<Player *> playersPlayingIter(playersPlaying);
|
||||
for (int col = 0; col < columns; ++col) {
|
||||
playersByColumn.append(QList<Player *>());
|
||||
columnWidth.append(0);
|
||||
qreal thisColumnHeight = -playerAreaSpacing;
|
||||
const int rowsInColumn = rows - (playersCount % columns) * col; // only correct for max. 2 cols
|
||||
for (int j = 0; j < rowsInColumn; ++j) {
|
||||
Player *player = playersPlaying[(firstPlayerOfColumn + j) % playersCount];
|
||||
Player *player = playersPlayingIter.next();
|
||||
if (col == 0)
|
||||
playersByColumn[col].prepend(player);
|
||||
else
|
||||
|
@ -88,8 +116,6 @@ void GameScene::rearrange()
|
|||
if (thisColumnHeight > sceneHeight)
|
||||
sceneHeight = thisColumnHeight;
|
||||
sceneWidth += columnWidth[col] + playerAreaSpacing;
|
||||
|
||||
firstPlayerOfColumn += rowsInColumn;
|
||||
}
|
||||
|
||||
phasesToolbar->setHeight(sceneHeight);
|
||||
|
@ -202,14 +228,14 @@ void GameScene::processViewSizeChange(const QSize &newSize)
|
|||
setSceneRect(0, 0, newWidth, sceneRect().height());
|
||||
|
||||
qreal extraWidthPerColumn = (newWidth - minWidth) / playersByColumn.size();
|
||||
for (int col = 0; col < playersByColumn.size(); ++col)
|
||||
qreal newx = phasesToolbar->getWidth();
|
||||
for (int col = 0; col < playersByColumn.size(); ++col) {
|
||||
for (int row = 0; row < playersByColumn[col].size(); ++row){
|
||||
playersByColumn[col][row]->processSceneSizeChange(minWidthByColumn[col] + extraWidthPerColumn);
|
||||
if (col == 0)
|
||||
playersByColumn[col][row]->setPos(phasesToolbar->getWidth(), playersByColumn[col][row]->y());
|
||||
else
|
||||
playersByColumn[col][row]->setPos(phasesToolbar->getWidth() + (newWidth - phasesToolbar->getWidth()) / 2, playersByColumn[col][row]->y());
|
||||
playersByColumn[col][row]->setPos(newx, playersByColumn[col][row]->y());
|
||||
}
|
||||
newx += minWidthByColumn[col] + extraWidthPerColumn;
|
||||
}
|
||||
}
|
||||
|
||||
void GameScene::updateHover(const QPointF &scenePos)
|
||||
|
@ -295,4 +321,4 @@ void GameScene::resizeRubberBand(const QPointF &cursorPoint)
|
|||
void GameScene::stopRubberBand()
|
||||
{
|
||||
emit sigStopRubberBand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ private:
|
|||
QPointer<CardItem> hoveredCard;
|
||||
QBasicTimer *animationTimer;
|
||||
QSet<CardItem *> cardsToAnimate;
|
||||
int playerRotation;
|
||||
void updateHover(const QPointF &scenePos);
|
||||
public:
|
||||
GameScene(PhasesToolbar *_phasesToolbar, QObject *parent = 0);
|
||||
|
@ -51,6 +52,7 @@ public slots:
|
|||
void removePlayer(Player *player);
|
||||
void clearViews();
|
||||
void closeMostRecentZoneView();
|
||||
void adjustPlayerRotation(int rotationAdjustment);
|
||||
void rearrange();
|
||||
protected:
|
||||
bool event(QEvent *event);
|
||||
|
|
|
@ -157,12 +157,11 @@ void GameSelector::checkResponse(const Response &response)
|
|||
|
||||
void GameSelector::actJoin()
|
||||
{
|
||||
bool spectator = sender() == spectateButton;
|
||||
|
||||
QModelIndex ind = gameListView->currentIndex();
|
||||
if (!ind.isValid())
|
||||
return;
|
||||
const ServerInfo_Game &game = gameListModel->getGame(ind.data(Qt::UserRole).toInt());
|
||||
bool spectator = sender() == spectateButton || game.player_count() == game.max_players();
|
||||
bool overrideRestrictions = !tabSupervisor->getAdminLocked();
|
||||
QString password;
|
||||
if (game.with_password() && !(spectator && !game.spectators_need_password()) && !overrideRestrictions) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "gameview.h"
|
||||
#include "gamescene.h"
|
||||
#include "settingscache.h"
|
||||
#include <QResizeEvent>
|
||||
#include <QAction>
|
||||
#include <QRubberBand>
|
||||
|
@ -19,10 +20,11 @@ GameView::GameView(QGraphicsScene *scene, QWidget *parent)
|
|||
connect(scene, SIGNAL(sigStopRubberBand()), this, SLOT(stopRubberBand()));
|
||||
|
||||
aCloseMostRecentZoneView = new QAction(this);
|
||||
aCloseMostRecentZoneView->setShortcut(QKeySequence("Esc"));
|
||||
|
||||
connect(aCloseMostRecentZoneView, SIGNAL(triggered()), scene, SLOT(closeMostRecentZoneView()));
|
||||
addAction(aCloseMostRecentZoneView);
|
||||
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
|
||||
}
|
||||
|
||||
|
@ -59,3 +61,8 @@ void GameView::stopRubberBand()
|
|||
{
|
||||
rubberBand->hide();
|
||||
}
|
||||
|
||||
void GameView::refreshShortcuts()
|
||||
{
|
||||
aCloseMostRecentZoneView->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aCloseMostRecentZoneView"));
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ private slots:
|
|||
void startRubberBand(const QPointF &selectionOrigin);
|
||||
void resizeRubberBand(const QPointF &cursorPoint);
|
||||
void stopRubberBand();
|
||||
void refreshShortcuts();
|
||||
public slots:
|
||||
void updateSceneRect(const QRectF &rect);
|
||||
public:
|
||||
|
|
132
cockatrice/src/lineeditcompleter.cpp
Normal file
132
cockatrice/src/lineeditcompleter.cpp
Normal file
|
@ -0,0 +1,132 @@
|
|||
#include <QStringListModel>
|
||||
#include <QLineEdit>
|
||||
#include <QCompleter>
|
||||
#include <QWidget>
|
||||
#include <QTextCursor>
|
||||
#include <QAbstractItemView>
|
||||
#include <QScrollBar>
|
||||
#include <QStringListModel>
|
||||
#include <QKeyEvent>
|
||||
#include <QFocusEvent>
|
||||
#include "lineeditcompleter.h"
|
||||
|
||||
LineEditCompleter::LineEditCompleter(QWidget *parent)
|
||||
: QLineEdit(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void LineEditCompleter::focusOutEvent(QFocusEvent * e){
|
||||
QLineEdit::focusOutEvent(e);
|
||||
if (c->popup()->isVisible()){
|
||||
//Remove Popup
|
||||
c->popup()->hide();
|
||||
//Truncate the line to last space or whole string
|
||||
QString textValue = text();
|
||||
int lastIndex = textValue.length();
|
||||
int lastWordStartIndex = textValue.lastIndexOf(" ") + 1;
|
||||
int leftShift = qMin(lastIndex, lastWordStartIndex);
|
||||
setText(textValue.left(leftShift));
|
||||
//Insert highlighted line from popup
|
||||
insert(c->completionModel()->index(c->popup()->currentIndex().row(), 0).data().toString() + " ");
|
||||
//Set focus back to the textbox since tab was pressed
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void LineEditCompleter::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
switch (event->key()){
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter:
|
||||
case Qt::Key_Escape:
|
||||
if (c->popup()->isVisible()){
|
||||
event->ignore();
|
||||
//Remove Popup
|
||||
c->popup()->hide();
|
||||
//Truncate the line to last space or whole string
|
||||
QString textValue = text();
|
||||
int lastIndexof = qMax(0, textValue.lastIndexOf(" "));
|
||||
QString finalString = textValue.left(lastIndexof);
|
||||
//Add a space if there's a word
|
||||
if (finalString != "")
|
||||
finalString += " ";
|
||||
setText(finalString);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
if (c->popup()->isVisible()){
|
||||
event->ignore();
|
||||
//Remove Popup
|
||||
c->popup()->hide();
|
||||
//Truncate the line to last space or whole string
|
||||
QString textValue = text();
|
||||
int lastIndex = textValue.length();
|
||||
int lastWordStartIndex = textValue.lastIndexOf(" ") + 1;
|
||||
int leftShift = qMin(lastIndex, lastWordStartIndex);
|
||||
setText(textValue.left(leftShift));
|
||||
//Insert highlighted line from popup
|
||||
insert(c->completionModel()->index(c->popup()->currentIndex().row(), 0).data().toString() + " ");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QLineEdit::keyPressEvent(event);
|
||||
QString textValue = text();
|
||||
//Wait until the first character after @
|
||||
if (!c || text().right(1).contains("@"))
|
||||
return;
|
||||
|
||||
//Set new completion prefix
|
||||
c->setCompletionPrefix(cursorWord(text()));
|
||||
if (c->completionPrefix().length() < 1){
|
||||
c->popup()->hide();
|
||||
return;
|
||||
}
|
||||
|
||||
//Draw completion box
|
||||
QRect cr = cursorRect();
|
||||
cr.setWidth(c->popup()->sizeHintForColumn(0) + c->popup()->verticalScrollBar()->sizeHint().width());
|
||||
c->complete(cr);
|
||||
|
||||
//Select first item in the completion popup
|
||||
QItemSelectionModel* sm = new QItemSelectionModel(c->completionModel());
|
||||
c->popup()->setSelectionModel(sm);
|
||||
sm->select(c->completionModel()->index(0, 0), QItemSelectionModel::ClearAndSelect);
|
||||
sm->setCurrentIndex(c->completionModel()->index(0, 0), QItemSelectionModel::NoUpdate);
|
||||
}
|
||||
|
||||
QString LineEditCompleter::cursorWord(const QString &line) const
|
||||
{
|
||||
return line.mid(line.left(cursorPosition()).lastIndexOf(" ") + 1,
|
||||
cursorPosition() - line.left(cursorPosition()).lastIndexOf(" ") - 1);
|
||||
}
|
||||
|
||||
void LineEditCompleter::insertCompletion(QString arg)
|
||||
{
|
||||
QString s_arg = arg + " ";
|
||||
setText(text().replace(text().left(cursorPosition()).lastIndexOf(" ") + 1,
|
||||
cursorPosition() - text().left(cursorPosition()).lastIndexOf(" ") - 1, s_arg));
|
||||
}
|
||||
|
||||
void LineEditCompleter::setCompleter(QCompleter* completer)
|
||||
{
|
||||
c = completer;
|
||||
c->setWidget(this);
|
||||
connect(c, SIGNAL(activated(QString)), this, SLOT(insertCompletion(QString)));
|
||||
}
|
||||
|
||||
void LineEditCompleter::setCompletionList(QStringList completionList)
|
||||
{
|
||||
if (!c || c->popup()->isVisible())
|
||||
return;
|
||||
|
||||
QStringListModel *model;
|
||||
model = (QStringListModel*)(c->model());
|
||||
if (model == NULL)
|
||||
model = new QStringListModel();
|
||||
model->setStringList(completionList);
|
||||
}
|
26
cockatrice/src/lineeditcompleter.h
Normal file
26
cockatrice/src/lineeditcompleter.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef LINEEDITCOMPLETER_H
|
||||
#define LINEEDITCOMPLETER_H
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QKeyEvent>
|
||||
#include <QFocusEvent>
|
||||
#include <QStringList>
|
||||
|
||||
class LineEditCompleter : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QString cursorWord(const QString& line) const;
|
||||
QCompleter* c;
|
||||
private slots:
|
||||
void insertCompletion(QString);
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent * event);
|
||||
void focusOutEvent(QFocusEvent * e);
|
||||
public:
|
||||
explicit LineEditCompleter(QWidget *parent = 0);
|
||||
void setCompleter(QCompleter*);
|
||||
void setCompletionList(QStringList);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
||||
LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent)
|
||||
LocalClient::LocalClient(LocalServerInterface *_lsi, const QString &_playerName, const QString &_clientId, QObject *parent)
|
||||
: AbstractClient(parent), lsi(_lsi)
|
||||
{
|
||||
connect(lsi, SIGNAL(itemToClient(const ServerMessage &)), this, SLOT(itemFromServer(const ServerMessage &)));
|
||||
|
||||
Command_Login loginCmd;
|
||||
loginCmd.set_user_name(_playerName.toStdString());
|
||||
loginCmd.set_clientid(_clientId.toStdString());
|
||||
sendCommand(prepareSessionCommand(loginCmd));
|
||||
|
||||
Command_JoinRoom joinCmd;
|
||||
|
|
|
@ -10,7 +10,7 @@ class LocalClient : public AbstractClient {
|
|||
private:
|
||||
LocalServerInterface *lsi;
|
||||
public:
|
||||
LocalClient(LocalServerInterface *_lsi, const QString &_playerName, QObject *parent = 0);
|
||||
LocalClient(LocalServerInterface *_lsi, const QString &_playerName, const QString &_clientId, QObject *parent = 0);
|
||||
~LocalClient();
|
||||
|
||||
void sendCommandContainer(const CommandContainer &cont);
|
||||
|
|
|
@ -6,7 +6,7 @@ LocalServer::LocalServer(QObject *parent)
|
|||
: Server(false, parent)
|
||||
{
|
||||
setDatabaseInterface(new LocalServer_DatabaseInterface(this));
|
||||
addRoom(new Server_Room(0, QString(), QString(), false, QString(), QStringList(), this));
|
||||
addRoom(new Server_Room(0, QString(), QString(), QString(), false, QString(), QStringList(), this));
|
||||
}
|
||||
|
||||
LocalServer::~LocalServer()
|
||||
|
@ -33,7 +33,7 @@ ServerInfo_User LocalServer_DatabaseInterface::getUserData(const QString &name,
|
|||
return result;
|
||||
}
|
||||
|
||||
AuthenticationResult LocalServer_DatabaseInterface::checkUserPassword(Server_ProtocolHandler * /* handler */, const QString & /* user */, const QString & /* password */, QString & /* reasonStr */, int & /* secondsLeft */)
|
||||
AuthenticationResult LocalServer_DatabaseInterface::checkUserPassword(Server_ProtocolHandler * /* handler */, const QString & /* user */, const QString & /* password */, const QString & /* clientId */, QString & /* reasonStr */, int & /* secondsLeft */)
|
||||
{
|
||||
return UnknownUser;
|
||||
}
|
||||
|
|
|
@ -24,9 +24,10 @@ protected:
|
|||
ServerInfo_User getUserData(const QString &name, bool withId = false);
|
||||
public:
|
||||
LocalServer_DatabaseInterface(LocalServer *_localServer);
|
||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reasonStr, int &secondsLeft);
|
||||
AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, const QString &clientId, QString &reasonStr, int &secondsLeft);
|
||||
int getNextGameId() { return localServer->getNextLocalGameId(); }
|
||||
int getNextReplayId() { return -1; }
|
||||
int getActiveUserCount() { return 0; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/***************************************************************************
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2008 by Max-Wilhelm Bruker *
|
||||
* brukie@gmx.net *
|
||||
* *
|
||||
|
@ -32,6 +32,8 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QDebug>
|
||||
#include <QSystemTrayIcon>
|
||||
#include "QtNetwork/QNetworkInterface"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
|
@ -98,6 +100,19 @@ bool settingsValid()
|
|||
!settingsCache->getPicsPath().isEmpty();
|
||||
}
|
||||
|
||||
QString const generateClientID()
|
||||
{
|
||||
QString macList;
|
||||
foreach(QNetworkInterface interface, QNetworkInterface::allInterfaces())
|
||||
{
|
||||
if (interface.hardwareAddress() != "")
|
||||
if (interface.hardwareAddress() != "00:00:00:00:00:00:00:E0")
|
||||
macList += interface.hardwareAddress() + ".";
|
||||
}
|
||||
QString strClientID = QCryptographicHash::hash(macList.toUtf8(), QCryptographicHash::Sha1).toHex().right(15);
|
||||
return strClientID;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
@ -206,6 +221,9 @@ int main(int argc, char *argv[])
|
|||
|
||||
QIcon icon("theme:cockatrice.svg");
|
||||
ui.setWindowIcon(icon);
|
||||
|
||||
settingsCache->setClientID(generateClientID());
|
||||
qDebug() << "ClientID In Cache: " << settingsCache->getClientID();
|
||||
|
||||
ui.show();
|
||||
qDebug("main(): ui.show() finished");
|
||||
|
|
|
@ -7,7 +7,6 @@ class QSystemTrayIcon;
|
|||
class SoundEngine;
|
||||
|
||||
extern CardDatabase *db;
|
||||
|
||||
extern QSystemTrayIcon *trayIcon;
|
||||
extern QTranslator *translator;
|
||||
extern const QString translationPrefix;
|
||||
|
@ -15,6 +14,8 @@ extern QString translationPath;
|
|||
|
||||
void installNewTranslator();
|
||||
|
||||
QString const generateClientID();
|
||||
|
||||
bool settingsValid();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -76,7 +76,7 @@ void MessageLogWidget::logGameClosed()
|
|||
|
||||
void MessageLogWidget::logKicked()
|
||||
{
|
||||
appendHtmlServerMessage(tr("You have been kicked out of the game."));
|
||||
appendHtmlServerMessage(tr("You have been kicked out of the game."), true);
|
||||
}
|
||||
|
||||
void MessageLogWidget::logJoinSpectator(QString name)
|
||||
|
@ -224,20 +224,7 @@ QPair<QString, QString> MessageLogWidget::getFromStr(CardZone *zone, QString car
|
|||
else if (startName == "hand")
|
||||
fromStr = isFemale(zone->getPlayer()) ? tr(" from her hand") : tr(" from his hand");
|
||||
else if (startName == "deck") {
|
||||
if (position >= zone->getCards().size() - 1) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange)
|
||||
cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
cardName = isFemale(zone->getPlayer()) ? tr("the bottom card of her library") : tr("the bottom card of his library");
|
||||
cardNameContainsStartZone = true;
|
||||
} else {
|
||||
if (ownerChange)
|
||||
fromStr = tr(" from the bottom of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
fromStr = isFemale(zone->getPlayer()) ? tr(" from the bottom of her library") : tr(" from the bottom of his library");
|
||||
}
|
||||
} else if (position == 0) {
|
||||
if (position == 0) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange)
|
||||
cardName = tr("the top card of %1's library").arg(zone->getPlayer()->getName());
|
||||
|
@ -250,6 +237,19 @@ QPair<QString, QString> MessageLogWidget::getFromStr(CardZone *zone, QString car
|
|||
else
|
||||
fromStr = isFemale(zone->getPlayer()) ? tr(" from the top of her library") : tr(" from the top of his library");
|
||||
}
|
||||
} else if (position >= zone->getCards().size() - 1) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (ownerChange)
|
||||
cardName = tr("the bottom card of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
cardName = isFemale(zone->getPlayer()) ? tr("the bottom card of her library") : tr("the bottom card of his library");
|
||||
cardNameContainsStartZone = true;
|
||||
} else {
|
||||
if (ownerChange)
|
||||
fromStr = tr(" from the bottom of %1's library").arg(zone->getPlayer()->getName());
|
||||
else
|
||||
fromStr = isFemale(zone->getPlayer()) ? tr(" from the bottom of her library") : tr(" from the bottom of his library");
|
||||
}
|
||||
} else {
|
||||
if (ownerChange)
|
||||
fromStr = tr(" from %1's library").arg(zone->getPlayer()->getName());
|
||||
|
|
|
@ -119,7 +119,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
|
|||
if (pmCache.contains(key))
|
||||
return pmCache.value(key);
|
||||
|
||||
QSvgRenderer svg(QString("theme:countries/" + countryCode + ".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);
|
||||
|
|
|
@ -96,6 +96,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
shortcutsActive(false),
|
||||
defaultNumberTopCards(1),
|
||||
lastTokenDestroy(true),
|
||||
lastTokenTableRow(0),
|
||||
id(_id),
|
||||
active(false),
|
||||
local(_local),
|
||||
|
@ -408,11 +409,14 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
aMoveToBottomLibrary = new QAction(this);
|
||||
aMoveToBottomLibrary->setData(cmMoveToBottomLibrary);
|
||||
aMoveToGraveyard = new QAction(this);
|
||||
aMoveToHand = new QAction(this);
|
||||
aMoveToHand->setData(cmMoveToHand);
|
||||
aMoveToGraveyard->setData(cmMoveToGraveyard);
|
||||
aMoveToExile = new QAction(this);
|
||||
aMoveToExile->setData(cmMoveToExile);
|
||||
connect(aMoveToTopLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToBottomLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToHand, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToGraveyard, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToExile, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
|
||||
|
@ -444,6 +448,8 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
|
||||
rearrangeZones();
|
||||
retranslateUi();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
|
@ -606,6 +612,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"));
|
||||
|
@ -670,53 +677,49 @@ void Player::retranslateUi()
|
|||
for (int i = 0; i < allPlayersActions.size(); ++i)
|
||||
allPlayersActions[i]->setText(tr("&All players"));
|
||||
}
|
||||
|
||||
|
||||
aPlay->setText(tr("&Play"));
|
||||
aHide->setText(tr("&Hide"));
|
||||
aPlayFacedown->setText(tr("Play &Face Down"));
|
||||
|
||||
aTap->setText(tr("&Tap"));
|
||||
aUntap->setText(tr("&Untap"));
|
||||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aPeek->setText(tr("&Peek at card face"));
|
||||
aClone->setText(tr("&Clone"));
|
||||
aClone->setShortcut(QKeySequence("Ctrl+J"));
|
||||
aAttach->setText(tr("Attac&h to card..."));
|
||||
aAttach->setShortcut(QKeySequence("Ctrl+A"));
|
||||
aUnattach->setText(tr("Unattac&h"));
|
||||
aDrawArrow->setText(tr("&Draw arrow..."));
|
||||
aIncP->setText(tr("&Increase power"));
|
||||
aIncP->setShortcut(QKeySequence("Ctrl++"));
|
||||
aDecP->setText(tr("&Decrease power"));
|
||||
aDecP->setShortcut(QKeySequence("Ctrl+-"));
|
||||
aIncT->setText(tr("I&ncrease toughness"));
|
||||
aIncT->setShortcut(QKeySequence("Alt++"));
|
||||
aDecT->setText(tr("D&ecrease toughness"));
|
||||
aDecT->setShortcut(QKeySequence("Alt+-"));
|
||||
aIncPT->setText(tr("In&crease power and toughness"));
|
||||
aIncPT->setShortcut(QKeySequence("Ctrl+Alt++"));
|
||||
aDecPT->setText(tr("Dec&rease power and toughness"));
|
||||
aDecPT->setShortcut(QKeySequence("Ctrl+Alt+-"));
|
||||
aSetPT->setText(tr("Set &power and toughness..."));
|
||||
aSetPT->setShortcut(QKeySequence("Ctrl+P"));
|
||||
aSetAnnotation->setText(tr("&Set annotation..."));
|
||||
|
||||
QStringList counterColors;
|
||||
counterColors.append(tr("Red"));
|
||||
counterColors.append(tr("Yellow"));
|
||||
counterColors.append(tr("Green"));
|
||||
for (int i = 0; i < aAddCounter.size(); ++i)
|
||||
|
||||
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)
|
||||
}
|
||||
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)
|
||||
}
|
||||
for (int i = 0; i < aSetCounter.size(); ++i){
|
||||
aSetCounter[i]->setText(tr("&Set counters (%1)...").arg(counterColors[i]));
|
||||
}
|
||||
|
||||
aMoveToTopLibrary->setText(tr("&Top of library"));
|
||||
aMoveToBottomLibrary->setText(tr("&Bottom of library"));
|
||||
aMoveToHand->setText(tr("&Hand"));
|
||||
aMoveToGraveyard->setText(tr("&Graveyard"));
|
||||
aMoveToGraveyard->setShortcut(QKeySequence("Ctrl+Del"));
|
||||
aMoveToExile->setText(tr("&Exile"));
|
||||
|
||||
|
||||
QMapIterator<QString, CardZone *> zoneIterator(zones);
|
||||
while (zoneIterator.hasNext())
|
||||
zoneIterator.next().value()->retranslateUi();
|
||||
|
@ -726,24 +729,73 @@ void Player::setShortcutsActive()
|
|||
{
|
||||
shortcutsActive = true;
|
||||
|
||||
aViewSideboard->setShortcut(QKeySequence("Ctrl+F3"));
|
||||
aViewLibrary->setShortcut(QKeySequence("F3"));
|
||||
aViewTopCards->setShortcut(QKeySequence("Ctrl+W"));
|
||||
aViewGraveyard->setShortcut(QKeySequence("F4"));
|
||||
aDrawCard->setShortcut(QKeySequence("Ctrl+D"));
|
||||
aDrawCards->setShortcut(QKeySequence("Ctrl+E"));
|
||||
aUndoDraw->setShortcut(QKeySequence("Ctrl+Shift+D"));
|
||||
aMulligan->setShortcut(QKeySequence("Ctrl+M"));
|
||||
aShuffle->setShortcut(QKeySequence("Ctrl+S"));
|
||||
aUntapAll->setShortcut(QKeySequence("Ctrl+U"));
|
||||
aRollDie->setShortcut(QKeySequence("Ctrl+I"));
|
||||
aCreateToken->setShortcut(QKeySequence("Ctrl+T"));
|
||||
aCreateAnotherToken->setShortcut(QKeySequence("Ctrl+G"));
|
||||
aAlwaysRevealTopCard->setShortcut(QKeySequence("Ctrl+N"));
|
||||
aPlay->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aPlay"));
|
||||
aTap->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aTap"));
|
||||
aUntap->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aUntap"));
|
||||
aDoesntUntap->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDoesntUntap"));
|
||||
aFlip->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aFlip"));
|
||||
aPeek->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aPeek"));
|
||||
aClone->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aClone"));
|
||||
aAttach->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aAttach"));
|
||||
aUnattach->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aUnattach"));
|
||||
aDrawArrow->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDrawArrow"));
|
||||
aIncP->setShortcuts(settingsCache->shortcuts().getShortcut("Player/IncP"));
|
||||
aDecP->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDecP"));
|
||||
aIncT->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aIncT"));
|
||||
aDecT->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDecT"));
|
||||
aIncPT->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aIncPT"));
|
||||
aDecPT->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aDecPT"));
|
||||
aSetPT->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aSetPT"));
|
||||
aSetAnnotation->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aSetAnnotation"));
|
||||
aMoveToTopLibrary->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aMoveToTopLibrary"));
|
||||
aMoveToBottomLibrary->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aMoveToBottomLibrary"));
|
||||
aMoveToHand->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aMoveToHand"));
|
||||
aMoveToGraveyard->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aMoveToGraveyard"));
|
||||
aMoveToExile->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aMoveToExile"));
|
||||
|
||||
QList<QKeySequence> addCCShortCuts;
|
||||
addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aCCRed"));
|
||||
addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aCCYellow"));
|
||||
addCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aCCGreen"));
|
||||
|
||||
QList<QKeySequence> removeCCShortCuts;
|
||||
removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aRCRed"));
|
||||
removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aRCYellow"));
|
||||
removeCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aRCGreen"));
|
||||
|
||||
QList<QKeySequence> setCCShortCuts;
|
||||
setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aSCRed"));
|
||||
setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aSCYellow"));
|
||||
setCCShortCuts.append(settingsCache->shortcuts().getSingleShortcut("Player/aSCGreen"));
|
||||
|
||||
for (int i = 0; i < aAddCounter.size(); ++i){
|
||||
aAddCounter[i]->setShortcut(addCCShortCuts.at(i));
|
||||
}
|
||||
for (int i = 0; i < aRemoveCounter.size(); ++i){
|
||||
aRemoveCounter[i]->setShortcut(removeCCShortCuts.at(i));
|
||||
}
|
||||
for (int i = 0; i < aSetCounter.size(); ++i){
|
||||
aSetCounter[i]->setShortcut(setCCShortCuts.at(i));
|
||||
}
|
||||
|
||||
QMapIterator<int, AbstractCounter *> counterIterator(counters);
|
||||
while (counterIterator.hasNext())
|
||||
counterIterator.next().value()->setShortcutsActive();
|
||||
|
||||
aViewSideboard->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aViewSideboard"));
|
||||
aViewLibrary->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aViewLibrary"));
|
||||
aViewTopCards->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aViewTopCards"));
|
||||
aViewGraveyard->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aViewGraveyard"));
|
||||
aDrawCard->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aDrawCard"));
|
||||
aDrawCards->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aDrawCards"));
|
||||
aUndoDraw->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aUndoDraw"));
|
||||
aMulligan->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aMulligan"));
|
||||
aShuffle->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aShuffle"));
|
||||
aUntapAll->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aUntapAll"));
|
||||
aRollDie->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aRollDie"));
|
||||
aCreateToken->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aCreateToken"));
|
||||
aCreateAnotherToken->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aCreateAnotherToken"));
|
||||
aAlwaysRevealTopCard->setShortcut(settingsCache->shortcuts().getSingleShortcut("Player/aAlwaysRevealTopCard"));
|
||||
}
|
||||
|
||||
void Player::setShortcutsInactive()
|
||||
|
@ -777,10 +829,12 @@ void Player::initSayMenu()
|
|||
QSettings settings;
|
||||
settings.beginGroup("messages");
|
||||
int count = settings.value("count", 0).toInt();
|
||||
|
||||
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(QString("Ctrl+%1").arg((i + 1) % 10)));
|
||||
if (i <= 10){
|
||||
newAction->setShortcut(QKeySequence("Ctrl+" + QString::number((i + 1) % 10)));
|
||||
}
|
||||
connect(newAction, SIGNAL(triggered()), this, SLOT(actSayMessage()));
|
||||
sayMenu->addAction(newAction);
|
||||
}
|
||||
|
@ -794,13 +848,16 @@ void Player::setDeck(const DeckLoader &_deck)
|
|||
createPredefinedTokenMenu->clear();
|
||||
predefinedTokens.clear();
|
||||
InnerDecklistNode *tokenZone = dynamic_cast<InnerDecklistNode *>(deck->getRoot()->findChild("tokens"));
|
||||
|
||||
if (tokenZone)
|
||||
for (int i = 0; i < tokenZone->size(); ++i) {
|
||||
const QString tokenName = tokenZone->at(i)->getName();
|
||||
predefinedTokens.append(tokenName);
|
||||
QAction *a = createPredefinedTokenMenu->addAction(tokenName);
|
||||
if (i < 10)
|
||||
{
|
||||
a->setShortcut(QKeySequence("Alt+" + QString::number((i + 1) % 10)));
|
||||
}
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(actCreatePredefinedToken()));
|
||||
}
|
||||
}
|
||||
|
@ -1029,6 +1086,7 @@ void Player::actCreateToken()
|
|||
lastTokenPT = dlg.getPT();
|
||||
if (CardInfo *correctedCard = db->getCardBySimpleName(lastTokenName, false)) {
|
||||
lastTokenName = correctedCard->getName();
|
||||
lastTokenTableRow = table->clampValidTableRow(2 - correctedCard->getTableRow());
|
||||
if (lastTokenPT.isEmpty())
|
||||
lastTokenPT = correctedCard->getPowTough();
|
||||
}
|
||||
|
@ -1050,7 +1108,7 @@ void Player::actCreateAnotherToken()
|
|||
cmd.set_annotation(lastTokenAnnotation.toStdString());
|
||||
cmd.set_destroy_on_zone_change(lastTokenDestroy);
|
||||
cmd.set_x(-1);
|
||||
cmd.set_y(0);
|
||||
cmd.set_y(lastTokenTableRow);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
@ -1063,13 +1121,39 @@ void Player::actCreatePredefinedToken()
|
|||
lastTokenName = cardInfo->getName();
|
||||
lastTokenColor = cardInfo->getColors().isEmpty() ? QString() : cardInfo->getColors().first().toLower();
|
||||
lastTokenPT = cardInfo->getPowTough();
|
||||
lastTokenAnnotation = cardInfo->getText();
|
||||
lastTokenAnnotation = settingsCache->getAnnotateTokens() ? cardInfo->getText() : "";
|
||||
lastTokenTableRow = table->clampValidTableRow(2 - cardInfo->getTableRow());
|
||||
lastTokenDestroy = true;
|
||||
aCreateAnotherToken->setEnabled(true);
|
||||
|
||||
actCreateAnotherToken();
|
||||
}
|
||||
|
||||
void Player::actCreateRelatedCard()
|
||||
{
|
||||
// get the clicked card
|
||||
CardItem * sourceCard = game->getActiveCard();
|
||||
if(!sourceCard)
|
||||
return;
|
||||
|
||||
// get the target card name
|
||||
QAction *action = static_cast<QAction *>(sender());
|
||||
CardInfo *cardInfo = db->getCard(action->text());
|
||||
|
||||
// create the token for the related card
|
||||
Command_CreateToken cmd;
|
||||
cmd.set_zone("table");
|
||||
cmd.set_card_name(cardInfo->getName().toStdString());
|
||||
cmd.set_color(cardInfo->getColors().isEmpty() ? QString().toStdString() : cardInfo->getColors().first().toLower().toStdString());
|
||||
cmd.set_pt(cardInfo->getPowTough().toStdString());
|
||||
cmd.set_annotation(settingsCache->getAnnotateTokens() ? cardInfo->getText().toStdString() : QString().toStdString());
|
||||
cmd.set_destroy_on_zone_change(true);
|
||||
cmd.set_target_zone(sourceCard->getZone()->getName().toStdString());
|
||||
cmd.set_target_card_id(sourceCard->getId());
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actSayMessage()
|
||||
{
|
||||
QAction *a = qobject_cast<QAction *>(sender());
|
||||
|
@ -1627,7 +1711,7 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
|||
cmd.set_y(0);
|
||||
} else {
|
||||
int tableRow = faceDown ? 2 : ci->getTableRow();
|
||||
QPoint gridPoint = QPoint(-1, 2 - tableRow);
|
||||
QPoint gridPoint = QPoint(-1, table->clampValidTableRow(2 - tableRow));
|
||||
cardToMove->set_face_down(faceDown);
|
||||
cardToMove->set_pt(ci->getPowTough().toStdString());
|
||||
cardToMove->set_tapped(faceDown ? false : tapped);
|
||||
|
@ -1926,6 +2010,18 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case cmMoveToHand: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
cmd->mutable_cards_to_move()->CopyFrom(idList);
|
||||
cmd->set_target_player_id(getId());
|
||||
cmd->set_target_zone("hand");
|
||||
cmd->set_x(0);
|
||||
cmd->set_y(0);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case cmMoveToGraveyard: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
|
@ -2188,6 +2284,12 @@ void Player::actPlayFacedown()
|
|||
playCard(game->getActiveCard(), true, false);
|
||||
}
|
||||
|
||||
void Player::refreshShortcuts()
|
||||
{
|
||||
if(shortcutsActive)
|
||||
setShortcutsActive();
|
||||
}
|
||||
|
||||
void Player::updateCardMenu(CardItem *card)
|
||||
{
|
||||
QMenu *cardMenu = card->getCardMenu();
|
||||
|
@ -2215,6 +2317,8 @@ void Player::updateCardMenu(CardItem *card)
|
|||
moveMenu->addAction(aMoveToTopLibrary);
|
||||
moveMenu->addAction(aMoveToBottomLibrary);
|
||||
moveMenu->addSeparator();
|
||||
moveMenu->addAction(aMoveToHand);
|
||||
moveMenu->addSeparator();
|
||||
moveMenu->addAction(aMoveToGraveyard);
|
||||
moveMenu->addSeparator();
|
||||
moveMenu->addAction(aMoveToExile);
|
||||
|
@ -2241,6 +2345,17 @@ void Player::updateCardMenu(CardItem *card)
|
|||
cardMenu->addAction(aFlip);
|
||||
if (card->getFaceDown())
|
||||
cardMenu->addAction(aPeek);
|
||||
|
||||
QStringList relatedCards = card->getInfo()->getRelatedCards();
|
||||
if(relatedCards.size())
|
||||
{
|
||||
QMenu * createRelatedCardMenu = cardMenu->addMenu(tr("Cr&eate related card"));
|
||||
|
||||
for (int i = 0; i < relatedCards.size(); ++i) {
|
||||
QAction *a = createRelatedCardMenu->addAction(relatedCards.at(i));
|
||||
connect(a, SIGNAL(triggered()), this, SLOT(actCreateRelatedCard()));
|
||||
}
|
||||
}
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aAttach);
|
||||
if (card->getAttachedTo())
|
||||
|
@ -2326,6 +2441,7 @@ void Player::setMirrored(bool _mirrored)
|
|||
|
||||
void Player::processSceneSizeChange(int newPlayerWidth)
|
||||
{
|
||||
// Extend table (and hand, if horizontal) to accomodate the new player width.
|
||||
qreal tableWidth = newPlayerWidth - CARD_HEIGHT - 15 - counterAreaWidth - stack->boundingRect().width();
|
||||
if (!settingsCache->getHorizontalHand())
|
||||
tableWidth -= hand->boundingRect().width();
|
||||
|
|
|
@ -140,6 +140,7 @@ private slots:
|
|||
|
||||
void actOpenDeckInDeckEditor();
|
||||
void actCreatePredefinedToken();
|
||||
void actCreateRelatedCard();
|
||||
void cardMenuAction();
|
||||
void actCardCounterTrigger();
|
||||
void actAttach();
|
||||
|
@ -157,6 +158,7 @@ private slots:
|
|||
void actPlay();
|
||||
void actHide();
|
||||
void actPlayFacedown();
|
||||
void refreshShortcuts();
|
||||
|
||||
private:
|
||||
TabGame *game;
|
||||
|
@ -177,12 +179,13 @@ private:
|
|||
QAction *aPlay, *aPlayFacedown,
|
||||
*aHide,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile;
|
||||
|
||||
bool shortcutsActive;
|
||||
int defaultNumberTopCards;
|
||||
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
||||
bool lastTokenDestroy;
|
||||
int lastTokenTableRow;
|
||||
ServerInfo_User *userInfo;
|
||||
int id;
|
||||
bool active;
|
||||
|
@ -238,7 +241,7 @@ private:
|
|||
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
|
||||
public:
|
||||
static const int counterAreaWidth = 55;
|
||||
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToGraveyard, cmMoveToExile };
|
||||
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToHand, cmMoveToGraveyard, cmMoveToExile };
|
||||
|
||||
enum { Type = typeOther };
|
||||
int type() const { return Type; }
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "tab_supervisor.h"
|
||||
#include "tab_userlists.h"
|
||||
#include "userlist.h"
|
||||
#include "userinfobox.h"
|
||||
#include "user_context_menu.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QAction>
|
||||
|
@ -67,7 +66,7 @@ PlayerListWidget::PlayerListWidget(TabSupervisor *_tabSupervisor, AbstractClient
|
|||
} else
|
||||
userContextMenu = 0;
|
||||
|
||||
setMinimumHeight(60);
|
||||
setMinimumHeight(40);
|
||||
setIconSize(QSize(20, 15));
|
||||
setColumnCount(6);
|
||||
setColumnWidth(0, 20);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <QTimer>
|
||||
#include <QThread>
|
||||
#include "remoteclient.h"
|
||||
|
||||
#include "settingscache.h"
|
||||
#include "pending_command.h"
|
||||
#include "pb/commands.pb.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
@ -10,14 +10,19 @@
|
|||
#include "pb/response_activate.pb.h"
|
||||
#include "pb/server_message.pb.h"
|
||||
#include "pb/event_server_identification.pb.h"
|
||||
#include "settingscache.h"
|
||||
#include "main.h"
|
||||
#include "version_string.h"
|
||||
|
||||
static const unsigned int protocolVersion = 14;
|
||||
|
||||
RemoteClient::RemoteClient(QObject *parent)
|
||||
: AbstractClient(parent), timeRunning(0), lastDataReceived(0), messageInProgress(false), handshakeStarted(false), messageLength(0)
|
||||
{
|
||||
|
||||
int keepalive = settingsCache->getKeepAlive();
|
||||
timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
timer->setInterval(keepalive * 1000);
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(ping()));
|
||||
|
||||
socket = new QTcpSocket(this);
|
||||
|
@ -75,6 +80,7 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
|||
cmdRegister.set_gender((ServerInfo_User_Gender) gender);
|
||||
cmdRegister.set_country(country.toStdString());
|
||||
cmdRegister.set_real_name(realName.toStdString());
|
||||
cmdRegister.set_clientid(settingsCache->getClientID().toStdString());
|
||||
|
||||
PendingCommand *pend = prepareSessionCommand(cmdRegister);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(registerResponse(Response)));
|
||||
|
@ -102,11 +108,12 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
|
|||
void RemoteClient::doLogin()
|
||||
{
|
||||
setStatus(StatusLoggingIn);
|
||||
|
||||
|
||||
Command_Login cmdLogin;
|
||||
cmdLogin.set_user_name(userName.toStdString());
|
||||
cmdLogin.set_password(password.toStdString());
|
||||
|
||||
cmdLogin.set_clientid(settingsCache->getClientID().toStdString());
|
||||
cmdLogin.set_clientver(VERSION_STRING);
|
||||
PendingCommand *pend = prepareSessionCommand(cmdLogin);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response)));
|
||||
sendCommand(pend);
|
||||
|
@ -123,12 +130,12 @@ void RemoteClient::loginResponse(const Response &response)
|
|||
if (response.response_code() == Response::RespOk) {
|
||||
setStatus(StatusLoggedIn);
|
||||
emit userInfoChanged(resp.user_info());
|
||||
|
||||
|
||||
QList<ServerInfo_User> buddyList;
|
||||
for (int i = resp.buddy_list_size() - 1; i >= 0; --i)
|
||||
buddyList.append(resp.buddy_list(i));
|
||||
emit buddyListReceived(buddyList);
|
||||
|
||||
|
||||
QList<ServerInfo_User> ignoreList;
|
||||
for (int i = resp.ignore_list_size() - 1; i >= 0; --i)
|
||||
ignoreList.append(resp.ignore_list(i));
|
||||
|
@ -177,7 +184,7 @@ void RemoteClient::readData()
|
|||
QByteArray data = socket->readAll();
|
||||
|
||||
inputBuffer.append(data);
|
||||
|
||||
|
||||
do {
|
||||
if (!messageInProgress) {
|
||||
if (inputBuffer.size() >= 4) {
|
||||
|
@ -202,7 +209,7 @@ void RemoteClient::readData()
|
|||
}
|
||||
if (inputBuffer.size() < messageLength)
|
||||
return;
|
||||
|
||||
|
||||
ServerMessage newServerMessage;
|
||||
newServerMessage.ParseFromArray(inputBuffer.data(), messageLength);
|
||||
#ifdef QT_DEBUG
|
||||
|
@ -210,9 +217,9 @@ void RemoteClient::readData()
|
|||
#endif
|
||||
inputBuffer.remove(0, messageLength);
|
||||
messageInProgress = false;
|
||||
|
||||
|
||||
processProtocolItem(newServerMessage);
|
||||
|
||||
|
||||
if (getStatus() == StatusDisconnecting) // use thread-safe getter
|
||||
doDisconnectFromServer();
|
||||
} while (!inputBuffer.isEmpty());
|
||||
|
@ -231,16 +238,17 @@ void RemoteClient::sendCommandContainer(const CommandContainer &cont)
|
|||
buf.data()[2] = (unsigned char) (size >> 8);
|
||||
buf.data()[1] = (unsigned char) (size >> 16);
|
||||
buf.data()[0] = (unsigned char) (size >> 24);
|
||||
|
||||
|
||||
socket->write(buf);
|
||||
}
|
||||
|
||||
void RemoteClient::doConnectToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password)
|
||||
{
|
||||
doDisconnectFromServer();
|
||||
|
||||
|
||||
userName = _userName;
|
||||
password = _password;
|
||||
QString clientid = settingsCache->getClientID();
|
||||
lastHostname = hostname;
|
||||
lastPort = port;
|
||||
|
||||
|
@ -251,7 +259,7 @@ void RemoteClient::doConnectToServer(const QString &hostname, unsigned int port,
|
|||
void RemoteClient::doRegisterToServer(const QString &hostname, unsigned int port, const QString &_userName, const QString &_password, const QString &_email, const int _gender, const QString &_country, const QString &_realname)
|
||||
{
|
||||
doDisconnectFromServer();
|
||||
|
||||
|
||||
userName = _userName;
|
||||
password = _password;
|
||||
email = _email;
|
||||
|
@ -268,7 +276,7 @@ void RemoteClient::doRegisterToServer(const QString &hostname, unsigned int port
|
|||
void RemoteClient::doActivateToServer(const QString &_token)
|
||||
{
|
||||
doDisconnectFromServer();
|
||||
|
||||
|
||||
token = _token;
|
||||
|
||||
socket->connectToHost(lastHostname, lastPort);
|
||||
|
@ -278,7 +286,7 @@ void RemoteClient::doActivateToServer(const QString &_token)
|
|||
void RemoteClient::doDisconnectFromServer()
|
||||
{
|
||||
timer->stop();
|
||||
|
||||
|
||||
messageInProgress = false;
|
||||
handshakeStarted = false;
|
||||
messageLength = 0;
|
||||
|
@ -289,7 +297,7 @@ void RemoteClient::doDisconnectFromServer()
|
|||
response.set_response_code(Response::RespNotConnected);
|
||||
response.set_cmd_id(pc[i]->getCommandContainer().cmd_id());
|
||||
pc[i]->processResponse(response);
|
||||
|
||||
|
||||
delete pc[i];
|
||||
}
|
||||
pendingCommands.clear();
|
||||
|
@ -309,9 +317,10 @@ void RemoteClient::ping()
|
|||
}
|
||||
}
|
||||
|
||||
int keepalive = settingsCache->getKeepAlive();
|
||||
int maxTime = timeRunning - lastDataReceived;
|
||||
emit maxPingTime(maxTime, maxTimeout);
|
||||
if (maxTime >= maxTimeout) {
|
||||
if (maxTime >= (keepalive * maxTimeout)) {
|
||||
disconnectFromServer();
|
||||
emit serverTimeout();
|
||||
} else {
|
||||
|
|
155
cockatrice/src/sequenceEdit/sequenceedit.cpp
Normal file
155
cockatrice/src/sequenceEdit/sequenceedit.cpp
Normal file
|
@ -0,0 +1,155 @@
|
|||
#include "sequenceedit.h"
|
||||
#include "../settingscache.h"
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QToolTip>
|
||||
|
||||
SequenceEdit::SequenceEdit(QString _shorcutName, QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
shorcutName = _shorcutName;
|
||||
currentKey = 0;
|
||||
maxKeys = 4;
|
||||
keys = 0;
|
||||
valid = false;
|
||||
|
||||
lineEdit = new QLineEdit(this);
|
||||
clearButton = new QPushButton("", this);
|
||||
defaultButton = new QPushButton("", this);
|
||||
|
||||
lineEdit->setMinimumWidth(70);
|
||||
clearButton->setMaximumWidth(lineEdit->height());
|
||||
defaultButton->setMaximumWidth(lineEdit->height());
|
||||
clearButton->setMaximumHeight(lineEdit->height());
|
||||
defaultButton->setMaximumHeight(lineEdit->height());
|
||||
|
||||
clearButton->setIcon(QIcon(":/resources/icon_clearsearch.svg"));
|
||||
defaultButton->setIcon(QIcon(":/resources/icon_update.png"));
|
||||
|
||||
clearButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
defaultButton->setAttribute(Qt::WA_LayoutUsesWidgetRect);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->setContentsMargins(0,0,0,0);
|
||||
layout->setSpacing(1);
|
||||
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(shorcutName));
|
||||
}
|
||||
|
||||
QString SequenceEdit::getSecuence()
|
||||
{
|
||||
return lineEdit->text();
|
||||
}
|
||||
|
||||
void SequenceEdit::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 SequenceEdit::restoreDefault()
|
||||
{
|
||||
lineEdit->setText(settingsCache->shortcuts().getDefaultShortcutString(shorcutName));
|
||||
updateSettings();
|
||||
}
|
||||
|
||||
bool SequenceEdit::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 SequenceEdit::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 SequenceEdit::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 SequenceEdit::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 SequenceEdit::updateSettings()
|
||||
{
|
||||
settingsCache->shortcuts().setShortcuts(shorcutName,lineEdit->text());
|
||||
}
|
||||
|
40
cockatrice/src/sequenceEdit/sequenceedit.h
Normal file
40
cockatrice/src/sequenceEdit/sequenceedit.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SECUENCEEDIT_H
|
||||
#define SECUENCEEDIT_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QKeySequence>
|
||||
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QEvent;
|
||||
|
||||
class SequenceEdit : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SequenceEdit(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
|
18
cockatrice/src/sequenceEdit/shortcutstab.cpp
Normal file
18
cockatrice/src/sequenceEdit/shortcutstab.cpp
Normal file
|
@ -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;
|
||||
}
|
25
cockatrice/src/sequenceEdit/shortcutstab.h
Normal file
25
cockatrice/src/sequenceEdit/shortcutstab.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef SHORTCUTSTAB_H
|
||||
#define SHORTCUTSTAB_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#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
|
1570
cockatrice/src/sequenceEdit/ui_shortcutstab.h
Normal file
1570
cockatrice/src/sequenceEdit/ui_shortcutstab.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,11 +1,34 @@
|
|||
#include "settingscache.h"
|
||||
#include <QSettings>
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#endif
|
||||
|
||||
QString SettingsCache::getSettingsPath()
|
||||
{
|
||||
QString file = "";
|
||||
|
||||
#ifndef PORTABLE_BUILD
|
||||
#if QT_VERSION >= 0x050000
|
||||
file = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
|
||||
#else
|
||||
file = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#endif
|
||||
file.append("/settings/");
|
||||
#endif
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
SettingsCache::SettingsCache()
|
||||
{
|
||||
settings = new QSettings(this);
|
||||
shortcutsSettings = new ShortcutsSettings(getSettingsPath(),this);
|
||||
|
||||
lang = settings->value("personal/lang").toString();
|
||||
keepalive = settings->value("personal/keepalive", 5).toInt();
|
||||
|
||||
deckPath = settings->value("paths/decks").toString();
|
||||
replaysPath = settings->value("paths/replays").toString();
|
||||
|
@ -42,6 +65,7 @@ SettingsCache::SettingsCache()
|
|||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
playToStack = settings->value("interface/playtostack", false).toBool();
|
||||
annotateTokens = settings->value("interface/annotatetokens", false).toBool();
|
||||
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
|
||||
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
|
@ -50,8 +74,11 @@ SettingsCache::SettingsCache()
|
|||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 5).toInt();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
|
||||
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||
chatHighlightForeground = settings->value("chat/highlightforeground", true).toBool();
|
||||
chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString();
|
||||
chatHighlightColor = settings->value("chat/highlightcolor", "A6120D").toString();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||
|
@ -77,6 +104,29 @@ SettingsCache::SettingsCache()
|
|||
masterVolume = settings->value("sound/mastervolume", 100).toInt();
|
||||
|
||||
cardInfoViewMode = settings->value("cards/cardinfoviewmode", 0).toInt();
|
||||
highlightWords = settings->value("personal/highlightWords", QString()).toString();
|
||||
gameDescription = settings->value("game/gamedescription","").toString();
|
||||
maxPlayers = settings->value("game/maxplayers", 2).toInt();
|
||||
gameTypes = settings->value("game/gametypes","").toString();
|
||||
onlyBuddies = settings->value("game/onlybuddies", false).toBool();
|
||||
onlyRegistered = settings->value("game/onlyregistered", true).toBool();
|
||||
spectatorsAllowed = settings->value("game/spectatorsallowed", true).toBool();
|
||||
spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool();
|
||||
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
|
||||
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
|
||||
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
|
||||
clientID = settings->value("personal/clientid", "notset").toString();
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
deckEditorLayoutState = layout_settings.value("layouts/deckEditor_state").toByteArray();
|
||||
deckEditorGeometry = layout_settings.value("layouts/deckEditor_geometry").toByteArray();
|
||||
|
||||
deckEditorCardSize = layout_settings.value("layouts/deckEditor_CardSize", QSize(250,500)).toSize();
|
||||
deckEditorFilterSize = layout_settings.value("layouts/deckEditor_FilterSize", QSize(250,250)).toSize();
|
||||
deckEditorDeckSize = layout_settings.value("layouts/deckEditor_DeckSize", QSize(250,360)).toSize();
|
||||
}
|
||||
|
||||
void SettingsCache::setCardInfoViewMode(const int _viewMode) {
|
||||
|
@ -84,6 +134,11 @@ void SettingsCache::setCardInfoViewMode(const int _viewMode) {
|
|||
settings->setValue("cards/cardinfoviewmode", cardInfoViewMode);
|
||||
}
|
||||
|
||||
void SettingsCache::setHighlightWords(const QString &_highlightWords) {
|
||||
highlightWords = _highlightWords;
|
||||
settings->setValue("personal/highlightWords", highlightWords);
|
||||
}
|
||||
|
||||
void SettingsCache::setMasterVolume(int _masterVolume) {
|
||||
masterVolume = _masterVolume;
|
||||
settings->setValue("sound/mastervolume", masterVolume);
|
||||
|
@ -219,6 +274,12 @@ void SettingsCache::setPlayToStack(int _playToStack)
|
|||
settings->setValue("interface/playtostack", playToStack);
|
||||
}
|
||||
|
||||
void SettingsCache::setAnnotateTokens(int _annotateTokens)
|
||||
{
|
||||
annotateTokens = _annotateTokens;
|
||||
settings->setValue("interface/annotatetokens", annotateTokens);
|
||||
}
|
||||
|
||||
void SettingsCache::setCardInfoMinimized(int _cardInfoMinimized)
|
||||
{
|
||||
cardInfoMinimized = _cardInfoMinimized;
|
||||
|
@ -270,16 +331,33 @@ void SettingsCache::setChatMention(int _chatMention) {
|
|||
settings->setValue("chat/mention", chatMention);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionCompleter(const int _enableMentionCompleter)
|
||||
{
|
||||
chatMentionCompleter = _enableMentionCompleter;
|
||||
settings->setValue("chat/mentioncompleter", chatMentionCompleter);
|
||||
emit chatMentionCompleterChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionForeground(int _chatMentionForeground) {
|
||||
chatMentionForeground = _chatMentionForeground;
|
||||
settings->setValue("chat/mentionforeground", chatMentionForeground);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatHighlightForeground(int _chatHighlightForeground) {
|
||||
chatHighlightForeground = _chatHighlightForeground;
|
||||
settings->setValue("chat/highlightforeground", chatHighlightForeground);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMentionColor(const QString &_chatMentionColor) {
|
||||
chatMentionColor = _chatMentionColor;
|
||||
settings->setValue("chat/mentioncolor", chatMentionColor);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatHighlightColor(const QString &_chatHighlightColor) {
|
||||
chatHighlightColor = _chatHighlightColor;
|
||||
settings->setValue("chat/highlightcolor", chatHighlightColor);
|
||||
}
|
||||
|
||||
void SettingsCache::setZoneViewSortByName(int _zoneViewSortByName)
|
||||
{
|
||||
zoneViewSortByName = _zoneViewSortByName;
|
||||
|
@ -354,3 +432,151 @@ void SettingsCache::setPixmapCacheSize(const int _pixmapCacheSize)
|
|||
settings->setValue("personal/pixmapCacheSize", pixmapCacheSize);
|
||||
emit pixmapCacheSizeChanged(pixmapCacheSize);
|
||||
}
|
||||
|
||||
void SettingsCache::setClientID(QString _clientID)
|
||||
{
|
||||
clientID = _clientID;
|
||||
settings->setValue("personal/clientid", clientID);
|
||||
}
|
||||
|
||||
QStringList SettingsCache::getCountries() const
|
||||
{
|
||||
static QStringList countries = QStringList()
|
||||
<< "ad" << "ae" << "af" << "ag" << "ai" << "al" << "am" << "ao" << "aq" << "ar"
|
||||
<< "as" << "at" << "au" << "aw" << "ax" << "az" << "ba" << "bb" << "bd" << "be"
|
||||
<< "bf" << "bg" << "bh" << "bi" << "bj" << "bl" << "bm" << "bn" << "bo" << "bq"
|
||||
<< "br" << "bs" << "bt" << "bv" << "bw" << "by" << "bz" << "ca" << "cc" << "cd"
|
||||
<< "cf" << "cg" << "ch" << "ci" << "ck" << "cl" << "cm" << "cn" << "co" << "cr"
|
||||
<< "cu" << "cv" << "cw" << "cx" << "cy" << "cz" << "de" << "dj" << "dk" << "dm"
|
||||
<< "do" << "dz" << "ec" << "ee" << "eg" << "eh" << "er" << "es" << "et" << "fi"
|
||||
<< "fj" << "fk" << "fm" << "fo" << "fr" << "ga" << "gb" << "gd" << "ge" << "gf"
|
||||
<< "gg" << "gh" << "gi" << "gl" << "gm" << "gn" << "gp" << "gq" << "gr" << "gs"
|
||||
<< "gt" << "gu" << "gw" << "gy" << "hk" << "hm" << "hn" << "hr" << "ht" << "hu"
|
||||
<< "id" << "ie" << "il" << "im" << "in" << "io" << "iq" << "ir" << "is" << "it"
|
||||
<< "je" << "jm" << "jo" << "jp" << "ke" << "kg" << "kh" << "ki" << "km" << "kn"
|
||||
<< "kp" << "kr" << "kw" << "ky" << "kz" << "la" << "lb" << "lc" << "li" << "lk"
|
||||
<< "lr" << "ls" << "lt" << "lu" << "lv" << "ly" << "ma" << "mc" << "md" << "me"
|
||||
<< "mf" << "mg" << "mh" << "mk" << "ml" << "mm" << "mn" << "mo" << "mp" << "mq"
|
||||
<< "mr" << "ms" << "mt" << "mu" << "mv" << "mw" << "mx" << "my" << "mz" << "na"
|
||||
<< "nc" << "ne" << "nf" << "ng" << "ni" << "nl" << "no" << "np" << "nr" << "nu"
|
||||
<< "nz" << "om" << "pa" << "pe" << "pf" << "pg" << "ph" << "pk" << "pl" << "pm"
|
||||
<< "pn" << "pr" << "ps" << "pt" << "pw" << "py" << "qa" << "re" << "ro" << "rs"
|
||||
<< "ru" << "rw" << "sa" << "sb" << "sc" << "sd" << "se" << "sg" << "sh" << "si"
|
||||
<< "sj" << "sk" << "sl" << "sm" << "sn" << "so" << "sr" << "ss" << "st" << "sv"
|
||||
<< "sx" << "sy" << "sz" << "tc" << "td" << "tf" << "tg" << "th" << "tj" << "tk"
|
||||
<< "tl" << "tm" << "tn" << "to" << "tr" << "tt" << "tv" << "tw" << "tz" << "ua"
|
||||
<< "ug" << "um" << "us" << "uy" << "uz" << "va" << "vc" << "ve" << "vg" << "vi"
|
||||
<< "vn" << "vu" << "wf" << "ws" << "ye" << "yt" << "za" << "zm" << "zw";
|
||||
|
||||
return countries;
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorLayoutState(const QByteArray &value)
|
||||
{
|
||||
deckEditorLayoutState = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_state",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorGeometry(const QByteArray &value)
|
||||
{
|
||||
deckEditorGeometry = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_geometry",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorCardSize(const QSize &value)
|
||||
{
|
||||
deckEditorCardSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_CardSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorDeckSize(const QSize &value)
|
||||
{
|
||||
deckEditorDeckSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_DeckSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setDeckEditorFilterSize(const QSize &value)
|
||||
{
|
||||
deckEditorFilterSize = value;
|
||||
|
||||
QString file = getSettingsPath();
|
||||
file.append("layouts/deckLayout.ini");
|
||||
QSettings layout_settings(file , QSettings::IniFormat);
|
||||
layout_settings.setValue("layouts/deckEditor_FilterSize",value);
|
||||
}
|
||||
|
||||
void SettingsCache::setGameDescription(const QString _gameDescription)
|
||||
{
|
||||
gameDescription = _gameDescription;
|
||||
settings->setValue("game/gamedescription", gameDescription);
|
||||
}
|
||||
|
||||
void SettingsCache::setMaxPlayers(const int _maxPlayers)
|
||||
{
|
||||
maxPlayers = _maxPlayers;
|
||||
settings->setValue("game/maxplayers", maxPlayers);
|
||||
}
|
||||
|
||||
void SettingsCache::setGameTypes(const QString _gameTypes)
|
||||
{
|
||||
gameTypes = _gameTypes;
|
||||
settings->setValue("game/gametypes", gameTypes);
|
||||
}
|
||||
|
||||
void SettingsCache::setOnlyBuddies(const bool _onlyBuddies)
|
||||
{
|
||||
onlyBuddies = _onlyBuddies;
|
||||
settings->setValue("game/onlybuddies", onlyBuddies);
|
||||
}
|
||||
|
||||
void SettingsCache::setOnlyRegistered(const bool _onlyRegistered)
|
||||
{
|
||||
onlyRegistered = _onlyRegistered;
|
||||
settings->setValue("game/onlyregistered", onlyRegistered);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsAllowed(const bool _spectatorsAllowed)
|
||||
{
|
||||
spectatorsAllowed = _spectatorsAllowed;
|
||||
settings->setValue("game/spectatorsallowed", spectatorsAllowed);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsNeedPassword(const bool _spectatorsNeedPassword)
|
||||
{
|
||||
spectatorsNeedPassword = _spectatorsNeedPassword;
|
||||
settings->setValue("game/spectatorsneedpassword", spectatorsNeedPassword);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsCanTalk(const bool _spectatorsCanTalk)
|
||||
{
|
||||
spectatorsCanTalk = _spectatorsCanTalk;
|
||||
settings->setValue("game/spectatorscantalk", spectatorsCanTalk);
|
||||
}
|
||||
|
||||
void SettingsCache::setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything)
|
||||
{
|
||||
spectatorsCanSeeEverything = _spectatorsCanSeeEverything;
|
||||
settings->setValue("game/spectatorscanseeeverything", spectatorsCanSeeEverything);
|
||||
}
|
||||
|
||||
void SettingsCache::setRememberGameSettings(const bool _rememberGameSettings)
|
||||
{
|
||||
rememberGameSettings = _rememberGameSettings;
|
||||
settings->setValue("game/remembergamesettings", rememberGameSettings);
|
||||
}
|
|
@ -2,11 +2,15 @@
|
|||
#define SETTINGSCACHE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
#include <QStringList>
|
||||
#include "shortcutssettings.h"
|
||||
|
||||
// the falbacks are used for cards without a muid
|
||||
#define PIC_URL_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
|
||||
#define PIC_URL_FALLBACK "http://mtgimage.com/set/!setcode!/!name!.jpg"
|
||||
#define PIC_URL_HQ_DEFAULT "http://mtgimage.com/multiverseid/!cardid!.jpg"
|
||||
#define PIC_URL_HQ_FALLBACK "http://mtgimage.com/set/!setcode!/!name!.jpg"
|
||||
#define PIC_URL_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?name=!name!&type=card"
|
||||
#define PIC_URL_HQ_DEFAULT "http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=!cardid!&type=card"
|
||||
#define PIC_URL_HQ_FALLBACK "http://gatherer.wizards.com/Handlers/Image.ashx?name=!name!&type=card"
|
||||
// size should be a multiple of 64
|
||||
#define PIXMAPCACHE_SIZE_DEFAULT 2047
|
||||
#define PIXMAPCACHE_SIZE_MIN 64
|
||||
|
@ -36,9 +40,10 @@ signals:
|
|||
void ignoreUnregisteredUserMessagesChanged();
|
||||
void pixmapCacheSizeChanged(int newSizeInMBs);
|
||||
void masterVolumeChanged(int value);
|
||||
void chatMentionCompleterChanged();
|
||||
private:
|
||||
QSettings *settings;
|
||||
|
||||
ShortcutsSettings *shortcutsSettings;
|
||||
QByteArray mainWindowGeometry;
|
||||
QString lang;
|
||||
QString deckPath, replaysPath, picsPath, cardDatabasePath, tokenDatabasePath, themeName;
|
||||
|
@ -48,6 +53,7 @@ private:
|
|||
bool spectatorNotificationsEnabled;
|
||||
bool doubleClickToPlay;
|
||||
bool playToStack;
|
||||
bool annotateTokens;
|
||||
int cardInfoMinimized;
|
||||
QByteArray tabGameSplitterSizes;
|
||||
bool displayCardNames;
|
||||
|
@ -56,8 +62,11 @@ private:
|
|||
int minPlayersForMultiColumnLayout;
|
||||
bool tapAnimation;
|
||||
bool chatMention;
|
||||
bool chatMentionCompleter;
|
||||
QString chatMentionColor;
|
||||
QString chatHighlightColor;
|
||||
bool chatMentionForeground;
|
||||
bool chatHighlightForeground;
|
||||
bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView;
|
||||
bool soundEnabled;
|
||||
QString soundPath;
|
||||
|
@ -69,6 +78,7 @@ private:
|
|||
QString picUrlHq;
|
||||
QString picUrlFallback;
|
||||
QString picUrlHqFallback;
|
||||
QString clientID;
|
||||
bool attemptAutoConnect;
|
||||
int pixmapCacheSize;
|
||||
bool scaleCards;
|
||||
|
@ -77,6 +87,22 @@ private:
|
|||
bool leftJustified;
|
||||
int masterVolume;
|
||||
int cardInfoViewMode;
|
||||
QString highlightWords;
|
||||
QString gameDescription;
|
||||
int maxPlayers;
|
||||
QString gameTypes;
|
||||
bool onlyBuddies;
|
||||
bool onlyRegistered;
|
||||
bool spectatorsAllowed;
|
||||
bool spectatorsNeedPassword;
|
||||
bool spectatorsCanTalk;
|
||||
bool spectatorsCanSeeEverything;
|
||||
bool rememberGameSettings;
|
||||
int keepalive;
|
||||
QByteArray deckEditorLayoutState, deckEditorGeometry;
|
||||
QSize deckEditorFilterSize, deckEditorDeckSize, deckEditorCardSize;
|
||||
QString getSettingsPath();
|
||||
|
||||
public:
|
||||
SettingsCache();
|
||||
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
||||
|
@ -88,6 +114,7 @@ public:
|
|||
QString getTokenDatabasePath() const { return tokenDatabasePath; }
|
||||
QString getThemeName() const { return themeName; }
|
||||
QString getChatMentionColor() const { return chatMentionColor; }
|
||||
QString getChatHighlightColor() const { return chatHighlightColor; }
|
||||
bool getPicDownload() const { return picDownload; }
|
||||
bool getPicDownloadHq() const { return picDownloadHq; }
|
||||
bool getNotificationsEnabled() const { return notificationsEnabled; }
|
||||
|
@ -95,6 +122,7 @@ public:
|
|||
|
||||
bool getDoubleClickToPlay() const { return doubleClickToPlay; }
|
||||
bool getPlayToStack() const { return playToStack; }
|
||||
bool getAnnotateTokens() const { return annotateTokens; }
|
||||
int getCardInfoMinimized() const { return cardInfoMinimized; }
|
||||
QByteArray getTabGameSplitterSizes() const { return tabGameSplitterSizes; }
|
||||
bool getDisplayCardNames() const { return displayCardNames; }
|
||||
|
@ -103,7 +131,9 @@ public:
|
|||
int getMinPlayersForMultiColumnLayout() const { return minPlayersForMultiColumnLayout; }
|
||||
bool getTapAnimation() const { return tapAnimation; }
|
||||
bool getChatMention() const { return chatMention; }
|
||||
bool getChatMentionCompleter() const { return chatMentionCompleter; }
|
||||
bool getChatMentionForeground() const { return chatMentionForeground; }
|
||||
bool getChatHighlightForeground() const { return chatHighlightForeground; }
|
||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||
/**
|
||||
|
@ -129,6 +159,33 @@ public:
|
|||
bool getLeftJustified() const { return leftJustified; }
|
||||
int getMasterVolume() const { return masterVolume; }
|
||||
int getCardInfoViewMode() const { return cardInfoViewMode; }
|
||||
QStringList getCountries() const;
|
||||
QString getHighlightWords() const { return highlightWords; }
|
||||
QString getGameDescription() const { return gameDescription; }
|
||||
int getMaxPlayers() const { return maxPlayers; }
|
||||
QString getGameTypes() const { return gameTypes; }
|
||||
bool getOnlyBuddies() const { return onlyBuddies; }
|
||||
bool getOnlyRegistered() const { return onlyRegistered; }
|
||||
bool getSpectatorsAllowed() const { return spectatorsAllowed; }
|
||||
bool getSpectatorsNeedPassword() const { return spectatorsNeedPassword; }
|
||||
bool getSpectatorsCanTalk() const { return spectatorsCanTalk; }
|
||||
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
|
||||
bool getRememberGameSettings() const { return rememberGameSettings; }
|
||||
int getKeepAlive() const { return keepalive; }
|
||||
void setClientID(QString clientID);
|
||||
QString getClientID() { return clientID; }
|
||||
QByteArray getDeckEditorLayoutState() const { return deckEditorLayoutState; }
|
||||
void setDeckEditorLayoutState(const QByteArray &value);
|
||||
QByteArray getDeckEditorGeometry() const { return deckEditorGeometry; }
|
||||
void setDeckEditorGeometry(const QByteArray &value);
|
||||
QSize getDeckEditorCardSize() const { return deckEditorCardSize; }
|
||||
void setDeckEditorCardSize(const QSize &value);
|
||||
QSize getDeckEditorDeckSize() const { return deckEditorDeckSize; }
|
||||
void setDeckEditorDeckSize(const QSize &value);
|
||||
QSize getDeckEditorFilterSize() const { return deckEditorFilterSize; }
|
||||
void setDeckEditorFilterSize(const QSize &value);
|
||||
ShortcutsSettings& shortcuts() const { return *shortcutsSettings; }
|
||||
|
||||
public slots:
|
||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||
void setLang(const QString &_lang);
|
||||
|
@ -139,12 +196,14 @@ public slots:
|
|||
void setTokenDatabasePath(const QString &_tokenDatabasePath);
|
||||
void setThemeName(const QString &_themeName);
|
||||
void setChatMentionColor(const QString &_chatMentionColor);
|
||||
void setChatHighlightColor(const QString &_chatHighlightColor);
|
||||
void setPicDownload(int _picDownload);
|
||||
void setPicDownloadHq(int _picDownloadHq);
|
||||
void setNotificationsEnabled(int _notificationsEnabled);
|
||||
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
|
||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||
void setPlayToStack(int _playToStack);
|
||||
void setAnnotateTokens(int _annotateTokens);
|
||||
void setCardInfoMinimized(int _cardInfoMinimized);
|
||||
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
|
||||
void setDisplayCardNames(int _displayCardNames);
|
||||
|
@ -153,7 +212,9 @@ public slots:
|
|||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||
void setTapAnimation(int _tapAnimation);
|
||||
void setChatMention(int _chatMention);
|
||||
void setChatMentionCompleter(int _chatMentionCompleter);
|
||||
void setChatMentionForeground(int _chatMentionForeground);
|
||||
void setChatHighlightForeground(int _chatHighlightForeground);
|
||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||
void setZoneViewPileView(int _zoneViewPileView);
|
||||
|
@ -175,6 +236,17 @@ public slots:
|
|||
void setLeftJustified( const int _leftJustified);
|
||||
void setMasterVolume(const int _masterVolume);
|
||||
void setCardInfoViewMode(const int _viewMode);
|
||||
void setHighlightWords(const QString &_highlightWords);
|
||||
void setGameDescription(const QString _gameDescription);
|
||||
void setMaxPlayers(const int _maxPlayers);
|
||||
void setGameTypes(const QString _gameTypes);
|
||||
void setOnlyBuddies(const bool _onlyBuddies);
|
||||
void setOnlyRegistered(const bool _onlyRegistered);
|
||||
void setSpectatorsAllowed(const bool _spectatorsAllowed);
|
||||
void setSpectatorsNeedPassword(const bool _spectatorsNeedPassword);
|
||||
void setSpectatorsCanTalk(const bool _spectatorsCanTalk);
|
||||
void setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything);
|
||||
void setRememberGameSettings(const bool _rememberGameSettings);
|
||||
};
|
||||
|
||||
extern SettingsCache *settingsCache;
|
||||
|
|
228
cockatrice/src/shortcutssettings.cpp
Normal file
228
cockatrice/src/shortcutssettings.cpp
Normal file
|
@ -0,0 +1,228 @@
|
|||
#include "shortcutssettings.h"
|
||||
#include <QFile>
|
||||
#include <QStringList>
|
||||
|
||||
ShortcutsSettings::ShortcutsSettings(QString settingsPath, QObject *parent) : QObject(parent)
|
||||
{
|
||||
this->settingsFilePath = settingsPath;
|
||||
this->settingsFilePath.append("shortcuts.ini");
|
||||
fillDefaultShorcuts();
|
||||
shortCuts = QMap<QString,QList<QKeySequence> >(defaultShortCuts);
|
||||
|
||||
bool exists = QFile(settingsFilePath).exists();
|
||||
|
||||
QSettings shortCutsFile(settingsFilePath, QSettings::IniFormat);
|
||||
|
||||
if(exists){
|
||||
shortCutsFile.beginGroup("Custom");
|
||||
const QStringList customKeys = shortCutsFile.allKeys();
|
||||
for(QStringList::const_iterator it = customKeys.constBegin(); it != customKeys.constEnd(); ++it)
|
||||
{
|
||||
QString stringSecuence = shortCutsFile.value(*it).toString();
|
||||
QList<QKeySequence> secuenceList = parseSecuenceString(stringSecuence);
|
||||
shortCuts.insert(*it, secuenceList);
|
||||
}
|
||||
shortCutsFile.endGroup();
|
||||
}
|
||||
}
|
||||
|
||||
QList<QKeySequence> ShortcutsSettings::getShortcut(QString name)
|
||||
{
|
||||
if(shortCuts.contains(name))
|
||||
return shortCuts.value(name);
|
||||
|
||||
return defaultShortCuts.value(name, QList<QKeySequence>());
|
||||
}
|
||||
|
||||
QKeySequence ShortcutsSettings::getSingleShortcut(QString name)
|
||||
{
|
||||
return getShortcut(name).at(0);
|
||||
}
|
||||
|
||||
QString ShortcutsSettings::getDefaultShortcutString(QString name)
|
||||
{
|
||||
return stringifySecuence(defaultShortCuts.value(name));
|
||||
}
|
||||
|
||||
QString ShortcutsSettings::getShortcutString(QString name)
|
||||
{
|
||||
return stringifySecuence(shortCuts.value(name));
|
||||
}
|
||||
|
||||
QString ShortcutsSettings::stringifySecuence(QList<QKeySequence> secuence) const
|
||||
{
|
||||
QString stringSecuence;
|
||||
for(int i=0; i < secuence.size(); ++i)
|
||||
{
|
||||
stringSecuence.append(secuence.at(i).toString(QKeySequence::PortableText));
|
||||
if(i < secuence.size() - 1)
|
||||
stringSecuence.append(";");
|
||||
}
|
||||
|
||||
return stringSecuence;
|
||||
}
|
||||
|
||||
QList<QKeySequence> ShortcutsSettings::parseSecuenceString(QString stringSecuence)
|
||||
{
|
||||
QStringList secuences = stringSecuence.split(";");
|
||||
QList<QKeySequence> secuenceList;
|
||||
for(QStringList::const_iterator ss = secuences.constBegin(); ss != secuences.constEnd(); ++ss)
|
||||
{
|
||||
secuenceList.append(QKeySequence(*ss, QKeySequence::PortableText));
|
||||
}
|
||||
|
||||
return secuenceList;
|
||||
}
|
||||
|
||||
void ShortcutsSettings::setShortcuts(QString name, QList<QKeySequence> secuence)
|
||||
{
|
||||
shortCuts[name] = secuence;
|
||||
|
||||
QSettings shortCutsFile(settingsFilePath, QSettings::IniFormat);
|
||||
shortCutsFile.beginGroup("Custom");
|
||||
QString stringSecuence = stringifySecuence(secuence);
|
||||
shortCutsFile.setValue(name, stringSecuence);
|
||||
shortCutsFile.endGroup();
|
||||
emit shortCutchanged();
|
||||
}
|
||||
|
||||
void ShortcutsSettings::setShortcuts(QString name, QKeySequence secuence)
|
||||
{
|
||||
setShortcuts(name, QList<QKeySequence>() << 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<QString> 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");
|
||||
defaultShortCuts["tab_room/aClearChat"] = parseSecuenceString("F12");
|
||||
defaultShortCuts["DlgLoadDeckFromClipboard/refreshButton"] = parseSecuenceString("F5");
|
||||
}
|
||||
|
40
cockatrice/src/shortcutssettings.h
Normal file
40
cockatrice/src/shortcutssettings.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef SHORTCUTSSETTINGS_H
|
||||
#define SHORTCUTSSETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSettings>
|
||||
#include <QMap>
|
||||
#include <QKeySequence>
|
||||
|
||||
class ShortcutsSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShortcutsSettings(QString settingsFilePath, QObject *parent = 0);
|
||||
~ShortcutsSettings() { }
|
||||
|
||||
QList<QKeySequence> getShortcut(QString name);
|
||||
QKeySequence getSingleShortcut(QString name);
|
||||
|
||||
QString getDefaultShortcutString(QString name);
|
||||
QString getShortcutString(QString name);
|
||||
|
||||
void setShortcuts(QString name, QList<QKeySequence> secuence);
|
||||
void setShortcuts(QString name, QKeySequence secuence);
|
||||
void setShortcuts(QString name, QString secuences);
|
||||
|
||||
bool isValid(QString name, QString secuences);
|
||||
signals:
|
||||
void shortCutchanged();
|
||||
|
||||
private:
|
||||
QString settingsFilePath;
|
||||
QMap<QString,QList<QKeySequence> > shortCuts;
|
||||
QMap<QString,QList<QKeySequence> > defaultShortCuts;
|
||||
void fillDefaultShorcuts();
|
||||
|
||||
QString stringifySecuence(QList<QKeySequence> secuence) const;
|
||||
QList<QKeySequence> parseSecuenceString(QString stringSecuence);
|
||||
};
|
||||
|
||||
#endif // SHORTCUTSSETTINGS_H
|
|
@ -58,10 +58,13 @@ TabAdmin::TabAdmin(TabSupervisor *_tabSupervisor, AbstractClient *_client, bool
|
|||
connect(updateServerMessageButton, SIGNAL(clicked()), this, SLOT(actUpdateServerMessage()));
|
||||
shutdownServerButton = new QPushButton;
|
||||
connect(shutdownServerButton, SIGNAL(clicked()), this, SLOT(actShutdownServer()));
|
||||
reloadConfigButton = new QPushButton;
|
||||
connect(reloadConfigButton, SIGNAL(clicked()), this, SLOT(actReloadConfig()));
|
||||
|
||||
QVBoxLayout *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(updateServerMessageButton);
|
||||
vbox->addWidget(shutdownServerButton);
|
||||
vbox->addWidget(reloadConfigButton);
|
||||
vbox->addStretch();
|
||||
|
||||
adminGroupBox = new QGroupBox;
|
||||
|
@ -87,6 +90,7 @@ void TabAdmin::retranslateUi()
|
|||
{
|
||||
updateServerMessageButton->setText(tr("Update server &message"));
|
||||
shutdownServerButton->setText(tr("&Shut down server"));
|
||||
reloadConfigButton->setText(tr("&Reload configuration"));
|
||||
adminGroupBox->setTitle(tr("Server administration functions"));
|
||||
|
||||
unlockButton->setText(tr("&Unlock functions"));
|
||||
|
@ -110,6 +114,12 @@ void TabAdmin::actShutdownServer()
|
|||
}
|
||||
}
|
||||
|
||||
void TabAdmin::actReloadConfig()
|
||||
{
|
||||
Command_ReloadConfig cmd;
|
||||
client->sendCommand(client->prepareAdminCommand(cmd));
|
||||
}
|
||||
|
||||
void TabAdmin::actUnlock()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Unlock administration functions"), tr("Do you really want to unlock the administration functions?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
|
|
|
@ -28,7 +28,7 @@ private:
|
|||
bool locked;
|
||||
AbstractClient *client;
|
||||
bool fullAdmin;
|
||||
QPushButton *updateServerMessageButton, *shutdownServerButton;
|
||||
QPushButton *updateServerMessageButton, *shutdownServerButton, *reloadConfigButton;
|
||||
QGroupBox *adminGroupBox;
|
||||
QPushButton *unlockButton, *lockButton;
|
||||
signals:
|
||||
|
@ -36,6 +36,7 @@ signals:
|
|||
private slots:
|
||||
void actUpdateServerMessage();
|
||||
void actShutdownServer();
|
||||
void actReloadConfig();
|
||||
|
||||
void actUnlock();
|
||||
void actLock();
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#include <QTextStream>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QTimer>
|
||||
#include <QDockWidget>
|
||||
#include <QPushButton>
|
||||
#include <QDir>
|
||||
#include <QDesktopServices>
|
||||
#include "tab_deck_editor.h"
|
||||
#include "window_sets.h"
|
||||
#include "carddatabase.h"
|
||||
|
@ -47,108 +51,37 @@ void SearchLineEdit::keyPressEvent(QKeyEvent *event)
|
|||
QLineEdit::keyPressEvent(event);
|
||||
}
|
||||
|
||||
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||
: Tab(_tabSupervisor, parent), modified(false)
|
||||
void TabDeckEditor::createShowHideDocksButtons()
|
||||
{
|
||||
aClearFilterAll = new QAction(QString(), this);
|
||||
aClearFilterAll->setIcon(QIcon("theme:icons/clearsearch.svg"));
|
||||
connect(aClearFilterAll, SIGNAL(triggered()), this, SLOT(actClearFilterAll()));
|
||||
btnFilter = new QPushButton(QIcon("theme:icons/view.svg"),QString());
|
||||
btnFilter->setObjectName("btnFilter");
|
||||
btnFilter->setCheckable(true);
|
||||
btnFilter->setChecked(true);
|
||||
btnFilter->setMaximumWidth(30);
|
||||
searchLayout->addWidget(btnFilter);
|
||||
|
||||
aClearFilterOne = new QAction(QString(), this);
|
||||
aClearFilterOne->setIcon(QIcon("theme:icons/decrement.svg"));
|
||||
connect(aClearFilterOne, SIGNAL(triggered()), this, SLOT(actClearFilterOne()));
|
||||
btnDeck = new QPushButton(QIcon("theme:hand.svg"),QString());
|
||||
btnDeck->setObjectName("btnDeck");
|
||||
btnDeck->setCheckable(true);
|
||||
btnDeck->setChecked(true);
|
||||
btnDeck->setMaximumWidth(30);
|
||||
searchLayout->addWidget(btnDeck);
|
||||
|
||||
searchEdit = new SearchLineEdit;
|
||||
#if QT_VERSION >= 0x050300
|
||||
searchEdit->addAction(QIcon("theme:icons/search.svg"), QLineEdit::LeadingPosition);
|
||||
#endif
|
||||
searchEdit->setObjectName("searchEdit");
|
||||
|
||||
setFocusProxy(searchEdit);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
searchEdit->installEventFilter(&searchKeySignals);
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
|
||||
connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actAddCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltRBracket()), this, SLOT(actAddCardToSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrementCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard()));
|
||||
|
||||
QToolBar *deckEditToolBar = new QToolBar;
|
||||
deckEditToolBar->setOrientation(Qt::Horizontal);
|
||||
deckEditToolBar->setIconSize(QSize(24, 24));
|
||||
|
||||
QHBoxLayout *searchLayout = new QHBoxLayout;
|
||||
searchLayout->addWidget(deckEditToolBar);
|
||||
searchLayout->addWidget(searchEdit);
|
||||
|
||||
databaseModel = new CardDatabaseModel(db, this);
|
||||
databaseDisplayModel = new CardDatabaseDisplayModel(this);
|
||||
databaseDisplayModel->setSourceModel(databaseModel);
|
||||
databaseDisplayModel->setFilterKeyColumn(0);
|
||||
databaseDisplayModel->sort(0, Qt::AscendingOrder);
|
||||
|
||||
databaseView = new QTreeView();
|
||||
databaseView->setFocusProxy(searchEdit);
|
||||
databaseView->setModel(databaseDisplayModel);
|
||||
databaseView->setUniformRowHeights(true);
|
||||
databaseView->setRootIsDecorated(false);
|
||||
databaseView->setAlternatingRowColors(true);
|
||||
databaseView->setSortingEnabled(true);
|
||||
databaseView->sortByColumn(0, Qt::AscendingOrder);
|
||||
databaseView->resizeColumnToContents(0);
|
||||
connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &)));
|
||||
connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard()));
|
||||
searchEdit->setTreeView(databaseView);
|
||||
|
||||
QVBoxLayout *leftFrame = new QVBoxLayout;
|
||||
leftFrame->addLayout(searchLayout);
|
||||
leftFrame->addWidget(databaseView);
|
||||
|
||||
cardInfo = new CardFrame(250, 356);
|
||||
|
||||
filterModel = new FilterTreeModel();
|
||||
databaseDisplayModel->setFilterTree(filterModel->filterTree());
|
||||
filterView = new QTreeView;
|
||||
filterView->setModel(filterModel);
|
||||
filterView->setMaximumWidth(250);
|
||||
filterView->setUniformRowHeights(true);
|
||||
filterView->setHeaderHidden(true);
|
||||
filterView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
|
||||
connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),
|
||||
this, SLOT(filterViewCustomContextMenu(const QPoint &)));
|
||||
FilterBuilder *filterBuilder = new FilterBuilder;
|
||||
connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));
|
||||
|
||||
QToolButton *filterDelOne = new QToolButton();
|
||||
filterDelOne->setDefaultAction(aClearFilterOne);
|
||||
filterDelOne->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
|
||||
QToolButton *filterDelAll = new QToolButton();
|
||||
filterDelAll->setDefaultAction(aClearFilterAll);
|
||||
filterDelAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
|
||||
QGridLayout *filterLayout = new QGridLayout;
|
||||
filterLayout->addWidget(filterBuilder, 0, 0, 1, 2);
|
||||
filterLayout->addWidget(filterView, 1, 0, 1, 2);
|
||||
filterLayout->addWidget(filterDelOne, 2, 0);
|
||||
filterLayout->addWidget(filterDelAll, 2, 1);
|
||||
|
||||
filterBox = new QGroupBox();
|
||||
filterBox->setMaximumWidth(250);
|
||||
filterBox->setLayout(filterLayout);
|
||||
|
||||
QVBoxLayout *middleFrame = new QVBoxLayout;
|
||||
middleFrame->addWidget(cardInfo, 0, Qt::AlignTop);
|
||||
middleFrame->addWidget(filterBox, 0);
|
||||
btnCard = new QPushButton(QIcon("theme:back.svg"),QString());
|
||||
btnCard->setObjectName("btnCard");
|
||||
btnCard->setCheckable(true);
|
||||
btnCard->setChecked(true);
|
||||
btnCard->setMaximumWidth(30);
|
||||
searchLayout->addWidget(btnCard);
|
||||
}
|
||||
|
||||
void TabDeckEditor::createDeckDock()
|
||||
{
|
||||
deckModel = new DeckListModel(this);
|
||||
deckModel->setObjectName("deckModel");
|
||||
connect(deckModel, SIGNAL(deckHashChanged()), this, SLOT(updateHash()));
|
||||
deckView = new QTreeView();
|
||||
deckView->setObjectName("deckView");
|
||||
deckView->setModel(deckModel);
|
||||
deckView->setUniformRowHeights(true);
|
||||
deckView->setSortingEnabled(true);
|
||||
|
@ -170,18 +103,26 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
connect(&deckViewKeySignals, SIGNAL(onDelete()), this, SLOT(actRemoveCard()));
|
||||
|
||||
nameLabel = new QLabel();
|
||||
nameLabel->setObjectName("nameLabel");
|
||||
nameEdit = new QLineEdit;
|
||||
nameEdit->setObjectName("nameEdit");
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
connect(nameEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateName(const QString &)));
|
||||
commentsLabel = new QLabel();
|
||||
commentsLabel->setObjectName("commentsLabel");
|
||||
commentsEdit = new QTextEdit;
|
||||
commentsEdit->setObjectName("commentsEdit");
|
||||
commentsEdit->setMaximumHeight(70);
|
||||
commentsLabel->setBuddy(commentsEdit);
|
||||
connect(commentsEdit, SIGNAL(textChanged()), this, SLOT(updateComments()));
|
||||
|
||||
hashLabel1 = new QLabel();
|
||||
hashLabel1->setObjectName("hashLabel1");
|
||||
hashLabel = new QLabel;
|
||||
hashLabel->setObjectName("hashLabel");
|
||||
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->setObjectName("grid");
|
||||
grid->addWidget(nameLabel, 0, 0);
|
||||
grid->addWidget(nameEdit, 0, 1);
|
||||
|
||||
|
@ -201,59 +142,161 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
*/
|
||||
|
||||
QToolBar *deckToolBar = new QToolBar;
|
||||
deckToolBar->setObjectName("deckToolBar");
|
||||
deckToolBar->setOrientation(Qt::Vertical);
|
||||
deckToolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
deckToolBar->setIconSize(QSize(24, 24));
|
||||
//deckToolBar->addAction(aUpdatePrices);
|
||||
QHBoxLayout *deckToolbarLayout = new QHBoxLayout;
|
||||
deckToolbarLayout->setObjectName("deckToolbarLayout");
|
||||
deckToolbarLayout->addStretch();
|
||||
deckToolbarLayout->addWidget(deckToolBar);
|
||||
deckToolbarLayout->addStretch();
|
||||
|
||||
QVBoxLayout *rightFrame = new QVBoxLayout;
|
||||
rightFrame->setObjectName("rightFrame");
|
||||
rightFrame->addLayout(grid);
|
||||
rightFrame->addWidget(deckView, 10);
|
||||
rightFrame->addLayout(deckToolbarLayout);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addLayout(leftFrame, 10);
|
||||
mainLayout->addLayout(middleFrame);
|
||||
mainLayout->addLayout(rightFrame);
|
||||
setLayout(mainLayout);
|
||||
deckDock = new QDockWidget(MainWindow);
|
||||
deckDock->setObjectName("deckDock");
|
||||
|
||||
deckDock->setMinimumSize(QSize(200, 41));
|
||||
deckDock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
|
||||
deckDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
|
||||
QWidget *deckDockContents = new QWidget();
|
||||
deckDockContents->setObjectName("deckDockContents");
|
||||
deckDockContents->setLayout(rightFrame);
|
||||
deckDock->setWidget(deckDockContents);
|
||||
|
||||
connect(btnDeck,SIGNAL(toggled(bool)),deckDock,SLOT(setVisible(bool)));
|
||||
deckDock->installEventFilter(this);
|
||||
}
|
||||
|
||||
void TabDeckEditor::createCardInfoDock()
|
||||
{
|
||||
cardInfo = new CardFrame();
|
||||
cardInfo->setObjectName("cardInfo");
|
||||
QVBoxLayout *cardInfoFrame = new QVBoxLayout;
|
||||
cardInfoFrame->setObjectName("cardInfoFrame");
|
||||
cardInfoFrame->addWidget(cardInfo);
|
||||
|
||||
cardInfoDock = new QDockWidget(MainWindow);
|
||||
cardInfoDock->setObjectName("cardInfoDock");
|
||||
|
||||
cardInfoDock->setMinimumSize(QSize(200, 41));
|
||||
cardInfoDock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
|
||||
cardInfoDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
|
||||
QWidget *cardInfoDockContents = new QWidget();
|
||||
cardInfoDockContents->setObjectName("cardInfoDockContents");
|
||||
cardInfoDockContents->setLayout(cardInfoFrame);
|
||||
cardInfoDock->setWidget(cardInfoDockContents);
|
||||
|
||||
connect(btnCard,SIGNAL(toggled(bool)),cardInfoDock,SLOT(setVisible(bool)));
|
||||
cardInfoDock->installEventFilter(this);
|
||||
}
|
||||
|
||||
void TabDeckEditor::createFiltersDock()
|
||||
{
|
||||
filterModel = new FilterTreeModel();
|
||||
filterModel->setObjectName("filterModel");
|
||||
databaseDisplayModel->setFilterTree(filterModel->filterTree());
|
||||
databaseDisplayModel->setObjectName("databaseDisplayModel");
|
||||
filterView = new QTreeView;
|
||||
filterView->setObjectName("filterView");
|
||||
filterView->setModel(filterModel);
|
||||
filterView->setUniformRowHeights(true);
|
||||
filterView->setHeaderHidden(true);
|
||||
filterView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(filterModel, SIGNAL(layoutChanged()), filterView, SLOT(expandAll()));
|
||||
connect(filterView, SIGNAL(customContextMenuRequested(const QPoint &)),this, SLOT(filterViewCustomContextMenu(const QPoint &)));
|
||||
|
||||
FilterBuilder *filterBuilder = new FilterBuilder;
|
||||
filterBuilder->setObjectName("filterBuilder");
|
||||
connect(filterBuilder, SIGNAL(add(const CardFilter *)), filterModel, SLOT(addFilter(const CardFilter *)));
|
||||
|
||||
QToolButton *filterDelOne = new QToolButton();
|
||||
filterDelOne->setObjectName("filterDelOne");
|
||||
filterDelOne->setDefaultAction(aClearFilterOne);
|
||||
filterDelOne->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
|
||||
QToolButton *filterDelAll = new QToolButton();
|
||||
filterDelAll->setObjectName("filterDelAll");
|
||||
filterDelAll->setDefaultAction(aClearFilterAll);
|
||||
filterDelAll->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
|
||||
QGridLayout *filterLayout = new QGridLayout;
|
||||
filterLayout->setObjectName("filterLayout");
|
||||
filterLayout->setContentsMargins(0,0,0,0);
|
||||
filterLayout->addWidget(filterBuilder, 0, 0, 1, 2);
|
||||
filterLayout->addWidget(filterView, 1, 0, 1, 2);
|
||||
|
||||
filterBox = new QWidget();
|
||||
filterBox->setObjectName("filterBox");
|
||||
filterBox->setLayout(filterLayout);
|
||||
|
||||
QVBoxLayout *filterFrame = new QVBoxLayout;
|
||||
filterFrame->setObjectName("filterFrame");
|
||||
filterFrame->addWidget(filterBox);
|
||||
|
||||
filterDock = new QDockWidget(MainWindow);
|
||||
filterDock->setObjectName("filterDock");
|
||||
|
||||
filterDock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
|
||||
QWidget *filterDockContents = new QWidget(MainWindow);
|
||||
filterDockContents->setObjectName("filterDockContents");
|
||||
filterDockContents->setLayout(filterFrame);
|
||||
filterDock->setWidget(filterDockContents);
|
||||
|
||||
connect(btnFilter,SIGNAL(toggled(bool)),filterDock,SLOT(setVisible(bool)));
|
||||
filterDock->installEventFilter(this);
|
||||
}
|
||||
|
||||
void TabDeckEditor::createMenus()
|
||||
{
|
||||
aNewDeck = new QAction(QString(), this);
|
||||
aNewDeck->setShortcuts(QKeySequence::New);
|
||||
connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck()));
|
||||
|
||||
aLoadDeck = new QAction(QString(), this);
|
||||
aLoadDeck->setShortcuts(QKeySequence::Open);
|
||||
connect(aLoadDeck, SIGNAL(triggered()), this, SLOT(actLoadDeck()));
|
||||
|
||||
aSaveDeck = new QAction(QString(), this);
|
||||
aSaveDeck->setShortcuts(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()));
|
||||
|
||||
aOpenCustomsetsFolder = new QAction(QString(), this);
|
||||
connect(aOpenCustomsetsFolder, SIGNAL(triggered()), this, SLOT(actOpenCustomsetsFolder()));
|
||||
|
||||
aLoadDeckFromClipboard = new QAction(QString(), this);
|
||||
connect(aLoadDeckFromClipboard, SIGNAL(triggered()), this, SLOT(actLoadDeckFromClipboard()));
|
||||
aLoadDeckFromClipboard->setShortcuts(QKeySequence::Paste);
|
||||
|
||||
aSaveDeckToClipboard = new QAction(QString(), this);
|
||||
connect(aSaveDeckToClipboard, SIGNAL(triggered()), this, SLOT(actSaveDeckToClipboard()));
|
||||
aSaveDeckToClipboard->setShortcuts(QKeySequence::Copy);
|
||||
|
||||
aPrintDeck = new QAction(QString(), this);
|
||||
aPrintDeck->setShortcuts(QKeySequence::Print);
|
||||
connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
|
||||
|
||||
aAnalyzeDeck = new QAction(QString(), this);
|
||||
connect(aAnalyzeDeck, SIGNAL(triggered()), this, SLOT(actAnalyzeDeck()));
|
||||
|
||||
aClose = new QAction(QString(), this);
|
||||
connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest()));
|
||||
|
||||
aOpenCustomFolder = new QAction(QString(), this);
|
||||
connect(aOpenCustomFolder, SIGNAL(triggered()), this, SLOT(actOpenCustomFolder()));
|
||||
|
||||
aEditSets = new QAction(QString(), this);
|
||||
connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets()));
|
||||
|
||||
aEditTokens = new QAction(QString(), this);
|
||||
connect(aEditTokens, SIGNAL(triggered()), this, SLOT(actEditTokens()));
|
||||
|
||||
aResetLayout = new QAction(QString(), this);
|
||||
connect(aResetLayout,SIGNAL(triggered()),this,SLOT(restartLayout()));
|
||||
|
||||
deckMenu = new QMenu(this);
|
||||
deckMenu->addAction(aNewDeck);
|
||||
deckMenu->addAction(aLoadDeck);
|
||||
|
@ -267,19 +310,75 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aAnalyzeDeck);
|
||||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aResetLayout);
|
||||
deckMenu->addSeparator();
|
||||
deckMenu->addAction(aClose);
|
||||
addTabMenu(deckMenu);
|
||||
|
||||
aClearFilterAll = new QAction(QString(), this);
|
||||
aClearFilterAll->setIcon(QIcon(":/resources/icon_clearsearch.svg"));
|
||||
connect(aClearFilterAll, SIGNAL(triggered()), this, SLOT(actClearFilterAll()));
|
||||
|
||||
aClearFilterOne = new QAction(QString(), this);
|
||||
aClearFilterOne->setIcon(QIcon(":/resources/decrement.svg"));
|
||||
connect(aClearFilterOne, SIGNAL(triggered()), this, SLOT(actClearFilterOne()));
|
||||
|
||||
dbMenu = new QMenu(this);
|
||||
dbMenu->addAction(aEditSets);
|
||||
dbMenu->addAction(aEditTokens);
|
||||
dbMenu->addSeparator();
|
||||
dbMenu->addAction(aClearFilterOne);
|
||||
dbMenu->addAction(aClearFilterAll);
|
||||
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
|
||||
dbMenu->addSeparator();
|
||||
dbMenu->addAction(aOpenCustomFolder);
|
||||
dbMenu->addAction(aOpenCustomsetsFolder);
|
||||
#endif
|
||||
addTabMenu(dbMenu);
|
||||
}
|
||||
|
||||
void TabDeckEditor::createCentralFrame()
|
||||
{
|
||||
searchEdit = new SearchLineEdit;
|
||||
searchEdit->setObjectName("searchEdit");
|
||||
#if QT_VERSION >= 0x050300
|
||||
searchEdit->addAction(QIcon(":/resources/icon_search_black.svg"), QLineEdit::LeadingPosition);
|
||||
#endif
|
||||
|
||||
setFocusProxy(searchEdit);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
searchEdit->installEventFilter(&searchKeySignals);
|
||||
searchKeySignals.setObjectName("searchKeySignals");
|
||||
connect(searchEdit, SIGNAL(textChanged(const QString &)), this, SLOT(updateSearch(const QString &)));
|
||||
connect(&searchKeySignals, SIGNAL(onEnter()), this, SLOT(actAddCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltEqual()), this, SLOT(actAddCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltRBracket()), this, SLOT(actAddCardToSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltMinus()), this, SLOT(actDecrementCard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltLBracket()), this, SLOT(actDecrementCardFromSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlAltEnter()), this, SLOT(actAddCardToSideboard()));
|
||||
connect(&searchKeySignals, SIGNAL(onCtrlEnter()), this, SLOT(actAddCardToSideboard()));
|
||||
|
||||
databaseModel = new CardDatabaseModel(db, this);
|
||||
databaseModel->setObjectName("databaseModel");
|
||||
databaseDisplayModel = new CardDatabaseDisplayModel(this);
|
||||
databaseDisplayModel->setSourceModel(databaseModel);
|
||||
databaseDisplayModel->setFilterKeyColumn(0);
|
||||
databaseDisplayModel->sort(0, Qt::AscendingOrder);
|
||||
|
||||
databaseView = new QTreeView();
|
||||
databaseView->setObjectName("databaseView");
|
||||
databaseView->setFocusProxy(searchEdit);
|
||||
databaseView->setModel(databaseDisplayModel);
|
||||
databaseView->setUniformRowHeights(true);
|
||||
databaseView->setRootIsDecorated(false);
|
||||
databaseView->setAlternatingRowColors(true);
|
||||
databaseView->setSortingEnabled(true);
|
||||
databaseView->sortByColumn(0, Qt::AscendingOrder);
|
||||
databaseView->resizeColumnToContents(0);
|
||||
connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &)));
|
||||
connect(databaseView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(actAddCard()));
|
||||
searchEdit->setTreeView(databaseView);
|
||||
|
||||
aAddCard = new QAction(QString(), this);
|
||||
aAddCard->setIcon(QIcon("theme:icons/arrow_right_green.svg"));
|
||||
|
@ -297,6 +396,11 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
aDecrement->setIcon(QIcon("theme:icons/decrement.svg"));
|
||||
connect(aDecrement, SIGNAL(triggered()), this, SLOT(actDecrement()));
|
||||
|
||||
QToolBar *deckEditToolBar = new QToolBar;
|
||||
deckEditToolBar->setObjectName("deckEditToolBar");
|
||||
deckEditToolBar->setOrientation(Qt::Horizontal);
|
||||
deckEditToolBar->setIconSize(QSize(24, 24));
|
||||
|
||||
deckEditToolBar->addAction(aAddCard);
|
||||
deckEditToolBar->addAction(aAddCardToSideboard);
|
||||
deckEditToolBar->addAction(aRemoveCard);
|
||||
|
@ -304,11 +408,135 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
deckEditToolBar->addAction(aIncrement);
|
||||
deckEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
searchLayout = new QHBoxLayout;
|
||||
searchLayout->setObjectName("searchLayout");
|
||||
searchLayout->addWidget(deckEditToolBar);
|
||||
searchLayout->addWidget(searchEdit);
|
||||
createShowHideDocksButtons();
|
||||
|
||||
centralFrame = new QVBoxLayout;
|
||||
centralFrame->setObjectName("centralFrame");
|
||||
centralFrame->addLayout(searchLayout);
|
||||
centralFrame->addWidget(databaseView);
|
||||
|
||||
centralWidget = new QWidget(MainWindow);
|
||||
centralWidget->setObjectName("centralWidget");
|
||||
centralWidget->setLayout(centralFrame);
|
||||
MainWindow->setCentralWidget(centralWidget);
|
||||
MainWindow->setDockOptions(QMainWindow::AnimatedDocks|QMainWindow::AllowNestedDocks|QMainWindow::AllowTabbedDocks);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setObjectName("mainLayout");
|
||||
mainLayout->addWidget(MainWindow);
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
void TabDeckEditor::restartLayout()
|
||||
{
|
||||
btnDeck->setChecked(true);
|
||||
btnFilter->setChecked(true);
|
||||
btnCard->setChecked(true);
|
||||
|
||||
deckDock->setFloating(false);
|
||||
cardInfoDock->setFloating(false);
|
||||
filterDock->setFloating(false);
|
||||
|
||||
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), deckDock);
|
||||
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), cardInfoDock);
|
||||
MainWindow->addDockWidget(static_cast<Qt::DockWidgetArea>(2), filterDock);
|
||||
|
||||
MainWindow->splitDockWidget(cardInfoDock, deckDock, Qt::Horizontal);
|
||||
MainWindow->splitDockWidget(cardInfoDock, filterDock, Qt::Vertical);
|
||||
|
||||
deckDock->setMinimumWidth(360);
|
||||
deckDock->setMaximumWidth(360);
|
||||
|
||||
cardInfoDock->setMinimumSize(250, 360);
|
||||
cardInfoDock->setMaximumSize(250, 360);
|
||||
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
|
||||
}
|
||||
|
||||
void TabDeckEditor::freeDocksSize()
|
||||
{
|
||||
deckDock->setMinimumSize(100, 100);
|
||||
deckDock->setMaximumSize(5000, 5000);
|
||||
|
||||
cardInfoDock->setMinimumSize(100, 100);
|
||||
cardInfoDock->setMaximumSize(5000, 5000);
|
||||
|
||||
filterDock->setMinimumSize(100,100);
|
||||
filterDock->setMaximumSize(5000,5000);
|
||||
}
|
||||
|
||||
void TabDeckEditor::refreshShortcuts()
|
||||
{
|
||||
aNewDeck->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aNewDeck"));
|
||||
aLoadDeck->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aLoadDeck"));
|
||||
aSaveDeck->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aSaveDeck"));
|
||||
aSaveDeckAs->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aSaveDeckAs"));
|
||||
aLoadDeckFromClipboard->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aLoadDeckFromClipboard"));
|
||||
aPrintDeck->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aPrintDeck"));
|
||||
aAnalyzeDeck->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aAnalyzeDeck"));
|
||||
aClose->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aClose"));
|
||||
aOpenCustomFolder->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aOpenCustomFolder"));
|
||||
aEditSets->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aEditSets"));
|
||||
aEditTokens->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aEditTokens"));
|
||||
aResetLayout->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aResetLayout"));
|
||||
aClearFilterAll->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aClearFilterAll"));
|
||||
aClearFilterOne->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aClearFilterOne"));
|
||||
aSaveDeckToClipboard->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aSaveDeckToClipboard"));
|
||||
aClearFilterOne->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aClearFilterOne"));
|
||||
aClose->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aClose"));
|
||||
aRemoveCard->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aRemoveCard"));
|
||||
aIncrement->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aIncrement"));
|
||||
aDecrement->setShortcuts(settingsCache->shortcuts().getShortcut("TabDeckEditor/aDecrement"));
|
||||
}
|
||||
|
||||
void TabDeckEditor::loadLayout()
|
||||
{
|
||||
MainWindow->restoreState(settingsCache->getDeckEditorLayoutState());
|
||||
MainWindow->restoreGeometry(settingsCache->getDeckEditorGeometry());
|
||||
|
||||
btnCard->setChecked(!cardInfoDock->isHidden());
|
||||
btnFilter->setChecked(!filterDock->isHidden());
|
||||
btnDeck->setChecked(!deckDock->isHidden());
|
||||
|
||||
cardInfoDock->setMinimumSize(settingsCache->getDeckEditorCardSize());
|
||||
cardInfoDock->setMaximumSize(settingsCache->getDeckEditorCardSize());
|
||||
|
||||
filterDock->setMinimumSize(settingsCache->getDeckEditorFilterSize());
|
||||
filterDock->setMaximumSize(settingsCache->getDeckEditorFilterSize());
|
||||
|
||||
deckDock->setMinimumSize(settingsCache->getDeckEditorDeckSize());
|
||||
deckDock->setMaximumSize(settingsCache->getDeckEditorDeckSize());
|
||||
|
||||
QTimer::singleShot(100, this, SLOT(freeDocksSize()));
|
||||
}
|
||||
|
||||
TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
||||
: Tab(_tabSupervisor, parent), modified(false)
|
||||
{
|
||||
MainWindow = new QMainWindow;
|
||||
MainWindow->setObjectName("MainWindow");
|
||||
|
||||
createMenus();
|
||||
|
||||
createCentralFrame();
|
||||
|
||||
createDeckDock();
|
||||
createCardInfoDock();
|
||||
createFiltersDock();
|
||||
|
||||
restartLayout();
|
||||
|
||||
this->installEventFilter(this);
|
||||
|
||||
retranslateUi();
|
||||
|
||||
resize(950, 700);
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
|
||||
QTimer::singleShot(0, this, SLOT(checkFirstRunDetected()));
|
||||
QTimer::singleShot(0, this, SLOT(loadLayout()));
|
||||
}
|
||||
|
||||
TabDeckEditor::~TabDeckEditor()
|
||||
|
@ -320,7 +548,6 @@ void TabDeckEditor::retranslateUi()
|
|||
{
|
||||
cardInfo->retranslateUi();
|
||||
|
||||
filterBox->setTitle(tr("Filters"));
|
||||
aClearFilterAll->setText(tr("&Clear all filters"));
|
||||
aClearFilterOne->setText(tr("Delete selected"));
|
||||
|
||||
|
@ -340,24 +567,31 @@ void TabDeckEditor::retranslateUi()
|
|||
aPrintDeck->setText(tr("&Print deck..."));
|
||||
aAnalyzeDeck->setText(tr("&Analyze deck on deckstats.net"));
|
||||
aOpenCustomFolder->setText(tr("Open custom image folder"));
|
||||
aOpenCustomsetsFolder->setText(tr("Open custom sets folder"));
|
||||
aClose->setText(tr("&Close"));
|
||||
aClose->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
|
||||
aAddCard->setText(tr("Add card to &maindeck"));
|
||||
aAddCardToSideboard->setText(tr("Add card to &sideboard"));
|
||||
|
||||
aRemoveCard->setText(tr("&Remove row"));
|
||||
aRemoveCard->setShortcut(QKeySequence("Del"));
|
||||
|
||||
aIncrement->setText(tr("&Increment number"));
|
||||
aIncrement->setShortcut(QKeySequence("+"));
|
||||
|
||||
aDecrement->setText(tr("&Decrement number"));
|
||||
aDecrement->setShortcut(QKeySequence("-"));
|
||||
|
||||
deckMenu->setTitle(tr("&Deck Editor"));
|
||||
dbMenu->setTitle(tr("C&ard Database"));
|
||||
|
||||
aEditSets->setText(tr("&Edit sets..."));
|
||||
aEditTokens->setText(tr("Edit &tokens..."));
|
||||
|
||||
btnCard->setToolTip(tr("Show/Hide card information"));
|
||||
btnDeck->setToolTip(tr("Show/Hide deck"));
|
||||
btnFilter->setToolTip(tr("Show/Hide filters"));
|
||||
aResetLayout->setText(tr("Reset layout"));
|
||||
cardInfoDock->setWindowTitle(tr("Card Info"));
|
||||
deckDock->setWindowTitle(tr("Deck"));
|
||||
filterDock->setWindowTitle(tr("Filters"));
|
||||
}
|
||||
|
||||
QString TabDeckEditor::getTabText() const
|
||||
|
@ -574,6 +808,33 @@ void TabDeckEditor::actOpenCustomFolder() {
|
|||
|
||||
}
|
||||
|
||||
void TabDeckEditor::actOpenCustomsetsFolder() {
|
||||
#if QT_VERSION < 0x050000
|
||||
QString dataDir = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
|
||||
#else
|
||||
QString dataDir = QStandardPaths::standardLocations(QStandardPaths::DataLocation).first();
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
|
||||
QStringList scriptArgs;
|
||||
scriptArgs << QLatin1String("-e");
|
||||
scriptArgs << QString::fromLatin1("tell application \"Finder\" to open POSIX file \"%1\"").arg(dataDir + "/customsets/");
|
||||
scriptArgs << QLatin1String("-e");
|
||||
scriptArgs << QLatin1String("tell application \"Finder\" to activate");
|
||||
|
||||
QProcess::execute("/usr/bin/osascript", scriptArgs);
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
QStringList args;
|
||||
dataDir.append("/customsets");
|
||||
args << QDir::toNativeSeparators(dataDir);
|
||||
aOpenCustomsetsFolder->setText(dataDir);
|
||||
QProcess::startDetached("explorer", args);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void TabDeckEditor::actEditSets()
|
||||
{
|
||||
WndSets *w = new WndSets;
|
||||
|
@ -657,7 +918,10 @@ void TabDeckEditor::actSwapCard()
|
|||
|
||||
void TabDeckEditor::actAddCard()
|
||||
{
|
||||
addCardHelper("main");
|
||||
if(QApplication::keyboardModifiers() & Qt::ControlModifier)
|
||||
actAddCardToSideboard();
|
||||
else
|
||||
addCardHelper("main");
|
||||
}
|
||||
|
||||
void TabDeckEditor::actAddCardToSideboard()
|
||||
|
@ -733,6 +997,27 @@ void TabDeckEditor::setPriceTagFeatureEnabled(int /* enabled */)
|
|||
deckModel->pricesUpdated();
|
||||
}
|
||||
|
||||
bool TabDeckEditor::eventFilter(QObject * o, QEvent * e)
|
||||
{
|
||||
if(e->type() == QEvent::Close)
|
||||
{
|
||||
if(o == cardInfoDock)
|
||||
btnCard->setChecked(false);
|
||||
else if(o == deckDock)
|
||||
btnDeck->setChecked(false);
|
||||
else if(o == filterDock)
|
||||
btnFilter->setChecked(false);
|
||||
}
|
||||
if( o == this && e->type() == QEvent::Hide){
|
||||
settingsCache->setDeckEditorLayoutState(MainWindow->saveState());
|
||||
settingsCache->setDeckEditorGeometry(MainWindow->saveGeometry());
|
||||
settingsCache->setDeckEditorCardSize(cardInfoDock->size());
|
||||
settingsCache->setDeckEditorFilterSize(filterDock->size());
|
||||
settingsCache->setDeckEditorDeckSize(deckDock->size());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void TabDeckEditor::actUpdatePrices()
|
||||
|
@ -818,4 +1103,4 @@ void TabDeckEditor::checkFirstRunDetected()
|
|||
QMessageBox::information(this, tr("Welcome"), tr("Hi! It seems like you're running this version of Cockatrice for the first time.\nAll the sets in the card database have been enabled.\nRead more about changing the set order or disabling specific sets and consequent effects in the \"Edit Sets\" window."));
|
||||
actEditSets();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,10 @@ class FilterTreeModel;
|
|||
class FilterBuilder;
|
||||
class CardInfo;
|
||||
class QGroupBox;
|
||||
class QHBoxLayout;
|
||||
class QPushButton;
|
||||
class QMainWindow;
|
||||
class QDockWidget;
|
||||
|
||||
class SearchLineEdit : public QLineEdit {
|
||||
private:
|
||||
|
@ -50,6 +54,7 @@ class TabDeckEditor : public Tab {
|
|||
void actPrintDeck();
|
||||
void actAnalyzeDeck();
|
||||
void actOpenCustomFolder();
|
||||
void actOpenCustomsetsFolder();
|
||||
|
||||
void actEditSets();
|
||||
void actEditTokens();
|
||||
|
@ -73,6 +78,13 @@ class TabDeckEditor : public Tab {
|
|||
void filterViewCustomContextMenu(const QPoint &point);
|
||||
void filterRemove(QAction *action);
|
||||
void setPriceTagFeatureEnabled(int enabled);
|
||||
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
void loadLayout();
|
||||
void restartLayout();
|
||||
void freeDocksSize();
|
||||
void refreshShortcuts();
|
||||
|
||||
private:
|
||||
CardInfo *currentCardInfo() const;
|
||||
void addCardHelper(QString zoneName);
|
||||
|
@ -99,14 +111,25 @@ private:
|
|||
QLabel *hashLabel;
|
||||
FilterTreeModel *filterModel;
|
||||
QTreeView *filterView;
|
||||
QGroupBox *filterBox;
|
||||
QWidget *filterBox;
|
||||
|
||||
QMenu *deckMenu, *dbMenu;
|
||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder;
|
||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs, *aLoadDeckFromClipboard, *aSaveDeckToClipboard, *aPrintDeck, *aAnalyzeDeck, *aClose, *aOpenCustomFolder, *aOpenCustomsetsFolder;
|
||||
QAction *aEditSets, *aEditTokens, *aClearFilterAll, *aClearFilterOne;
|
||||
QAction *aAddCard, *aAddCardToSideboard, *aRemoveCard, *aIncrement, *aDecrement;// *aUpdatePrices;
|
||||
QAction *aResetLayout;
|
||||
|
||||
bool modified;
|
||||
QMainWindow *MainWindow;
|
||||
QVBoxLayout *centralFrame;
|
||||
QHBoxLayout *searchLayout;
|
||||
QPushButton *btnFilter;
|
||||
QPushButton *btnDeck;
|
||||
QPushButton *btnCard;
|
||||
QDockWidget *cardInfoDock;
|
||||
QDockWidget *deckDock;
|
||||
QDockWidget *filterDock;
|
||||
QWidget *centralWidget;
|
||||
public:
|
||||
TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent = 0);
|
||||
~TabDeckEditor();
|
||||
|
@ -115,6 +138,13 @@ public:
|
|||
void setDeck(DeckLoader *_deckLoader);
|
||||
void setModified(bool _windowModified);
|
||||
bool confirmClose();
|
||||
void createShowHideDocksButtons();
|
||||
void createDeckDock();
|
||||
void createCardInfoDock();
|
||||
void createFiltersDock();
|
||||
void createMenus();
|
||||
void createCentralFrame();
|
||||
|
||||
public slots:
|
||||
void closeRequest();
|
||||
void checkFirstRunDetected();
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#include <QTimer>
|
||||
#include <QToolButton>
|
||||
#include <QDebug>
|
||||
#include <QCompleter>
|
||||
#include <QWidget>
|
||||
|
||||
#include "dlg_creategame.h"
|
||||
#include "tab_game.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "cardinfowidget.h"
|
||||
#include "cardframe.h"
|
||||
#include "playerlistwidget.h"
|
||||
#include "messagelogwidget.h"
|
||||
#include "phasestoolbar.h"
|
||||
|
@ -31,6 +33,7 @@
|
|||
#include "settingscache.h"
|
||||
#include "carddatabase.h"
|
||||
#include "replay_timeline_widget.h"
|
||||
#include "lineeditcompleter.h"
|
||||
|
||||
#include <google/protobuf/descriptor.h>
|
||||
#include "pending_command.h"
|
||||
|
@ -120,12 +123,14 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
|
|||
setLayout(deckViewLayout);
|
||||
|
||||
retranslateUi();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
}
|
||||
|
||||
void DeckViewContainer::retranslateUi()
|
||||
{
|
||||
loadLocalButton->setText(tr("Load &local deck"));
|
||||
loadRemoteButton->setText(tr("Load d&eck from server"));
|
||||
loadLocalButton->setText(tr("Load local deck"));
|
||||
loadRemoteButton->setText(tr("Load deck from server"));
|
||||
readyStartButton->setText(tr("Ready to s&tart"));
|
||||
updateSideboardLockButtonText();
|
||||
}
|
||||
|
@ -146,6 +151,58 @@ void DeckViewContainer::updateSideboardLockButtonText()
|
|||
sideboardLockButton->setText(tr("S&ideboard locked"));
|
||||
}
|
||||
|
||||
void DeckViewContainer::refreshShortcuts()
|
||||
{
|
||||
loadLocalButton->setShortcut(settingsCache->shortcuts().getSingleShortcut("DeckViewContainer/loadLocalButton"));
|
||||
loadRemoteButton->setShortcut(settingsCache->shortcuts().getSingleShortcut("DeckViewContainer/loadRemoteButton"));
|
||||
}
|
||||
|
||||
void TabGame::refreshShortcuts()
|
||||
{
|
||||
for (int i = 0; i < phaseActions.size(); ++i) {
|
||||
QAction *temp = phaseActions.at(i);
|
||||
switch (i) {
|
||||
case 0: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase0")); break;
|
||||
case 1: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase1")); break;
|
||||
case 2: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase2")); break;
|
||||
case 3: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase3")); break;
|
||||
case 4: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase4")); break;
|
||||
case 5: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase5")); break;
|
||||
case 6: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase6")); break;
|
||||
case 7: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase7")); break;
|
||||
case 8: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase8")); break;
|
||||
case 9: temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase9")); break;
|
||||
case 10:temp->setShortcuts(settingsCache->shortcuts().getShortcut("Player/phase10")); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
|
||||
if (aNextPhase) {
|
||||
aNextPhase->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aNextPhase"));
|
||||
}
|
||||
if (aNextTurn) {
|
||||
aNextTurn->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aNextTurn"));
|
||||
}
|
||||
if (aRemoveLocalArrows) {
|
||||
aRemoveLocalArrows->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aRemoveLocalArrows"));
|
||||
}
|
||||
if (aRotateViewCW) {
|
||||
aRotateViewCW->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aRotateViewCW"));
|
||||
}
|
||||
if (aRotateViewCCW) {
|
||||
aRotateViewCCW->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aRotateViewCCW"));
|
||||
}
|
||||
if (aConcede) {
|
||||
aConcede->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aConcede"));
|
||||
}
|
||||
if (aLeaveGame) {
|
||||
aLeaveGame->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aLeaveGame"));
|
||||
}
|
||||
if (aCloseReplay) {
|
||||
aCloseReplay->setShortcuts(settingsCache->shortcuts().getShortcut("Player/aCloseReplay"));
|
||||
}
|
||||
}
|
||||
|
||||
void DeckViewContainer::loadLocalDeck()
|
||||
{
|
||||
QFileDialog dialog(this, tr("Load deck"));
|
||||
|
@ -280,7 +337,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
gameView = new GameView(scene);
|
||||
gameView->hide();
|
||||
|
||||
cardInfo = new CardInfoWidget(CardInfoWidget::ModeGameTab);
|
||||
cardInfo = new CardFrame();
|
||||
playerListWidget = new PlayerListWidget(0, 0, this);
|
||||
playerListWidget->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
|
@ -293,6 +350,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
deckViewContainerLayout = new QVBoxLayout;
|
||||
|
||||
QVBoxLayout *messageLogLayout = new QVBoxLayout;
|
||||
messageLogLayout->setContentsMargins(0, 0, 0, 0);
|
||||
messageLogLayout->addWidget(messageLog);
|
||||
|
||||
QWidget *messageLogLayoutWidget = new QWidget;
|
||||
|
@ -342,6 +400,8 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
aNextPhase = 0;
|
||||
aNextTurn = 0;
|
||||
aRemoveLocalArrows = 0;
|
||||
aRotateViewCW = 0;
|
||||
aRotateViewCCW = 0;
|
||||
aGameInfo = 0;
|
||||
aConcede = 0;
|
||||
aLeaveGame = 0;
|
||||
|
@ -354,10 +414,13 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, GameReplay *_replay)
|
|||
addTabMenu(gameMenu);
|
||||
|
||||
retranslateUi();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
setLayout(superMainLayout);
|
||||
|
||||
splitter->restoreState(settingsCache->getTabGameSplitterSizes());
|
||||
|
||||
splitter->setChildrenCollapsible(false);
|
||||
|
||||
messageLog->logReplayStarted(gameInfo.game_id());
|
||||
}
|
||||
|
||||
|
@ -390,7 +453,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
gameView = new GameView(scene);
|
||||
gameView->hide();
|
||||
|
||||
cardInfo = new CardInfoWidget(CardInfoWidget::ModeGameTab);
|
||||
cardInfo = new CardFrame();
|
||||
playerListWidget = new PlayerListWidget(tabSupervisor, clients.first(), this);
|
||||
playerListWidget->setFocusPolicy(Qt::NoFocus);
|
||||
connect(playerListWidget, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||
|
@ -403,8 +466,9 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
connect(messageLog, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(messageLog, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(messageLog, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
|
||||
connect(settingsCache, SIGNAL(chatMentionCompleterChanged()), this, SLOT(actCompleterChanged()));
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new QLineEdit;
|
||||
sayEdit = new LineEditCompleter;
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
|
||||
QHBoxLayout *hLayout = new QHBoxLayout;
|
||||
|
@ -414,6 +478,7 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
deckViewContainerLayout = new QVBoxLayout;
|
||||
|
||||
QVBoxLayout *messageLogLayout = new QVBoxLayout;
|
||||
messageLogLayout->setContentsMargins(0, 0, 0, 0);
|
||||
messageLogLayout->addWidget(timeElapsedLabel);
|
||||
messageLogLayout->addWidget(messageLog);
|
||||
messageLogLayout->addLayout(hLayout);
|
||||
|
@ -445,6 +510,10 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
connect(aNextTurn, SIGNAL(triggered()), this, SLOT(actNextTurn()));
|
||||
aRemoveLocalArrows = new QAction(this);
|
||||
connect(aRemoveLocalArrows, SIGNAL(triggered()), this, SLOT(actRemoveLocalArrows()));
|
||||
aRotateViewCW = new QAction(this);
|
||||
connect(aRotateViewCW, SIGNAL(triggered()), this, SLOT(actRotateViewCW()));
|
||||
aRotateViewCCW = new QAction(this);
|
||||
connect(aRotateViewCCW, SIGNAL(triggered()), this, SLOT(actRotateViewCCW()));
|
||||
aGameInfo = new QAction(this);
|
||||
connect(aGameInfo, SIGNAL(triggered()), this, SLOT(actGameInfo()));
|
||||
aConcede = new QAction(this);
|
||||
|
@ -457,18 +526,10 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
for (int i = 0; i < phasesToolbar->phaseCount(); ++i) {
|
||||
QAction *temp = new QAction(QString(), this);
|
||||
connect(temp, SIGNAL(triggered()), this, SLOT(actPhaseAction()));
|
||||
switch (i) {
|
||||
case 0: temp->setShortcut(QKeySequence("F5")); break;
|
||||
case 2: temp->setShortcut(QKeySequence("F6")); break;
|
||||
case 3: temp->setShortcut(QKeySequence("F7")); break;
|
||||
case 4: temp->setShortcut(QKeySequence("F8")); break;
|
||||
case 9: temp->setShortcut(QKeySequence("F9")); break;
|
||||
case 10: temp->setShortcut(QKeySequence("F10")); break;
|
||||
default: ;
|
||||
}
|
||||
phasesMenu->addAction(temp);
|
||||
phaseActions.append(temp);
|
||||
}
|
||||
|
||||
phasesMenu->addSeparator();
|
||||
phasesMenu->addAction(aNextPhase);
|
||||
|
||||
|
@ -478,6 +539,8 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
gameMenu->addAction(aNextTurn);
|
||||
gameMenu->addSeparator();
|
||||
gameMenu->addAction(aRemoveLocalArrows);
|
||||
gameMenu->addAction(aRotateViewCW);
|
||||
gameMenu->addAction(aRotateViewCCW);
|
||||
gameMenu->addSeparator();
|
||||
gameMenu->addAction(aGameInfo);
|
||||
gameMenu->addAction(aConcede);
|
||||
|
@ -485,14 +548,28 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_client
|
|||
addTabMenu(gameMenu);
|
||||
|
||||
retranslateUi();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
setLayout(mainLayout);
|
||||
|
||||
splitter->restoreState(settingsCache->getTabGameSplitterSizes());
|
||||
splitter->setChildrenCollapsible(false);
|
||||
|
||||
messageLog->logGameJoined(gameInfo.game_id());
|
||||
|
||||
for (int i = gameInfo.game_types_size() - 1; i >= 0; i--)
|
||||
gameTypes.append(roomGameTypes.find(gameInfo.game_types(i)).value());
|
||||
|
||||
completer = new QCompleter(autocompleteUserList, sayEdit);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completer->setMaxVisibleItems(5);
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
completer->setFilterMode(Qt::MatchStartsWith);
|
||||
#endif
|
||||
|
||||
sayEdit->setCompleter(completer);
|
||||
actCompleterChanged();
|
||||
}
|
||||
|
||||
void TabGame::addMentionTag(QString value) {
|
||||
|
@ -531,29 +608,29 @@ void TabGame::retranslateUi()
|
|||
gameMenu->setTitle(tr("&Game"));
|
||||
if (aNextPhase) {
|
||||
aNextPhase->setText(tr("Next &phase"));
|
||||
aNextPhase->setShortcuts(QList<QKeySequence>() << QKeySequence("Ctrl+Space") << QKeySequence("Tab"));
|
||||
}
|
||||
if (aNextTurn) {
|
||||
aNextTurn->setText(tr("Next &turn"));
|
||||
aNextTurn->setShortcuts(QList<QKeySequence>() << QKeySequence("Ctrl+Return") << QKeySequence("Ctrl+Enter"));
|
||||
}
|
||||
if (aRemoveLocalArrows) {
|
||||
aRemoveLocalArrows->setText(tr("&Remove all local arrows"));
|
||||
aRemoveLocalArrows->setShortcut(QKeySequence("Ctrl+R"));
|
||||
}
|
||||
if (aRotateViewCW) {
|
||||
aRotateViewCW->setText(tr("Rotate View Cl&ockwise"));
|
||||
}
|
||||
if (aRotateViewCCW) {
|
||||
aRotateViewCCW->setText(tr("Rotate View Co&unterclockwise"));
|
||||
}
|
||||
if (aGameInfo)
|
||||
aGameInfo->setText(tr("Game &information"));
|
||||
if (aConcede) {
|
||||
aConcede->setText(tr("&Concede"));
|
||||
aConcede->setShortcut(QKeySequence("F2"));
|
||||
}
|
||||
if (aLeaveGame) {
|
||||
aLeaveGame->setText(tr("&Leave game"));
|
||||
aLeaveGame->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
}
|
||||
if (aCloseReplay) {
|
||||
aCloseReplay->setText(tr("C&lose replay"));
|
||||
aCloseReplay->setShortcut(QKeySequence("Ctrl+Q"));
|
||||
}
|
||||
|
||||
if (sayLabel)
|
||||
|
@ -659,6 +736,9 @@ void TabGame::actLeaveGame()
|
|||
|
||||
void TabGame::actSay()
|
||||
{
|
||||
if (completer->popup()->isVisible())
|
||||
return;
|
||||
|
||||
if (!sayEdit->text().isEmpty()) {
|
||||
Command_GameSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
@ -707,11 +787,31 @@ void TabGame::actRemoveLocalArrows()
|
|||
}
|
||||
}
|
||||
|
||||
void TabGame::actRotateViewCW()
|
||||
{
|
||||
scene->adjustPlayerRotation(-1);
|
||||
}
|
||||
|
||||
void TabGame::actRotateViewCCW()
|
||||
{
|
||||
scene->adjustPlayerRotation(1);
|
||||
}
|
||||
|
||||
void TabGame::actCompleterChanged()
|
||||
{
|
||||
settingsCache->getChatMentionCompleter() ? completer->setCompletionRole(2) : completer->setCompletionRole(1);
|
||||
}
|
||||
|
||||
Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
|
||||
{
|
||||
bool local = ((clients.size() > 1) || (playerId == localPlayerId));
|
||||
Player *newPlayer = new Player(info, playerId, local, this);
|
||||
connect(newPlayer, SIGNAL(openDeckEditor(const DeckLoader *)), this, SIGNAL(openDeckEditor(const DeckLoader *)));
|
||||
QString newPlayerName = "@" + newPlayer->getName();
|
||||
if (!autocompleteUserList.contains(newPlayerName)){
|
||||
autocompleteUserList << newPlayerName;
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
scene->addPlayer(newPlayer);
|
||||
|
||||
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
||||
|
@ -731,7 +831,6 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
|
|||
|
||||
players.insert(playerId, newPlayer);
|
||||
emit playerAdded(newPlayer);
|
||||
|
||||
return newPlayer;
|
||||
}
|
||||
|
||||
|
@ -906,6 +1005,9 @@ void TabGame::eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, c
|
|||
|
||||
void TabGame::eventSpectatorLeave(const Event_Leave & /*event*/, int eventPlayerId, const GameEventContext & /*context*/)
|
||||
{
|
||||
QString playerName = "@" + QString::fromStdString(spectators.value(eventPlayerId).name());
|
||||
if (autocompleteUserList.removeOne(playerName))
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
messageLog->logLeaveSpectator(QString::fromStdString(spectators.value(eventPlayerId).name()));
|
||||
playerListWidget->removePlayer(eventPlayerId);
|
||||
spectators.remove(eventPlayerId);
|
||||
|
@ -920,6 +1022,11 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event, int /*e
|
|||
const ServerInfo_Player &playerInfo = event.player_list(i);
|
||||
const ServerInfo_PlayerProperties &prop = playerInfo.properties();
|
||||
const int playerId = prop.player_id();
|
||||
QString playerName = "@" + QString::fromStdString(prop.user_info().name());
|
||||
if (!autocompleteUserList.contains(playerName)){
|
||||
autocompleteUserList << playerName;
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
if (prop.spectator()) {
|
||||
if (!spectators.contains(playerId)) {
|
||||
spectators.insert(playerId, prop.user_info());
|
||||
|
@ -1027,11 +1134,18 @@ void TabGame::eventJoin(const Event_Join &event, int /*eventPlayerId*/, const Ga
|
|||
{
|
||||
const ServerInfo_PlayerProperties &playerInfo = event.player_properties();
|
||||
const int playerId = playerInfo.player_id();
|
||||
QString playerName = QString::fromStdString(playerInfo.user_info().name());
|
||||
if (!autocompleteUserList.contains("@" + playerName)){
|
||||
autocompleteUserList << "@" + playerName;
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
|
||||
if (players.contains(playerId))
|
||||
return;
|
||||
|
||||
if (playerInfo.spectator()) {
|
||||
spectators.insert(playerId, playerInfo.user_info());
|
||||
messageLog->logJoinSpectator(QString::fromStdString(playerInfo.user_info().name()));
|
||||
messageLog->logJoinSpectator(playerName);
|
||||
} else {
|
||||
Player *newPlayer = addPlayer(playerId, playerInfo.user_info());
|
||||
messageLog->logJoin(newPlayer);
|
||||
|
@ -1046,6 +1160,10 @@ void TabGame::eventLeave(const Event_Leave & /*event*/, int eventPlayerId, const
|
|||
if (!player)
|
||||
return;
|
||||
|
||||
QString playerName = "@" + player->getName();
|
||||
if(autocompleteUserList.removeOne(playerName))
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
|
||||
messageLog->logLeave(player);
|
||||
playerListWidget->removePlayer(eventPlayerId);
|
||||
players.remove(eventPlayerId);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <QMap>
|
||||
#include <QPushButton>
|
||||
#include <QCompleter>
|
||||
#include "tab.h"
|
||||
#include "pb/serverinfo_game.pb.h"
|
||||
|
||||
|
@ -11,7 +12,7 @@ class CardDatabase;
|
|||
class GameView;
|
||||
class DeckView;
|
||||
class GameScene;
|
||||
class CardInfoWidget;
|
||||
class CardFrame;
|
||||
class MessageLogWidget;
|
||||
class QTimer;
|
||||
class QSplitter;
|
||||
|
@ -54,6 +55,7 @@ class QHBoxLayout;
|
|||
class GameReplay;
|
||||
class ServerInfo_User;
|
||||
class PendingCommand;
|
||||
class LineEditCompleter;
|
||||
|
||||
class ToggleButton : public QPushButton {
|
||||
Q_OBJECT
|
||||
|
@ -84,6 +86,7 @@ private slots:
|
|||
void sideboardPlanChanged();
|
||||
void sideboardLockButtonClicked();
|
||||
void updateSideboardLockButtonText();
|
||||
void refreshShortcuts();
|
||||
signals:
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
public:
|
||||
|
@ -116,6 +119,8 @@ private:
|
|||
CardItem *activeCard;
|
||||
bool gameClosed;
|
||||
QStringList gameTypes;
|
||||
QCompleter *completer;
|
||||
QStringList autocompleteUserList;
|
||||
|
||||
// Replay related members
|
||||
GameReplay *replay;
|
||||
|
@ -125,12 +130,12 @@ private:
|
|||
QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton;
|
||||
|
||||
QSplitter *splitter;
|
||||
CardInfoWidget *cardInfo;
|
||||
CardFrame *cardInfo;
|
||||
PlayerListWidget *playerListWidget;
|
||||
QLabel *timeElapsedLabel;
|
||||
MessageLogWidget *messageLog;
|
||||
QLabel *sayLabel;
|
||||
QLineEdit *sayEdit;
|
||||
LineEditCompleter *sayEdit;
|
||||
PhasesToolbar *phasesToolbar;
|
||||
GameScene *scene;
|
||||
GameView *gameView;
|
||||
|
@ -141,7 +146,7 @@ private:
|
|||
QAction *playersSeparator;
|
||||
QMenu *gameMenu;
|
||||
QMenu *phasesMenu;
|
||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows;
|
||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW;
|
||||
QList<QAction *> phaseActions;
|
||||
|
||||
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
||||
|
@ -190,6 +195,8 @@ private slots:
|
|||
void actConcede();
|
||||
void actLeaveGame();
|
||||
void actRemoveLocalArrows();
|
||||
void actRotateViewCW();
|
||||
void actRotateViewCCW();
|
||||
void actSay();
|
||||
void actPhaseAction();
|
||||
void actNextPhase();
|
||||
|
@ -197,6 +204,10 @@ private slots:
|
|||
|
||||
void addMentionTag(QString value);
|
||||
void commandFinished(const Response &response);
|
||||
|
||||
void refreshShortcuts();
|
||||
|
||||
void actCompleterChanged();
|
||||
public:
|
||||
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
||||
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
|
||||
|
|
|
@ -80,12 +80,14 @@ TabReplays::TabReplays(TabSupervisor *_tabSupervisor, AbstractClient *_client)
|
|||
aOpenLocalReplay = new QAction(this);
|
||||
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("theme:icons/remove_row.svg"));
|
||||
connect(aDeleteLocalReplay, SIGNAL(triggered()), this, SLOT(actDeleteLocalReplay()));
|
||||
aOpenRemoteReplay = new QAction(this);
|
||||
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("theme:icons/arrow_left_green.svg"));
|
||||
connect(aDownload, SIGNAL(triggered()), this, SLOT(actDownload()));
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
#include <QSplitter>
|
||||
#include <QApplication>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QCompleter>
|
||||
#include <QWidget>
|
||||
#include "tab_supervisor.h"
|
||||
#include "tab_room.h"
|
||||
#include "tab_userlists.h"
|
||||
|
@ -20,6 +22,7 @@
|
|||
#include "gameselector.h"
|
||||
#include "settingscache.h"
|
||||
#include "main.h"
|
||||
#include "lineeditcompleter.h"
|
||||
|
||||
#include "get_pb_extension.h"
|
||||
#include "pb/room_commands.pb.h"
|
||||
|
@ -51,15 +54,15 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
|
||||
connect(settingsCache, SIGNAL(chatMentionCompleterChanged()), this, SLOT(actCompleterChanged()));
|
||||
sayLabel = new QLabel;
|
||||
sayEdit = new QLineEdit;
|
||||
sayEdit = new LineEditCompleter;
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
QMenu *chatSettingsMenu = new QMenu(this);
|
||||
|
||||
aClearChat = chatSettingsMenu->addAction(QString());
|
||||
aClearChat->setShortcut(QKeySequence("F12"));
|
||||
connect(aClearChat, SIGNAL(triggered()), this, SLOT(actClearChat()));
|
||||
|
||||
chatSettingsMenu->addSeparator();
|
||||
|
@ -103,13 +106,28 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
setLayout(hbox);
|
||||
|
||||
const int userListSize = info.user_list_size();
|
||||
for (int i = 0; i < userListSize; ++i)
|
||||
for (int i = 0; i < userListSize; ++i){
|
||||
userList->processUserInfo(info.user_list(i), true);
|
||||
autocompleteUserList.append("@" + QString::fromStdString(info.user_list(i).name()));
|
||||
}
|
||||
userList->sortItems();
|
||||
|
||||
const int gameListSize = info.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i)
|
||||
gameSelector->processGameInfo(info.game_list(i));
|
||||
|
||||
completer = new QCompleter(autocompleteUserList, sayEdit);
|
||||
completer->setCaseSensitivity(Qt::CaseInsensitive);
|
||||
completer->setMaxVisibleItems(5);
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
completer->setFilterMode(Qt::MatchStartsWith);
|
||||
#endif
|
||||
|
||||
sayEdit->setCompleter(completer);
|
||||
actCompleterChanged();
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
}
|
||||
|
||||
TabRoom::~TabRoom()
|
||||
|
@ -119,7 +137,7 @@ TabRoom::~TabRoom()
|
|||
|
||||
void TabRoom::retranslateUi()
|
||||
{
|
||||
gameSelector->retranslateUi();
|
||||
gameSelector->retranslateUi();
|
||||
chatView->retranslateUi();
|
||||
userList->retranslateUi();
|
||||
sayLabel->setText(tr("&Say:"));
|
||||
|
@ -166,16 +184,20 @@ QString TabRoom::sanitizeHtml(QString dirty) const
|
|||
|
||||
void TabRoom::sendMessage()
|
||||
{
|
||||
if (sayEdit->text().isEmpty())
|
||||
return;
|
||||
if (sayEdit->text().isEmpty()){
|
||||
return;
|
||||
}else if (completer->popup()->isVisible()){
|
||||
completer->popup()->hide();
|
||||
return;
|
||||
}else{
|
||||
Command_RoomSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
Command_RoomSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
PendingCommand *pend = prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(sayFinished(const Response &)));
|
||||
sendRoomCommand(pend);
|
||||
sayEdit->clear();
|
||||
PendingCommand *pend = prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(sayFinished(const Response &)));
|
||||
sendRoomCommand(pend);
|
||||
sayEdit->clear();
|
||||
}
|
||||
}
|
||||
|
||||
void TabRoom::sayFinished(const Response &response)
|
||||
|
@ -200,6 +222,11 @@ void TabRoom::actOpenChatSettings() {
|
|||
settings.exec();
|
||||
}
|
||||
|
||||
void TabRoom::actCompleterChanged()
|
||||
{
|
||||
settingsCache->getChatMentionCompleter() ? completer->setCompletionRole(2) : completer->setCompletionRole(1);
|
||||
}
|
||||
|
||||
void TabRoom::processRoomEvent(const RoomEvent &event)
|
||||
{
|
||||
switch (static_cast<RoomEvent::RoomEventType>(getPbExtension(event))) {
|
||||
|
@ -222,11 +249,17 @@ void TabRoom::processJoinRoomEvent(const Event_JoinRoom &event)
|
|||
{
|
||||
userList->processUserInfo(event.user_info(), true);
|
||||
userList->sortItems();
|
||||
if (!autocompleteUserList.contains("@" + QString::fromStdString(event.user_info().name()))){
|
||||
autocompleteUserList << "@" + QString::fromStdString(event.user_info().name());
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
}
|
||||
|
||||
void TabRoom::processLeaveRoomEvent(const Event_LeaveRoom &event)
|
||||
{
|
||||
userList->deleteUser(QString::fromStdString(event.name()));
|
||||
autocompleteUserList.removeOne("@" + QString::fromStdString(event.name()));
|
||||
sayEdit->setCompletionList(autocompleteUserList);
|
||||
}
|
||||
|
||||
void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
|
||||
|
@ -245,6 +278,11 @@ void TabRoom::processRoomSayEvent(const Event_RoomSay &event)
|
|||
emit userEvent(false);
|
||||
}
|
||||
|
||||
void TabRoom::refreshShortcuts()
|
||||
{
|
||||
aClearChat->setShortcuts(settingsCache->shortcuts().getShortcut("tab_room/aClearChat"));
|
||||
}
|
||||
|
||||
void TabRoom::addMentionTag(QString mentionTag) {
|
||||
sayEdit->insert(mentionTag + " ");
|
||||
sayEdit->setFocus();
|
||||
|
@ -258,4 +296,4 @@ PendingCommand *TabRoom::prepareRoomCommand(const ::google::protobuf::Message &c
|
|||
void TabRoom::sendRoomCommand(PendingCommand *pend)
|
||||
{
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
}
|
|
@ -2,8 +2,12 @@
|
|||
#define TAB_ROOM_H
|
||||
|
||||
#include "tab.h"
|
||||
#include "lineeditcompleter.h"
|
||||
#include <QGroupBox>
|
||||
#include <QMap>
|
||||
#include <QLineEdit>
|
||||
#include <QKeyEvent>
|
||||
#include <QFocusEvent>
|
||||
|
||||
namespace google { namespace protobuf { class Message; } }
|
||||
class AbstractClient;
|
||||
|
@ -13,6 +17,7 @@ class ChatView;
|
|||
class QLineEdit;
|
||||
class QPushButton;
|
||||
class QTextTable;
|
||||
class QCompleter;
|
||||
class RoomEvent;
|
||||
class ServerInfo_Room;
|
||||
class ServerInfo_Game;
|
||||
|
@ -24,6 +29,7 @@ class GameSelector;
|
|||
class Response;
|
||||
class PendingCommand;
|
||||
class ServerInfo_User;
|
||||
class LineEditCompleter;
|
||||
|
||||
class TabRoom : public Tab {
|
||||
Q_OBJECT
|
||||
|
@ -38,14 +44,17 @@ private:
|
|||
UserList *userList;
|
||||
ChatView *chatView;
|
||||
QLabel *sayLabel;
|
||||
QLineEdit *sayEdit;
|
||||
LineEditCompleter *sayEdit;
|
||||
QGroupBox *chatGroupBox;
|
||||
|
||||
QMenu *roomMenu;
|
||||
QAction *aLeaveRoom;
|
||||
QAction *aOpenChatSettings;
|
||||
QAction * aClearChat;
|
||||
QAction *aClearChat;
|
||||
QString sanitizeHtml(QString dirty) const;
|
||||
|
||||
QStringList autocompleteUserList;
|
||||
QCompleter *completer;
|
||||
signals:
|
||||
void roomClosing(TabRoom *tab);
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
|
@ -59,11 +68,13 @@ private slots:
|
|||
void addMentionTag(QString mentionTag);
|
||||
void focusTab();
|
||||
void actShowMentionPopup(QString &sender);
|
||||
|
||||
void actCompleterChanged();
|
||||
|
||||
void processListGamesEvent(const Event_ListGames &event);
|
||||
void processJoinRoomEvent(const Event_JoinRoom &event);
|
||||
void processLeaveRoomEvent(const Event_LeaveRoom &event);
|
||||
void processRoomSayEvent(const Event_RoomSay &event);
|
||||
void refreshShortcuts();
|
||||
public:
|
||||
TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerInfo_User *_ownUser, const ServerInfo_Room &info);
|
||||
~TabRoom();
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "tab_server.h"
|
||||
#include "abstractclient.h"
|
||||
#include "userlist.h"
|
||||
#include "userinfobox.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include "pending_command.h"
|
||||
|
@ -26,7 +25,7 @@ RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent)
|
|||
{
|
||||
roomList = new QTreeWidget;
|
||||
roomList->setRootIsDecorated(false);
|
||||
roomList->setColumnCount(4);
|
||||
roomList->setColumnCount(5);
|
||||
roomList->header()->setStretchLastSection(false);
|
||||
#if QT_VERSION < 0x050000
|
||||
roomList->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||
|
@ -36,6 +35,7 @@ RoomSelector::RoomSelector(AbstractClient *_client, QWidget *parent)
|
|||
#else
|
||||
roomList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
|
||||
roomList->header()->setSectionResizeMode(1, QHeaderView::Stretch);
|
||||
roomList->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents);
|
||||
roomList->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
|
||||
roomList->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
|
||||
#endif
|
||||
|
@ -64,10 +64,12 @@ void RoomSelector::retranslateUi()
|
|||
QTreeWidgetItem *header = roomList->headerItem();
|
||||
header->setText(0, tr("Room"));
|
||||
header->setText(1, tr("Description"));
|
||||
header->setText(2, tr("Players"));
|
||||
header->setText(3, tr("Games"));
|
||||
header->setText(2, tr("Permissions"));
|
||||
header->setText(3, tr("Players"));
|
||||
header->setText(4, tr("Games"));
|
||||
header->setTextAlignment(2, Qt::AlignRight);
|
||||
header->setTextAlignment(3, Qt::AlignRight);
|
||||
header->setTextAlignment(4, Qt::AlignRight);
|
||||
}
|
||||
|
||||
void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
|
||||
|
@ -83,10 +85,12 @@ void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
|
|||
twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
|
||||
if (room.has_description())
|
||||
twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
|
||||
if (room.has_permissionlevel())
|
||||
twi->setData(2, Qt::DisplayRole, QString::fromStdString(room.permissionlevel()).toLower());
|
||||
if (room.has_player_count())
|
||||
twi->setData(2, Qt::DisplayRole, room.player_count());
|
||||
twi->setData(3, Qt::DisplayRole, room.player_count());
|
||||
if (room.has_game_count())
|
||||
twi->setData(3, Qt::DisplayRole, room.game_count());
|
||||
twi->setData(4, Qt::DisplayRole, room.game_count());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -96,10 +100,13 @@ void RoomSelector::processListRoomsEvent(const Event_ListRooms &event)
|
|||
twi->setData(0, Qt::DisplayRole, QString::fromStdString(room.name()));
|
||||
if (room.has_description())
|
||||
twi->setData(1, Qt::DisplayRole, QString::fromStdString(room.description()));
|
||||
twi->setData(2, Qt::DisplayRole, room.player_count());
|
||||
twi->setData(3, Qt::DisplayRole, room.game_count());
|
||||
if (room.has_permissionlevel())
|
||||
twi->setData(2, Qt::DisplayRole, QString::fromStdString(room.permissionlevel()).toLower());
|
||||
twi->setData(3, Qt::DisplayRole, room.player_count());
|
||||
twi->setData(4, Qt::DisplayRole, room.game_count());
|
||||
twi->setTextAlignment(2, Qt::AlignRight);
|
||||
twi->setTextAlignment(3, Qt::AlignRight);
|
||||
twi->setTextAlignment(4, Qt::AlignRight);
|
||||
|
||||
roomList->addTopLevelItem(twi);
|
||||
if (room.has_auto_join())
|
||||
|
@ -131,10 +138,15 @@ void RoomSelector::joinClicked()
|
|||
|
||||
void RoomSelector::joinFinished(const Response &r, const CommandContainer & /*commandContainer*/, const QVariant &extraData)
|
||||
{
|
||||
if (r.response_code() != Response::RespOk)
|
||||
return;
|
||||
switch (r.response_code()) {
|
||||
case Response::RespOk: break;
|
||||
case Response::RespUserLevelTooLow: QMessageBox::critical(this, tr("Error"), tr("You do not have the proper permission to join this room.")); return;
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to join the room due to an unknown error."));
|
||||
return;
|
||||
}
|
||||
|
||||
const Response_JoinRoom &resp = r.GetExtension(Response_JoinRoom::ext);
|
||||
|
||||
emit roomJoined(resp.room_info(), extraData.toBool());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
#include <QApplication>
|
||||
#include "tab_supervisor.h"
|
||||
#include "abstractclient.h"
|
||||
|
@ -13,14 +16,12 @@
|
|||
#include "pixmapgenerator.h"
|
||||
#include "userlist.h"
|
||||
#include "settingscache.h"
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "pb/room_commands.pb.h"
|
||||
#include "pb/room_event.pb.h"
|
||||
#include "pb/game_event_container.pb.h"
|
||||
#include "pb/event_user_message.pb.h"
|
||||
#include "pb/event_notify_user.pb.h"
|
||||
#include "pb/event_game_joined.pb.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
#include "pb/serverinfo_room.pb.h"
|
||||
|
@ -90,6 +91,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
|||
connect(client, SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(gameJoined(const Event_GameJoined &)));
|
||||
connect(client, SIGNAL(userMessageEventReceived(const Event_UserMessage &)), this, SLOT(processUserMessageEvent(const Event_UserMessage &)));
|
||||
connect(client, SIGNAL(maxPingTime(int, int)), this, SLOT(updatePingTime(int, int)));
|
||||
connect(client, SIGNAL(notifyUserEventReceived(const Event_NotifyUser &)), this, SLOT(processNotifyUserEvent(const Event_NotifyUser &)));
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -184,6 +186,7 @@ int TabSupervisor::myAddTab(Tab *tab)
|
|||
|
||||
void TabSupervisor::start(const ServerInfo_User &_userInfo)
|
||||
{
|
||||
isLocalGame = false;
|
||||
userInfo = new ServerInfo_User(_userInfo);
|
||||
|
||||
tabServer = new TabServer(this, client);
|
||||
|
@ -227,6 +230,7 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
|||
tabDeckStorage = 0;
|
||||
tabReplays = 0;
|
||||
tabAdmin = 0;
|
||||
isLocalGame = true;
|
||||
userInfo = new ServerInfo_User;
|
||||
localClients = _clients;
|
||||
for (int i = 0; i < localClients.size(); ++i)
|
||||
|
@ -557,3 +561,13 @@ bool TabSupervisor::getAdminLocked() const
|
|||
return true;
|
||||
return tabAdmin->getLocked();
|
||||
}
|
||||
|
||||
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||
{
|
||||
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
||||
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
||||
default: ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class RoomEvent;
|
|||
class GameEventContainer;
|
||||
class Event_GameJoined;
|
||||
class Event_UserMessage;
|
||||
class Event_NotifyUser;
|
||||
class ServerInfo_Room;
|
||||
class ServerInfo_User;
|
||||
class GameReplay;
|
||||
|
@ -60,6 +61,7 @@ private:
|
|||
void addCloseButtonToTab(Tab *tab, int tabIndex);
|
||||
QString sanitizeTabName(QString dirty) const;
|
||||
QString sanitizeHtml(QString dirty) const;
|
||||
bool isLocalGame;
|
||||
public:
|
||||
TabSupervisor(AbstractClient *_client, QWidget *parent = 0);
|
||||
~TabSupervisor();
|
||||
|
@ -67,6 +69,7 @@ public:
|
|||
void start(const ServerInfo_User &userInfo);
|
||||
void startLocal(const QList<AbstractClient *> &_clients);
|
||||
void stop();
|
||||
bool getIsLocalGame() const { return isLocalGame; }
|
||||
int getGameCount() const { return gameTabs.size(); }
|
||||
TabUserLists *getUserListsTab() const { return tabUserLists; }
|
||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||
|
@ -103,6 +106,7 @@ private slots:
|
|||
void processRoomEvent(const RoomEvent &event);
|
||||
void processGameEventContainer(const GameEventContainer &cont);
|
||||
void processUserMessageEvent(const Event_UserMessage &event);
|
||||
void processNotifyUserEvent(const Event_NotifyUser &event);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -21,7 +21,7 @@ TabUserLists::TabUserLists(TabSupervisor *_tabSupervisor, AbstractClient *_clien
|
|||
allUsersList = new UserList(_tabSupervisor, client, UserList::AllUsersList);
|
||||
buddyList = new UserList(_tabSupervisor, client, UserList::BuddyList);
|
||||
ignoreList = new UserList(_tabSupervisor, client, UserList::IgnoreList);
|
||||
userInfoBox = new UserInfoBox(client, false);
|
||||
userInfoBox = new UserInfoBox(client, true);
|
||||
userInfoBox->updateInfo(userInfo);
|
||||
|
||||
connect(allUsersList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
||||
|
|
|
@ -30,9 +30,9 @@ TableZone::TableZone(Player *_p, QGraphicsItem *parent)
|
|||
|
||||
updateBg();
|
||||
|
||||
height = 2 * BOX_LINE_WIDTH + 3 * (CARD_HEIGHT + 20) + 2 * PADDING_Y;
|
||||
width = MIN_WIDTH + 2 * MARGIN_X + 2 * BOX_LINE_WIDTH;
|
||||
currentMinimumWidth = MIN_WIDTH;
|
||||
height = MARGIN_TOP + MARGIN_BOTTOM + TABLEROWS * CARD_HEIGHT + (TABLEROWS-1) * PADDING_Y;
|
||||
width = MIN_WIDTH;
|
||||
currentMinimumWidth = width;
|
||||
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
#if QT_VERSION < 0x050000
|
||||
|
@ -107,10 +107,12 @@ void TableZone::paintZoneOutline(QPainter *painter) {
|
|||
@painter QPainter object
|
||||
*/
|
||||
void TableZone::paintLandDivider(QPainter *painter){
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
qreal separatorY = 2 * (CARD_HEIGHT + 20 + PADDING_Y) + BOX_LINE_WIDTH - PADDING_Y / 2;
|
||||
// Place the line 2 grid heights down then back it off just enough to allow
|
||||
// some space between a 3-card stack and the land area.
|
||||
qreal separatorY = MARGIN_TOP + 2 * (CARD_HEIGHT + PADDING_Y) - STACKED_CARD_OFFSET_Y / 2;
|
||||
if (isInverted())
|
||||
separatorY = height - separatorY;
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
painter->drawLine(QPointF(0, separatorY), QPointF(width, separatorY));
|
||||
}
|
||||
|
||||
|
@ -157,30 +159,9 @@ void TableZone::reorganizeCards()
|
|||
{
|
||||
QList<ArrowItem *> arrowsToUpdate;
|
||||
|
||||
// Calculate table grid distortion so that the mapping functions work properly
|
||||
QMap<int, int> gridPointStackCount;
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
const QPoint &gridPoint = cards[i]->getGridPos();
|
||||
if (gridPoint.x() == -1)
|
||||
continue;
|
||||
|
||||
const int key = gridPoint.x() / 3 + gridPoint.y() * 1000;
|
||||
gridPointStackCount.insert(key, gridPointStackCount.value(key, 0) + 1);
|
||||
}
|
||||
gridPointWidth.clear();
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
const QPoint &gridPoint = cards[i]->getGridPos();
|
||||
if (gridPoint.x() == -1)
|
||||
continue;
|
||||
|
||||
const int key = gridPoint.x() / 3 + gridPoint.y() * 1000;
|
||||
const int stackCount = gridPointStackCount.value(key, 0);
|
||||
if (stackCount == 1)
|
||||
gridPointWidth.insert(key, CARD_WIDTH * (1 + cards[i]->getAttachedCards().size() / 3.0));
|
||||
else
|
||||
gridPointWidth.insert(key, CARD_WIDTH * (1 + (stackCount - 1) / 3.0));
|
||||
}
|
||||
|
||||
// Calculate card stack widths so mapping functions work properly
|
||||
computeCardStackWidths();
|
||||
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
QPoint gridPoint = cards[i]->getGridPos();
|
||||
if (gridPoint.x() == -1)
|
||||
|
@ -191,7 +172,7 @@ void TableZone::reorganizeCards()
|
|||
qreal y = mapPoint.y();
|
||||
|
||||
int numberAttachedCards = cards[i]->getAttachedCards().size();
|
||||
qreal actualX = x + numberAttachedCards * CARD_WIDTH / 3.0;
|
||||
qreal actualX = x + numberAttachedCards * STACKED_CARD_OFFSET_X;
|
||||
qreal actualY = y;
|
||||
if (numberAttachedCards)
|
||||
actualY += 15;
|
||||
|
@ -204,7 +185,7 @@ void TableZone::reorganizeCards()
|
|||
while (attachedCardIterator.hasNext()) {
|
||||
++j;
|
||||
CardItem *attachedCard = attachedCardIterator.next();
|
||||
qreal childX = actualX - j * CARD_WIDTH / 3.0;
|
||||
qreal childX = actualX - j * STACKED_CARD_OFFSET_X;
|
||||
qreal childY = y + 5;
|
||||
attachedCard->setPos(childX, childY);
|
||||
attachedCard->setRealZValue((childY + CARD_HEIGHT) * 100000 + (childX + 1) * 100);
|
||||
|
@ -263,13 +244,19 @@ CardItem *TableZone::takeCard(int position, int cardId, bool canResize)
|
|||
void TableZone::resizeToContents()
|
||||
{
|
||||
int xMax = 0;
|
||||
|
||||
// Find rightmost card position, which includes the left margin amount.
|
||||
for (int i = 0; i < cards.size(); ++i)
|
||||
if (cards[i]->pos().x() > xMax)
|
||||
xMax = (int) cards[i]->pos().x();
|
||||
xMax += 2 * CARD_WIDTH;
|
||||
if (xMax < MIN_WIDTH)
|
||||
xMax = MIN_WIDTH;
|
||||
currentMinimumWidth = xMax + 2 * MARGIN_X + 2 * BOX_LINE_WIDTH;
|
||||
|
||||
// Minimum width is the rightmost card position plus enough room for
|
||||
// another card with padding, then margin.
|
||||
currentMinimumWidth = xMax + (2 * CARD_WIDTH) + PADDING_X + MARGIN_RIGHT;
|
||||
|
||||
if (currentMinimumWidth < MIN_WIDTH)
|
||||
currentMinimumWidth = MIN_WIDTH;
|
||||
|
||||
if (currentMinimumWidth != width) {
|
||||
prepareGeometryChange();
|
||||
width = currentMinimumWidth;
|
||||
|
@ -286,6 +273,7 @@ CardItem *TableZone::getCardFromGrid(const QPoint &gridPoint) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
CardItem *TableZone::getCardFromCoords(const QPointF &point) const
|
||||
{
|
||||
QPoint gridPoint = mapToGrid(point);
|
||||
|
@ -293,57 +281,110 @@ CardItem *TableZone::getCardFromCoords(const QPointF &point) const
|
|||
}
|
||||
|
||||
|
||||
void TableZone::computeCardStackWidths()
|
||||
{
|
||||
// Each card stack is three grid points worth of card locations.
|
||||
// First pass: compute the number of cards at each card stack.
|
||||
QMap<int, int> cardStackCount;
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
const QPoint &gridPoint = cards[i]->getGridPos();
|
||||
if (gridPoint.x() == -1)
|
||||
continue;
|
||||
|
||||
const int key = getCardStackMapKey(gridPoint.x() / 3, gridPoint.y());
|
||||
cardStackCount.insert(key, cardStackCount.value(key, 0) + 1);
|
||||
}
|
||||
|
||||
// Second pass: compute the width at each card stack.
|
||||
cardStackWidth.clear();
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
const QPoint &gridPoint = cards[i]->getGridPos();
|
||||
if (gridPoint.x() == -1)
|
||||
continue;
|
||||
|
||||
const int key = getCardStackMapKey(gridPoint.x() / 3, gridPoint.y());
|
||||
const int stackCount = cardStackCount.value(key, 0);
|
||||
if (stackCount == 1)
|
||||
cardStackWidth.insert(key, CARD_WIDTH + cards[i]->getAttachedCards().size() * STACKED_CARD_OFFSET_X);
|
||||
else
|
||||
cardStackWidth.insert(key, CARD_WIDTH + (stackCount - 1) * STACKED_CARD_OFFSET_X);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPointF TableZone::mapFromGrid(QPoint gridPoint) const
|
||||
{
|
||||
qreal x, y;
|
||||
x = MARGIN_X + (gridPoint.x() % 3) * CARD_WIDTH / 3.0;
|
||||
|
||||
// Start with margin plus stacked card offset
|
||||
x = MARGIN_LEFT + (gridPoint.x() % 3) * STACKED_CARD_OFFSET_X;
|
||||
|
||||
// Add in width of card stack plus padding for each column
|
||||
for (int i = 0; i < gridPoint.x() / 3; ++i)
|
||||
x += gridPointWidth.value(gridPoint.y() * 1000 + i, CARD_WIDTH) + PADDING_X;
|
||||
{
|
||||
const int key = getCardStackMapKey(i, gridPoint.y());
|
||||
x += cardStackWidth.value(key, CARD_WIDTH) + PADDING_X;
|
||||
}
|
||||
|
||||
if (isInverted())
|
||||
gridPoint.setY(2 - gridPoint.y());
|
||||
gridPoint.setY(TABLEROWS - 1 - gridPoint.y());
|
||||
|
||||
y = BOX_LINE_WIDTH + gridPoint.y() * (CARD_HEIGHT + PADDING_Y + 20) + (gridPoint.x() % 3) * 10;
|
||||
/*
|
||||
if (isInverted())
|
||||
y = height - CARD_HEIGHT - y;
|
||||
*/
|
||||
// Start with margin plus stacked card offset
|
||||
y = MARGIN_TOP + (gridPoint.x() % 3) * STACKED_CARD_OFFSET_Y;
|
||||
|
||||
// Add in card size and padding for each row
|
||||
for (int i = 0; i < gridPoint.y(); ++i)
|
||||
y += CARD_HEIGHT + PADDING_Y;
|
||||
|
||||
return QPointF(x, y);
|
||||
}
|
||||
|
||||
|
||||
QPoint TableZone::mapToGrid(const QPointF &mapPoint) const
|
||||
{
|
||||
qreal x = mapPoint.x() - MARGIN_X;
|
||||
qreal y = mapPoint.y();
|
||||
/* if (isInverted())
|
||||
y = height - y;
|
||||
*/ y -= BOX_LINE_WIDTH;
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x > width - CARD_WIDTH - MARGIN_X)
|
||||
x = width - CARD_WIDTH - MARGIN_X;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
else if (y > height - CARD_HEIGHT)
|
||||
y = height - CARD_HEIGHT;
|
||||
|
||||
int resultY = round(y / (CARD_HEIGHT + PADDING_Y + 20));
|
||||
if (isInverted())
|
||||
resultY = 2 - resultY;
|
||||
// Begin by calculating the y-coordinate of the grid space, which will be
|
||||
// used for the x-coordinate.
|
||||
|
||||
int baseX = -1;
|
||||
qreal oldTempX = 0, tempX = 0;
|
||||
do {
|
||||
++baseX;
|
||||
oldTempX = tempX;
|
||||
tempX += gridPointWidth.value(resultY * 1000 + baseX, CARD_WIDTH) + PADDING_X;
|
||||
} while (tempX < x + 1);
|
||||
|
||||
qreal xdiff = x - oldTempX;
|
||||
int resultX = baseX * 3 + qMin((int) floor(xdiff * 3 / CARD_WIDTH), 2);
|
||||
return QPoint(resultX, resultY);
|
||||
// Offset point by the margin amount to reference point within grid area.
|
||||
int y = mapPoint.y() - MARGIN_TOP;
|
||||
|
||||
// Below calculation effectively rounds to the nearest grid point.
|
||||
const int gridPointHeight = CARD_HEIGHT + PADDING_Y;
|
||||
int gridPointY = (y + gridPointHeight / 2) / gridPointHeight;
|
||||
|
||||
gridPointY = clampValidTableRow(gridPointY);
|
||||
|
||||
if (isInverted())
|
||||
gridPointY = TABLEROWS - 1 - gridPointY;
|
||||
|
||||
// Calculating the x-coordinate of the grid space requires adding up the
|
||||
// widths of each card stack along the row.
|
||||
|
||||
// Offset point by the margin amount to reference point within grid area.
|
||||
int x = mapPoint.x() - MARGIN_LEFT;
|
||||
|
||||
// Maximum value is a card width from the right margin, referenced to the
|
||||
// grid area.
|
||||
const int xMax = width - MARGIN_LEFT - MARGIN_RIGHT - CARD_WIDTH;
|
||||
|
||||
int xStack = 0;
|
||||
int xNextStack = 0;
|
||||
int nextStackCol = 0;
|
||||
while ((xNextStack <= x) && (xNextStack <= xMax)) {
|
||||
xStack = xNextStack;
|
||||
const int key = getCardStackMapKey(nextStackCol, gridPointY);
|
||||
xNextStack += cardStackWidth.value(key, CARD_WIDTH) + PADDING_X;
|
||||
nextStackCol++;
|
||||
}
|
||||
int stackCol = qMax(nextStackCol - 1, 0);
|
||||
|
||||
// Have the stack column, need to refine to the grid column. Take the
|
||||
// difference between the point and the stack point and divide by stacked
|
||||
// card offsets.
|
||||
int xDiff = x - xStack;
|
||||
int gridPointX = stackCol * 3 + qMin(xDiff / STACKED_CARD_OFFSET_X, 2);
|
||||
|
||||
return QPoint(gridPointX, gridPointY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -357,3 +398,12 @@ QPointF TableZone::closestGridPoint(const QPointF &point)
|
|||
gridPoint.setX(gridPoint.x() + 1);
|
||||
return mapFromGrid(gridPoint);
|
||||
}
|
||||
|
||||
int TableZone::clampValidTableRow(const int row)
|
||||
{
|
||||
if(row < 0)
|
||||
return 0;
|
||||
if(row >= TABLEROWS)
|
||||
return TABLEROWS - 1;
|
||||
return row;
|
||||
}
|
||||
|
|
|
@ -20,12 +20,34 @@ signals:
|
|||
void sizeChanged();
|
||||
|
||||
private:
|
||||
static const int BOX_LINE_WIDTH = 10;
|
||||
static const int TABLEROWS = 3;
|
||||
|
||||
/*
|
||||
Margins between table edges and cards, paddings between cards
|
||||
*/
|
||||
static const int MARGIN_LEFT = 20;
|
||||
static const int MARGIN_RIGHT = 15;
|
||||
static const int MARGIN_TOP = 10;
|
||||
static const int MARGIN_BOTTOM = 30;
|
||||
static const int PADDING_X = 35;
|
||||
static const int PADDING_Y = 10;
|
||||
static const int MARGIN_X = 20;
|
||||
static const int MIN_WIDTH = 15 * CARD_WIDTH / 2;
|
||||
|
||||
static const int PADDING_Y = 30;
|
||||
|
||||
/*
|
||||
Minimum width of the table zone including margins.
|
||||
*/
|
||||
static const int MIN_WIDTH = MARGIN_LEFT + (5 * CARD_WIDTH) + MARGIN_RIGHT;
|
||||
|
||||
/*
|
||||
Offset sizes when cards are stacked on each other in the grid
|
||||
*/
|
||||
static const int STACKED_CARD_OFFSET_X = CARD_WIDTH / 3;
|
||||
static const int STACKED_CARD_OFFSET_Y = PADDING_Y / 3;
|
||||
|
||||
/*
|
||||
Width of the box line drawn in the margin around the active player's area
|
||||
*/
|
||||
static const int BOX_LINE_WIDTH = 10;
|
||||
|
||||
/*
|
||||
Default inactive mask and border gradient
|
||||
*/
|
||||
|
@ -37,11 +59,20 @@ private:
|
|||
/*
|
||||
Size and shape variables
|
||||
*/
|
||||
QMap<int, int> gridPointWidth;
|
||||
int width;
|
||||
int height;
|
||||
int currentMinimumWidth;
|
||||
|
||||
/*
|
||||
Internal cache for widths of stacks of cards by row and column.
|
||||
*/
|
||||
QMap<int, int> cardStackWidth;
|
||||
|
||||
/*
|
||||
Holds any custom background image for the TableZone
|
||||
*/
|
||||
QPixmap backgroundPixelMap;
|
||||
|
||||
/*
|
||||
If this TableZone is currently active
|
||||
*/
|
||||
|
@ -108,10 +139,10 @@ public:
|
|||
*/
|
||||
CardItem *getCardFromCoords(const QPointF &point) const;
|
||||
|
||||
QPointF mapFromGrid(QPoint gridPoint) const;
|
||||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||
QPointF closestGridPoint(const QPointF &point);
|
||||
|
||||
static int clampValidTableRow(const int row);
|
||||
|
||||
/**
|
||||
Removes a card from view.
|
||||
|
||||
|
@ -129,7 +160,7 @@ public:
|
|||
void resizeToContents();
|
||||
|
||||
int getMinimumWidth() const { return currentMinimumWidth; }
|
||||
void setWidth(qreal _width){ prepareGeometryChange(); width = _width;};
|
||||
void setWidth(qreal _width) { prepareGeometryChange(); width = _width; }
|
||||
qreal getWidth() const { return width; }
|
||||
void setActive(bool _active) { active = _active; update(); }
|
||||
|
||||
|
@ -139,6 +170,22 @@ protected:
|
|||
private:
|
||||
void paintZoneOutline(QPainter *painter);
|
||||
void paintLandDivider(QPainter *painter);
|
||||
|
||||
/*
|
||||
Calculates card stack widths so mapping functions work properly
|
||||
*/
|
||||
void computeCardStackWidths();
|
||||
|
||||
/*
|
||||
Mapping functions for points to/from gridpoints.
|
||||
*/
|
||||
QPointF mapFromGrid(QPoint gridPoint) const;
|
||||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||
|
||||
/*
|
||||
Helper function to create a single key from a card stack location.
|
||||
*/
|
||||
int getCardStackMapKey (int x, int y) const { return x + (y * 1000); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include "user_context_menu.h"
|
||||
#include "tab_supervisor.h"
|
||||
#include "tab_userlists.h"
|
||||
|
@ -31,6 +32,8 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p
|
|||
aRemoveFromIgnoreList = new QAction(QString(), this);
|
||||
aKick = new QAction(QString(), this);
|
||||
aBan = new QAction(QString(), this);
|
||||
aPromoteToMod = new QAction(QString(), this);
|
||||
aDemoteFromMod = new QAction(QString(), this);
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
@ -46,6 +49,8 @@ void UserContextMenu::retranslateUi()
|
|||
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
|
||||
aKick->setText(tr("Kick from &game"));
|
||||
aBan->setText(tr("Ban from &server"));
|
||||
aPromoteToMod->setText(tr("&Promote user to moderator"));
|
||||
aDemoteFromMod->setText(tr("Dem&ote user from moderator"));
|
||||
}
|
||||
|
||||
void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
|
||||
|
@ -89,6 +94,27 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
|||
dlg->show();
|
||||
}
|
||||
|
||||
void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer)
|
||||
{
|
||||
|
||||
const Command_AdjustMod &cmd = commandContainer.admin_command(0).GetExtension(Command_AdjustMod::ext);
|
||||
|
||||
if (resp.response_code() == Response::RespOk) {
|
||||
if (cmd.should_be_mod()) {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully promoted user."));
|
||||
} else {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully demoted user."));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (cmd.should_be_mod()) {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to promote user."));
|
||||
} else {
|
||||
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to demote user."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UserContextMenu::banUser_dialogFinished()
|
||||
{
|
||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||
|
@ -99,6 +125,7 @@ void UserContextMenu::banUser_dialogFinished()
|
|||
cmd.set_minutes(dlg->getMinutes());
|
||||
cmd.set_reason(dlg->getReason().toStdString());
|
||||
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
|
||||
cmd.set_clientid(dlg->getBanId().toStdString());
|
||||
|
||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||
}
|
||||
|
@ -131,6 +158,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
if (!tabSupervisor->getAdminLocked()) {
|
||||
menu->addSeparator();
|
||||
menu->addAction(aBan);
|
||||
|
||||
menu->addSeparator();
|
||||
if (userLevel.testFlag(ServerInfo_User::IsModerator) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
menu->addAction(aDemoteFromMod);
|
||||
|
||||
} else if (userLevel.testFlag(ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
|
||||
menu->addAction(aPromoteToMod);
|
||||
}
|
||||
}
|
||||
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
|
||||
aDetails->setEnabled(online);
|
||||
|
@ -142,10 +177,12 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
||||
aKick->setEnabled(anotherUser);
|
||||
aBan->setEnabled(anotherUser);
|
||||
aPromoteToMod->setEnabled(anotherUser);
|
||||
aDemoteFromMod->setEnabled(anotherUser);
|
||||
|
||||
QAction *actionClicked = menu->exec(pos);
|
||||
if (actionClicked == aDetails) {
|
||||
UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
UserInfoBox *infoWidget = new UserInfoBox(client, false, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
infoWidget->setAttribute(Qt::WA_DeleteOnClose);
|
||||
infoWidget->updateInfo(userName);
|
||||
} else if (actionClicked == aChat)
|
||||
|
@ -185,6 +222,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
} else if (actionClicked == aKick) {
|
||||
Command_KickFromGame cmd;
|
||||
cmd.set_player_id(playerId);
|
||||
|
||||
game->sendGameCommand(cmd);
|
||||
} else if (actionClicked == aBan) {
|
||||
Command_GetUserInfo cmd;
|
||||
|
@ -192,7 +230,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
|
||||
client->sendCommand(pend);
|
||||
} else if (actionClicked == aPromoteToMod || actionClicked == aDemoteFromMod) {
|
||||
Command_AdjustMod cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
cmd.set_should_be_mod(actionClicked == aPromoteToMod);
|
||||
|
||||
PendingCommand *pend = client->prepareAdminCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(adjustMod_processUserResponse(Response, CommandContainer)));
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,12 @@ private:
|
|||
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
|
||||
QAction *aKick;
|
||||
QAction *aBan;
|
||||
QAction *aPromoteToMod, *aDemoteFromMod;
|
||||
signals:
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
private slots:
|
||||
void banUser_processUserInfoResponse(const Response &resp);
|
||||
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
|
||||
void banUser_dialogFinished();
|
||||
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
|
||||
public:
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
#include "userinfobox.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "abstractclient.h"
|
||||
#include "dlg_edit_user.h"
|
||||
#include "dlg_edit_password.h"
|
||||
#include "dlg_edit_avatar.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QDateTime>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "pending_command.h"
|
||||
#include "pb/session_commands.pb.h"
|
||||
|
@ -14,13 +19,16 @@ const qint64 SIXTY = 60;
|
|||
const qint64 HOURS_IN_A_DAY = 24;
|
||||
const qint64 DAYS_IN_A_YEAR = 365;
|
||||
|
||||
UserInfoBox::UserInfoBox(AbstractClient *_client, bool _fullInfo, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags), client(_client), fullInfo(_fullInfo)
|
||||
UserInfoBox::UserInfoBox(AbstractClient *_client, bool _editable, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QWidget(parent, flags), client(_client), editable(_editable)
|
||||
{
|
||||
QFont nameFont = nameLabel.font();
|
||||
nameFont.setBold(true);
|
||||
nameFont.setPointSize(nameFont.pointSize() * 1.5);
|
||||
nameLabel.setFont(nameFont);
|
||||
|
||||
avatarLabel.setMaximumWidth(400);
|
||||
avatarLabel.setMaximumHeight(200);
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout;
|
||||
mainLayout->addWidget(&avatarLabel, 0, 0, 1, 3, Qt::AlignCenter);
|
||||
|
@ -38,6 +46,19 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _fullInfo, QWidget *paren
|
|||
mainLayout->addWidget(&accountAgeLebel1, 6, 0, 1, 1);
|
||||
mainLayout->addWidget(&accountAgeLabel2, 6, 2, 1, 1);
|
||||
mainLayout->setColumnStretch(2, 10);
|
||||
|
||||
if(editable)
|
||||
{
|
||||
QHBoxLayout * buttonsLayout = new QHBoxLayout;
|
||||
buttonsLayout->addWidget(&editButton);
|
||||
buttonsLayout->addWidget(&passwordButton);
|
||||
buttonsLayout->addWidget(&avatarButton);
|
||||
mainLayout->addLayout(buttonsLayout, 7, 0, 1, 3);
|
||||
|
||||
connect(&editButton, SIGNAL(clicked()), this, SLOT(actEdit()));
|
||||
connect(&passwordButton, SIGNAL(clicked()), this, SLOT(actPassword()));
|
||||
connect(&avatarButton, SIGNAL(clicked()), this, SLOT(actAvatar()));
|
||||
}
|
||||
|
||||
setWindowTitle(tr("User information"));
|
||||
setLayout(mainLayout);
|
||||
|
@ -47,10 +68,14 @@ UserInfoBox::UserInfoBox(AbstractClient *_client, bool _fullInfo, QWidget *paren
|
|||
void UserInfoBox::retranslateUi()
|
||||
{
|
||||
realNameLabel1.setText(tr("Real name:"));
|
||||
genderLabel1.setText(tr("Gender:"));
|
||||
genderLabel1.setText(tr("Pronouns:"));
|
||||
countryLabel1.setText(tr("Location:"));
|
||||
userLevelLabel1.setText(tr("User level:"));
|
||||
accountAgeLebel1.setText(tr("Account Age:"));
|
||||
|
||||
editButton.setText(tr("Edit"));
|
||||
passwordButton.setText(tr("Change password"));
|
||||
avatarButton.setText(tr("Change avatar"));
|
||||
}
|
||||
|
||||
void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
||||
|
@ -61,7 +86,7 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
|||
const std::string bmp = user.avatar_bmp();
|
||||
if (!avatarPixmap.loadFromData((const uchar *) bmp.data(), bmp.size()))
|
||||
avatarPixmap = UserLevelPixmapGenerator::generatePixmap(64, userLevel, false);
|
||||
avatarLabel.setPixmap(avatarPixmap);
|
||||
avatarLabel.setPixmap(avatarPixmap.scaled(avatarLabel.size(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
||||
|
||||
nameLabel.setText(QString::fromStdString(user.name()));
|
||||
realNameLabel2.setText(QString::fromStdString(user.real_name()));
|
||||
|
@ -137,3 +162,126 @@ void UserInfoBox::processResponse(const Response &r)
|
|||
setFixedSize(sizeHint());
|
||||
show();
|
||||
}
|
||||
|
||||
void UserInfoBox::actEdit()
|
||||
{
|
||||
Command_GetUserInfo cmd;
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(actEditInternal(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void UserInfoBox::actEditInternal(const Response &r)
|
||||
{
|
||||
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
|
||||
const ServerInfo_User &user = response.user_info();
|
||||
|
||||
QString email = QString::fromStdString(user.email());
|
||||
int gender = user.gender();
|
||||
QString country = QString::fromStdString(user.country());
|
||||
QString realName = QString::fromStdString(user.real_name());
|
||||
|
||||
DlgEditUser dlg(this, email, gender, country, realName);
|
||||
if(!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountEdit cmd;
|
||||
cmd.set_real_name(dlg.getRealName().toStdString());
|
||||
cmd.set_email(dlg.getEmail().toStdString());
|
||||
cmd.set_gender((ServerInfo_User_Gender) dlg.getGender());
|
||||
cmd.set_country(dlg.getCountry().toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processEditResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void UserInfoBox::actPassword()
|
||||
{
|
||||
DlgEditPassword dlg(this);
|
||||
if(!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountPassword cmd;
|
||||
cmd.set_old_password(dlg.getOldPassword().toStdString());
|
||||
cmd.set_new_password(dlg.getNewPassword().toStdString());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processPasswordResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void UserInfoBox::actAvatar()
|
||||
{
|
||||
DlgEditAvatar dlg(this);
|
||||
if(!dlg.exec())
|
||||
return;
|
||||
|
||||
Command_AccountImage cmd;
|
||||
cmd.set_image(dlg.getImage().data(), dlg.getImage().size());
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(processAvatarResponse(const Response &)));
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
void UserInfoBox::processEditResponse(const Response &r)
|
||||
{
|
||||
switch (r.response_code()) {
|
||||
case Response::RespOk:
|
||||
updateInfo(nameLabel.text());
|
||||
QMessageBox::information(this, tr("Information"), tr("User information updated."));
|
||||
break;
|
||||
case Response::RespFunctionNotAllowed:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server does not permit you to update your user informations."));
|
||||
break;
|
||||
case Response::RespInternalError:
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An error occured while trying to update your user informations."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserInfoBox::processPasswordResponse(const Response &r)
|
||||
{
|
||||
switch (r.response_code()) {
|
||||
case Response::RespOk:
|
||||
QMessageBox::information(this, tr("Information"), tr("Password changed."));
|
||||
break;
|
||||
case Response::RespFunctionNotAllowed:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server does not permit you to change your password."));
|
||||
break;
|
||||
case Response::RespPasswordTooShort:
|
||||
QMessageBox::critical(this, tr("Error"), tr("The new password is too short."));
|
||||
break;
|
||||
case Response::RespWrongPassword:
|
||||
QMessageBox::critical(this, tr("Error"), tr("The old password is incorrect."));
|
||||
break;
|
||||
case Response::RespInternalError:
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An error occured while trying to update your user informations."));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void UserInfoBox::processAvatarResponse(const Response &r)
|
||||
{
|
||||
switch (r.response_code()) {
|
||||
case Response::RespOk:
|
||||
updateInfo(nameLabel.text());
|
||||
QMessageBox::information(this, tr("Information"), tr("Avatar updated."));
|
||||
break;
|
||||
case Response::RespFunctionNotAllowed:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server does not permit you to update your avatar."));
|
||||
break;
|
||||
case Response::RespInternalError:
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An error occured while trying to updater your avatar."));
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
class QLabel;
|
||||
class ServerInfo_User;
|
||||
class AbstractClient;
|
||||
class Response;
|
||||
|
@ -13,14 +13,24 @@ class UserInfoBox : public QWidget {
|
|||
Q_OBJECT
|
||||
private:
|
||||
AbstractClient *client;
|
||||
bool fullInfo;
|
||||
bool editable;
|
||||
QLabel avatarLabel, nameLabel, realNameLabel1, realNameLabel2, genderLabel1, genderLabel2, countryLabel1,
|
||||
countryLabel2, countryLabel3, userLevelLabel1, userLevelLabel2, userLevelLabel3, accountAgeLebel1, accountAgeLabel2;
|
||||
QPushButton editButton, passwordButton, avatarButton;
|
||||
|
||||
public:
|
||||
UserInfoBox(AbstractClient *_client, bool fullInfo, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
UserInfoBox(AbstractClient *_client, bool editable, QWidget *parent = 0, Qt::WindowFlags flags = 0);
|
||||
void retranslateUi();
|
||||
private slots:
|
||||
void processResponse(const Response &r);
|
||||
void processEditResponse(const Response &r);
|
||||
void processPasswordResponse(const Response &r);
|
||||
void processAvatarResponse(const Response &r);
|
||||
|
||||
void actEdit();
|
||||
void actEditInternal(const Response &r);
|
||||
void actPassword();
|
||||
void actAvatar();
|
||||
public slots:
|
||||
void updateInfo(const ServerInfo_User &user);
|
||||
void updateInfo(const QString &userName);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "tab_supervisor.h"
|
||||
#include "abstractclient.h"
|
||||
#include "pixmapgenerator.h"
|
||||
#include "userinfobox.h"
|
||||
#include "user_context_menu.h"
|
||||
#include "gameselector.h"
|
||||
#include <QHeaderView>
|
||||
|
@ -37,11 +36,19 @@ BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent)
|
|||
ipBanCheckBox = new QCheckBox(tr("ban &IP address"));
|
||||
ipBanCheckBox->setChecked(true);
|
||||
ipBanEdit = new QLineEdit(QString::fromStdString(info.address()));
|
||||
idBanCheckBox = new QCheckBox(tr("ban client I&D"));
|
||||
idBanCheckBox->setChecked(true);
|
||||
idBanEdit = new QLineEdit(QString::fromStdString(info.clientid()));
|
||||
if (QString::fromStdString(info.clientid()).isEmpty())
|
||||
idBanCheckBox->setChecked(false);
|
||||
|
||||
QGridLayout *banTypeGrid = new QGridLayout;
|
||||
banTypeGrid->addWidget(nameBanCheckBox, 0, 0);
|
||||
banTypeGrid->addWidget(nameBanEdit, 0, 1);
|
||||
banTypeGrid->addWidget(ipBanCheckBox, 1, 0);
|
||||
banTypeGrid->addWidget(ipBanEdit, 1, 1);
|
||||
banTypeGrid->addWidget(idBanCheckBox, 2, 0);
|
||||
banTypeGrid->addWidget(idBanEdit, 2, 1);
|
||||
QGroupBox *banTypeGroupBox = new QGroupBox(tr("Ban type"));
|
||||
banTypeGroupBox->setLayout(banTypeGrid);
|
||||
|
||||
|
@ -111,8 +118,8 @@ BanDialog::BanDialog(const ServerInfo_User &info, QWidget *parent)
|
|||
|
||||
void BanDialog::okClicked()
|
||||
{
|
||||
if (!nameBanCheckBox->isChecked() && !ipBanCheckBox->isChecked()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("You have to select a name-based or IP-based ban, or both."));
|
||||
if (!nameBanCheckBox->isChecked() && !ipBanCheckBox->isChecked() && !idBanCheckBox->isChecked()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("You have to select a name-based, IP-based, clientId based, or some combination of the three to place a ban."));
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
|
@ -128,6 +135,11 @@ void BanDialog::enableTemporaryEdits(bool enabled)
|
|||
minutesEdit->setEnabled(enabled);
|
||||
}
|
||||
|
||||
QString BanDialog::getBanId() const
|
||||
{
|
||||
return idBanCheckBox->isChecked() ? idBanEdit->text() : QString();
|
||||
}
|
||||
|
||||
QString BanDialog::getBanName() const
|
||||
{
|
||||
return nameBanCheckBox->isChecked() ? nameBanEdit->text() : QString();
|
||||
|
|
|
@ -24,8 +24,8 @@ class BanDialog : public QDialog {
|
|||
Q_OBJECT
|
||||
private:
|
||||
QLabel *daysLabel, *hoursLabel, *minutesLabel;
|
||||
QCheckBox *nameBanCheckBox, *ipBanCheckBox;
|
||||
QLineEdit *nameBanEdit, *ipBanEdit;
|
||||
QCheckBox *nameBanCheckBox, *ipBanCheckBox, *idBanCheckBox;
|
||||
QLineEdit *nameBanEdit, *ipBanEdit, *idBanEdit;
|
||||
QSpinBox *daysEdit, *hoursEdit, *minutesEdit;
|
||||
QRadioButton *permanentRadio, *temporaryRadio;
|
||||
QPlainTextEdit *reasonEdit, *visibleReasonEdit;
|
||||
|
@ -36,6 +36,7 @@ public:
|
|||
BanDialog(const ServerInfo_User &info, QWidget *parent = 0);
|
||||
QString getBanName() const;
|
||||
QString getBanIP() const;
|
||||
QString getBanId() const;
|
||||
int getMinutes() const;
|
||||
QString getReason() const;
|
||||
QString getVisibleReason() const;
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
#include <QDateTime>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QApplication>
|
||||
#if QT_VERSION < 0x050000
|
||||
#include <QtGui/qtextdocument.h> // for Qt::escape()
|
||||
#endif
|
||||
|
||||
#include "main.h"
|
||||
#include "window_main.h"
|
||||
|
@ -43,7 +46,6 @@
|
|||
#include "localclient.h"
|
||||
#include "settingscache.h"
|
||||
#include "tab_game.h"
|
||||
|
||||
#include "version_string.h"
|
||||
|
||||
#include "pb/game_replay.pb.h"
|
||||
|
@ -51,6 +53,14 @@
|
|||
#include "pb/event_connection_closed.pb.h"
|
||||
#include "pb/event_server_shutdown.pb.h"
|
||||
|
||||
#define GITHUB_CONTRIBUTORS_URL "https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c"
|
||||
#define GITHUB_CONTRIBUTE_URL "https://github.com/Cockatrice/Cockatrice#cockatrice"
|
||||
#define GITHUB_TRANSLATOR_RECOGNIZE_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translators"
|
||||
#define GITHUB_TRANSLATOR_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ"
|
||||
#define GITHUB_ISSUES_URL "https://github.com/Cockatrice/Cockatrice/issues"
|
||||
#define GITHUB_TROUBLESHOOTING_URL "https://github.com/Cockatrice/Cockatrice/wiki/Troubleshooting"
|
||||
#define GITHUB_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Frequently-Asked-Questions"
|
||||
|
||||
const QString MainWindow::appName = "Cockatrice";
|
||||
|
||||
void MainWindow::updateTabMenu(const QList<QMenu *> &newMenuList)
|
||||
|
@ -67,6 +77,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
|
|||
client->disconnectFromServer();
|
||||
QString reasonStr;
|
||||
switch (event.reason()) {
|
||||
case Event_ConnectionClosed::USER_LIMIT_REACHED: reasonStr = tr("The server has reached its maximum user capacity, please check back later."); break;
|
||||
case Event_ConnectionClosed::TOO_MANY_CONNECTIONS: reasonStr = tr("There are too many concurrent connections from your address."); break;
|
||||
case Event_ConnectionClosed::BANNED: {
|
||||
reasonStr = tr("Banned by moderator");
|
||||
|
@ -79,7 +90,8 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
|
|||
break;
|
||||
}
|
||||
case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break;
|
||||
case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username.\nYou may only use A-Z, a-z, 0-9, _, ., and - in your username."); break;
|
||||
case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username."); break;
|
||||
case Event_ConnectionClosed::LOGGEDINELSEWERE: reasonStr = tr("You have been logged out due to logging in at another location."); break;
|
||||
default: reasonStr = QString::fromStdString(event.reason_str());
|
||||
}
|
||||
QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
|
||||
|
@ -177,24 +189,24 @@ void MainWindow::actSinglePlayer()
|
|||
int numberPlayers = QInputDialog::getInt(this, tr("Number of players"), tr("Please enter the number of players."), 1, 1, 8, 1, &ok);
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
|
||||
aConnect->setEnabled(false);
|
||||
aRegister->setEnabled(false);
|
||||
aSinglePlayer->setEnabled(false);
|
||||
|
||||
|
||||
localServer = new LocalServer(this);
|
||||
LocalServerInterface *mainLsi = localServer->newConnection();
|
||||
LocalClient *mainClient = new LocalClient(mainLsi, tr("Player %1").arg(1), this);
|
||||
LocalClient *mainClient = new LocalClient(mainLsi, tr("Player %1").arg(1), settingsCache->getClientID(), this);
|
||||
QList<AbstractClient *> localClients;
|
||||
localClients.append(mainClient);
|
||||
|
||||
|
||||
for (int i = 0; i < numberPlayers - 1; ++i) {
|
||||
LocalServerInterface *slaveLsi = localServer->newConnection();
|
||||
LocalClient *slaveClient = new LocalClient(slaveLsi, tr("Player %1").arg(i + 2), this);
|
||||
LocalClient *slaveClient = new LocalClient(slaveLsi, tr("Player %1").arg(i + 2), settingsCache->getClientID(), this);
|
||||
localClients.append(slaveClient);
|
||||
}
|
||||
tabSupervisor->startLocal(localClients);
|
||||
|
||||
|
||||
Command_CreateGame createCommand;
|
||||
createCommand.set_max_players(numberPlayers);
|
||||
mainClient->sendCommand(mainClient->prepareRoomCommand(createCommand, 0));
|
||||
|
@ -207,17 +219,17 @@ void MainWindow::actWatchReplay()
|
|||
dlg.setNameFilters(QStringList() << QObject::tr("Cockatrice replays (*.cor)"));
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
|
||||
QString fileName = dlg.selectedFiles().at(0);
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return;
|
||||
QByteArray buf = file.readAll();
|
||||
file.close();
|
||||
|
||||
|
||||
GameReplay *replay = new GameReplay;
|
||||
replay->ParseFromArray(buf.data(), buf.size());
|
||||
|
||||
|
||||
tabSupervisor->openReplay(replay);
|
||||
}
|
||||
|
||||
|
@ -225,7 +237,7 @@ void MainWindow::localGameEnded()
|
|||
{
|
||||
delete localServer;
|
||||
localServer = 0;
|
||||
|
||||
|
||||
aConnect->setEnabled(true);
|
||||
aRegister->setEnabled(true);
|
||||
aSinglePlayer->setEnabled(true);
|
||||
|
@ -263,15 +275,15 @@ void MainWindow::actAbout()
|
|||
+ "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>"
|
||||
+ "<b>" + tr("Past Project Managers:") + "</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br><br>"
|
||||
+ "<b>" + tr("Developers:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c'>" + tr("Our Developers") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice#cockatrice'>" + tr("Help Develop!") + "</a><br><br>"
|
||||
+ "<a href='" + GITHUB_CONTRIBUTORS_URL + "'>" + tr("Our Developers") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_CONTRIBUTE_URL + "'>" + tr("Help Develop!") + "</a><br><br>"
|
||||
+ "<b>" + tr("Translators:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translators'>" + tr("Recognition Page") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ'>" + tr("Help Translate!") + "</a><br><br>"
|
||||
+ "<a href='" + GITHUB_TRANSLATOR_RECOGNIZE_URL + "'>" + tr("Recognition Page") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_TRANSLATOR_FAQ_URL + "'>" + tr("Help Translate!") + "</a><br><br>"
|
||||
+ "<b>" + tr("Support:") + "</b><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/issues'>" + tr("Report an Issue") + "</a><br>"
|
||||
+ "<a href='https://github.com/Cockatrice/Cockatrice/issues'>" + tr("Suggest an Improvement") + "</a><br>"
|
||||
|
||||
+ "<a href='" + GITHUB_ISSUES_URL + "'>" + tr("Report an Issue") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_TROUBLESHOOTING_URL + "'>" + tr("Troubleshooting") + "</a><br>"
|
||||
+ "<a href='" + GITHUB_FAQ_URL + "'>" + tr("F.A.Q.") + "</a><br>"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -298,21 +310,28 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
|
|||
bannedStr = tr("You are banned indefinitely.");
|
||||
if (!reasonStr.isEmpty())
|
||||
bannedStr.append("\n\n" + reasonStr);
|
||||
|
||||
|
||||
QMessageBox::critical(this, tr("Error"), bannedStr);
|
||||
break;
|
||||
}
|
||||
case Response::RespUsernameInvalid:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid username.\nYou may only use A-Z, a-z, 0-9, _, ., and - in your username."));
|
||||
case Response::RespUsernameInvalid: {
|
||||
QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr));
|
||||
break;
|
||||
}
|
||||
case Response::RespRegistrationRequired:
|
||||
if (QMessageBox::question(this, tr("Error"), tr("This server requires user registration. Do you want to register now?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
actRegister();
|
||||
}
|
||||
break;
|
||||
case Response::RespClientIdRequired:
|
||||
QMessageBox::critical(this, tr("Error"), tr("This server requires client ID's. Your client is either failing to generate an ID or you are running a modified client.\nPlease close and reopen your client to try again."));
|
||||
break;
|
||||
case Response::RespContextError:
|
||||
QMessageBox::critical(this, tr("Error"), tr("An internal error has occurred, please try closing and reopening your client and try again. If the error persists try updating your client to the most recent build and if need be contact your software provider."));
|
||||
break;
|
||||
case Response::RespAccountNotActivated: {
|
||||
bool ok = false;
|
||||
QString token = QInputDialog::getText(this, tr("Account activation"), tr("Your account has not been activated yet.\n You need to provide the activation token received in the activation email"), QLineEdit::Normal, QString(), &ok);
|
||||
QString token = QInputDialog::getText(this, tr("Account activation"), tr("Your account has not been activated yet.\nYou need to provide the activation token received in the activation email"), QLineEdit::Normal, QString(), &ok);
|
||||
if(ok && !token.isEmpty())
|
||||
{
|
||||
client->activateToServer(token);
|
||||
|
@ -322,12 +341,47 @@ void MainWindow::loginError(Response::ResponseCode r, QString reasonStr, quint32
|
|||
break;
|
||||
}
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Unknown login error: %1").arg(static_cast<int>(r)));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Unknown login error: %1").arg(static_cast<int>(r)) + tr("\nThis usually means that your client version is out of date, and the server sent a reply your client doesn't understand."));
|
||||
break;
|
||||
}
|
||||
actConnect();
|
||||
}
|
||||
|
||||
QString MainWindow::extractInvalidUsernameMessage(QString & in)
|
||||
{
|
||||
QString out = tr("Invalid username.") + "<br/>";
|
||||
QStringList rules = in.split(QChar('|'));
|
||||
if (rules.size() == 7)
|
||||
{
|
||||
out += tr("Your username must respect these rules:") + "<br><ul>";
|
||||
|
||||
out += "<li>" + tr("is %1 - %2 characters long").arg(rules.at(0)).arg(rules.at(1)) + "</li>";
|
||||
out += "<li>" + tr("can %1 contain lowercase characters").arg((rules.at(2).toInt() > 0) ? "" : tr("NOT")) + "</li>";
|
||||
out += "<li>" + tr("can %1 contain uppercase characters").arg((rules.at(3).toInt() > 0) ? "" : tr("NOT")) + "</li>";
|
||||
out += "<li>" + tr("can %1 contain numeric characters").arg((rules.at(4).toInt() > 0) ? "" : tr("NOT")) + "</li>";
|
||||
|
||||
if (rules.at(6).size() > 0)
|
||||
{
|
||||
out += "<li>" + tr("can contain the following punctuation: %1").arg(
|
||||
#if QT_VERSION < 0x050000
|
||||
Qt::escape(rules.at(6))
|
||||
#else
|
||||
rules.at(6).toHtmlEscaped()
|
||||
#endif
|
||||
) + "</li>";
|
||||
}
|
||||
|
||||
out += "<li>" + tr("first character can %1 be a punctuation mark").arg((rules.at(5).toInt() > 0) ? "" : tr("NOT")) + "</li>";
|
||||
out += "</ul>";
|
||||
}
|
||||
else
|
||||
{
|
||||
out += tr("You may only use A-Z, a-z, 0-9, _, ., and - in your username.");
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quint32 endTime)
|
||||
{
|
||||
switch (r) {
|
||||
|
@ -354,18 +408,19 @@ void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quin
|
|||
bannedStr = tr("You are banned indefinitely.");
|
||||
if (!reasonStr.isEmpty())
|
||||
bannedStr.append("\n\n" + reasonStr);
|
||||
|
||||
|
||||
QMessageBox::critical(this, tr("Error"), bannedStr);
|
||||
break;
|
||||
}
|
||||
case Response::RespUsernameInvalid:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid username.\nYou may only use A-Z, a-z, 0-9, _, ., and - in your username."));
|
||||
case Response::RespUsernameInvalid: {
|
||||
QMessageBox::critical(this, tr("Error"), extractInvalidUsernameMessage(reasonStr));
|
||||
break;
|
||||
}
|
||||
case Response::RespRegistrationFailed:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Registration failed for a technical problem on the server."));
|
||||
break;
|
||||
default:
|
||||
QMessageBox::critical(this, tr("Error"), tr("Unknown login error: %1").arg(static_cast<int>(r)));
|
||||
QMessageBox::critical(this, tr("Error"), tr("Unknown registration error: %1").arg(static_cast<int>(r)) + tr("\nThis usually means that your client version is out of date, and the server sent a reply your client doesn't understand."));
|
||||
}
|
||||
actRegister();
|
||||
}
|
||||
|
@ -398,7 +453,7 @@ void MainWindow::setClientStatusTitle()
|
|||
case StatusRegistering: setWindowTitle(appName + " - " + tr("Registering to %1 as %2...").arg(client->peerName()).arg(client->getUserName())); break;
|
||||
case StatusDisconnected: setWindowTitle(appName + " - " + tr("Disconnected")); break;
|
||||
case StatusLoggingIn: setWindowTitle(appName + " - " + tr("Connected, logging in at %1").arg(client->peerName())); break;
|
||||
case StatusLoggedIn: setWindowTitle(appName + " - " + tr("Logged in as %1 at %2").arg(client->getUserName()).arg(client->peerName())); break;
|
||||
case StatusLoggedIn: setWindowTitle(client->getUserName() + "@" + client->peerName()); break;
|
||||
default: setWindowTitle(appName);
|
||||
}
|
||||
}
|
||||
|
@ -406,27 +461,26 @@ void MainWindow::setClientStatusTitle()
|
|||
void MainWindow::retranslateUi()
|
||||
{
|
||||
setClientStatusTitle();
|
||||
|
||||
|
||||
aConnect->setText(tr("&Connect..."));
|
||||
aDisconnect->setText(tr("&Disconnect"));
|
||||
aSinglePlayer->setText(tr("Start &local game..."));
|
||||
aWatchReplay->setText(tr("&Watch replay..."));
|
||||
aDeckEditor->setText(tr("&Deck editor"));
|
||||
aFullScreen->setText(tr("&Full screen"));
|
||||
aFullScreen->setShortcut(QKeySequence("Ctrl+F"));
|
||||
aRegister->setText(tr("&Register to server..."));
|
||||
aSettings->setText(tr("&Settings..."));
|
||||
aExit->setText(tr("&Exit"));
|
||||
|
||||
|
||||
#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..."));
|
||||
|
||||
tabSupervisor->retranslateUi();
|
||||
}
|
||||
|
||||
|
@ -452,7 +506,7 @@ void MainWindow::createActions()
|
|||
connect(aSettings, SIGNAL(triggered()), this, SLOT(actSettings()));
|
||||
aExit = new QAction(this);
|
||||
connect(aExit, SIGNAL(triggered()), this, SLOT(actExit()));
|
||||
|
||||
|
||||
aAbout = new QAction(this);
|
||||
connect(aAbout, SIGNAL(triggered()), this, SLOT(actAbout()));
|
||||
|
||||
|
@ -493,7 +547,7 @@ void MainWindow::createMenus()
|
|||
cockatriceMenu->addAction(aCheckCardUpdates);
|
||||
cockatriceMenu->addSeparator();
|
||||
cockatriceMenu->addAction(aExit);
|
||||
|
||||
|
||||
helpMenu = menuBar()->addMenu(QString());
|
||||
helpMenu->addAction(aAbout);
|
||||
}
|
||||
|
@ -526,17 +580,17 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
|
||||
createActions();
|
||||
createMenus();
|
||||
|
||||
|
||||
tabSupervisor = new TabSupervisor(client);
|
||||
connect(tabSupervisor, SIGNAL(setMenu(QList<QMenu *>)), this, SLOT(updateTabMenu(QList<QMenu *>)));
|
||||
connect(tabSupervisor, SIGNAL(localGameEnded()), this, SLOT(localGameEnded()));
|
||||
connect(tabSupervisor, SIGNAL(maximize()), this, SLOT(maximize()));
|
||||
tabSupervisor->addDeckEditorTab(0);
|
||||
|
||||
tabSupervisor->addDeckEditorTab(0);
|
||||
|
||||
setCentralWidget(tabSupervisor);
|
||||
|
||||
retranslateUi();
|
||||
|
||||
|
||||
resize(900, 700);
|
||||
restoreGeometry(settingsCache->getMainWindowGeometry());
|
||||
aFullScreen->setChecked(windowState() & Qt::WindowFullScreen);
|
||||
|
@ -545,6 +599,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
createTrayActions();
|
||||
createTrayIcon();
|
||||
}
|
||||
|
||||
connect(&settingsCache->shortcuts(), SIGNAL(shortCutchanged()),this,SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -558,7 +615,7 @@ MainWindow::~MainWindow()
|
|||
void MainWindow::createTrayIcon() {
|
||||
QMenu *trayIconMenu = new QMenu(this);
|
||||
trayIconMenu->addAction(closeAction);
|
||||
|
||||
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
trayIcon->setContextMenu(trayIconMenu);
|
||||
trayIcon->setIcon(QIcon("theme:cockatrice.svg"));
|
||||
|
@ -668,7 +725,7 @@ void MainWindow::actCheckCardUpdates()
|
|||
binaryName = getCardUpdaterBinaryName() + ".exe";
|
||||
#else
|
||||
binaryName = getCardUpdaterBinaryName();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(dir.exists(binaryName))
|
||||
updaterCmd = dir.absoluteFilePath(binaryName);
|
||||
|
@ -724,3 +781,17 @@ void MainWindow::cardUpdateFinished(int, QProcess::ExitStatus)
|
|||
// this will force a database reload
|
||||
settingsCache->setCardDatabasePath(settingsCache->getCardDatabasePath());
|
||||
}
|
||||
|
||||
void MainWindow::refreshShortcuts()
|
||||
{
|
||||
aConnect->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aConnect"));
|
||||
aDisconnect->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aDisconnect"));
|
||||
aSinglePlayer->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aSinglePlayer"));
|
||||
aWatchReplay->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aWatchReplay"));
|
||||
aDeckEditor->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aDeckEditor"));
|
||||
aFullScreen->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aFullScreen"));
|
||||
aRegister->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aRegister"));
|
||||
aSettings->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aSettings"));
|
||||
aExit->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aExit"));
|
||||
aCheckCardUpdates->setShortcuts(settingsCache->shortcuts().getShortcut("MainWindow/aCheckCardUpdates"));
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ private slots:
|
|||
void actCheckCardUpdates();
|
||||
void cardUpdateError(QProcess::ProcessError err);
|
||||
void cardUpdateFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
void refreshShortcuts();
|
||||
private:
|
||||
static const QString appName;
|
||||
void setClientStatusTitle();
|
||||
|
@ -109,6 +110,7 @@ public:
|
|||
protected:
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void changeEvent(QEvent *event);
|
||||
QString extractInvalidUsernameMessage(QString & in);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -92,7 +92,7 @@ WndSets::WndSets(QWidget *parent)
|
|||
|
||||
|
||||
QLabel *labNotes = new QLabel;
|
||||
labNotes->setText("<b>" + tr("hints:") + "</b>" + "<ul><li>" + tr("Enable the sets that you want to have available in the deck editor") + "</li><li>" + tr("Move sets around to change their order, or click on a column header to sort sets on that field") + "</li><li>" + tr("Sets order decides the source that will be used when loading images for a specific card") + "</li><li>" + tr("Disabled sets will still be used for loading images") + "</li></ul>");
|
||||
labNotes->setText("<b>" + tr("hints:") + "</b>" + "<ul><li>" + tr("Enable the sets that you want to have available in the deck editor") + "</li><li>" + tr("Move sets around to change their order, or click on a column header to sort sets on that field") + "</li><li>" + tr("Sets order decides the source that will be used when loading images for a specific card") + "</li><li>" + tr("Disabled sets will be used for loading images only if all the enabled sets failed") + "</li></ul>");
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave()));
|
||||
|
@ -123,6 +123,7 @@ WndSets::~WndSets()
|
|||
void WndSets::actSave()
|
||||
{
|
||||
model->save(db);
|
||||
db->clearPixmapCache();
|
||||
QMessageBox::information(this, tr("Success"), tr("The sets database has been saved successfully."));
|
||||
close();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue