summaryrefslogtreecommitdiffstats
path: root/bibletime/frontend/displaywindow/chtmlwritewindow.cpp
blob: 5393a42bd1a7d62e3dcc1f221aafcba5a3e272a8 (plain)
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
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2006 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/



#include "chtmlwritewindow.h"

//frontend includes
#include "frontend/keychooser/ckeychooser.h"
#include "frontend/cprofilewindow.h"

#include "util/cresmgr.h"

//TQt includes

//KDE includes
#include <tdeaction.h>
#include <tdelocale.h>

using namespace Profile;

CHTMLWriteWindow::CHTMLWriteWindow(ListCSwordModuleInfo modules, CMDIArea* parent, const char *name)
: CPlainWriteWindow(modules, parent, name) {}

CHTMLWriteWindow::~CHTMLWriteWindow() {}

void CHTMLWriteWindow::initView() {
	CWriteDisplay* writeDisplay = CDisplay::createWriteInstance(this, CDisplay::HTMLDisplay);
	Q_ASSERT(writeDisplay);
	setDisplayWidget( writeDisplay );
	setCentralWidget( displayWidget()->view() );

	setMainToolBar( new TDEToolBar(this) );
	mainToolBar()->setFullSize(true);
	addDockWindow(mainToolBar());

	setKeyChooser( CKeyChooser::createInstance(modules(), key(), mainToolBar()) );
	mainToolBar()->insertWidget(0,keyChooser()->sizeHint().width(),keyChooser());
	mainToolBar()->setFullSize(false);
};

void CHTMLWriteWindow::initConnections() {
	CWriteWindow::initConnections();

	connect(keyChooser(), TQT_SIGNAL(keyChanged(CSwordKey*)),
			TQT_TQOBJECT(this), TQT_SLOT(lookup(CSwordKey*)));
	connect(displayWidget()->connectionsProxy(), TQT_SIGNAL(textChanged()),
			TQT_TQOBJECT(this), TQT_SLOT(textChanged()) );
};

void CHTMLWriteWindow::initToolbars() {
	//setup the toolbar
	m_actions.syncWindow = new TDEToggleAction(i18n("Sync with active Bible"),
						   CResMgr::displaywindows::commentaryWindow::syncWindow::icon,
						   CResMgr::displaywindows::commentaryWindow::syncWindow::accel,
						   actionCollection(),
						   CResMgr::displaywindows::commentaryWindow::syncWindow::actionName
											);
	m_actions.syncWindow->setToolTip(CResMgr::displaywindows::commentaryWindow::syncWindow::tooltip);
	m_actions.syncWindow->plug(mainToolBar());

	m_actions.saveText = new TDEAction( i18n("Save text"),
									  CResMgr::displaywindows::writeWindow::saveText::icon,
									  CResMgr::displaywindows::writeWindow::saveText::accel,
									  TQT_TQOBJECT(this), TQT_SLOT( saveCurrentText()  ),
									  actionCollection(),
									  CResMgr::displaywindows::writeWindow::saveText::actionName
									);
	m_actions.saveText->setToolTip( CResMgr::displaywindows::writeWindow::saveText::tooltip );
	m_actions.saveText->plug(mainToolBar());

	m_actions.deleteEntry = new TDEAction(i18n("Delete current entry"),
										CResMgr::displaywindows::writeWindow::deleteEntry::icon,
										CResMgr::displaywindows::writeWindow::deleteEntry::accel,
										TQT_TQOBJECT(this), TQT_SLOT(deleteEntry()),
										actionCollection(),
										CResMgr::displaywindows::writeWindow::deleteEntry::actionName
									   );
	m_actions.deleteEntry->setToolTip( CResMgr::displaywindows::writeWindow::deleteEntry::tooltip );
	m_actions.deleteEntry->plug(mainToolBar());

	m_actions.restoreText = new TDEAction(i18n("Restore original text"),
										CResMgr::displaywindows::writeWindow::restoreText::icon,
										CResMgr::displaywindows::writeWindow::restoreText::accel,
										TQT_TQOBJECT(this), TQT_SLOT(restoreText()), actionCollection(),
										CResMgr::displaywindows::writeWindow::restoreText::actionName
									   );
	m_actions.restoreText->setToolTip( CResMgr::displaywindows::writeWindow::restoreText::tooltip );
	m_actions.restoreText->plug(mainToolBar());


	TDEToolBar* bar = new TDEToolBar(this);
	bar->setFullSize(true);
	addDockWindow(bar);

	displayWidget()->setupToolbar( bar, actionCollection() );
}

void CHTMLWriteWindow::storeProfileSettings( CProfileWindow* profileWindow ) {
	CWriteWindow::storeProfileSettings(profileWindow);
	profileWindow->setWindowSettings( m_actions.syncWindow->isChecked() );
};

void CHTMLWriteWindow::applyProfileSettings( CProfileWindow* profileWindow ) {
	CWriteWindow::applyProfileSettings(profileWindow);
	if (profileWindow->windowSettings()) {
		m_actions.syncWindow->setChecked(true);
	}
};

/** Is called when the current text was changed. */
void CHTMLWriteWindow::textChanged() {
	m_actions.saveText->setEnabled( displayWidget()->isModified() );
	m_actions.restoreText->setEnabled( displayWidget()->isModified() );
}

/** Loads the original text from the module. */
void CHTMLWriteWindow::restoreText() {
	lookup(key());
	displayWidget()->setModified(false);
	textChanged();
}

const bool CHTMLWriteWindow::syncAllowed() const {
	return m_actions.syncWindow->isChecked();
}

#include "chtmlwritewindow.moc"