BtInstallPathDialog::BtInstallPathDialog() { namespace DU = util::directory; setWindowTitle(tr("Bookshelf Folders")); QVBoxLayout *mainLayout; QHBoxLayout *viewLayout; mainLayout = new QVBoxLayout(this); viewLayout = new QHBoxLayout(); QString l1 = tr("Works can be installed in one or more folders. After setting up folders here you can choose one of them in Install page."); /// \bug The following string has an extra space character: QString l2 = tr("BibleTime and the SWORD library find the works from all of these folders. If a folder is removed here it still exists in the system with all the works in it."); QLabel* mainLabel = util::tool::explanationLabel(this, tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>")); mainLayout->addWidget(mainLabel); QString swordConfPath = instbackend::swordConfigFilename(); /// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this); QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this); confPathLabel->setWordWrap(true); mainLayout->addWidget(confPathLabel); m_swordPathListBox = new QTreeWidget(this); m_swordPathListBox->header()->hide(); QString rwfolderitem(tr("Folders where new works can be installed")); m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));; m_writableItem->setFlags(Qt::ItemIsEnabled); m_readableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Read-only folders")));; m_readableItem->setFlags(Qt::ItemIsEnabled); m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));; m_nonexistingItem->setFlags(Qt::ItemIsEnabled); QStringList targets = instbackend::targetList(); foreach (QString pathname, targets) { addPathToList(pathname); }
BtInstallPathDialog::BtInstallPathDialog() { namespace DU = util::directory; setWindowTitle(tr("Bookshelf Folders")); QVBoxLayout *mainLayout; QHBoxLayout *viewLayout; mainLayout = new QVBoxLayout(this); viewLayout = new QHBoxLayout(); QString l1 = tr("Works can be installed in one or more folders. After setting up folders here you can choose one of them in Install page."); /// \bug The following string has an extra space character: QString l2 = tr("BibleTime and the SWORD library find the works from all of these folders. If a folder is removed here it still exists in the system with all the works in it."); QLabel* mainLabel = util::tool::explanationLabel(this, tr("Configure bookshelf folders"), l1 + QString("<small><br/><br/>") + l2 + QString("</small>")); mainLayout->addWidget(mainLabel); QString swordConfPath = BtInstallBackend::swordConfigFilename(); /// \todo After releasing 2.4, change the following line to: QLabel *confPathLabel = new QLabel(tr("Configuration file for the folders is: <b>%1</b>").arg(swordConfPath), this); QLabel* confPathLabel = new QLabel(tr("Configuration file for the folders is: ").append("<b>%1</b>").arg(swordConfPath), this); confPathLabel->setWordWrap(true); mainLayout->addWidget(confPathLabel); m_swordPathListBox = new QTreeWidget(this); m_swordPathListBox->setHeaderHidden(true); QString rwfolderitem(tr("Folders where new works can be installed")); m_writableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(rwfolderitem));; m_writableItem->setFlags(Qt::ItemIsEnabled); m_readableItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Read-only folders")));; m_readableItem->setFlags(Qt::ItemIsEnabled); m_nonexistingItem = new QTreeWidgetItem(m_swordPathListBox, QStringList(tr("Nonexistent folders")));; m_nonexistingItem->setFlags(Qt::ItemIsEnabled); QStringList targets = BtInstallBackend::targetList(); Q_FOREACH(QString const & pathname, targets) addPathToList(pathname); updateTopLevelItems(); viewLayout->addWidget(m_swordPathListBox); QVBoxLayout* buttonLayout = new QVBoxLayout(); m_addButton = new QPushButton(tr("&Add..."), this); m_addButton->setToolTip(tr("Add new folder")); m_addButton->setIcon(CResMgr::bookshelfmgr::paths::icon_add()); connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAddClicked())); buttonLayout->addWidget(m_addButton); m_editButton = new QPushButton(tr("&Edit..."), this); m_editButton->setToolTip(tr("Edit the selected folder")); m_editButton->setIcon(CResMgr::bookshelfmgr::paths::icon_edit()); connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEditClicked())); buttonLayout->addWidget(m_editButton); m_removeButton = new QPushButton(tr("&Remove"), this); m_removeButton->setToolTip(tr("Remove the selected folder")); m_removeButton->setIcon(CResMgr::bookshelfmgr::paths::icon_remove()); connect(m_removeButton, SIGNAL(clicked()), this, SLOT(slotRemoveClicked())); buttonLayout->addWidget(m_removeButton); QSpacerItem* spacerItem = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); buttonLayout->addItem(spacerItem); viewLayout->addLayout(buttonLayout); mainLayout->addLayout(viewLayout); QDialogButtonBox* buttonBox = new QDialogButtonBox(this); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::NoButton | QDialogButtonBox::Ok); message::prepareDialogBox(buttonBox); mainLayout->addWidget(buttonBox); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); //clumsy way to set width. Could someone please fix Qt to have an easy way to set widget sizes? int textWidth = fontMetrics().width(rwfolderitem.append("MMMMMMMMMM")); int buttonWidth = m_addButton->width(); resize(textWidth + buttonWidth, size().height()); }