Moved m_url into the controller. Fixes #62.
[tagua/yd.git] / src / mainwindow.h
blobb7494cbd9f79a12323f3be278e6b41ef1d180303
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 "ui.h"
24 #include "common.h"
25 #include "export.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 TabWidget;
38 class QStackedWidget;
39 class QActionGroup;
40 class KAction;
41 class KIcon;
43 class TAGUA_EXPORT MainWindow : public KXmlGuiWindow {
44 Q_OBJECT
45 QDockWidget* movelist_dock;
46 QDockWidget* console_dock;
48 TabWidget* m_main;
49 QStackedWidget* m_movelist_stack;
50 boost::shared_ptr<ICSConnection> m_connection;
51 Console* console;
53 QMenu* m_engine_menu;
55 ChessTable* table();
56 UI m_ui;
57 UI& ui() { return m_ui; }
58 void createTab(ChessTable*, const boost::shared_ptr<Controller>&,
59 const QString& label, int index = -1);
61 QDir m_iconDir;
62 std::vector<EngineInfo*> m_engines;
64 boost::shared_ptr<QConnect> quickConnectDialog;
65 NewGame* newGameDialog;
67 // QAction *mkAction(const QString& txt, QKeySequence shk, QObject *o,
68 // const char *sl, QString name, QObject *par = NULL);
69 void setupActions();
70 void setupEngineMenu();
71 KAction* addPromotionAction(const QString& name, const QString& text, const char* uiSlot);
72 KAction* installRegularAction(const QString& name, const KIcon& icon, const QString& text,
73 QObject* obj, const char* slot);
74 void updateVariantActions(bool unplug = true);
76 bool openFile(const QString&);
77 void saveFile(QFile&);
78 KUrl saveGame(const KUrl& url);
80 void readSettings();
81 void writeSettings();
82 public:
83 MainWindow(const QString& variant);
84 virtual ~MainWindow();
86 protected:
87 void closeEvent(QCloseEvent*);
88 void keyPressEvent(QKeyEvent*);
89 void keyReleaseEvent(QKeyEvent*);
90 private Q_SLOTS:
91 void changeTab(int);
92 void closeTab();
93 public Q_SLOTS:
94 void createConnection(const QString&, const QString&, const QString&,
95 quint16, const QString&, const QString&);
96 void destroyConnection();
97 void testConnect(); // DEBUG
98 void icsConnect();
99 void icsDisconnect();
100 // // void receivedCommand(const QString&);
102 void onEstablishConnection();
103 void onHostLookup();
104 void onConnectionError(int);
105 void onHostFound();
107 void sendLogin();
108 void sendBlankPassword();
109 void prompt();
110 void cleanupGame(const QString&, const QString&);
111 void cleanupGame();
113 void editPosition();
114 void setupGame(const GameInfo*, const PositionInfo&);
115 void setupPGN(const QString& s);
116 void setupExaminedGame(const GameInfo*, const PositionInfo&);
117 void setupObservedGame(const GameInfo*, const PositionInfo&);
118 void newGame();
119 bool newGame(const QString& var, AbstractPosition::Ptr, bool);
120 void loadGame();
121 void saveGame();
122 void saveGameAs();
123 void quit();
124 void flipView();
125 void toggleConsole();
126 void toggleMoveList();
128 void displayMessage(const QString& msg);
129 void displayErrorMessage(ErrorCode);
130 void flash();
132 // void prefHighlight();
133 void preferences();
134 void settingsChanged();
139 #endif // MAINWINDOW_H