summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/btmodulemanagerdialog.cpp
blob: c26de6f79087a52e7a8cb1896bfb9cafabc8eee0 (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
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2008 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/

#include "btmodulemanagerdialog.h"

#include "installpage/btinstallpage.h"
#include "removepage/btremovepage.h"
#include "indexpage/btindexpage.h"

#include "util/cpointers.h"
#include "util/dialogutil.h"
#include "backend/managers/cswordbackend.h"
#include "backend/config/cbtconfig.h"

#include <QDialogButtonBox>


static BtModuleManagerDialog* m_staticModuleManagerDialog = 0;

BtModuleManagerDialog* BtModuleManagerDialog::getInstance(QWidget* parent)
{
	if (!m_staticModuleManagerDialog) {
		m_staticModuleManagerDialog = new BtModuleManagerDialog(parent);
	};
	Q_ASSERT(m_staticModuleManagerDialog);
	return m_staticModuleManagerDialog;
}

BtModuleManagerDialog::BtModuleManagerDialog(QWidget* parent)
	: BtConfigDialog(parent)
{
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowTitle(tr("Bookshelf Manager"));

	// Install page
	BtInstallPage* installPage = new BtInstallPage();
	addPage(installPage);

	//Uninstall page
	BtRemovePage* removePage = new BtRemovePage();
	addPage(removePage);

	//Index page
	BtIndexPage* indexPage = new BtIndexPage();
	addPage(indexPage);

	slotChangePage(0);

	// Dialog button (Close)
	QDialogButtonBox* bbox = new QDialogButtonBox(this);
	bbox->addButton(QDialogButtonBox::Close);
	util::prepareDialogBox(bbox);
	addButtonBox(bbox);
	connect(bbox, SIGNAL(rejected()), SLOT(close()));

	loadDialogSettings();
}

BtModuleManagerDialog::~BtModuleManagerDialog()
{
	saveDialogSettings();
	m_staticModuleManagerDialog = 0;
}

// The QWidget close() sends close event, so does closing by the window X button.
void BtModuleManagerDialog::closeEvent(QCloseEvent*)
{
	qDebug("BtModuleManagerDialog::closeEvent");
}

void BtModuleManagerDialog::loadDialogSettings()
{
	resize(CBTConfig::get(CBTConfig::bookshelfWidth), CBTConfig::get(CBTConfig::bookshelfHeight));
	move(CBTConfig::get(CBTConfig::bookshelfPosX), CBTConfig::get(CBTConfig::bookshelfPosY));
}

void BtModuleManagerDialog::saveDialogSettings()
{
	CBTConfig::set(CBTConfig::bookshelfWidth, size().width());
	CBTConfig::set(CBTConfig::bookshelfHeight, size().height());
	CBTConfig::set(CBTConfig::bookshelfPosX, x());
	CBTConfig::set(CBTConfig::bookshelfPosY, y());
}