1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/***************************************************************************
* Copyright (C) 2004-2007 by Georgy Yunaev, gyunaev@ulduzsoft.com *
* Please do not use email address above for bug reports; see *
* the README file *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#ifndef KCHMMAINWINDOW_H
#define KCHMMAINWINDOW_H
#include "kde-qt.h"
#include "libchmfile.h"
#include "forwarddeclarations.h"
#include "kchmviewwindow.h"
#define ENABLE_AUTOTEST_SUPPORT
//! OpenPage extra flags, specifying extra behavior
//! Locate this page in the content tree, and move the cursor there
static const unsigned int OPF_CONTENT_TREE = 1 << 0;
//! Add the previous page into the history
static const unsigned int OPF_ADD2HISTORY = 1 << 1;
//! Open the page in a new tab
static const unsigned int OPF_NEW_TAB = 1 << 2;
//! Open the page in a new tab in background
static const unsigned int OPF_BACKGROUND = 1 << 3;
//! Those events could be sent to main window to do useful things. See handleUserEvents()
class KCHMUserEvent : public TQEvent
{
public:
KCHMUserEvent( const TQString& action, const TQStringList& args = TQStringList())
: TQEvent( TQEvent::User ), m_action(action), m_args(args) {};
TQString m_action;
TQStringList m_args;
};
class KCHMMainWindow : public KQMainWindow
{
Q_OBJECT
TQ_OBJECT
public:
KCHMMainWindow();
~KCHMMainWindow();
bool openPage ( const TQString &url, unsigned int flags = OPF_CONTENT_TREE );
LCHMFile * chmFile() const { return m_chmFile; }
const TQString& getOpenedFileName () { return m_chmFilename; }
KCHMViewWindow * currentBrowser() const;
KCHMContentsWindow * contentsWindow() const { return m_contentsWindow; }
KCHMSettings * currentSettings() const { return m_currentSettings; }
KCHMViewWindowMgr* viewWindowMgr() const { return m_viewWindowMgr; }
KCHMNavToolbar * navigationToolbar() const { return m_navToolbar; }
KCHMSearchWindow * searchWindow() const { return m_searchWindow; }
void showInStatusBar (const TQString& text) { statusBar()->message( text, 2000 ); }
void setTextEncoding (const LCHMTextEncoding * enc);
public slots:
void slotOnTreeClicked( TQListViewItem *item );
void slotOnTreeDoubleClicked( TQListViewItem *item, const TQPoint &, int );
void slotAddBookmark ( );
void slotOpenPageInNewTab( );
void slotOpenPageInNewBackgroundTab( );
void slotEnableFullScreenMode( bool enable );
void slotShowContentsWindow( bool show );
void slotLocateInContentWindow( );
void slotBrowserChanged( KCHMViewWindow * newbrowser );
private slots:
void slotLinkClicked ( const TQString & link, bool& follow_link );
void slotOpenMenuItemActivated();
void slotPrintMenuItemActivated();
void slotAboutMenuItemActivated();
void slotAboutQtMenuItemActivated();
void slotActivateContentTab();
void slotActivateIndexTab();
void slotActivateSearchTab();
void slotActivateBookmarkTab();
void slotBrowserSelectAll();
void slotBrowserCopy();
void slotExtractCHM();
void slotChangeSettingsMenuItemActivated();
void slotHistoryMenuItemActivated ( int );
void slotToggleFullScreenMode( );
void slotNavigateBack() { currentBrowser()->navigateBack(); }
void slotNavigateHome() { currentBrowser()->navigateHome(); }
void slotNavigateForward(){ currentBrowser()->navigateForward(); }
private:
bool parseCmdLineArgs();
void showEvent( TQShowEvent * );
void closeEvent ( TQCloseEvent * e );
void setupSignals ();
void setupToolbarsAndMenu ( );
bool loadChmFile ( const TQString &fileName, bool call_open_page = true );
void closeChmFile();
void refreshCurrentBrowser();
void updateHistoryMenu();
void showOrHideContextWindow( int tabindex );
void showOrHideIndexWindow( int tabindex );
void showOrHideSearchWindow( int tabindex );
// User events
bool event ( TQEvent * e );
bool handleUserEvent( const KCHMUserEvent * event );
void locateInContentTree( const TQString& url );
TQString m_chmFilename;
TQString m_aboutDlgMenuText; // to show in KDE or TQt about dialogs
KCHMViewWindowMgr * m_viewWindowMgr;
KCHMIndexWindow * m_indexWindow;
KCHMSearchWindow * m_searchWindow;
KCHMBookmarkWindow * m_bookmarkWindow;
KCHMContentsWindow * m_contentsWindow;
KTQTabWidget * m_tabWidget;
TQSplitter * m_windowSplitter;
KCHMSearchAndViewToolbar * m_searchToolbar;
KCHMNavToolbar * m_navToolbar;
KCHMSettings * m_currentSettings;
LCHMFile * m_chmFile;
bool m_FirstTimeShow;
KTQPopupMenu * m_menuHistory;
int m_tabContextPage;
int m_tabIndexPage;
int m_tabSearchPage;
int m_tabBookmarkPage;
#if defined (ENABLE_AUTOTEST_SUPPORT)
enum auto_test_state_t
{
STATE_OFF,
STATE_INITIAL,
STATE_CONTENTS_OPENNEXTPAGE,
STATE_OPEN_INDEX,
STATE_SHUTDOWN
};
bool m_useShortAutotest;
auto_test_state_t m_autoteststate;
TQListViewItemIterator m_autotestlistiterator;
private slots:
void runAutoTest();
#endif /* defined (ENABLE_AUTOTEST_SUPPORT) */
};
extern KCHMMainWindow * mainWindow;
#endif // KCHMMAINWINDOW_H
|