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
6b14b4e5
Commit
6b14b4e5
authored
Mar 30, 2012
by
Max-Wilhelm Bruker
Browse files
added game filter dialog in GameSelector; switched all dialogs to QDialogButtonBox; issue #32 fixed
parent
facfc3cc
Changes
21
Hide whitespace changes
Inline
Side-by-side
cockatrice/CMakeLists.txt
View file @
6b14b4e5
...
...
@@ -6,6 +6,7 @@ SET(cockatrice_SOURCES
src/abstractcounter.cpp
src/counter_general.cpp
src/dlg_creategame.cpp
src/dlg_filter_games.cpp
src/dlg_connect.cpp
src/dlg_create_token.cpp
src/abstractclient.cpp
...
...
@@ -79,6 +80,7 @@ SET(cockatrice_HEADERS
src/abstractcounter.h
src/counter_general.h
src/dlg_creategame.h
src/dlg_filter_games.h
src/dlg_connect.h
src/dlg_create_token.h
src/gamesmodel.h
...
...
cockatrice/src/dlg_connect.cpp
View file @
6b14b4e5
#include
<QSettings>
#include
<QLabel>
#include
<QPushButton>
#include
<QCheckBox>
#include
<QGridLayout>
#include
<QHBoxLayout>
#include
<QDialogButtonBox>
#include
"dlg_connect.h"
DlgConnect
::
DlgConnect
(
QWidget
*
parent
)
...
...
@@ -32,10 +32,6 @@ DlgConnect::DlgConnect(QWidget *parent)
savePasswordCheckBox
=
new
QCheckBox
(
tr
(
"&Save password"
));
savePasswordCheckBox
->
setChecked
(
settings
.
value
(
"save_password"
,
1
).
toInt
());
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QGridLayout
*
grid
=
new
QGridLayout
;
grid
->
addWidget
(
hostLabel
,
0
,
0
);
grid
->
addWidget
(
hostEdit
,
0
,
1
);
...
...
@@ -46,23 +42,19 @@ DlgConnect::DlgConnect(QWidget *parent)
grid
->
addWidget
(
passwordLabel
,
3
,
0
);
grid
->
addWidget
(
passwordEdit
,
3
,
1
);
grid
->
addWidget
(
savePasswordCheckBox
,
4
,
0
,
1
,
2
);
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOk
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
grid
);
mainLayout
->
add
Layou
t
(
button
Layout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Connect to server"
));
setFixedHeight
(
sizeHint
().
height
());
setMinimumWidth
(
300
);
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOk
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
}
void
DlgConnect
::
actOk
()
...
...
cockatrice/src/dlg_connect.h
View file @
6b14b4e5
...
...
@@ -22,7 +22,6 @@ private:
QLabel
*
hostLabel
,
*
portLabel
,
*
playernameLabel
,
*
passwordLabel
;
QLineEdit
*
hostEdit
,
*
portEdit
,
*
playernameEdit
,
*
passwordEdit
;
QCheckBox
*
savePasswordCheckBox
;
QPushButton
*
okButton
,
*
cancelButton
;
};
#endif
cockatrice/src/dlg_create_token.cpp
View file @
6b14b4e5
#include
<QLabel>
#include
<QLineEdit>
#include
<QComboBox>
#include
<QPushButton>
#include
<QCheckBox>
#include
<QGridLayout>
#include
<QHBoxLayout>
#include
<QVBoxLayout>
#include
<QDialogButtonBox>
#include
"dlg_create_token.h"
DlgCreateToken
::
DlgCreateToken
(
QWidget
*
parent
)
...
...
@@ -38,10 +38,6 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
destroyCheckBox
=
new
QCheckBox
(
tr
(
"&Destroy token when it leaves the table"
));
destroyCheckBox
->
setChecked
(
true
);
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QGridLayout
*
grid
=
new
QGridLayout
;
grid
->
addWidget
(
nameLabel
,
0
,
0
);
grid
->
addWidget
(
nameEdit
,
0
,
1
);
...
...
@@ -52,23 +48,19 @@ DlgCreateToken::DlgCreateToken(QWidget *parent)
grid
->
addWidget
(
annotationLabel
,
3
,
0
);
grid
->
addWidget
(
annotationEdit
,
3
,
1
);
grid
->
addWidget
(
destroyCheckBox
,
4
,
0
,
1
,
2
);
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOk
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
grid
);
mainLayout
->
add
Layou
t
(
button
Layout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Create token"
));
setFixedHeight
(
sizeHint
().
height
());
setMinimumWidth
(
300
);
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOk
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
}
void
DlgCreateToken
::
actOk
()
...
...
cockatrice/src/dlg_create_token.h
View file @
6b14b4e5
...
...
@@ -25,7 +25,6 @@ private:
QComboBox
*
colorEdit
;
QLineEdit
*
nameEdit
,
*
ptEdit
,
*
annotationEdit
;
QCheckBox
*
destroyCheckBox
;
QPushButton
*
okButton
,
*
cancelButton
;
};
#endif
cockatrice/src/dlg_creategame.cpp
View file @
6b14b4e5
...
...
@@ -7,6 +7,7 @@
#include
<QHBoxLayout>
#include
<QSpinBox>
#include
<QGroupBox>
#include
<QDialogButtonBox>
#include
<QMessageBox>
#include
<QSet>
#include
"dlg_creategame.h"
...
...
@@ -85,18 +86,12 @@ void DlgCreateGame::sharedCtor()
grid
->
addWidget
(
joinRestrictionsGroupBox
,
0
,
1
);
grid
->
addWidget
(
gameTypeGroupBox
,
1
,
1
);
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
);
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
grid
);
mainLayout
->
add
Layou
t
(
button
Layout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
...
...
@@ -108,10 +103,10 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
{
sharedCtor
();
setWindowTitle
(
tr
(
"Create game"
));
buttonBox
->
addButton
(
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOK
()));
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOK
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
setWindowTitle
(
tr
(
"Create game"
));
}
DlgCreateGame
::
DlgCreateGame
(
const
ServerInfo_Game
&
gameInfo
,
const
QMap
<
int
,
QString
>
&
_gameTypes
,
QWidget
*
parent
)
...
...
@@ -151,10 +146,9 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
gameTypeCheckBox
->
setChecked
(
types
.
contains
(
gameTypeIterator
.
key
()));
}
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
setWindowTitle
(
tr
(
"Game information"
));
okButton
->
setAutoDefault
(
true
);
cancelButton
->
hide
();
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
accept
()));
}
void
DlgCreateGame
::
actOK
()
...
...
@@ -181,14 +175,12 @@ void DlgCreateGame::actOK()
connect
(
pend
,
SIGNAL
(
finished
(
Response
,
CommandContainer
,
QVariant
)),
this
,
SLOT
(
checkResponse
(
Response
)));
room
->
sendRoomCommand
(
pend
);
okButton
->
setEnabled
(
false
);
cancelButton
->
setEnabled
(
false
);
buttonBox
->
setEnabled
(
false
);
}
void
DlgCreateGame
::
checkResponse
(
const
Response
&
response
)
{
okButton
->
setEnabled
(
true
);
cancelButton
->
setEnabled
(
true
);
buttonBox
->
setEnabled
(
true
);
if
(
response
.
response_code
()
==
Response
::
RespOk
)
accept
();
...
...
cockatrice/src/dlg_creategame.h
View file @
6b14b4e5
...
...
@@ -10,6 +10,7 @@ class QPushButton;
class
QCheckBox
;
class
QGroupBox
;
class
QSpinBox
;
class
QDialogButtonBox
;
class
TabRoom
;
class
Response
;
...
...
@@ -35,7 +36,7 @@ private:
QSpinBox
*
maxPlayersEdit
;
QCheckBox
*
onlyBuddiesCheckBox
,
*
onlyRegisteredCheckBox
;
QCheckBox
*
spectatorsAllowedCheckBox
,
*
spectatorsNeedPasswordCheckBox
,
*
spectatorsCanTalkCheckBox
,
*
spectatorsSeeEverythingCheckBox
;
Q
PushButton
*
okButton
,
*
cancelButton
;
Q
DialogButtonBox
*
buttonBox
;
void
sharedCtor
();
};
...
...
cockatrice/src/dlg_filter_games.cpp
0 → 100644
View file @
6b14b4e5
#include
"dlg_filter_games.h"
#include
<QCheckBox>
#include
<QPushButton>
#include
<QLabel>
#include
<QSpinBox>
#include
<QLineEdit>
#include
<QGroupBox>
#include
<QHBoxLayout>
#include
<QVBoxLayout>
#include
<QGridLayout>
#include
<QDialogButtonBox>
DlgFilterGames
::
DlgFilterGames
(
const
QMap
<
int
,
QString
>
&
allGameTypes
,
QWidget
*
parent
)
:
QDialog
(
parent
)
{
unavailableGamesVisibleCheckBox
=
new
QCheckBox
(
tr
(
"Show &unavailable games"
));
QLabel
*
gameNameFilterLabel
=
new
QLabel
(
tr
(
"Game &description:"
));
gameNameFilterEdit
=
new
QLineEdit
;
QLabel
*
creatorNameFilterLabel
=
new
QLabel
(
tr
(
"&Creator name:"
));
creatorNameFilterEdit
=
new
QLineEdit
;
QVBoxLayout
*
gameTypeFilterLayout
=
new
QVBoxLayout
;
QMapIterator
<
int
,
QString
>
gameTypesIterator
(
allGameTypes
);
while
(
gameTypesIterator
.
hasNext
())
{
gameTypesIterator
.
next
();
QCheckBox
*
temp
=
new
QCheckBox
(
gameTypesIterator
.
value
());
gameTypeFilterCheckBoxes
.
insert
(
gameTypesIterator
.
key
(),
temp
);
gameTypeFilterLayout
->
addWidget
(
temp
);
}
QGroupBox
*
gameTypeFilterGroupBox
;
if
(
!
allGameTypes
.
isEmpty
())
{
gameTypeFilterGroupBox
=
new
QGroupBox
(
tr
(
"&Game types"
));
gameTypeFilterGroupBox
->
setLayout
(
gameTypeFilterLayout
);
}
else
gameTypeFilterGroupBox
=
0
;
QLabel
*
maxPlayersFilterMinLabel
=
new
QLabel
(
tr
(
"at &least:"
));
maxPlayersFilterMinSpinBox
=
new
QSpinBox
;
maxPlayersFilterMinSpinBox
->
setMinimum
(
1
);
maxPlayersFilterMinSpinBox
->
setMaximum
(
99
);
maxPlayersFilterMinSpinBox
->
setValue
(
1
);
maxPlayersFilterMinLabel
->
setBuddy
(
maxPlayersFilterMinSpinBox
);
QLabel
*
maxPlayersFilterMaxLabel
=
new
QLabel
(
tr
(
"at &most:"
));
maxPlayersFilterMaxSpinBox
=
new
QSpinBox
;
maxPlayersFilterMaxSpinBox
->
setMinimum
(
1
);
maxPlayersFilterMaxSpinBox
->
setMaximum
(
99
);
maxPlayersFilterMaxSpinBox
->
setValue
(
99
);
maxPlayersFilterMaxLabel
->
setBuddy
(
maxPlayersFilterMaxSpinBox
);
QGridLayout
*
maxPlayersFilterLayout
=
new
QGridLayout
;
maxPlayersFilterLayout
->
addWidget
(
maxPlayersFilterMinLabel
,
0
,
0
);
maxPlayersFilterLayout
->
addWidget
(
maxPlayersFilterMinSpinBox
,
0
,
1
);
maxPlayersFilterLayout
->
addWidget
(
maxPlayersFilterMaxLabel
,
1
,
0
);
maxPlayersFilterLayout
->
addWidget
(
maxPlayersFilterMaxSpinBox
,
1
,
1
);
QGroupBox
*
maxPlayersGroupBox
=
new
QGroupBox
(
tr
(
"Maximum player count"
));
maxPlayersGroupBox
->
setLayout
(
maxPlayersFilterLayout
);
QGridLayout
*
leftColumn
=
new
QGridLayout
;
leftColumn
->
addWidget
(
gameNameFilterLabel
,
0
,
0
);
leftColumn
->
addWidget
(
gameNameFilterEdit
,
0
,
1
);
leftColumn
->
addWidget
(
creatorNameFilterLabel
,
1
,
0
);
leftColumn
->
addWidget
(
creatorNameFilterEdit
,
1
,
1
);
leftColumn
->
addWidget
(
maxPlayersGroupBox
,
2
,
0
,
1
,
2
);
QVBoxLayout
*
rightColumn
=
new
QVBoxLayout
;
rightColumn
->
addWidget
(
gameTypeFilterGroupBox
);
QHBoxLayout
*
hbox
=
new
QHBoxLayout
;
hbox
->
addLayout
(
leftColumn
);
hbox
->
addLayout
(
rightColumn
);
QPushButton
*
okButton
=
new
QPushButton
(
tr
(
"O&K"
));
okButton
->
setDefault
(
true
);
okButton
->
setAutoDefault
(
true
);
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
accept
()));
QPushButton
*
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
hbox
);
mainLayout
->
addWidget
(
buttonBox
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Filter games"
));
}
bool
DlgFilterGames
::
getUnavailableGamesVisible
()
const
{
return
unavailableGamesVisibleCheckBox
->
isChecked
();
}
void
DlgFilterGames
::
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
)
{
unavailableGamesVisibleCheckBox
->
setChecked
(
_unavailableGamesVisible
);
}
QString
DlgFilterGames
::
getGameNameFilter
()
const
{
return
gameNameFilterEdit
->
text
();
}
void
DlgFilterGames
::
setGameNameFilter
(
const
QString
&
_gameNameFilter
)
{
gameNameFilterEdit
->
setText
(
_gameNameFilter
);
}
QString
DlgFilterGames
::
getCreatorNameFilter
()
const
{
return
creatorNameFilterEdit
->
text
();
}
void
DlgFilterGames
::
setCreatorNameFilter
(
const
QString
&
_creatorNameFilter
)
{
creatorNameFilterEdit
->
setText
(
_creatorNameFilter
);
}
QSet
<
int
>
DlgFilterGames
::
getGameTypeFilter
()
const
{
QSet
<
int
>
result
;
QMapIterator
<
int
,
QCheckBox
*>
i
(
gameTypeFilterCheckBoxes
);
while
(
i
.
hasNext
())
{
i
.
next
();
if
(
i
.
value
()
->
isChecked
())
result
.
insert
(
i
.
key
());
}
return
result
;
}
void
DlgFilterGames
::
setGameTypeFilter
(
const
QSet
<
int
>
&
_gameTypeFilter
)
{
QMapIterator
<
int
,
QCheckBox
*>
i
(
gameTypeFilterCheckBoxes
);
while
(
i
.
hasNext
())
{
i
.
next
();
i
.
value
()
->
setChecked
(
_gameTypeFilter
.
contains
(
i
.
key
()));
}
}
int
DlgFilterGames
::
getMaxPlayersFilterMin
()
const
{
return
maxPlayersFilterMinSpinBox
->
value
();
}
int
DlgFilterGames
::
getMaxPlayersFilterMax
()
const
{
return
maxPlayersFilterMaxSpinBox
->
value
();
}
void
DlgFilterGames
::
setMaxPlayersFilter
(
int
_maxPlayersFilterMin
,
int
_maxPlayersFilterMax
)
{
maxPlayersFilterMinSpinBox
->
setValue
(
_maxPlayersFilterMin
);
maxPlayersFilterMaxSpinBox
->
setValue
(
_maxPlayersFilterMax
==
-
1
?
maxPlayersFilterMaxSpinBox
->
maximum
()
:
_maxPlayersFilterMax
);
}
cockatrice/src/dlg_filter_games.h
0 → 100644
View file @
6b14b4e5
#ifndef DLG_FILTER_GAMES_H
#define DLG_FILTER_GAMES_H
#include
<QDialog>
#include
<QSet>
#include
<QMap>
class
QCheckBox
;
class
QLineEdit
;
class
QSpinBox
;
class
DlgFilterGames
:
public
QDialog
{
Q_OBJECT
private:
QCheckBox
*
unavailableGamesVisibleCheckBox
;
QLineEdit
*
gameNameFilterEdit
;
QLineEdit
*
creatorNameFilterEdit
;
QMap
<
int
,
QCheckBox
*>
gameTypeFilterCheckBoxes
;
QSpinBox
*
maxPlayersFilterMinSpinBox
;
QSpinBox
*
maxPlayersFilterMaxSpinBox
;
public:
DlgFilterGames
(
const
QMap
<
int
,
QString
>
&
allGameTypes
,
QWidget
*
parent
=
0
);
bool
getUnavailableGamesVisible
()
const
;
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
QString
getGameNameFilter
()
const
;
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
QString
getCreatorNameFilter
()
const
;
void
setCreatorNameFilter
(
const
QString
&
_creatorNameFilter
);
QSet
<
int
>
getGameTypeFilter
()
const
;
void
setGameTypeFilter
(
const
QSet
<
int
>
&
_gameTypeFilter
);
int
getMaxPlayersFilterMin
()
const
;
int
getMaxPlayersFilterMax
()
const
;
void
setMaxPlayersFilter
(
int
_maxPlayersFilterMin
,
int
_maxPlayersFilterMax
);
};
#endif
cockatrice/src/dlg_load_deck_from_clipboard.cpp
View file @
6b14b4e5
...
...
@@ -6,6 +6,7 @@
#include
<QKeySequence>
#include
<QApplication>
#include
<QTextStream>
#include
<QDialogButtonBox>
#include
<QMessageBox>
#include
"dlg_load_deck_from_clipboard.h"
#include
"decklist.h"
...
...
@@ -17,28 +18,21 @@ DlgLoadDeckFromClipboard::DlgLoadDeckFromClipboard(QWidget *parent)
refreshButton
=
new
QPushButton
(
tr
(
"&Refresh"
));
refreshButton
->
setShortcut
(
QKeySequence
(
"F5"
));
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addWidget
(
refreshButton
);
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
connect
(
refreshButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actRefresh
()));
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
buttonBox
->
addButton
(
refreshButton
,
QDialogButtonBox
::
ActionRole
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOK
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
contentsEdit
);
mainLayout
->
add
Layou
t
(
button
Layout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Load deck from clipboard"
));
resize
(
500
,
500
);
connect
(
refreshButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actRefresh
()));
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOK
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
actRefresh
();
}
...
...
cockatrice/src/dlg_load_deck_from_clipboard.h
View file @
6b14b4e5
...
...
@@ -19,7 +19,7 @@ public:
DeckList
*
getDeckList
()
const
{
return
deckList
;
}
private:
QPlainTextEdit
*
contentsEdit
;
QPushButton
*
refreshButton
,
*
okButton
,
*
cancelButton
;
QPushButton
*
refreshButton
;
};
#endif
cockatrice/src/dlg_load_remote_deck.cpp
View file @
6b14b4e5
#include
<QPushButton>
#include
<QHBoxLayout>
#include
<QVBoxLayout>
#include
<QDialogButtonBox>
#include
"remotedecklist_treewidget.h"
#include
"dlg_load_remote_deck.h"
#include
"main.h"
...
...
@@ -9,36 +10,27 @@ DlgLoadRemoteDeck::DlgLoadRemoteDeck(AbstractClient *_client, QWidget *parent)
:
QDialog
(
parent
),
client
(
_client
)
{
dirView
=
new
RemoteDeckList_TreeWidget
(
client
);
okButton
=
new
QPushButton
(
tr
(
"O&K"
));
okButton
->
setDefault
(
true
);
okButton
->
setAutoDefault
(
true
);
okButton
->
setEnabled
(
false
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
dirView
);
mainLayout
->
add
Layou
t
(
button
Layout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Load deck"
));
setMinimumWidth
(
sizeHint
().
width
());
resize
(
3
00
,
5
00
);
resize
(
4
00
,
6
00
);
connect
(
dirView
->
selectionModel
(),
SIGNAL
(
currentChanged
(
const
QModelIndex
&
,
const
QModelIndex
&
)),
this
,
SLOT
(
currentItemChanged
(
const
QModelIndex
&
,
const
QModelIndex
&
)));
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
accept
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
}
void
DlgLoadRemoteDeck
::
currentItemChanged
(
const
QModelIndex
&
current
,
const
QModelIndex
&
/*previous*/
)
{
okButton
->
setEnabled
(
dynamic_cast
<
RemoteDeckList_TreeModel
::
FileNode
*>
(
dirView
->
getNode
(
current
)));
buttonBox
->
button
(
QDialogButtonBox
::
Ok
)
->
setEnabled
(
dynamic_cast
<
RemoteDeckList_TreeModel
::
FileNode
*>
(
dirView
->
getNode
(
current
)));
}
int
DlgLoadRemoteDeck
::
getDeckId
()
const
...
...
cockatrice/src/dlg_load_remote_deck.h
View file @
6b14b4e5
...
...
@@ -7,13 +7,14 @@ class RemoteDeckList_TreeWidget;
class
QModelIndex
;
class
AbstractClient
;
class
QPushButton
;
class
QDialogButtonBox
;
class
DlgLoadRemoteDeck
:
public
QDialog
{
Q_OBJECT
private:
AbstractClient
*
client
;
RemoteDeckList_TreeWidget
*
dirView
;
Q
PushButton
*
okButton
,
*
cancelButton
;
Q
DialogButtonBox
*
buttonBox
;
private
slots
:
void
currentItemChanged
(
const
QModelIndex
&
current
,
const
QModelIndex
&
previous
);
public:
...
...
cockatrice/src/dlg_settings.cpp
View file @
6b14b4e5
...
...
@@ -17,6 +17,7 @@
#include
<QApplication>
#include
<QInputDialog>
#include
<QSpinBox>
#include
<QDialogButtonBox>
#include
"carddatabase.h"
#include
"dlg_settings.h"
#include
"main.h"
...
...
@@ -606,9 +607,6 @@ DlgSettings::DlgSettings(QWidget *parent)
pagesWidget
->
addWidget
(
new
DeckEditorSettingsPage
);
pagesWidget
->
addWidget
(
new
MessagesSettingsPage
);
closeButton
=
new
QPushButton
;
connect
(
closeButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
close
()));
createIcons
();
contentsWidget
->
setCurrentRow
(
0
);
...
...
@@ -616,14 +614,13 @@ DlgSettings::DlgSettings(QWidget *parent)
hboxLayout
->
addWidget
(
contentsWidget
);
hboxLayout
->
addWidget
(
pagesWidget
);
QHBoxLayout
*
buttonsLayout
=
new
QHBoxLayout
;
buttonsLayout
->
addStretch
(
1
);
buttonsLayout
->
addWidget
(
closeButton
);
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
close
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
hboxLayout
);
mainLayout
->
addSpacing
(
12
);
mainLayout
->
add
Layou
t
(
button
sLayout
);
mainLayout
->
add
Widge
t
(
button
Box
);
setLayout
(
mainLayout
);
retranslateUi
();
...
...
@@ -712,8 +709,6 @@ void DlgSettings::retranslateUi()
deckEditorButton
->
setText
(
tr
(
"Deck editor"
));
messagesButton
->
setText
(
tr
(
"Messages"
));
closeButton
->
setText
(
tr
(
"&Close"
));
for
(
int
i
=
0
;
i
<
pagesWidget
->
count
();
i
++
)
dynamic_cast
<
AbstractSettingsPage
*>
(
pagesWidget
->
widget
(
i
))
->
retranslateUi
();
}
cockatrice/src/dlg_settings.h
View file @
6b14b4e5
...
...
@@ -129,7 +129,6 @@ private:
QListWidget
*
contentsWidget
;
QStackedWidget
*
pagesWidget
;
QListWidgetItem
*
generalButton
,
*
appearanceButton
,
*
userInterfaceButton
,
*
deckEditorButton
,
*
messagesButton
;
QPushButton
*
closeButton
;
void
createIcons
();
void
retranslateUi
();
protected:
...
...
cockatrice/src/gameselector.cpp
View file @
6b14b4e5
...
...
@@ -8,6 +8,7 @@
#include
<QInputDialog>
#include
"tab_supervisor.h"
#include
"dlg_creategame.h"
#include
"dlg_filter_games.h"
#include
"gameselector.h"
#include
"gamesmodel.h"
#include
"tab_room.h"
...
...
@@ -32,11 +33,14 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
gameListView
->
header
()
->
hideSection
(
1
);
gameListView
->
header
()
->
setResizeMode
(
1
,
QHeaderView
::
ResizeToContents
);
showUnavailableGamesCheckBox
=
new
QCheckBox
;
QVBoxLayout
*
filterLayout
=
new
QVBoxLayout
;
filterLayout
->
addWidget
(
showUnavailableGamesCheckBox
);
filterButton
=
new
QPushButton
;
filterButton
->
setIcon
(
QIcon
(
":/resources/icon_search.svg"
));
connect
(
filterButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actSetFilter
()));
clearFilterButton
=
new
QPushButton
;
clearFilterButton
->
setIcon
(
QIcon
(
":/resources/icon_clearsearch.svg"
));
clearFilterButton
->
setEnabled
(
false
);
connect
(
clearFilterButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actClearFilter
()));
if
(
room
)
{
createButton
=
new
QPushButton
;
connect
(
createButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actCreate
()));
...
...
@@ -46,20 +50,18 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
spectateButton
=
new
QPushButton
;
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addWidget
(
filterButton
);
buttonLayout
->
addWidget
(
clearFilterButton
);
buttonLayout
->
addStretch
();
if
(
room
)
buttonLayout
->
addWidget
(
createButton
);
buttonLayout
->
addWidget
(
joinButton
);
buttonLayout
->
addWidget
(
spectateButton
);
buttonLayout
->
setAlignment
(
Qt
::
AlignTop
);
QHBoxLayout
*
hbox
=
new
QHBoxLayout
;
hbox
->
addLayout
(
filterLayout
);
hbox
->
addStretch
();
hbox
->
addLayout
(
buttonLayout
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
gameListView
);
mainLayout
->
addLayout
(
hbox
);
mainLayout
->
addLayout
(
buttonLayout
);
retranslateUi
();
setLayout
(
mainLayout
);
...
...
@@ -67,14 +69,39 @@ GameSelector::GameSelector(AbstractClient *_client, TabSupervisor *_tabSuperviso
setMinimumWidth
((
qreal
)
(
gameListView
->
columnWidth
(
0
)
*
gameListModel
->
columnCount
())
/
1.5
);
setMinimumHeight
(
200
);
connect
(
showUnavailableGamesCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
showUnavailableGamesChanged
(
int
)));
connect
(
joinButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
connect
(
spectateButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actJoin
()));
}
void
GameSelector
::
showUnavailableGamesChanged
(
int
state
)
void
GameSelector
::
actSetFilter
(
)
{
gameListProxyModel
->
setUnavailableGamesVisible
(
state
);
GameTypeMap
gameTypeMap
;
if
(
room
)
gameTypeMap
=
gameListModel
->
getGameTypes
().
value
(
room
->
getRoomId
());
DlgFilterGames
dlg
(
gameTypeMap
,
this
);
dlg
.
setUnavailableGamesVisible
(
gameListProxyModel
->
getUnavailableGamesVisible
());
dlg
.
setGameNameFilter
(
gameListProxyModel
->
getGameNameFilter
());
dlg
.
setCreatorNameFilter
(
gameListProxyModel
->
getCreatorNameFilter
());
dlg
.
setGameTypeFilter
(
gameListProxyModel
->
getGameTypeFilter
());
dlg
.
setMaxPlayersFilter
(
gameListProxyModel
->
getMaxPlayersFilterMin
(),
gameListProxyModel
->
getMaxPlayersFilterMax
());
if
(
!
dlg
.
exec
())
return
;
clearFilterButton
->
setEnabled
(
true
);
gameListProxyModel
->
setUnavailableGamesVisible
(
dlg
.
getUnavailableGamesVisible
());
gameListProxyModel
->
setGameNameFilter
(
dlg
.
getGameNameFilter
());
gameListProxyModel
->
setCreatorNameFilter
(
dlg
.
getCreatorNameFilter
());
gameListProxyModel
->
setGameTypeFilter
(
dlg
.
getGameTypeFilter
());
gameListProxyModel
->
setMaxPlayersFilter
(
dlg
.
getMaxPlayersFilterMin
(),
dlg
.
getMaxPlayersFilterMax
());
}
void
GameSelector
::
actClearFilter
()
{
clearFilterButton
->
setEnabled
(
false
);
gameListProxyModel
->
resetFilterParameters
();
}
void
GameSelector
::
actCreate
()
...
...
@@ -145,7 +172,8 @@ void GameSelector::actJoin()
void
GameSelector
::
retranslateUi
()
{
setTitle
(
tr
(
"Games"
));
showUnavailableGamesCheckBox
->
setText
(
tr
(
"Show u&navailable games"
));
filterButton
->
setText
(
tr
(
"&Filter games"
));
clearFilterButton
->
setText
(
tr
(
"C&lear filter"
));
if
(
createButton
)
createButton
->
setText
(
tr
(
"C&reate"
));
joinButton
->
setText
(
tr
(
"&Join"
));
...
...
cockatrice/src/gameselector.h
View file @
6b14b4e5
...
...
@@ -19,7 +19,8 @@ class Response;
class
GameSelector
:
public
QGroupBox
{
Q_OBJECT
private
slots
:
void
showUnavailableGamesChanged
(
int
state
);
void
actSetFilter
();
void
actClearFilter
();
void
actCreate
();
void
actJoin
();
void
checkResponse
(
const
Response
&
response
);
...
...
@@ -33,8 +34,7 @@ private:
QTreeView
*
gameListView
;
GamesModel
*
gameListModel
;
GamesProxyModel
*
gameListProxyModel
;
QPushButton
*
createButton
,
*
joinButton
,
*
spectateButton
;
QCheckBox
*
showUnavailableGamesCheckBox
;
QPushButton
*
filterButton
,
*
clearFilterButton
,
*
createButton
,
*
joinButton
,
*
spectateButton
;
public:
GameSelector
(
AbstractClient
*
_client
,
TabSupervisor
*
_tabSupervisor
,
TabRoom
*
_room
,
const
QMap
<
int
,
QString
>
&
_rooms
,
const
QMap
<
int
,
GameTypeMap
>
&
_gameTypes
,
QWidget
*
parent
=
0
);
void
retranslateUi
();
...
...
cockatrice/src/gamesmodel.cpp
View file @
6b14b4e5
...
...
@@ -147,6 +147,8 @@ void GamesProxyModel::resetFilterParameters()
gameTypeFilter
.
clear
();
maxPlayersFilterMin
=
-
1
;
maxPlayersFilterMax
=
-
1
;
invalidateFilter
();
}
bool
GamesProxyModel
::
filterAcceptsRow
(
int
sourceRow
,
const
QModelIndex
&
/*sourceParent*/
)
const
...
...
cockatrice/src/gamesmodel.h
View file @
6b14b4e5
...
...
@@ -26,6 +26,7 @@ public:
const
ServerInfo_Game
&
getGame
(
int
row
);
void
updateGameList
(
const
ServerInfo_Game
&
game
);
const
QMap
<
int
,
GameTypeMap
>
&
getGameTypes
()
{
return
gameTypes
;
}
};
class
GamesProxyModel
:
public
QSortFilterProxyModel
{
...
...
@@ -39,10 +40,16 @@ private:
public:
GamesProxyModel
(
QObject
*
parent
=
0
,
ServerInfo_User
*
_ownUser
=
0
);
bool
getUnavailableGamesVisible
()
const
{
return
unavailableGamesVisible
;
}
void
setUnavailableGamesVisible
(
bool
_unavailableGamesVisible
);
QString
getGameNameFilter
()
const
{
return
gameNameFilter
;
}
void
setGameNameFilter
(
const
QString
&
_gameNameFilter
);
QString
getCreatorNameFilter
()
const
{
return
creatorNameFilter
;
}
void
setCreatorNameFilter
(
const
QString
&
_creatorNameFilter
);
QSet
<
int
>
getGameTypeFilter
()
const
{
return
gameTypeFilter
;
}
void
setGameTypeFilter
(
const
QSet
<
int
>
&
_gameTypeFilter
);
int
getMaxPlayersFilterMin
()
const
{
return
maxPlayersFilterMin
;
}
int
getMaxPlayersFilterMax
()
const
{
return
maxPlayersFilterMax
;
}
void
setMaxPlayersFilter
(
int
_maxPlayersFilterMin
,
int
_maxPlayersFilterMax
);
void
resetFilterParameters
();
protected:
...
...
cockatrice/src/tab_game.cpp
View file @
6b14b4e5
...
...
@@ -82,6 +82,7 @@ void ToggleButton::paintEvent(QPaintEvent *event)
void
ToggleButton
::
setState
(
bool
_state
)
{
state
=
_state
;
emit
stateChanged
();
update
();
}
...
...
@@ -99,6 +100,7 @@ DeckViewContainer::DeckViewContainer(int _playerId, TabGame *parent)
connect
(
loadRemoteButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
loadRemoteDeck
()));
connect
(
readyStartButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
readyStart
()));
connect
(
sideboardLockButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
sideboardLockButtonClicked
()));
connect
(
sideboardLockButton
,
SIGNAL
(
stateChanged
()),
this
,
SLOT
(
updateSideboardLockButtonText
()));
QHBoxLayout
*
buttonHBox
=
new
QHBoxLayout
;
buttonHBox
->
addWidget
(
loadLocalButton
);
...
...
@@ -219,7 +221,6 @@ void DeckViewContainer::setReadyStart(bool ready)
void
DeckViewContainer
::
setSideboardLocked
(
bool
locked
)
{
sideboardLockButton
->
setState
(
!
locked
);
updateSideboardLockButtonText
();
deckView
->
setLocked
(
readyStartButton
->
getState
()
||
!
sideboardLockButton
->
getState
());
if
(
locked
)
deckView
->
resetSideboardPlan
();
...
...
Prev
1
2
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