Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
f4ae08f8
Commit
f4ae08f8
authored
Sep 02, 2015
by
Zach
Browse files
Merge pull request #1439 from woogerboy21/feature_check
Added server/client feature set communication
parents
3188ef4c
044c2356
Changes
54
Hide whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
f4ae08f8
...
...
@@ -99,6 +99,12 @@ SET(cockatrice_SOURCES
src/sequenceEdit/sequenceedit.cpp
src/sequenceEdit/shortcutstab.cpp
src/lineeditcompleter.cpp
src/settings/settingsmanager.cpp
src/settings/carddatabasesettings.cpp
src/settings/serverssettings.cpp
src/settings/messagesettings.cpp
src/settings/gamefilterssettings.cpp
src/settings/layoutssettings.cpp
${
VERSION_STRING_CPP
}
)
...
...
@@ -328,3 +334,8 @@ Data = Resources\")
install
(
FILES
${
WIN32SSLRUNTIME_LIBRARIES
}
DESTINATION ./
)
endif
()
endif
()
#Compile a portable version, default off
option
(
PORTABLE
"portable build"
OFF
)
IF
(
PORTABLE
)
add_definitions
(
-DPORTABLE_BUILD
)
endif
()
cockatrice/src/abstractclient.cpp
View file @
f4ae08f8
...
...
@@ -19,6 +19,7 @@
#include
"get_pb_extension.h"
#include
<google/protobuf/descriptor.h>
#include
"client_metatypes.h"
#include
"featureset.h"
AbstractClient
::
AbstractClient
(
QObject
*
parent
)
:
QObject
(
parent
),
nextCmdId
(
0
),
status
(
StatusDisconnected
)
...
...
@@ -45,6 +46,10 @@ AbstractClient::AbstractClient(QObject *parent)
qRegisterMetaType
<
ServerInfo_User
>
(
"ServerInfo_User"
);
qRegisterMetaType
<
QList
<
ServerInfo_User
>
>
(
"QList<ServerInfo_User>"
);
qRegisterMetaType
<
Event_ReplayAdded
>
(
"Event_ReplayAdded"
);
qRegisterMetaType
<
QList
<
QString
>
>
(
"missingFeatures"
);
FeatureSet
features
;
features
.
initalizeFeatureList
(
clientFeatures
);
connect
(
this
,
SIGNAL
(
sigQueuePendingCommand
(
PendingCommand
*
)),
this
,
SLOT
(
queuePendingCommand
(
PendingCommand
*
)));
}
...
...
cockatrice/src/abstractclient.h
View file @
f4ae08f8
...
...
@@ -25,6 +25,7 @@ class Event_NotifyUser;
class
Event_ConnectionClosed
;
class
Event_ServerShutdown
;
class
Event_ReplayAdded
;
class
FeatureSet
;
enum
ClientStatus
{
StatusDisconnected
,
...
...
@@ -96,6 +97,8 @@ public:
static
PendingCommand
*
prepareRoomCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
,
int
roomId
);
static
PendingCommand
*
prepareModeratorCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
);
static
PendingCommand
*
prepareAdminCommand
(
const
::
google
::
protobuf
::
Message
&
cmd
);
QMap
<
QString
,
bool
>
clientFeatures
;
};
#endif
cockatrice/src/carddatabase.cpp
View file @
f4ae08f8
...
...
@@ -7,7 +7,6 @@
#include
<QDirIterator>
#include
<QFile>
#include
<QTextStream>
#include
<QSettings>
#include
<QSvgRenderer>
#include
<QPainter>
#include
<QUrl>
...
...
@@ -52,46 +51,29 @@ QString CardSet::getCorrectedShortName() const
return
invalidFileNames
.
contains
(
shortName
)
?
shortName
+
"_"
:
shortName
;
}
void
CardSet
::
setSortKey
(
unsigned
int
_sortKey
)
void
CardSet
::
loadSetOptions
(
)
{
sortKey
=
_sortKey
;
QSettings
settings
;
settings
.
beginGroup
(
"sets"
);
settings
.
beginGroup
(
shortName
);
settings
.
setValue
(
"sortkey"
,
sortKey
);
sortKey
=
settingsCache
->
cardDatabase
().
getSortKey
(
shortName
);
enabled
=
settingsCache
->
cardDatabase
().
isEnabled
(
shortName
);
isknown
=
settingsCache
->
cardDatabase
().
isKnown
(
shortName
);
}
void
CardSet
::
loadSetOptions
(
)
void
CardSet
::
setSortKey
(
unsigned
int
_sortKey
)
{
QSettings
settings
;
settings
.
beginGroup
(
"sets"
);
settings
.
beginGroup
(
shortName
);
sortKey
=
settings
.
value
(
"sortkey"
,
0
).
toInt
();
enabled
=
settings
.
value
(
"enabled"
,
false
).
toBool
();
isknown
=
settings
.
value
(
"isknown"
,
false
).
toBool
();
// qDebug() << "load set" << shortName << "key" << sortKey;
sortKey
=
_sortKey
;
settingsCache
->
cardDatabase
().
setSortKey
(
shortName
,
_sortKey
);
}
void
CardSet
::
setEnabled
(
bool
_enabled
)
{
enabled
=
_enabled
;
QSettings
settings
;
settings
.
beginGroup
(
"sets"
);
settings
.
beginGroup
(
shortName
);
settings
.
setValue
(
"enabled"
,
enabled
);
settingsCache
->
cardDatabase
().
setEnabled
(
shortName
,
_enabled
);
}
void
CardSet
::
setIsKnown
(
bool
_isknown
)
{
isknown
=
_isknown
;
QSettings
settings
;
settings
.
beginGroup
(
"sets"
);
settings
.
beginGroup
(
shortName
);
settings
.
setValue
(
"isknown"
,
isknown
);
settingsCache
->
cardDatabase
().
setIsKnown
(
shortName
,
_isknown
);
}
class
SetList
::
KeyCompareFunctor
{
...
...
@@ -1255,4 +1237,4 @@ bool CardDatabase::hasDetectedFirstRun()
}
return
false
;
}
\ No newline at end of file
}
cockatrice/src/client_metatypes.h
View file @
f4ae08f8
...
...
@@ -24,6 +24,6 @@ Q_DECLARE_METATYPE(Event_UserMessage)
Q_DECLARE_METATYPE
(
ServerInfo_User
)
Q_DECLARE_METATYPE
(
QList
<
ServerInfo_User
>
)
Q_DECLARE_METATYPE
(
Event_ReplayAdded
)
Q_DECLARE_METATYPE
(
QList
<
QString
>
)
#endif
cockatrice/src/dlg_connect.cpp
View file @
f4ae08f8
#include
<QSettings>
#include
<QLabel>
#include
<QCheckBox>
#include
<QComboBox>
...
...
@@ -11,25 +10,23 @@
#include
<QKeyEvent>
#include
<iostream>
#include
"dlg_connect.h"
#include
"settingscache.h"
DlgConnect
::
DlgConnect
(
QWidget
*
parent
)
:
QDialog
(
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
();
QStringList
previousHostList
=
settingsCache
->
servers
().
getPreviousHostList
();
if
(
previousHostList
.
isEmpty
())
{
previousHostList
<<
"cockatrice.woogerworks.com"
;
previousHostList
<<
"vps.poixen.com"
;
previousHostList
<<
"chickatrice.net"
;
}
previousHosts
->
addItems
(
previousHostList
);
previousHosts
->
setCurrentIndex
(
settings
.
value
(
"p
revioushostindex
"
).
toInt
());
previousHosts
->
setCurrentIndex
(
settings
Cache
->
servers
().
getP
revioushostindex
());
newHostButton
=
new
QRadioButton
(
tr
(
"New Host"
),
this
);
...
...
@@ -39,28 +36,28 @@ DlgConnect::DlgConnect(QWidget *parent)
hostLabel
->
setBuddy
(
hostEdit
);
portLabel
=
new
QLabel
(
tr
(
"&Port:"
));
portEdit
=
new
QLineEdit
(
settings
.
value
(
"port"
,
"4747"
).
toString
(
));
portEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getPort
(
"4747"
));
portLabel
->
setBuddy
(
portEdit
);
playernameLabel
=
new
QLabel
(
tr
(
"Player &name:"
));
playernameEdit
=
new
QLineEdit
(
settings
.
value
(
"p
layer
n
ame
"
,
"Player"
)
.
toString
()
);
playernameEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getP
layer
N
ame
(
"Player"
));
playernameLabel
->
setBuddy
(
playernameEdit
);
passwordLabel
=
new
QLabel
(
tr
(
"P&assword:"
));
passwordEdit
=
new
QLineEdit
(
settings
.
value
(
"password"
).
toString
());
passwordEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getPassword
());
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordEdit
->
setEchoMode
(
QLineEdit
::
Password
);
savePasswordCheckBox
=
new
QCheckBox
(
tr
(
"&Save password"
));
savePasswordCheckBox
->
setChecked
(
settings
.
value
(
"s
ave
_p
assword
"
,
1
).
toInt
());
savePasswordCheckBox
->
setChecked
(
settings
Cache
->
servers
().
getS
ave
P
assword
());
autoConnectCheckBox
=
new
QCheckBox
(
tr
(
"A&uto connect at start"
));
if
(
savePasswordCheckBox
->
isChecked
())
{
autoConnectCheckBox
->
setChecked
(
settings
.
value
(
"a
uto
_c
onnect
"
,
0
).
toInt
());
autoConnectCheckBox
->
setChecked
(
settings
Cache
->
servers
().
getA
uto
C
onnect
());
autoConnectCheckBox
->
setEnabled
(
true
);
}
else
{
settings
.
setValue
(
"a
uto
_c
onnect
"
,
0
);
settings
Cache
->
servers
().
setA
uto
C
onnect
(
0
);
autoConnectCheckBox
->
setChecked
(
0
);
autoConnectCheckBox
->
setEnabled
(
false
);
}
...
...
@@ -98,7 +95,7 @@ DlgConnect::DlgConnect(QWidget *parent)
connect
(
previousHostButton
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
previousHostSelected
(
bool
)));
connect
(
newHostButton
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
newHostSelected
(
bool
)));
if
(
settings
.
value
(
"p
revious
h
ost
l
ogin
"
,
1
).
toInt
())
if
(
settings
Cache
->
servers
().
getP
revious
H
ost
L
ogin
())
previousHostButton
->
setChecked
(
true
);
else
newHostButton
->
setChecked
(
true
);
...
...
@@ -133,14 +130,12 @@ void DlgConnect::passwordSaved(int state)
void
DlgConnect
::
actOk
()
{
QSettings
settings
;
settings
.
beginGroup
(
"server"
);
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
);
settingsCache
->
servers
().
setPort
(
portEdit
->
text
());
settingsCache
->
servers
().
setPlayerName
(
playernameEdit
->
text
());
settingsCache
->
servers
().
setPassword
(
savePasswordCheckBox
->
isChecked
()
?
passwordEdit
->
text
()
:
QString
());
settingsCache
->
servers
().
setSavePassword
(
savePasswordCheckBox
->
isChecked
()
?
1
:
0
);
settingsCache
->
servers
().
setAutoConnect
(
autoConnectCheckBox
->
isChecked
()
?
1
:
0
);
settingsCache
->
servers
().
setPreviousHostLogin
(
previousHostButton
->
isChecked
()
?
1
:
0
);
QStringList
hostList
;
if
(
newHostButton
->
isChecked
())
...
...
@@ -151,9 +146,8 @@ void DlgConnect::actOk()
if
(
!
previousHosts
->
itemText
(
i
).
trimmed
().
isEmpty
())
hostList
<<
previousHosts
->
itemText
(
i
);
settings
.
setValue
(
"previoushosts"
,
hostList
);
settings
.
setValue
(
"previoushostindex"
,
previousHosts
->
currentIndex
());
settings
.
endGroup
();
settingsCache
->
servers
().
setPreviousHostList
(
hostList
);
settingsCache
->
servers
().
setPrevioushostindex
(
previousHosts
->
currentIndex
());
accept
();
}
...
...
@@ -165,12 +159,8 @@ QString DlgConnect::getHost() const {
void
DlgConnect
::
actCancel
()
{
QSettings
settings
;
settings
.
beginGroup
(
"server"
);
settings
.
setValue
(
"save_password"
,
savePasswordCheckBox
->
isChecked
()
?
1
:
0
);
settings
.
setValue
(
"auto_connect"
,
autoConnectCheckBox
->
isChecked
()
?
1
:
0
);
settings
.
endGroup
();
settingsCache
->
servers
().
setSavePassword
(
savePasswordCheckBox
->
isChecked
()
?
1
:
0
);
settingsCache
->
servers
().
setAutoConnect
(
autoConnectCheckBox
->
isChecked
()
?
1
:
0
);
reject
();
}
...
...
cockatrice/src/dlg_edit_password.cpp
View file @
f4ae08f8
...
...
@@ -3,21 +3,19 @@
#include
<QHBoxLayout>
#include
<QLabel>
#include
<QMessageBox>
#include
<QSettings>
#include
"settingscache.h"
#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
(
"s
ave
_p
assword
"
,
1
).
toInt
())
oldPasswordEdit
->
setText
(
settings
.
value
(
"password"
).
toString
());
if
(
settings
Cache
->
servers
().
getS
ave
P
assword
())
oldPasswordEdit
->
setText
(
settings
Cache
->
servers
().
getPassword
());
oldPasswordLabel
->
setBuddy
(
oldPasswordEdit
);
oldPasswordEdit
->
setEchoMode
(
QLineEdit
::
Password
);
...
...
@@ -62,12 +60,8 @@ void DlgEditPassword::actOk()
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
();
settingsCache
->
servers
().
setPassword
(
newPasswordEdit
->
text
());
accept
();
}
...
...
cockatrice/src/dlg_edit_user.cpp
View file @
f4ae08f8
#include
<QSettings>
#include
<QLabel>
#include
<QGridLayout>
#include
<QHBoxLayout>
...
...
cockatrice/src/dlg_filter_games.cpp
View file @
f4ae08f8
...
...
@@ -9,7 +9,6 @@
#include
<QVBoxLayout>
#include
<QGridLayout>
#include
<QDialogButtonBox>
#include
<QSettings>
#include
<QCryptographicHash>
DlgFilterGames
::
DlgFilterGames
(
const
QMap
<
int
,
QString
>
&
_allGameTypes
,
const
GamesProxyModel
*
_gamesProxyModel
,
QWidget
*
parent
)
...
...
@@ -17,9 +16,6 @@ DlgFilterGames::DlgFilterGames(const QMap<int, QString> &_allGameTypes, const Ga
allGameTypes
(
_allGameTypes
),
gamesProxyModel
(
_gamesProxyModel
)
{
QSettings
settings
;
settings
.
beginGroup
(
"filter_games"
);
unavailableGamesVisibleCheckBox
=
new
QCheckBox
(
tr
(
"Show &unavailable games"
));
unavailableGamesVisibleCheckBox
->
setChecked
(
gamesProxyModel
->
getUnavailableGamesVisible
());
...
...
cockatrice/src/dlg_register.cpp
View file @
f4ae08f8
#include
<QSettings>
#include
<QLabel>
#include
<QCheckBox>
#include
<QGridLayout>
...
...
@@ -14,23 +13,20 @@
DlgRegister
::
DlgRegister
(
QWidget
*
parent
)
:
QDialog
(
parent
)
{
QSettings
settings
;
settings
.
beginGroup
(
"server"
);
hostLabel
=
new
QLabel
(
tr
(
"&Host:"
));
hostEdit
=
new
QLineEdit
(
settings
.
value
(
"h
ostname
"
,
"cockatrice.woogerworks.com"
)
.
toString
()
);
hostEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getH
ostname
(
"cockatrice.woogerworks.com"
));
hostLabel
->
setBuddy
(
hostEdit
);
portLabel
=
new
QLabel
(
tr
(
"&Port:"
));
portEdit
=
new
QLineEdit
(
settings
.
value
(
"port"
,
"4747"
).
toString
(
));
portLabel
=
new
QLabel
(
tr
(
"&Port:"
));
portEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getPort
(
"4747"
));
portLabel
->
setBuddy
(
portEdit
);
playernameLabel
=
new
QLabel
(
tr
(
"Player &name:"
));
playernameEdit
=
new
QLineEdit
(
settings
.
value
(
"p
layer
n
ame
"
,
"Player"
)
.
toString
()
);
playernameLabel
=
new
QLabel
(
tr
(
"Player &name:"
));
playernameEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getP
layer
N
ame
(
"Player"
));
playernameLabel
->
setBuddy
(
playernameEdit
);
passwordLabel
=
new
QLabel
(
tr
(
"P&assword:"
));
passwordEdit
=
new
QLineEdit
(
settings
.
value
(
"password"
).
toString
());
passwordLabel
=
new
QLabel
(
tr
(
"P&assword:"
));
passwordEdit
=
new
QLineEdit
(
settings
Cache
->
servers
().
getPassword
());
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordEdit
->
setEchoMode
(
QLineEdit
::
Password
);
...
...
@@ -366,14 +362,11 @@ void DlgRegister::actOk()
return
;
}
QSettings
settings
;
settings
.
beginGroup
(
"server"
);
settings
.
setValue
(
"hostname"
,
hostEdit
->
text
());
settings
.
setValue
(
"port"
,
portEdit
->
text
());
settings
.
setValue
(
"playername"
,
playernameEdit
->
text
());
settingsCache
->
servers
().
setHostName
(
hostEdit
->
text
());
settingsCache
->
servers
().
setPort
(
portEdit
->
text
());
settingsCache
->
servers
().
setPlayerName
(
playernameEdit
->
text
());
// always save the password so it will be picked up by the connect dialog
settings
.
setValue
(
"password"
,
passwordEdit
->
text
());
settings
.
endGroup
();
settingsCache
->
servers
().
setPassword
(
passwordEdit
->
text
());
accept
();
}
...
...
cockatrice/src/dlg_settings.cpp
View file @
f4ae08f8
...
...
@@ -13,7 +13,6 @@
#include
<QToolBar>
#include
<QTranslator>
#include
<QAction>
#include
<QSettings>
#include
<QApplication>
#include
<QInputDialog>
#include
<QSpinBox>
...
...
@@ -46,6 +45,7 @@ GeneralSettingsPage::GeneralSettingsPage()
picDownloadCheckBox
.
setChecked
(
settingsCache
->
getPicDownload
());
picDownloadHqCheckBox
.
setChecked
(
settingsCache
->
getPicDownloadHq
());
updateNotificationCheckBox
.
setChecked
(
settingsCache
->
getNotifyAboutUpdates
());
pixmapCacheEdit
.
setMinimum
(
PIXMAPCACHE_SIZE_MIN
);
// 2047 is the max value to avoid overflowing of QPixmapCache::setCacheLimit(int size)
...
...
@@ -65,19 +65,21 @@ GeneralSettingsPage::GeneralSettingsPage()
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
(
&
updateNotificationCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
settingsCache
,
SLOT
(
setNotifyAboutUpdate
(
int
)));
connect
(
highQualityURLEdit
,
SIGNAL
(
textChanged
(
QString
)),
settingsCache
,
SLOT
(
setPicUrlHq
(
QString
)));
QGridLayout
*
personalGrid
=
new
QGridLayout
;
personalGrid
->
addWidget
(
&
languageLabel
,
0
,
0
);
personalGrid
->
addWidget
(
&
languageBox
,
0
,
1
);
personalGrid
->
addWidget
(
&
pixmapCacheLabel
,
1
,
0
,
1
,
1
);
personalGrid
->
addWidget
(
&
pixmapCacheEdit
,
1
,
1
,
1
,
1
);
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
);
personalGrid
->
addWidget
(
&
pixmapCacheLabel
,
1
,
0
);
personalGrid
->
addWidget
(
&
pixmapCacheEdit
,
1
,
1
);
personalGrid
->
addWidget
(
&
updateNotificationCheckBox
,
2
,
0
);
personalGrid
->
addWidget
(
&
picDownloadCheckBox
,
3
,
0
);
personalGrid
->
addWidget
(
&
picDownloadHqCheckBox
,
4
,
0
);
personalGrid
->
addWidget
(
&
highQualityURLLabel
,
5
,
0
);
personalGrid
->
addWidget
(
highQualityURLEdit
,
5
,
1
);
personalGrid
->
addWidget
(
&
highQualityURLLinkLabel
,
6
,
1
);
personalGrid
->
addWidget
(
&
clearDownloadedPicsButton
,
6
,
0
);
highQualityURLLinkLabel
.
setTextInteractionFlags
(
Qt
::
LinksAccessibleByMouse
);
highQualityURLLinkLabel
.
setOpenExternalLinks
(
true
);
...
...
@@ -247,6 +249,7 @@ void GeneralSettingsPage::retranslateUi()
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"
));
updateNotificationCheckBox
.
setText
(
tr
(
"Notify when new client features are available"
));
}
void
GeneralSettingsPage
::
setEnabledStatus
(
bool
status
)
...
...
@@ -512,12 +515,11 @@ MessagesSettingsPage::MessagesSettingsPage()
highlightGroupBox
=
new
QGroupBox
;
highlightGroupBox
->
setLayout
(
highlightNotice
);
QSettings
settings
;
messageList
=
new
QListWidget
;
settings
.
beginGroup
(
"messages"
);
int
count
=
settings
.
value
(
"count"
,
0
).
toI
nt
();
int
count
=
settings
Cache
->
messages
().
getCou
nt
();
for
(
int
i
=
0
;
i
<
count
;
i
++
)
messageList
->
addItem
(
settings
.
value
(
QString
(
"msg%1"
).
arg
(
i
)).
toString
(
));
messageList
->
addItem
(
settings
Cache
->
messages
().
getMessageAt
(
i
));
aAdd
=
new
QAction
(
this
);
aAdd
->
setIcon
(
QIcon
(
"theme:icons/increment.svg"
));
...
...
@@ -589,11 +591,9 @@ void MessagesSettingsPage::updateHighlightPreview() {
void
MessagesSettingsPage
::
storeSettings
()
{
QSettings
settings
;
settings
.
beginGroup
(
"messages"
);
settings
.
setValue
(
"count"
,
messageList
->
count
());
settingsCache
->
messages
().
setCount
(
messageList
->
count
());
for
(
int
i
=
0
;
i
<
messageList
->
count
();
i
++
)
settings
.
setValue
(
QString
(
"msg%1"
).
arg
(
i
)
,
messageList
->
item
(
i
)
->
text
());
settings
Cache
->
messages
().
setMessageAt
(
i
,
messageList
->
item
(
i
)
->
text
());
}
void
MessagesSettingsPage
::
actAdd
()
...
...
@@ -918,3 +918,4 @@ void DlgSettings::retranslateUi()
for
(
int
i
=
0
;
i
<
pagesWidget
->
count
();
i
++
)
dynamic_cast
<
AbstractSettingsPage
*>
(
pagesWidget
->
widget
(
i
))
->
retranslateUi
();
}
cockatrice/src/dlg_settings.h
View file @
f4ae08f8
...
...
@@ -60,6 +60,7 @@ private:
QComboBox
languageBox
;
QCheckBox
picDownloadCheckBox
;
QCheckBox
picDownloadHqCheckBox
;
QCheckBox
updateNotificationCheckBox
;
QLabel
languageLabel
;
QLabel
pixmapCacheLabel
;
QLabel
deckPathLabel
;
...
...
cockatrice/src/gamesmodel.cpp
View file @
f4ae08f8
#include
"gamesmodel.h"
#include
"pb/serverinfo_game.pb.h"
#include
"pixmapgenerator.h"
#include
"settingscache.h"
#include
<QDebug>
#include
<QIcon>
#include
<QStringList>
#include
<QDateTime>
#include
<QSettings>
#include
<QCryptographicHash>
enum
GameListColumn
{
ROOM
,
CREATED
,
DESCRIPTION
,
CREATOR
,
GAME_TYPE
,
RESTRICTIONS
,
PLAYERS
,
SPECTATORS
};
...
...
@@ -283,19 +283,17 @@ void GamesProxyModel::resetFilterParameters()
void
GamesProxyModel
::
loadFilterParameters
(
const
QMap
<
int
,
QString
>
&
allGameTypes
)
{
QSettings
settings
;
settings
.
beginGroup
(
"filter_games"
);
unavailableGamesVisible
=
settings
.
value
(
"u
navailable
_g
ames
_v
isible
"
,
false
).
toBool
();
showPasswordProtectedGames
=
settings
.
value
(
"s
how
_p
assword
_p
rotected
_g
ames
"
,
true
).
toBool
();
gameNameFilter
=
settings
.
value
(
"g
ame
_n
ame
_f
ilter
"
,
""
).
toString
();
maxPlayersFilterMin
=
settings
.
value
(
"min_players"
,
1
).
toInt
();
maxPlayersFilterMax
=
settings
.
value
(
"max_players"
,
DEFAULT_MAX_PLAYERS_MAX
).
toInt
();
unavailableGamesVisible
=
settings
Cache
->
gameFilters
().
isU
navailable
G
ames
V
isible
();
showPasswordProtectedGames
=
settings
Cache
->
gameFilters
().
isS
how
P
assword
P
rotected
G
ames
();
gameNameFilter
=
settings
Cache
->
gameFilters
().
getG
ame
N
ame
F
ilter
();
maxPlayersFilterMin
=
settings
Cache
->
gameFilters
().
getMinPlayers
();
maxPlayersFilterMax
=
settings
Cache
->
gameFilters
().
getMaxPlayers
();
QMapIterator
<
int
,
QString
>
gameTypesIterator
(
allGameTypes
);
while
(
gameTypesIterator
.
hasNext
())
{
gameTypesIterator
.
next
();
if
(
settings
.
value
(
"game_type/"
+
hash
GameType
(
gameTypesIterator
.
value
())
,
false
).
toBool
())
{
if
(
settings
Cache
->
gameFilters
().
is
GameType
Enabled
(
gameTypesIterator
.
value
())
)
{
gameTypeFilter
.
insert
(
gameTypesIterator
.
key
());
}
}
...
...
@@ -305,28 +303,19 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
void
GamesProxyModel
::
saveFilterParameters
(
const
QMap
<
int
,
QString
>
&
allGameTypes
)
{
QSettings
settings
;
settings
.
beginGroup
(
"filter_games"
);
settings
.
setValue
(
"unavailable_games_visible"
,
unavailableGamesVisible
);
settings
.
setValue
(
"show_password_protected_games"
,
showPasswordProtectedGames
);
settings
.
setValue
(
"game_name_filter"
,
gameNameFilter
);
settingsCache
->
gameFilters
().
setUnavailableGamesVisible
(
unavailableGamesVisible
);
settingsCache
->
gameFilters
().
setShowPasswordProtectedGames
(
showPasswordProtectedGames
);
settingsCache
->
gameFilters
().
setGameNameFilter
(
gameNameFilter
);
QMapIterator
<
int
,
QString
>
gameTypeIterator
(
allGameTypes
);
while
(
gameTypeIterator
.
hasNext
())
{
gameTypeIterator
.
next
();
settings
.
setValue
(
"game_type/"
+
hashGameType
(
gameTypeIterator
.
value
()),
gameTypeFilter
.
contains
(
gameTypeIterator
.
key
())
);
bool
enabled
=
gameTypeFilter
.
contains
(
gameTypeIterator
.
key
());
settingsCache
->
gameFilters
().
setGameTypeEnabled
(
gameTypeIterator
.
value
(),
enabled
);
}
settings
.
setValue
(
"min_p
layers
"
,
maxPlayersFilterMin
);
settings
.
setValue
(
"max_p
layers
"
,
maxPlayersFilterMax
);
settings
Cache
->
gameFilters
().
setMinP
layers
(
maxPlayersFilterMin
);
settings
Cache
->
gameFilters
().
setMaxP
layers
(
maxPlayersFilterMax
);
}
bool
GamesProxyModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
/*sourceParent*/
)
const
...
...
@@ -367,7 +356,3 @@ bool GamesProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &/*sourc
return
true
;
}
QString
GamesProxyModel
::
hashGameType
(
const
QString
&
gameType
)
const
{
return
QCryptographicHash
::
hash
(
gameType
.
toUtf8
(),
QCryptographicHash
::
Md5
).
toHex
();
}
cockatrice/src/gamesmodel.h
View file @
f4ae08f8
...
...
@@ -52,13 +52,7 @@ private:
QSet
<
int
>
gameTypeFilter
;
int
maxPlayersFilterMin
,
maxPlayersFilterMax
;
static
const
int
DEFAULT_MAX_PLAYERS_MAX
=
99
;
/*
* The game type might contain special characters, so to use it in
* QSettings we just hash it.
*/
QString
hashGameType
(
const
QString
&
gameType
)
const
;
static
const
int
DEFAULT_MAX_PLAYERS_MAX
=
99
;
public:
GamesProxyModel
(
QObject
*
parent
=
0
,
ServerInfo_User
*
_ownUser
=
0
);
...
...
cockatrice/src/main.cpp
View file @
f4ae08f8
...
...
@@ -26,7 +26,6 @@
#include
<QTranslator>
#include
<QLibraryInfo>
#include
<QDateTime>
#include
<QSettings>
#include
<QIcon>
#include
<QDir>
#include
<QDesktopServices>
...
...
@@ -34,7 +33,6 @@
#include
<QSystemTrayIcon>
#include
"QtNetwork/QNetworkInterface"
#include
<QCryptographicHash>
#include
"main.h"
#include
"window_main.h"
#include
"dlg_settings.h"
...
...
@@ -44,6 +42,7 @@
#include
"pixmapgenerator.h"
#include
"rng_sfmt.h"
#include
"soundengine.h"
#include
"featureset.h"
//Q_IMPORT_PLUGIN(qjpeg)
...
...
@@ -156,11 +155,15 @@ int main(int argc, char *argv[])
installNewTranslator
();
qsrand
(
QDateTime
::
currentDateTime
().
toTime_t
());
#ifdef PORTABLE_BUILD
const
QString
dataDir
=
"data/"
;
#else
#if QT_VERSION < 0x050000
const
QString
dataDir
=
QDesktopServices
::
storageLocation
(
QDesktopServices
::
DataLocation
);
#else
const
QString
dataDir
=
QStandardPaths
::
standardLocations
(
QStandardPaths
::
DataLocation
).
first
();
#endif
#endif
if
(
!
db
->
getLoadSuccess
())
if
(
!
db
->
loadCardDatabase
(
dataDir
+
"/cards.xml"
))
...
...
cockatrice/src/player.cpp
View file @
f4ae08f8
...
...
@@ -21,7 +21,6 @@
#include
"color.h"
#include
"deck_loader.h"
#include
"main.h"
#include
<QSettings>
#include
<QPainter>
#include
<QMenu>
#include
<QDebug>
...
...
@@ -826,12 +825,10 @@ void Player::initSayMenu()
{
sayMenu
->
clear
();
QSettings
settings
;
settings
.
beginGroup
(
"messages"
);
int
count
=
settings
.
value
(
"count"
,
0
).
toInt
();
int
count
=
settingsCache
->
messages
().
getCount
();
for
(
int
i
=
0
;
i
<
count
;
i
++
)
{
QAction
*
newAction
=
new
QAction
(
settings
.
value
(
QString
(
"msg%1"
).
arg
(
i
)).
toString
(
),
this
);
QAction
*
newAction
=
new
QAction
(
settings
Cache
->
messages
().
getMessageAt
(
i
),
this
);
if
(
i
<=
10
){
newAction
->
setShortcut
(
QKeySequence
(
"Ctrl+"
+
QString
::
number
((
i
+
1
)
%
10
)));
}
...
...
cockatrice/src/remoteclient.cpp
View file @
f4ae08f8
#include
<QList>
#include
<QTimer>
#include
<QThread>
#include
"remoteclient.h"
...
...
@@ -81,7 +82,6 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
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
)));
sendCommand
(
pend
);
...
...
@@ -105,8 +105,7 @@ void RemoteClient::processServerIdentificationEvent(const Event_ServerIdentifica
doLogin
();
}
void
RemoteClient
::
doLogin
()
{
void
RemoteClient
::
doLogin
()
{
setStatus
(
StatusLoggingIn
);
Command_Login
cmdLogin
;
...
...
@@ -114,6 +113,13 @@ void RemoteClient::doLogin()
cmdLogin
.
set_password
(
password
.
toStdString
());
cmdLogin
.
set_clientid
(
settingsCache
->
getClientID
().
toStdString
());
cmdLogin
.
set_clientver
(
VERSION_STRING
);
if
(
!
clientFeatures
.
isEmpty
())
{
QMap
<
QString
,
bool
>::
iterator
i
;
for
(
i
=
clientFeatures
.
begin
();
i
!=
clientFeatures
.
end
();
++
i
)
cmdLogin
.
add_clientfeatures
(
i
.
key
().
toStdString
().
c_str
());
}
PendingCommand
*
pend
=
prepareSessionCommand
(
cmdLogin
);
connect
(
pend
,
SIGNAL
(
finished
(
Response
,
CommandContainer
,
QVariant
)),
this
,
SLOT
(
loginResponse
(
Response
)));
sendCommand
(
pend
);
...
...
@@ -140,8 +146,17 @@ void RemoteClient::loginResponse(const Response &response)
for
(
int
i
=
resp
.
ignore_list_size
()
-
1
;
i
>=
0
;
--
i
)
ignoreList
.
append
(
resp
.
ignore_list
(
i
));
emit
ignoreListReceived
(
ignoreList
);
if
(
resp
.
missing_features_size
()
>
0
&&
settingsCache
->
getNotifyAboutUpdates
())
emit
notifyUserAboutUpdate
();
}
else
{
emit
loginError
(
response
.
response_code
(),
QString
::
fromStdString
(
resp
.
denied_reason_str
()),
resp
.
denied_end_time
());
QList
<
QString
>
missingFeatures
;
if
(
resp
.
missing_features_size
()
>
0
)
{
for
(
int
i
=
0
;
i
<
resp
.
missing_features_size
();
++
i
)
missingFeatures
<<
QString
::
fromStdString
(
resp
.
missing_features
(
i
));
}
emit
loginError
(
response
.
response_code
(),
QString
::
fromStdString
(
resp
.
denied_reason_str
()),
resp
.
denied_end_time
(),
missingFeatures
);
setStatus
(
StatusDisconnecting
);
}
}
...
...
cockatrice/src/remoteclient.h
View file @
f4ae08f8
...
...
@@ -11,7 +11,7 @@ class RemoteClient : public AbstractClient {
signals:
void
maxPingTime
(
int
seconds
,
int
maxSeconds
);
void
serverTimeout
();
void
loginError
(
Response
::
ResponseCode
resp
,
QString
reasonStr
,
quint32
endTime
);
void
loginError
(
Response
::
ResponseCode
resp
,
QString
reasonStr
,
quint32
endTime
,
QList
<
QString
>
missingFeatures
);
void
registerError
(
Response
::
ResponseCode
resp
,
QString
reasonStr
,
quint32
endTime
);
void
activateError
();
void
socketError
(
const
QString
&
errorString
);
...
...
@@ -21,6 +21,7 @@ signals:
void
sigRegisterToServer
(
const
QString
&
hostname
,
unsigned
int
port
,
const
QString
&
_userName
,
const
QString
&
_password
,
const
QString
&
_email
,
const
int
_gender
,
const
QString
&
_country
,
const
QString
&
_realname
);
void
sigActivateToServer
(
const
QString
&
_token
);
void
sigDisconnectFromServer
();
void
notifyUserAboutUpdate
();
private
slots
:
void
slotConnected
();
void
readData
();
...
...
cockatrice/src/settings/carddatabasesettings.cpp
0 → 100644
View file @
f4ae08f8
#include
"carddatabasesettings.h"
CardDatabaseSettings
::
CardDatabaseSettings
(
QString
settingPath
,
QObject
*
parent
)
:
SettingsManager
(
settingPath
+
"cardDatabase.ini"
,
parent
)
{
}
void
CardDatabaseSettings
::
setSortKey
(
QString
shortName
,
unsigned
int
sortKey
)
{
setValue
(
sortKey
,
"sortkey"
,
"sets"
,
shortName
);
}
void
CardDatabaseSettings
::
setEnabled
(
QString
shortName
,
bool
enabled
)
{
setValue
(
enabled
,
"enabled"
,
"sets"
,
shortName
);
}
void
CardDatabaseSettings
::
setIsKnown
(
QString
shortName
,
bool
isknown
)
{
setValue
(
isknown
,
"isknown"
,
"sets"
,
shortName
);
}
unsigned
int
CardDatabaseSettings
::
getSortKey
(
QString
shortName
)
{
return
getValue
(
"sortkey"
,
"sets"
,
shortName
).
toUInt
();
}
bool
CardDatabaseSettings
::
isEnabled
(
QString
shortName
)
{
return
getValue
(
"enabled"
,
"sets"
,
shortName
).
toBool
();
}
bool
CardDatabaseSettings
::
isKnown
(
QString
shortName
)
{
return
getValue
(
"isknown"
,
"sets"
,
shortName
).
toBool
();
}
cockatrice/src/settings/carddatabasesettings.h
0 → 100644
View file @
f4ae08f8
#ifndef CARDDATABASESETTINGS_H
#define CARDDATABASESETTINGS_H
#include
"settingsmanager.h"
#include
<QObject>
#include
<QVariant>
#include
<QSettings>
class
CardDatabaseSettings
:
public
SettingsManager
{
Q_OBJECT
friend
class
SettingsCache
;
public:
void
setSortKey
(
QString
shortName
,
unsigned
int
sortKey
);
void
setEnabled
(
QString
shortName
,
bool
enabled
);
void
setIsKnown
(
QString
shortName
,
bool
isknown
);
unsigned
int
getSortKey
(
QString
shortName
);
bool
isEnabled
(
QString
shortName
);
bool
isKnown
(
QString
shortName
);
signals:
public
slots
:
private:
CardDatabaseSettings
(
QString
settingPath
,
QObject
*
parent
=
0
);
CardDatabaseSettings
(
const
CardDatabaseSettings
&
/*other*/
);
CardDatabaseSettings
(
CardDatabaseSettings
&
/*other*/
);
CardDatabaseSettings
(
volatile
const
CardDatabaseSettings
&
/*other*/
);
CardDatabaseSettings
(
volatile
CardDatabaseSettings
&
/*other*/
);
};
#endif // CARDDATABASESETTINGS_H
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment