Allow building as monolithic app (no plugins) for easier developement.
[tagua.git] / src / mainwindow.h
blob92bb11e5de0f648177f95bab4a42ff8735f28d5f
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>
18 #include <QApplication>
19 #include <QMainWindow>
20 #include <QDir>
21 #include "boost/shared_ptr.hpp"
23 #include <core/state_fwd.h>
25 #include "ui.h"
26 #include "common.h"
27 #include "export.h"
29 class ChessTable;
30 class ICSConnection;
31 class Console;
32 class GameInfo;
33 class PositionInfo;
34 class Controller;
35 class QConnect;
36 class NewGame;
37 class EngineInfo;
38 class QDockWidget;
39 class TabWidget;
40 class QStackedWidget;
41 class QActionGroup;
42 class KAction;
43 class KIcon;
45 class TAGUA_EXPORT MainWindow : public KXmlGuiWindow {
46 Q_OBJECT
47 QDockWidget* movelist_dock;
48 QDockWidget* console_dock;
50 TabWidget* m_main;
51 QStackedWidget* m_movelist_stack;
52 boost::shared_ptr<ICSConnection> m_connection;
53 Console* console;
55 QMenu* m_engine_menu;
57 ChessTable* table();
58 UI m_ui;
59 UI& ui() { return m_ui; }
60 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
61 const QString& label, int index = -1);
63 QDir m_iconDir;
64 std::vector<EngineInfo*> m_engines;
66 boost::shared_ptr<QConnect> quickConnectDialog;
67 NewGame* newGameDialog;
69 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
70 // const char *sl, QString name, QObject *par = NULL);
71 void setupActions();
72 void setupEngineMenu();
73 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
74 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
75 QObject* obj, const char* slot);
76 void updateVariantActions(bool unplug = true);
78 bool openFile(const QString&);
79 void saveFile(QFile&);
80 KUrl saveGame(const KUrl& url);
82 void readSettings();
83 void writeSettings();
84 public:
85 MainWindow(const QString& variant);
86 virtual ~MainWindow();
88 protected:
89 void closeEvent(QCloseEvent*);
90 void keyPressEvent(QKeyEvent*);
91 void keyReleaseEvent(QKeyEvent*);
92 private Q_SLOTS:
93 void changeTab(int);
94 void closeTab();
95 public Q_SLOTS:
96 void createConnection(const QString&, const QString&, const QString&,
97 quint16, const QString&, const QString&);
98 void destroyConnection();
99 void testConnect(); // DEBUG
100 void icsConnect();
101 void icsDisconnect();
102 // // void receivedCommand(const QString&);
104 void onEstablishConnection();
105 void onHostLookup();
106 void onConnectionError(int);
107 void onHostFound();
109 void sendLogin();
110 void sendBlankPassword();
111 void prompt();
112 void cleanupGame(const QString&, const QString&);
113 void cleanupGame();
115 void editPosition();
116 void setupGame(const GameInfo*, const PositionInfo&);
117 void setupPGN(const QString& s);
118 void setupExaminedGame(const GameInfo*, const PositionInfo&);
119 void setupObservedGame(const GameInfo*, const PositionInfo&);
120 void newGame();
121 bool newGame(const QString& var, const StatePtr&, bool);
122 void loadGame();
123 void saveGame();
124 void saveGameAs();
125 bool checkOverwrite(const KUrl& url);
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 preferences();
137 void settingsChanged();
142 #endif // MAINWINDOW_H