File indexing completed on 2024-04-21 04:04:01

0001 /*
0002     SPDX-FileCopyrightText: 2013 Denis Kuplyakov <dener.kup@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef STARTGAMEDIALOG_H
0008 #define STARTGAMEDIALOG_H
0009 
0010 #include "gamestartinformation.h"
0011 #include "commondefs.h"
0012 
0013 #include <QDialog>
0014 #include <KUser>
0015 #include <KGameThemeProvider>
0016 class QAbstractButton;
0017 namespace Ui
0018 {
0019 class StartGameDialog;
0020 }
0021 
0022 /**
0023  * Dialog used to gather information about new game.
0024  * @see GameStartInformation
0025  */
0026 class StartGameDialog : public QDialog
0027 {
0028     Q_OBJECT
0029 
0030 public:
0031     explicit StartGameDialog(QWidget *parent, KGameThemeProvider *provider);
0032     ~StartGameDialog() override;
0033 
0034     /**
0035      * @return collected GameStartInformation
0036      */
0037     GameStartInformation createGameStartInformation() const;
0038     /**
0039      * Sets chips color according to @p prefix
0040      */
0041     void setChipsPrefix(ChipsPrefix prefix);
0042 
0043 Q_SIGNALS:
0044     /**
0045      * Emitted when user has finished entering information
0046      */
0047     void startGame();
0048 
0049 private Q_SLOTS:
0050     /**
0051      * Handles "User changed player type for black player" event
0052      */
0053     void slotUpdateBlack(QAbstractButton *button);
0054 
0055     /**
0056      * Handles "User changed player type for white player" event
0057      */
0058     void slotUpdateWhite(QAbstractButton *button);
0059 
0060     void slotAccepted();
0061 
0062 private:
0063     /**
0064      * Updates chip images
0065      */
0066     void loadChipImages();
0067     /**
0068      * Encapsulates UI
0069      */
0070     Ui::StartGameDialog *ui;
0071     /**
0072      * Main dialog widget
0073      */
0074     QWidget *m_contents;
0075     /**
0076      * Needed to get username
0077      */
0078     KUser m_user;
0079     /**
0080      * Used to draw chip
0081      */
0082     KGameThemeProvider *m_provider;
0083     /**
0084      * Sets chip's color to use
0085      */
0086     ChipsPrefix m_chipsPrefix;
0087 };
0088 
0089 #endif // STARTGAMEDIALOG_H