Removed unimplemented GUI actions.
[tagua/yd.git] / src / mainwindow.h
blob7b957fbf043339e52b7f3ce3b12652f0a38e7d7a
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.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 TabWidget;
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 TabWidget* m_main;
50 QStackedWidget* m_movelist_stack;
51 boost::shared_ptr<ICSConnection> m_connection;
52 Console* console;
54 QMenu* m_engine_menu;
56 ChessTable* table();
57 UI m_ui;
58 UI& ui() { return m_ui; }
59 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
60 const QString& label, int index = -1);
62 QDir m_iconDir;
63 std::vector<EngineInfo*> m_engines;
65 boost::shared_ptr<QConnect> quickConnectDialog;
66 NewGame* newGameDialog;
68 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
69 // const char *sl, QString name, QObject *par = NULL);
70 void setupActions();
71 void setupEngineMenu();
72 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
73 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
74 QObject* obj, const char* slot);
75 void updateVariantActions();
77 bool openFile(const QString&);
79 void readSettings();
80 void writeSettings();
81 public:
82 MainWindow(const QString& variant);
83 virtual ~MainWindow();
85 protected:
86 void closeEvent(QCloseEvent*);
87 void keyPressEvent(QKeyEvent*);
88 void keyReleaseEvent(QKeyEvent*);
89 private Q_SLOTS:
90 void changeTab(int);
91 void closeTab();
92 public Q_SLOTS:
93 void createConnection(const QString&, const QString&, const QString&,
94 quint16, const QString&, const QString&);
95 void destroyConnection();
96 void testConnect(); // DEBUG
97 void icsConnect();
98 void icsDisconnect();
99 // // void receivedCommand(const QString&);
101 void onEstablishConnection();
102 void onHostLookup();
103 void onConnectionError(int);
104 void onHostFound();
106 void sendLogin();
107 void sendBlankPassword();
108 void prompt();
109 void cleanupGame(const QString&, const QString&);
110 void cleanupGame();
112 void editPosition();
113 void setupGame(const GameInfo*, const PositionInfo&);
114 void setupPGN(const QString& s);
115 void setupExaminedGame(const GameInfo*, const PositionInfo&);
116 void setupObservedGame(const GameInfo*, const PositionInfo&);
117 void newGame();
118 bool newGame(const QString& var, AbstractPosition::Ptr, bool);
119 void loadGame();
120 void quit();
121 void flipView();
122 void toggleConsole();
123 void toggleMoveList();
125 void displayMessage(const QString& msg);
126 void displayErrorMessage(ErrorCode);
127 void flash();
129 // void prefHighlight();
130 void preferences();
131 void settingsChanged();
136 #endif // MAINWINDOW_H