summaryrefslogtreecommitdiff
path: root/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/bookshelfmanager/installpage/btinstallpage.cpp')
-rw-r--r--src/frontend/bookshelfmanager/installpage/btinstallpage.cpp95
1 files changed, 49 insertions, 46 deletions
diff --git a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
index d3bac59..9c7955a 100644
--- a/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
+++ b/src/frontend/bookshelfmanager/installpage/btinstallpage.cpp
@@ -46,8 +46,8 @@ const QString selectedModuleKey("GUI/BookshelfManager/InstallPage/selectedModule
// *********** Config dialog page: Install/Update **********
// *********************************************************
-BtInstallPage::BtInstallPage(QWidget *parent)
- : BtConfigPage(parent)
+BtInstallPage::BtInstallPage(BtModuleManagerDialog *parent)
+ : BtConfigDialog::Page(util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon), parent)
, m_groupingOrder(groupingOrderKey)
, m_modulesSelected(0)
, m_modulesSelectedSources(0)
@@ -58,10 +58,11 @@ BtInstallPage::BtInstallPage(QWidget *parent)
// Initialize widgets:
initView();
initConnections();
+
+ retranslateUi();
}
void BtInstallPage::setInstallEnabled(bool b) {
- qDebug() << "void BtInstallPage::setInstallEnabled(bool b) start";
m_installButton->setEnabled(b);
}
@@ -73,36 +74,31 @@ void BtInstallPage::initView() {
namespace DU = util::directory;
// Warning label:
-
- m_warningLabel = util::tool::explanationLabel(this, tr("WARNING!!!"),
- tr("If you live in a persecuted country and don't want to risk "
- "detection don't use remote sources."));
+ m_warningLabel = new QLabel(this);
// Source chooser:
- m_sourceGroupBox = new QGroupBox(tr("Select installation &source:"), this);
+ m_sourceGroupBox = new QGroupBox(this);
m_sourceGroupBox->setFlat(true);
m_sourceComboBox = new QComboBox(this);
m_sourceComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
initSourcesCombo();
- m_sourceAddButton = new QPushButton(tr("&Add..."));
- m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceAddButton = new QPushButton(this);
m_sourceAddButton ->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::add_icon));
- m_sourceDeleteButton = new QPushButton(tr("&Delete..."));
- m_sourceDeleteButton->setToolTip(tr("Delete this source"));
+ m_sourceDeleteButton = new QPushButton(this);
m_sourceDeleteButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::delete_icon));
QHBoxLayout *sourceChooserLayout = new QHBoxLayout();
- sourceChooserLayout->setContentsMargins(0, 0, 0, 0);
+ sourceChooserLayout->setContentsMargins(0, 8, 0, 0);
sourceChooserLayout->addWidget(m_sourceComboBox, 1);
sourceChooserLayout->addWidget(m_sourceAddButton);
sourceChooserLayout->addWidget(m_sourceDeleteButton);
m_sourceGroupBox->setLayout(sourceChooserLayout);
// Works chooser:
- m_worksGroupBox = new QGroupBox(tr("Select &works to install:"), this);
+ m_worksGroupBox = new QGroupBox(this);
m_worksGroupBox->setFlat(true);
m_worksLayout = new QStackedLayout();
m_worksGroupBox->setLayout(m_worksLayout);
@@ -113,35 +109,31 @@ void BtInstallPage::initView() {
m_installGroupBox->setFlat(true);
retranslateInstallGroupBox();
- m_pathLabel = new QLabel(tr("Install &folder:"));
+ m_pathLabel = new QLabel(this);
m_pathCombo = new QComboBox(this);
m_pathCombo->setMinimumContentsLength(20);
m_pathCombo->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
m_pathCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
- m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
m_pathCombo->view()->setTextElideMode(Qt::ElideMiddle);
m_pathLabel->setBuddy(m_pathCombo);
initPathCombo();
m_configurePathButton = new QToolButton(this);
- m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
m_configurePathButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::path_icon));
- m_installButton = new QPushButton(tr("&Install..."), this);
- m_installButton->setToolTip(tr("Install or update selected works"));
+ m_installButton = new QPushButton(this);
m_installButton->setIcon(DU::getIcon(CResMgr::bookshelfmgr::installpage::install_icon));
m_installButton->setEnabled(false);
QHBoxLayout *pathLayout = new QHBoxLayout();
- pathLayout->setContentsMargins(0, 0, 0, 0);
+ pathLayout->setContentsMargins(0, 8, 0, 0);
pathLayout->addWidget(m_pathLabel);
pathLayout->addWidget(m_pathCombo);
pathLayout->addWidget(m_configurePathButton);
pathLayout->addWidget(m_installButton);
m_installGroupBox->setLayout(pathLayout);
- Q_ASSERT(qobject_cast<QVBoxLayout*>(layout()) != 0);
- QVBoxLayout *mainLayout = static_cast<QVBoxLayout*>(layout());
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(m_warningLabel);
mainLayout->addWidget(m_sourceGroupBox);
mainLayout->addWidget(m_worksGroupBox, 1);
@@ -232,11 +224,10 @@ void BtInstallPage::initSourcesCombo() {
}
void BtInstallPage::activateSource(const sword::InstallSource &src) {
- qDebug() << "Selected source" << src.caption;
qApp->setOverrideCursor(Qt::WaitCursor);
BtInstallPageWorksWidget *w = m_sourceMap.value(QString(src.caption), 0);
if (w == 0) {
- if (parentDialog() != 0) parentDialog()->setEnabled(false);
+ window()->setEnabled(false);
qApp->processEvents();
w = new BtInstallPageWorksWidget(src, m_groupingOrder, this);
m_sourceMap.insert(QString(src.caption), w);
@@ -245,7 +236,7 @@ void BtInstallPage::activateSource(const sword::InstallSource &src) {
this, SLOT(slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping&)));
connect(w->treeModel(), SIGNAL(moduleChecked(CSwordModuleInfo*,bool)),
this, SLOT(slotSelectedModulesChanged()));
- if (parentDialog() != 0) parentDialog()->setEnabled(true);
+ window()->setEnabled(true);
} else {
disconnect(w->treeView()->header(), SIGNAL(geometriesChanged()),
this, SLOT(slotHeaderChanged()));
@@ -268,6 +259,30 @@ void BtInstallPage::retranslateInstallGroupBox() {
}
}
+void BtInstallPage::retranslateUi() {
+ setHeaderText(tr("Install/Update"));
+
+ util::tool::initExplanationLabel(m_warningLabel, tr("WARNING!!!"),
+ tr("If you live in a persecuted country and don't want to risk "
+ "detection don't use remote sources."));
+
+ m_sourceGroupBox->setTitle(tr("Select installation &source:"));
+ m_sourceAddButton->setText(tr("&Add..."));
+ m_sourceAddButton ->setToolTip(tr("Add new source"));
+ m_sourceDeleteButton->setText(tr("&Delete..."));
+ m_sourceDeleteButton->setToolTip(tr("Delete this source"));
+
+ m_worksGroupBox->setTitle(tr("Select &works to install:"));
+
+ m_pathLabel->setText(tr("Install &folder:"));
+ m_pathCombo->setToolTip(tr("The folder where the new works will be installed"));
+ m_configurePathButton->setToolTip(tr("Configure folders where works are installed and found"));
+ m_installButton->setText(tr("&Install..."));
+ m_installButton->setToolTip(tr("Install or update selected works"));
+
+ retranslateInstallGroupBox();
+}
+
void BtInstallPage::slotGroupingOrderChanged(const BtBookshelfTreeModel::Grouping &g) {
m_groupingOrder = g;
m_groupingOrder.saveTo(groupingOrderKey);
@@ -282,8 +297,6 @@ void BtInstallPage::slotHeaderChanged() {
}
void BtInstallPage::slotInstall() {
- qDebug() << "BtInstallPage::slotInstall";
-
// check that the destination path is writable, do nothing if not and user doesn't want to continue
QDir dir = selectedInstallPath();
bool canWrite = true;
@@ -319,23 +332,20 @@ void BtInstallPage::slotInstall() {
cm.insert(m);
}
- if (cm.empty()) return;
+ if (cm.empty())
+ return;
/// \todo first remove all modules which will be updated from the module list
// but what modules? all with the same real name? (there may be _n modules...)
- BtModuleManagerDialog *parentDlg = dynamic_cast<BtModuleManagerDialog*>(parentDialog());
-
- BtInstallProgressDialog *dlg = new BtInstallProgressDialog(cm, selectedInstallPath(), parentDlg);
-
- if (!parentDlg) qDebug() << "error, wrong parent!";
+ // progressDialog is WA_DeleteOnClose
+ BtInstallProgressDialog *progressDialog = new BtInstallProgressDialog(cm, selectedInstallPath(), this);
m_installButton->setEnabled(false);
// the progress dialog is now modal, it can be made modeless later.
- dlg->exec();
+ progressDialog->exec();
- qDebug() << "BtSourceWidget::slotInstallAccepted end";
}
delete dlg;
}
@@ -358,7 +368,10 @@ void BtInstallPage::slotSourceAdd() {
QSharedPointer<SSISD> dlg(new SSISD());
if (dlg->exec() == QDialog::Accepted) {
- if (!dlg->wasRemoteListAdded()) {
+ if (dlg->wasRemoteListAdded()) {
+ initSourcesCombo();
+ }
+ else {
sword::InstallSource newSource = dlg->getSource();
if ( !((QString)newSource.type.c_str()).isEmpty() ) { // we have a valid source to add
BtInstallBackend::addSource(newSource);
@@ -415,16 +428,6 @@ void BtInstallPage::slotSelectedModulesChanged() {
retranslateInstallGroupBox();
}
-// implement the BtConfigPage methods
-
-const QIcon &BtInstallPage::icon() const {
- return util::directory::getIcon(CResMgr::bookshelfmgr::installpage::icon);
-}
-
-QString BtInstallPage::header() const {
- return tr("Install/Update");
-}
-
void BtInstallPage::slotSwordSetupChanged() {
QString moduleName = m_sourceComboBox->currentText();