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
be9ac2e0
Commit
be9ac2e0
authored
Jun 19, 2009
by
Max-Wilhelm Bruker
Browse files
save/restore login information
parent
a246a8d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_connect.cpp
View file @
be9ac2e0
...
@@ -4,27 +4,30 @@
...
@@ -4,27 +4,30 @@
DlgConnect
::
DlgConnect
(
QWidget
*
parent
)
DlgConnect
::
DlgConnect
(
QWidget
*
parent
)
:
QDialog
(
parent
)
:
QDialog
(
parent
)
{
{
QSettings
settings
;
settings
.
beginGroup
(
"server"
);
hostLabel
=
new
QLabel
(
tr
(
"&Host:"
));
hostLabel
=
new
QLabel
(
tr
(
"&Host:"
));
hostEdit
=
new
QLineEdit
(
"cockatrice.de"
);
hostEdit
=
new
QLineEdit
(
settings
.
value
(
"hostname"
,
"cockatrice.de"
)
.
toString
())
;
hostLabel
->
setBuddy
(
hostEdit
);
hostLabel
->
setBuddy
(
hostEdit
);
portLabel
=
new
QLabel
(
tr
(
"&Port:"
));
portLabel
=
new
QLabel
(
tr
(
"&Port:"
));
portEdit
=
new
QLineEdit
(
"4747"
);
portEdit
=
new
QLineEdit
(
settings
.
value
(
"port"
,
"4747"
).
toString
()
);
portLabel
->
setBuddy
(
portEdit
);
portLabel
->
setBuddy
(
portEdit
);
playernameLabel
=
new
QLabel
(
tr
(
"Player &name:"
));
playernameLabel
=
new
QLabel
(
tr
(
"Player &name:"
));
playernameEdit
=
new
QLineEdit
(
"Player"
);
playernameEdit
=
new
QLineEdit
(
settings
.
value
(
"playername"
,
"Player"
).
toString
()
);
playernameLabel
->
setBuddy
(
playernameEdit
);
playernameLabel
->
setBuddy
(
playernameEdit
);
passwordLabel
=
new
QLabel
(
tr
(
"P&assword:"
));
passwordLabel
=
new
QLabel
(
tr
(
"P&assword:"
));
passwordEdit
=
new
QLineEdit
;
passwordEdit
=
new
QLineEdit
(
settings
.
value
(
"password"
).
toString
())
;
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordEdit
->
setEchoMode
(
QLineEdit
::
Password
);
passwordEdit
->
setEchoMode
(
QLineEdit
::
Password
);
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
=
new
QPushButton
(
tr
(
"&OK"
));
okButton
->
setDefault
(
true
);
okButton
->
setDefault
(
true
);
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
cancelButton
=
new
QPushButton
(
tr
(
"&Cancel"
));
QGridLayout
*
grid
=
new
QGridLayout
;
QGridLayout
*
grid
=
new
QGridLayout
;
grid
->
addWidget
(
hostLabel
,
0
,
0
);
grid
->
addWidget
(
hostLabel
,
0
,
0
);
grid
->
addWidget
(
hostEdit
,
0
,
1
);
grid
->
addWidget
(
hostEdit
,
0
,
1
);
...
@@ -34,40 +37,33 @@ DlgConnect::DlgConnect(QWidget *parent)
...
@@ -34,40 +37,33 @@ DlgConnect::DlgConnect(QWidget *parent)
grid
->
addWidget
(
playernameEdit
,
2
,
1
);
grid
->
addWidget
(
playernameEdit
,
2
,
1
);
grid
->
addWidget
(
passwordLabel
,
3
,
0
);
grid
->
addWidget
(
passwordLabel
,
3
,
0
);
grid
->
addWidget
(
passwordEdit
,
3
,
1
);
grid
->
addWidget
(
passwordEdit
,
3
,
1
);
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
QHBoxLayout
*
buttonLayout
=
new
QHBoxLayout
;
buttonLayout
->
addStretch
();
buttonLayout
->
addStretch
();
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
okButton
);
buttonLayout
->
addWidget
(
cancelButton
);
buttonLayout
->
addWidget
(
cancelButton
);
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
grid
);
mainLayout
->
addLayout
(
grid
);
mainLayout
->
addLayout
(
buttonLayout
);
mainLayout
->
addLayout
(
buttonLayout
);
setLayout
(
mainLayout
);
setLayout
(
mainLayout
);
setWindowTitle
(
tr
(
"Connect to server"
));
setWindowTitle
(
tr
(
"Connect to server"
));
setFixedHeight
(
sizeHint
().
height
());
setFixedHeight
(
sizeHint
().
height
());
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
accept
()));
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
}
QString
DlgConnect
::
getHost
()
{
return
hostEdit
->
text
();
}
int
DlgConnect
::
getPort
()
connect
(
okButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
actOk
()));
{
connect
(
cancelButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
reject
()));
return
portEdit
->
text
().
toInt
();
}
}
QString
DlgConnect
::
getPlayerName
()
void
DlgConnect
::
actOk
()
{
{
return
playernameEdit
->
text
();
QSettings
settings
;
}
settings
.
beginGroup
(
"server"
);
settings
.
setValue
(
"hostname"
,
hostEdit
->
text
());
settings
.
setValue
(
"port"
,
portEdit
->
text
());
settings
.
setValue
(
"playername"
,
playernameEdit
->
text
());
settings
.
setValue
(
"password"
,
passwordEdit
->
text
());
settings
.
endGroup
();
QString
DlgConnect
::
getPassword
()
accept
();
{
return
passwordEdit
->
text
();
}
}
cockatrice/src/dlg_connect.h
View file @
be9ac2e0
...
@@ -2,19 +2,21 @@
...
@@ -2,19 +2,21 @@
#define DLG_CONNECT_H
#define DLG_CONNECT_H
#include
<QDialog>
#include
<QDialog>
#include
<QLineEdit>
class
QLabel
;
class
QLabel
;
class
QLineEdit
;
class
QPushButton
;
class
QPushButton
;
class
DlgConnect
:
public
QDialog
{
class
DlgConnect
:
public
QDialog
{
Q_OBJECT
Q_OBJECT
public:
public:
DlgConnect
(
QWidget
*
parent
=
0
);
DlgConnect
(
QWidget
*
parent
=
0
);
QString
getHost
();
QString
getHost
()
const
{
return
hostEdit
->
text
();
}
int
getPort
();
int
getPort
()
const
{
return
portEdit
->
text
().
toInt
();
}
QString
getPlayerName
();
QString
getPlayerName
()
const
{
return
playernameEdit
->
text
();
}
QString
getPassword
();
QString
getPassword
()
const
{
return
passwordEdit
->
text
();
}
private
slots
:
void
actOk
();
private:
private:
QLabel
*
hostLabel
,
*
portLabel
,
*
playernameLabel
,
*
passwordLabel
;
QLabel
*
hostLabel
,
*
portLabel
,
*
playernameLabel
,
*
passwordLabel
;
QLineEdit
*
hostEdit
,
*
portEdit
,
*
playernameEdit
,
*
passwordEdit
;
QLineEdit
*
hostEdit
,
*
portEdit
,
*
playernameEdit
,
*
passwordEdit
;
...
...
cockatrice/src/main.cpp
View file @
be9ac2e0
...
@@ -43,6 +43,10 @@ int main(int argc, char *argv[])
...
@@ -43,6 +43,10 @@ int main(int argc, char *argv[])
app
.
addLibraryPath
(
"plugins"
);
app
.
addLibraryPath
(
"plugins"
);
QTextCodec
::
setCodecForCStrings
(
QTextCodec
::
codecForName
(
"UTF-8"
));
QTextCodec
::
setCodecForCStrings
(
QTextCodec
::
codecForName
(
"UTF-8"
));
QCoreApplication
::
setOrganizationName
(
"Cockatrice"
);
QCoreApplication
::
setOrganizationDomain
(
"cockatrice.de"
);
QCoreApplication
::
setApplicationName
(
"Cockatrice"
);
MainWindow
*
ui
=
new
MainWindow
;
MainWindow
*
ui
=
new
MainWindow
;
qDebug
(
"main(): MainWindow constructor finished"
);
qDebug
(
"main(): MainWindow constructor finished"
);
ui
->
show
();
ui
->
show
();
...
...
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