refresh 080b1da3c594fb6ca84009c352cc5fb9cc294c43
[tagua/yd.git] / src / mainwindow.h
blobcea36335f9124f9ae9bb08b6fa0e6c8bf8a4e6f8
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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>
17 #include <KUrl>
19 #include <QApplication>
20 #include <QMainWindow>
21 #include <QDir>
22 #include "boost/shared_ptr.hpp"
24 #include <core/state_fwd.h>
26 #include "ui.h"
27 #include "common.h"
28 #include "export.h"
30 class ChessTable;
31 class ICSConnection;
32 class Console;
33 class GameInfo;
34 class PositionInfo;
35 class Controller;
36 class QConnect;
37 class NewGame;
38 class EngineInfo;
39 class QDockWidget;
40 class TabWidget;
41 class QStackedWidget;
42 class QActionGroup;
43 class KAction;
44 class KIcon;
46 class TAGUA_EXPORT MainWindow : public KXmlGuiWindow {
47 Q_OBJECT
48 QDockWidget* movelist_dock;
49 QDockWidget* console_dock;
51 TabWidget* m_main;
52 QStackedWidget* m_movelist_stack;
53 boost::shared_ptr<ICSConnection> m_connection;
54 Console* console;
56 QMenu* m_engine_menu;
58 ChessTable* table();
59 KUrl m_url;
60 UI m_ui;
61 UI& ui() { return m_ui; }
62 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
63 const QString& label, int index = -1);
65 QDir m_iconDir;
66 std::vector<EngineInfo*> m_engines;
68 boost::shared_ptr<QConnect> quickConnectDialog;
69 NewGame* newGameDialog;
71 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
72 // const char *sl, QString name, QObject *par = NULL);
73 void setupActions();
74 void setupEngineMenu();
75 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
76 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
77 QObject* obj, const char* slot);
78 void updateVariantActions();
80 bool openFile(const QString&);
81 void saveFile(QFile&);
82 KUrl saveGame(const KUrl& url);
84 void readSettings();
85 void writeSettings();
86 public:
87 MainWindow(const QString& variant);
88 virtual ~MainWindow();
90 protected:
91 void closeEvent(QCloseEvent*);
92 void keyPressEvent(QKeyEvent*);
93 void keyReleaseEvent(QKeyEvent*);
94 private Q_SLOTS:
95 void changeTab(int);
96 void closeTab();
97 public Q_SLOTS:
98 void createConnection(const QString&, const QString&, const QString&,
99 quint16, const QString&, const QString&);
100 void destroyConnection();
101 void testConnect(); // DEBUG
102 void icsConnect();
103 void icsDisconnect();
104 // // void receivedCommand(const QString&);
106 void onEstablishConnection();
107 void onHostLookup();
108 void onConnectionError(int);
109 void onHostFound();
111 void sendLogin();
112 void sendBlankPassword();
113 void prompt();
114 void cleanupGame(const QString&, const QString&);
115 void cleanupGame();
117 void editPosition();
118 void setupGame(const GameInfo*, const PositionInfo&);
119 void setupPGN(const QString& s);
120 void setupExaminedGame(const GameInfo*, const PositionInfo&);
121 void setupObservedGame(const GameInfo*, const PositionInfo&);
122 void newGame();
123 bool newGame(const QString& var, const StatePtr&, bool);
124 void loadGame();
125 void saveGame();
126 void saveGameAs();
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();
138 void settingsChanged();
143 #endif // MAINWINDOW_H