Commit 62739a12 authored by Benjamin Meyer's avatar Benjamin Meyer

Bug 65451 about dialog not consistent with KDE

Along with a number of other issues that wern't reported, but found

svn path=/trunk/kdegames/lskat/; revision=330966
parent fd12a0b2
......@@ -79,6 +79,5 @@ class KEInput : public QObject
void signalPrepareProcessMove(KEMessage *msg);
void signalPrepareInteractiveMove(KEMessage *msg);
};
#endif
####### kdevelop will overwrite this part!!! (begin)##########
bin_PROGRAMS = lskat
lskat_SOURCES = msgdlg.cpp movielabel.cpp aboutdlg.cpp networkdlg.cpp namedlg.cpp KRemoteConnect.cpp KRSocket.cpp KProcessConnect.cpp KMessageEntry.cpp KInteractiveConnect.cpp KInputChildProcess.cpp KEMessage.cpp KEInput.cpp KConnectEntry.cpp KChildConnect.cpp lskatview.cpp lskatdoc.cpp lskat.cpp main.cpp
lskat_SOURCES = msgdlg.cpp networkdlg.cpp namedlg.cpp KRemoteConnect.cpp KRSocket.cpp KProcessConnect.cpp KMessageEntry.cpp KInteractiveConnect.cpp KInputChildProcess.cpp KEMessage.cpp KEInput.cpp KConnectEntry.cpp KChildConnect.cpp lskatview.cpp lskatdoc.cpp lskat.cpp main.cpp
lskat_LDADD = $(LIB_KFILE) $(LIB_KDEGAMES)
......
/****************************************************************************
** Form implementation generated from reading ui file 'aboutDlg.ui'
**
** Created: Thu Nov 23 11:42:20 2000
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "aboutdlg.h"
#include <qframe.h>
#include <qlabel.h>
#include <qlayout.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kstdguiitem.h>
#define VERSION 0.91
/*
* Constructs a aboutDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
aboutDlg::aboutDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name ) setName( "aboutDlg" );
resize( 315, 318 );
setCaption( i18n( "About Lieutenant Skat" ) );
vbox = new QVBoxLayout( this );
vbox->setSpacing( 6 );
vbox->setMargin( 11 );
Frame5 = new QFrame( this, "Frame5" );
Frame5->setFrameShadow( QFrame::Sunken );
Frame5->setFrameShape( QFrame::StyledPanel );
Frame5->setBackgroundColor(Qt::white);
Frame5->setLineWidth( 3 );
Frame5->setMidLineWidth( 2 );
vbox_2 = new QVBoxLayout( Frame5 );
vbox_2->setSpacing( 6 );
vbox_2->setMargin( 11 );
hbox = new QHBoxLayout;
hbox->setSpacing( 6 );
hbox->setMargin( 0 );
MovieLabel= new QMovieLabel(Frame5,"Movei1");
MovieLabel->setMinimumSize( QSize( 160, 60 ) );
MovieLabel->setMaximumSize( QSize( 160, 60 ) );
MovieLabel->setEMovie(0);
hbox->addWidget( MovieLabel );
QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
hbox->addItem( spacer );
TextLabel3 = new QLabel( Frame5, "TextLabel3" );
TextLabel3->setText( i18n( "Lieutenant\nSkat\n\nVersion %1" ).arg(VERSION) );
TextLabel3->setAlignment( int( QLabel::AlignCenter ) );
TextLabel3->setBackgroundColor(Qt::white);
hbox->addWidget( TextLabel3 );
vbox_2->addLayout( hbox );
TextLabel4 = new QLabel( Frame5, "TextLabel4" );
TextLabel4->setText( i18n( "(c) 2000 Martin Heni\nEmail: martin@heni-online.de\n\nGame features:\n - Multiplayer network game\n - Up to two computer players\n\n\n Many thanks to Laura for beta testing!" ) );
TextLabel4->setBackgroundColor(Qt::white);
vbox_2->addWidget( TextLabel4 );
vbox->addWidget( Frame5 );
hbox_2 = new QHBoxLayout;
hbox_2->setSpacing( 6 );
hbox_2->setMargin( 0 );
QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
hbox_2->addItem( spacer_2 );
PushButton15 = new KPushButton( KStdGuiItem::ok(), this, "PushButton15" );
hbox_2->addWidget( PushButton15 );
QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
hbox_2->addItem( spacer_3 );
vbox->addLayout( hbox_2 );
// signals and slots connections
connect( PushButton15, SIGNAL( clicked() ), this, SLOT( accept() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
aboutDlg::~aboutDlg()
{
// no need to delete child widgets, Qt does it all for us
}
void aboutDlg::SetMovie(EMovie *movie)
{
MovieLabel->setEMovie(movie);
}
#include "aboutdlg.moc"
/****************************************************************************
** Form interface generated from reading ui file 'aboutDlg.ui'
**
** Created: Thu Nov 23 11:42:06 2000
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef ABOUTDLG_H
#define ABOUTDLG_H
#include <qdialog.h>
#include "movielabel.h"
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QPushButton;
class aboutDlg : public QDialog
{
Q_OBJECT
public:
aboutDlg( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0 );
~aboutDlg();
void SetMovie(EMovie *movie);
QFrame* Frame5;
//QLabel* PixmapLabel1;
QMovieLabel *MovieLabel;
QLabel* TextLabel3;
QLabel* TextLabel4;
QPushButton* PushButton15;
protected:
QHBoxLayout* hbox;
QHBoxLayout* hbox_2;
QVBoxLayout* vbox;
QVBoxLayout* vbox_2;
private:
};
#endif // ABOUTDLG_H
......@@ -35,12 +35,9 @@
#include "lskatdoc.h"
#include "namedlg.h"
#include "networkdlg.h"
#include "aboutdlg.h"
#include "movielabel.h"
#include "msgdlg.h"
#include <kcarddialog.h>
#include <stdlib.h>
#include <kstatusbar.h>
......@@ -64,14 +61,14 @@ LSkatApp::LSkatApp() : KMainWindow(0)
// call inits to invoke all other construction parts
initGUI();
initStatusBar();
setHelpMenuEnabled(false);
setupGUI(KMainWindow::StatusBar | Save);
createGUI(QString::null, false);
initDocument();
initView();
readOptions();
doc->ReadConfig(config);
// Needs to be after readOptions as we read in default paths
doc->LoadGrafix(mGrafix);
......@@ -93,7 +90,6 @@ LSkatApp::LSkatApp() : KMainWindow(0)
// better be last in init
checkMenus();
}
LSkatApp::~LSkatApp()
......@@ -120,14 +116,8 @@ void LSkatApp::checkMenus(int menu)
{
disableAction("send_message");
}
}
if (!menu || (menu&CheckViewMenu))
{
if (statusBar()->isHidden()) ((KToggleAction*)ACTION("show_statusbar"))->setChecked(false);
else ((KToggleAction*)ACTION("show_statusbar"))->setChecked(true);
}
if (!menu || (menu&CheckOptionsMenu))
{
((KSelectAction *)ACTION("startplayer"))->setCurrentItem(doc->GetStartPlayer());
......@@ -187,12 +177,6 @@ void LSkatApp::initGUI()
ACTION("game_exit")->setStatusText(i18n("Exiting..."));
ACTION("game_exit")->setWhatsThis(i18n("Quits the program."));
KToggleAction* act = new KToggleAction(i18n("&Show Statusbar"),0,this,SLOT(slotViewStatusBar()),
actionCollection(), "show_statusbar");
act->setCheckedState(i18n("Hide Statusbar"));
ACTION("show_statusbar")->setStatusText(i18n("Toggle the statusbar..."));
ACTION("show_statusbar")->setWhatsThis(i18n("Toggle the statusbar..."));
(void)new KSelectAction(i18n("Starting Player"),0,this,SLOT(slotStartplayer()),
actionCollection(), "startplayer");
ACTION("startplayer")->setStatusText(i18n("Changing starting player..."));
......@@ -243,9 +227,6 @@ void LSkatApp::initGUI()
KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()),
actionCollection());
KHelpMenu *helpMenu = new KHelpMenu(this, 0, true, actionCollection());
connect( helpMenu, SIGNAL(showAboutApplication()), this, SLOT(slotHelpAbout()));
}
......@@ -306,30 +287,6 @@ LSkatDoc *LSkatApp::getDocument() const
return doc;
}
void LSkatApp::saveOptions()
{
config->setGroup("General Options");
config->writeEntry("Geometry", size());
config->writeEntry("Show Statusbar",statusBar()->isVisible());
doc->WriteConfig(config);
}
void LSkatApp::readOptions()
{
config->setGroup("General Options");
bool bViewStatusbar = config->readBoolEntry("Show Statusbar", true);
((KToggleAction *)ACTION("show_statusbar"))->setChecked(bViewStatusbar);
if(!bViewStatusbar) statusBar()->hide();
QSize size=config->readSizeEntry("Geometry");
if(!size.isEmpty())
{
resize(size);
}
doc->ReadConfig(config);
}
void LSkatApp::saveProperties(KConfig *_cfg)
{
if(doc->getTitle()!=i18n("Untitled") && !doc->isModified())
......@@ -387,7 +344,7 @@ bool LSkatApp::queryClose()
bool LSkatApp::queryExit()
{
saveOptions();
doc->WriteConfig(config);
return true;
}
......@@ -395,11 +352,9 @@ bool LSkatApp::queryExit()
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////
void LSkatApp::slotFileStatistics()
{
QString message;
message=i18n("Do you really want to clear the all time "
"statistical data?");
......@@ -409,6 +364,7 @@ void LSkatApp::slotFileStatistics()
doc->slotUpdateAllViews(0);
}
}
/** send message */
void LSkatApp::slotFileMessage()
{
......@@ -434,8 +390,6 @@ void LSkatApp::slotFileMessage()
}
}
void LSkatApp::slotFileNew()
{
NewGame();
......@@ -466,22 +420,21 @@ void LSkatApp::slotFileEnd()
slotStatusNames();
}
void LSkatApp::slotFileQuit()
{
saveOptions();
doc->WriteConfig(config);
if (view) view->close();
close();
kdDebug() << "slotFileQuit done"<<endl;
}
void LSkatApp::slotStartplayer()
{
int i=((KSelectAction *)ACTION("startplayer"))->currentItem();
doc->SetStartPlayer(i);
doc->UpdateViews(UPDATE_STATUS);
}
void LSkatApp::slotPlayer1By()
{
switch(((KSelectAction *)ACTION("player1"))->currentItem())
......@@ -497,6 +450,7 @@ void LSkatApp::slotPlayer1By()
break;
}
}
void LSkatApp::slotPlayer2By()
{
switch(((KSelectAction *)ACTION("player2"))->currentItem())
......@@ -512,6 +466,7 @@ void LSkatApp::slotPlayer2By()
break;
}
}
void LSkatApp::slotPlayer1(KG_INPUTTYPE i)
{
doc->SetPlayedBy(0,i);
......@@ -528,6 +483,7 @@ void LSkatApp::slotPlayer1(KG_INPUTTYPE i)
}
doc->UpdateViews(UPDATE_STATUS);
}
void LSkatApp::slotPlayer2(KG_INPUTTYPE i)
{
doc->SetPlayedBy(1,i);
......@@ -544,6 +500,7 @@ void LSkatApp::slotPlayer2(KG_INPUTTYPE i)
}
doc->UpdateViews(UPDATE_STATUS);
}
void LSkatApp::slotOptionsNames()
{
NameDlg *dlg=new NameDlg(this,QCString("Enter your name..."));
......@@ -572,7 +529,6 @@ void LSkatApp::slotOptionsCardDeck()
doc->SetCardDeckPath(s1,s2);
doc->slotUpdateAllViews(0);
}
}
void LSkatApp::slotLevel()
......@@ -584,23 +540,11 @@ void LSkatApp::slotLevel()
printf("Level set to %d\n",i);
}
void LSkatApp::slotViewStatusBar()
{
///////////////////////////////////////////////////////////////////
//turn Statusbar on or off
if (statusBar()->isVisible())
{
statusBar()->hide();
}
else
{
statusBar()->show();
}
}
void LSkatApp::slotClearStatusMsg()
{
slotStatusMsg(i18n("Ready"));
}
void LSkatApp::slotStatusMsg(const QString &text)
{
///////////////////////////////////////////////////////////////////
......@@ -625,7 +569,6 @@ void LSkatApp::slotStatusHelpMsg(const QString &text)
statusBar()->message(text, 2000);
}
/** Triggers the processmove timer */
void LSkatApp::slotProcTimer(void)
{
......@@ -801,22 +744,6 @@ bool LSkatApp::MakeInputDevice(int no)
return res;
}
void LSkatApp::slotHelpAbout()
{
slotStatusMsg(i18n("About the program..."));
EMovie *movie=new EMovie;
movie->frameDelay=70;
movie->frameArray=doc->mPixAnim;
movie->frameCnt=NO_OF_ANIM;
aboutDlg *dlg=new aboutDlg(this);
dlg->SetMovie(movie);
dlg->exec();
delete movie;
slotStatusMsg(i18n("Ready"));
}
void LSkatApp::OptionsNetwork()
{
int res;
......@@ -845,18 +772,21 @@ void LSkatApp::slotPrepareProcessMove(KEMessage *msg)
msg->AddData(QCString("KLogSendMsg"),"process.log");
PrepareGame(msg);
}
void LSkatApp::slotPrepareRemoteMove(KEMessage *)
{
if (global_debug>3)
printf("+++ main should prepare remote move\n");
slotStatusMsg(i18n("Waiting for remote player..."));
}
void LSkatApp::slotPrepareInteractiveMove(KEMessage *)
{
if (global_debug>3)
printf("+++ main should prepare interactive move\n");
slotStatusMsg(i18n("Please make your move..."));
}
void LSkatApp::slotReceiveInput(KEMessage *msg,int )
{
/*
......@@ -1013,6 +943,7 @@ void LSkatApp::MoveFinished()
}
slotStatusNames();
}
void LSkatApp::Move(int x,int y,int player,bool remote)
{
KEMessage *msg;
......@@ -1062,9 +993,12 @@ void LSkatApp::Move(int x,int y,int player,bool remote)
return ;
}
}
void LSkatApp::PrepareGame(KEMessage *msg)
{
if (!msg) return ;
if (!msg)
return;
msg->AddData(QCString("Cards"),(char *)doc->GetCardP(),NO_OF_CARDS*sizeof(int));
msg->AddData(QCString("Startplayer"),(short)doc->GetStartPlayer());
msg->AddData(QCString("CurrentPlayer"),(short)doc->GetCurrentPlayer());
......@@ -1082,9 +1016,11 @@ void LSkatApp::PrepareGame(KEMessage *msg)
msg->AddData(QCString("Sc2"),(short)doc->GetScore(1));
msg->AddData(QCString("Level"),(short)doc->GetComputerLevel());
}
void LSkatApp::ExtractGame(KEMessage *msg)
{
if (!msg) return ;
if (!msg)
return;
// Do we have to switch players?
bool switchit;
short remote;
......
......@@ -101,13 +101,6 @@ class LSkatApp : public KMainWindow
void PrepareGame(KEMessage *msg);
void ExtractGame(KEMessage *msg);
/** save general Options like all bar positions and status as well as the geometry and the recent file list to the configuration
* file
*/
void saveOptions();
/** read general Options again and initialize all variables like the recent file list
*/
void readOptions();
/** initGUI creates the menubar and inserts the menupopups as well as creating the helpMenu.
* @see KApplication#getHelpMenu
*/
......@@ -158,9 +151,6 @@ class LSkatApp : public KMainWindow
void slotPrepareInteractiveMove(KEMessage *msg);
void slotReceiveInput(KEMessage *msg,int id);
void slotHelpAbout();
/** clears the document in the actual view to reuse it as the new document */
void slotFileNew();
/** asks for saving if the file is modified, then closes the actual file and window*/
......@@ -173,9 +163,6 @@ class LSkatApp : public KMainWindow
void slotFileStatistics();
/** Msg to remote player */
void slotFileMessage();
/** toggles the statusbar
*/
void slotViewStatusBar();
/** changes the statusbar contents for the standard label permanently, used to indicate current actions.
* @param text the text that is displayed in the statusbar
*/
......@@ -223,7 +210,7 @@ protected: // Protected attributes
* information such as filename and does the serialization of your files.
*/
LSkatDoc *doc;
};
#endif // LSKAT_H
......@@ -732,13 +732,12 @@ void LSkatDoc::ReadConfig(KConfig *config)
name = QString::fromLocal8Bit( pw->pw_gecos );
}
config->setGroup("Parameter");
host=config->readEntry("host");
port=(unsigned short)config->readNumEntry("port",7432);
procfile=config->readEntry("process",QCString("lskatproc"));
names[0]=config->readEntry("Name1",i18n("Alice"));
// names[1]=config->readEntry("Name2",i18n("Bob"));
// names[1]=config->readEntry("Name2",i18n("Bob"));
names[1]=config->readEntry("Name2", name.isEmpty() ? i18n("Bob") : name);
......
......@@ -114,8 +114,6 @@ LSkatView::LSkatView(QWidget *parent, const char *name) : QWidget(parent, name)
status_rect3=QRect(CARD_X_OFFSET+60,CARD_Y_OFFSET+5+100+15+20,
400,320-100-CARD_Y_OFFSET-30);
setBackgroundColor(QColor(0,0,128));
setBackgroundPixmap( getDocument()->mPixBackground );
......@@ -135,15 +133,10 @@ LSkatView::LSkatView(QWidget *parent, const char *name) : QWidget(parent, name)
}
}
LSkatView::~LSkatView()
{
}
// Access the document with the game data
LSkatDoc *LSkatView::getDocument() const
{
LSkatApp *theApp=(LSkatApp *) parentWidget();
return theApp->getDocument();
}
......
......@@ -22,10 +22,8 @@
#include <config.h>
#endif
// include files for Qt
#include <qwidget.h>
#include <qrect.h>
#include <qdatetime.h>
#include "lskat.h"
......@@ -46,8 +44,6 @@ class LSkatView : public QWidget
public:
/** Constructor for the main view */
LSkatView(QWidget *parent = 0, const char *name=0);
/** Destructor for the main view */
~LSkatView();
/** returns a pointer to the document connected to the view instance. Mind that this method requires a LSkatApp instance as a parent
* widget to get to the window document pointer by calling the LSkatApp::getDocument() method.
......
/***************************************************************************
main.cpp - description
-------------------
begin : Tue May 2 15:47:11 CEST 2000
copyright : (C) 2000 by Martin Heni
email : martin@heni-online.de
......@@ -14,12 +12,9 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kaboutdata.h>
#include "lskat.h"
static KCmdLineOptions options[] =
......@@ -35,13 +30,14 @@ int main(int argc, char *argv[])
{
global_debug=0;
KAboutData *aboutData=new KAboutData( "lskat", I18N_NOOP("Lieutenant Skat"),
KAboutData aboutData( "lskat", I18N_NOOP("Lieutenant Skat"),
"1.0",
I18N_NOOP("Card Game"),
KAboutData::License_GPL,
"(c) 2000, Martin Heni");
aboutData->addAuthor("Martin Heni",0, "martin@heni-online.de");
KCmdLineArgs::init( argc, argv, aboutData );
aboutData.addAuthor("Martin Heni",0, "martin@heni-online.de");
aboutData.addCredit("Laura", I18N_NOOP("Beta testing"), 0);
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
/* command line handling */
......@@ -49,10 +45,9 @@ int main(int argc, char *argv[])
if (args->isSet("debug"))
{
QString s;
s=args->getOption("debug") ;
global_debug=atoi(s.latin1() );
printf("Debug level set to %d\n",global_debug);
QString s = args->getOption("debug");
global_debug = s.toInt();
qDebug("Debug level set to %d\n", global_debug);
}
args->clear();
......@@ -66,10 +61,7 @@ int main(int argc, char *argv[])
{
LSkatApp *lskat = new LSkatApp();
lskat->show();
}