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
ca12aeb5
Commit
ca12aeb5
authored
May 28, 2010
by
Max-Wilhelm Bruker
Browse files
load deck from clipboard; closing feature request 0000019
parent
e6e20cb0
Changes
10
Expand all
Show whitespace changes
Inline
Side-by-side
cockatrice/cockatrice.pro
View file @
ca12aeb5
...
...
@@ -26,6 +26,7 @@ HEADERS += src/counter.h \
src
/
gameview
.
h
\
src
/
deck_picturecacher
.
h
\
src
/
decklistmodel
.
h
\
src
/
dlg_load_deck_from_clipboard
.
h
\
src
/
dlg_load_remote_deck
.
h
\
src
/
cardinfowidget
.
h
\
src
/
messagelogwidget
.
h
\
...
...
@@ -81,6 +82,7 @@ SOURCES += src/counter.cpp \
src
/
gameview
.
cpp
\
src
/
deck_picturecacher
.
cpp
\
src
/
decklistmodel
.
cpp
\
src
/
dlg_load_deck_from_clipboard
.
cpp
\
src
/
dlg_load_remote_deck
.
cpp
\
src
/
cardinfowidget
.
cpp
\
src
/
messagelogwidget
.
cpp
\
...
...
cockatrice/src/dlg_creategame.cpp
View file @
ca12aeb5
...
...
@@ -24,7 +24,7 @@ DlgCreateGame::DlgCreateGame(Client *_client, QWidget *parent)
spectatorsAllowedCheckBox
->
setChecked
(
true
);
connect
(
spectatorsAllowedCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
spectatorsAllowedChanged
(
int
)));
spectatorsNeedPasswordCheckBox
=
new
QCheckBox
(
tr
(
"Spectators &need a password to join"
));
spectatorsCanTalkCheckBox
=
new
QCheckBox
(
tr
(
"Spectators can &
talk
"
));
spectatorsCanTalkCheckBox
=
new
QCheckBox
(
tr
(
"Spectators can &
chat
"
));
spectatorsSeeEverythingCheckBox
=
new
QCheckBox
(
tr
(
"Spectators see &everything"
));
QVBoxLayout
*
spectatorsLayout
=
new
QVBoxLayout
;
spectatorsLayout
->
addWidget
(
spectatorsAllowedCheckBox
);
...
...
cockatrice/src/dlg_load_deck_from_clipboard.cpp
0 → 100644
View file @
ca12aeb5
#include
<QClipboard>
#include
<QPlainTextEdit>
#include
<QPushButton>
#include
<QVBoxLayout>
#include
<QHBoxLayout>
#include
<QKeySequence>
#include
<QApplication>
#include
<QTextStream>
#include
<QMessageBox>
#include
"dlg_load_deck_from_clipboard.h"
#include
"decklist.h"
DlgLoadDeckFromClipboard
::
DlgLoadDeckFromClipboard
(
QWidget
*
parent
)
:
QDialog
(
parent
),
deckList
(
0
)
{
contentsEdit
=
new
QPlainTextEdit
;
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
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addWidget
(
contentsEdit
);
mainLayout
->
addLayout
(
buttonLayout
);
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
();
}
void
DlgLoadDeckFromClipboard
::
actRefresh
()
{
contentsEdit
->
setPlainText
(
QApplication
::
clipboard
()
->
text
());
}
void
DlgLoadDeckFromClipboard
::
actOK
()
{
QString
buffer
=
contentsEdit
->
toPlainText
();
QTextStream
stream
(
&
buffer
);
DeckList
*
l
=
new
DeckList
;
if
(
l
->
loadFromStream_Plain
(
stream
))
{
deckList
=
l
;
accept
();
}
else
{
QMessageBox
::
critical
(
this
,
tr
(
"Error"
),
tr
(
"Invalid deck list."
));
delete
l
;
}
}
cockatrice/src/dlg_load_deck_from_clipboard.h
0 → 100644
View file @
ca12aeb5
#ifndef DLG_LOAD_DECK_FROM_CLIPBOARD_H
#define DLG_LOAD_DECK_FROM_CLIPBOARD_H
#include
<QDialog>
class
DeckList
;
class
QPlainTextEdit
;
class
QPushButton
;
class
DlgLoadDeckFromClipboard
:
public
QDialog
{
Q_OBJECT
private
slots
:
void
actOK
();
void
actRefresh
();
private:
DeckList
*
deckList
;
public:
DlgLoadDeckFromClipboard
(
QWidget
*
parent
=
0
);
DeckList
*
getDeckList
()
const
{
return
deckList
;
}
private:
QPlainTextEdit
*
contentsEdit
;
QPushButton
*
refreshButton
,
*
okButton
,
*
cancelButton
;
};
#endif
cockatrice/src/window_deckeditor.cpp
View file @
ca12aeb5
...
...
@@ -7,6 +7,7 @@
#include
"cardinfowidget.h"
#include
"deck_picturecacher.h"
#include
"dlg_cardsearch.h"
#include
"dlg_load_deck_from_clipboard.h"
#include
"main.h"
void
SearchLineEdit
::
keyPressEvent
(
QKeyEvent
*
event
)
...
...
@@ -122,6 +123,8 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
aLoadDeck
=
new
QAction
(
tr
(
"&Load deck..."
),
this
);
aLoadDeck
->
setShortcuts
(
QKeySequence
::
Open
);
connect
(
aLoadDeck
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actLoadDeck
()));
aLoadDeckFromClipboard
=
new
QAction
(
tr
(
"Load deck from cl&ipboard..."
),
this
);
connect
(
aLoadDeckFromClipboard
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actLoadDeckFromClipboard
()));
aSaveDeck
=
new
QAction
(
tr
(
"&Save deck"
),
this
);
aSaveDeck
->
setShortcuts
(
QKeySequence
::
Save
);
connect
(
aSaveDeck
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actSaveDeck
()));
...
...
@@ -141,6 +144,7 @@ WndDeckEditor::WndDeckEditor(QWidget *parent)
deckMenu
=
menuBar
()
->
addMenu
(
tr
(
"&Deck"
));
deckMenu
->
addAction
(
aNewDeck
);
deckMenu
->
addAction
(
aLoadDeck
);
deckMenu
->
addAction
(
aLoadDeckFromClipboard
);
deckMenu
->
addAction
(
aSaveDeck
);
deckMenu
->
addAction
(
aSaveDeckAs
);
deckMenu
->
addSeparator
();
...
...
@@ -275,6 +279,19 @@ void WndDeckEditor::actLoadDeck()
delete
l
;
}
void
WndDeckEditor
::
actLoadDeckFromClipboard
()
{
if
(
!
confirmClose
())
return
;
DlgLoadDeckFromClipboard
dlg
;
if
(
!
dlg
.
exec
())
return
;
setDeck
(
dlg
.
getDeckList
());
setWindowModified
(
true
);
}
bool
WndDeckEditor
::
actSaveDeck
()
{
if
(
lastFileName
.
isEmpty
())
...
...
cockatrice/src/window_deckeditor.h
View file @
ca12aeb5
...
...
@@ -36,6 +36,7 @@ private slots:
void
actNewDeck
();
void
actLoadDeck
();
void
actLoadDeckFromClipboard
();
bool
actSaveDeck
();
bool
actSaveDeckAs
();
void
actPrintDeck
();
...
...
@@ -70,7 +71,7 @@ private:
DlgCardSearch
*
dlgCardSearch
;
QMenu
*
deckMenu
,
*
dbMenu
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aPrintDeck
,
*
aClose
;
QAction
*
aNewDeck
,
*
aLoadDeck
,
*
aLoadDeckFromClipboard
,
*
aSaveDeck
,
*
aSaveDeckAs
,
*
aPrintDeck
,
*
aClose
;
QAction
*
aEditSets
,
*
aSearch
,
*
aClearSearch
;
QAction
*
aAddCard
,
*
aAddCardToSideboard
,
*
aRemoveCard
,
*
aIncrement
,
*
aDecrement
;
public:
...
...
cockatrice/translations/cockatrice_de.ts
View file @
ca12aeb5
This diff is collapsed.
Click to expand it.
cockatrice/translations/cockatrice_en.ts
View file @
ca12aeb5
This diff is collapsed.
Click to expand it.
common/decklist.cpp
View file @
ca12aeb5
...
...
@@ -359,11 +359,11 @@ bool DeckList::saveToFile_Native(QIODevice *device)
return
true
;
}
bool
DeckList
::
loadFrom
File
_Plain
(
Q
IODevice
*
device
)
bool
DeckList
::
loadFrom
Stream
_Plain
(
Q
TextStream
&
in
)
{
InnerDecklistNode
*
main
=
0
,
*
side
=
0
;
QTextStream
in
(
device
)
;
int
okRows
=
0
;
while
(
!
in
.
atEnd
())
{
QString
line
=
in
.
readLine
().
simplified
();
if
(
line
.
startsWith
(
"//"
))
...
...
@@ -393,9 +393,16 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
int
number
=
line
.
left
(
i
).
toInt
(
&
ok
);
if
(
!
ok
)
continue
;
++
okRows
;
new
DecklistCardNode
(
line
.
mid
(
i
+
1
),
number
,
zone
);
}
return
true
;
return
(
okRows
>
0
);
}
bool
DeckList
::
loadFromFile_Plain
(
QIODevice
*
device
)
{
QTextStream
in
(
device
);
return
loadFromStream_Plain
(
in
);
}
bool
DeckList
::
saveToFile_Plain
(
QIODevice
*
device
)
...
...
common/decklist.h
View file @
ca12aeb5
...
...
@@ -9,6 +9,7 @@
class
CardDatabase
;
class
QIODevice
;
class
QTextStream
;
class
QXmlStreamReader
;
class
QXmlStreamWriter
;
...
...
@@ -137,6 +138,7 @@ public:
bool
loadFromFile_Native
(
QIODevice
*
device
);
bool
saveToFile_Native
(
QIODevice
*
device
);
bool
loadFromStream_Plain
(
QTextStream
&
stream
);
bool
loadFromFile_Plain
(
QIODevice
*
device
);
bool
saveToFile_Plain
(
QIODevice
*
device
);
bool
loadFromFile
(
const
QString
&
fileName
,
FileFormat
fmt
);
...
...
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