Starting to make things work again: dragging
[tagua.git] / src / mainwindow.h
blob63874c7fad79ea0cc5ab4e1405352cce2a695f30
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 <kxmlguiwindow.h>
16 #include <kmainwindow.h>
18 #include <QApplication>
19 #include <QMainWindow>
20 #include <QDir>
21 #include "boost/shared_ptr.hpp"
23 #include "ui.h"
24 #include "common.h"
26 class ChessTable;
27 class ICSConnection;
28 class Console;
29 class GameInfo;
30 class PositionInfo;
31 class Controller;
32 class QConnect;
33 class NewGame;
34 class EngineInfo;
35 class QDockWidget;
36 class KTabWidget;
37 class QStackedWidget;
38 class QActionGroup;
39 class KAction;
40 class KIcon;
42 class MainWindow : public KXmlGuiWindow {
43 Q_OBJECT
44 QDockWidget* movelist_dock;
45 QDockWidget* console_dock;
47 KTabWidget* m_main;
48 QStackedWidget* m_movelist_stack;
49 boost::shared_ptr<ICSConnection> m_connection;
50 Console* console;
52 QMenu* m_engine_menu;
53 KAction* m_promote_queen;
54 KAction* m_promote_rook;
55 KAction* m_promote_bishop;
56 KAction* m_promote_knight;
57 QActionGroup* m_promote_group;
59 KAction* m_do_promotion;
61 ChessTable* table();
62 UI m_ui;
63 UI& ui() { return m_ui; }
64 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
65 const QString& label, int index = -1);
67 QDir m_iconDir;
68 std::vector<EngineInfo*> m_engines;
70 boost::shared_ptr<QConnect> quickConnectDialog;
71 NewGame* newGameDialog;
73 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
74 // const char *sl, QString name, QObject *par = NULL);
75 void setupActions();
76 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
77 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
78 QObject* obj, const char* slot);
79 void updatePromotionType();
81 bool openFile(const QString&);
83 void readSettings();
84 void writeSettings();
85 public:
86 MainWindow();
87 virtual ~MainWindow();
89 protected:
90 void closeEvent(QCloseEvent*);
91 void keyPressEvent(QKeyEvent*);
92 void keyReleaseEvent(QKeyEvent*);
93 private slots:
94 void changeTab(int);
95 void closeTab();
96 public slots:
97 void createConnection(const QString&, const QString&, const QString&,
98 quint16, const QString&, const QString&);
99 void destroyConnection();
100 void testConnect(); // DEBUG
101 void icsConnect();
102 void icsDisconnect();
103 // // void receivedCommand(const QString&);
105 void onEstablishConnection();
106 void onHostLookup();
107 void onConnectionError(int);
108 void onHostFound();
110 void sendLogin();
111 void sendBlankPassword();
112 void prompt();
113 void cleanupGame(const QString&, const QString&);
114 void cleanupGame();
116 void editPosition();
117 void setupGame(const GameInfo*, const PositionInfo&);
118 void setupPGN(const QString& s);
119 void setupExaminedGame(const GameInfo*, const PositionInfo&);
120 void setupObservedGame(const GameInfo*, const PositionInfo&);
121 void newGame();
122 bool newGame(const QString& var, AbstractPosition::Ptr);
123 void loadGame();
124 void quit();
125 void flipView();
126 void toggleConsole();
127 void toggleMoveList();
129 void displayMessage(const QString& msg);
130 void displayErrorMessage(ErrorCode);
131 void flash();
133 // void prefHighlight();
134 void prefClock();
135 void preferences();
140 #endif // MAINWINDOW_H