Refactored TurnTest.
[tagua/yd.git] / src / mainwindow.h
blob83585f7333fabef296c04919a6eb9a3901439c6a
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef MAINWINDOW_H
12 #define MAINWINDOW_H
14 #include <map>
15 #include <vector>
16 #include <kxmlguiwindow.h>
17 #include <kmainwindow.h>
19 #include <QApplication>
20 #include <QMainWindow>
21 #include <QDir>
22 #include "boost/shared_ptr.hpp"
24 #include "ui.h"
25 #include "common.h"
26 #include "export.h"
28 class ChessTable;
29 class ICSConnection;
30 class Console;
31 class GameInfo;
32 class PositionInfo;
33 class Controller;
34 class QConnect;
35 class NewGame;
36 class EngineInfo;
37 class QDockWidget;
38 class KTabWidget;
39 class QStackedWidget;
40 class QActionGroup;
41 class KAction;
42 class KIcon;
44 class TAGUA_EXPORT MainWindow : public KXmlGuiWindow {
45 Q_OBJECT
46 QDockWidget* movelist_dock;
47 QDockWidget* console_dock;
49 KTabWidget* m_main;
50 QStackedWidget* m_movelist_stack;
51 boost::shared_ptr<ICSConnection> m_connection;
52 Console* console;
54 QMenu* m_engine_menu;
55 KAction* m_promote_queen;
56 KAction* m_promote_rook;
57 KAction* m_promote_bishop;
58 KAction* m_promote_knight;
59 QActionGroup* m_promote_group;
61 KAction* m_do_promotion;
63 ChessTable* table();
64 UI m_ui;
65 UI& ui() { return m_ui; }
66 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
67 const QString& label, int index = -1);
69 QDir m_iconDir;
70 std::vector<EngineInfo*> m_engines;
72 boost::shared_ptr<QConnect> quickConnectDialog;
73 NewGame* newGameDialog;
75 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
76 // const char *sl, QString name, QObject *par = NULL);
77 void setupActions();
78 void setupEngineMenu();
79 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
80 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
81 QObject* obj, const char* slot);
82 void updatePromotionType();
84 bool openFile(const QString&);
86 void readSettings();
87 void writeSettings();
88 public:
89 MainWindow();
90 virtual ~MainWindow();
92 protected:
93 void closeEvent(QCloseEvent*);
94 void keyPressEvent(QKeyEvent*);
95 void keyReleaseEvent(QKeyEvent*);
96 private Q_SLOTS:
97 void changeTab(int);
98 void closeTab();
99 public Q_SLOTS:
100 void createConnection(const QString&, const QString&, const QString&,
101 quint16, const QString&, const QString&);
102 void destroyConnection();
103 void testConnect(); // DEBUG
104 void icsConnect();
105 void icsDisconnect();
106 // // void receivedCommand(const QString&);
108 void onEstablishConnection();
109 void onHostLookup();
110 void onConnectionError(int);
111 void onHostFound();
113 void sendLogin();
114 void sendBlankPassword();
115 void prompt();
116 void cleanupGame(const QString&, const QString&);
117 void cleanupGame();
119 void editPosition();
120 void setupGame(const GameInfo*, const PositionInfo&);
121 void setupPGN(const QString& s);
122 void setupExaminedGame(const GameInfo*, const PositionInfo&);
123 void setupObservedGame(const GameInfo*, const PositionInfo&);
124 void newGame();
125 bool newGame(const QString& var, AbstractPosition::Ptr);
126 void loadGame();
127 void quit();
128 void flipView();
129 void toggleConsole();
130 void toggleMoveList();
132 void displayMessage(const QString& msg);
133 void displayErrorMessage(ErrorCode);
134 void flash();
136 // void prefHighlight();
137 void preferences();
142 #endif // MAINWINDOW_H