Normalized whitespace.
[tagua/yd.git] / src / mainwindow.h
blob518a0b3a01c82e5903914d24fab7c03eda56f900
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"
27 class ChessTable;
28 class ICSConnection;
29 class Console;
30 class GameInfo;
31 class PositionInfo;
32 class Controller;
33 class QConnect;
34 class NewGame;
35 class EngineInfo;
36 class QDockWidget;
37 class KTabWidget;
38 class QStackedWidget;
39 class QActionGroup;
40 class KAction;
41 class KIcon;
43 class MainWindow : public KXmlGuiWindow {
44 Q_OBJECT
45 QDockWidget* movelist_dock;
46 QDockWidget* console_dock;
48 KTabWidget* m_main;
49 QStackedWidget* m_movelist_stack;
50 boost::shared_ptr<ICSConnection> m_connection;
51 Console* console;
53 QMenu* m_engine_menu;
54 KAction* m_promote_queen;
55 KAction* m_promote_rook;
56 KAction* m_promote_bishop;
57 KAction* m_promote_knight;
58 QActionGroup* m_promote_group;
60 KAction* m_do_promotion;
62 ChessTable* table();
63 UI m_ui;
64 UI& ui() { return m_ui; }
65 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
66 const QString& label, int index = -1);
68 QDir m_iconDir;
69 std::vector<EngineInfo*> m_engines;
71 boost::shared_ptr<QConnect> quickConnectDialog;
72 NewGame* newGameDialog;
74 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
75 // const char *sl, QString name, QObject *par = NULL);
76 void setupActions();
77 void setupEngineMenu();
78 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
79 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
80 QObject* obj, const char* slot);
81 void updatePromotionType();
83 bool openFile(const QString&);
85 void readSettings();
86 void writeSettings();
87 public:
88 MainWindow();
89 virtual ~MainWindow();
91 protected:
92 void closeEvent(QCloseEvent*);
93 void keyPressEvent(QKeyEvent*);
94 void keyReleaseEvent(QKeyEvent*);
95 private slots:
96 void changeTab(int);
97 void closeTab();
98 public slots:
99 void createConnection(const QString&, const QString&, const QString&,
100 quint16, const QString&, const QString&);
101 void destroyConnection();
102 void testConnect(); // DEBUG
103 void icsConnect();
104 void icsDisconnect();
105 // // void receivedCommand(const QString&);
107 void onEstablishConnection();
108 void onHostLookup();
109 void onConnectionError(int);
110 void onHostFound();
112 void sendLogin();
113 void sendBlankPassword();
114 void prompt();
115 void cleanupGame(const QString&, const QString&);
116 void cleanupGame();
118 void editPosition();
119 void setupGame(const GameInfo*, const PositionInfo&);
120 void setupPGN(const QString& s);
121 void setupExaminedGame(const GameInfo*, const PositionInfo&);
122 void setupObservedGame(const GameInfo*, const PositionInfo&);
123 void newGame();
124 bool newGame(const QString& var, AbstractPosition::Ptr);
125 void loadGame();
126 void quit();
127 void flipView();
128 void toggleConsole();
129 void toggleMoveList();
131 void displayMessage(const QString& msg);
132 void displayErrorMessage(ErrorCode);
133 void flash();
135 // void prefHighlight();
136 void prefClock();
137 void preferences();
142 #endif // MAINWINDOW_H