BtBookshelfWidget::BtBookshelfWidget(QWidget *parent, Qt::WindowFlags flags)
        : QWidget(parent, flags)
        , m_sourceModel(nullptr)
        , m_treeModel(nullptr)
        , m_leftCornerWidget(nullptr)
        , m_rightCornerWidget(nullptr)
{
    // Setup post-filter:
    m_postFilterModel = new BtBookshelfFilterModel(this);

    // Init widgets and such:
    initActions();
    initMenus();
    initWidgets();

    // Connect treeview to model:
    m_treeView->setModel(m_postFilterModel);

    retranslateUi();

    BT_CONNECT(m_nameFilterEdit,  SIGNAL(textEdited(QString)),
               m_postFilterModel, SLOT(setNameFilterFixedString(QString)));
    BT_CONNECT(m_treeView, SIGNAL(contextMenuActivated(QPoint)),
               this,       SLOT(slotShowContextMenu(QPoint)));
    BT_CONNECT(m_treeView,
               SIGNAL(moduleContextMenuActivated(CSwordModuleInfo *, QPoint)),
               this, SLOT(slotShowItemContextMenu(CSwordModuleInfo *, QPoint)));
}
/** Initializes this widget. */
void CModuleResultView::initView() {
    // see also csearchresultview.cpp
    setToolTip(tr("Works chosen for the search and the number of the hits in each work"));
    setHeaderLabels( QStringList(tr("Work")) << tr("Hits") );

    setColumnWidth(0, util::tool::mWidth(this, 8));
    setColumnWidth(1, util::tool::mWidth(this, 4));
    QSize sz(util::tool::mWidth(this, 13), util::tool::mWidth(this, 5));
    //setMinimumSize(sz);
    m_size = sz;
    /// \todo sorting
    //setSorting(0, true);
    //setSorting(1, true);

    //setup the popup menu
    m_popup = new QMenu(this);

    m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
    m_actions.copyMenu->setIcon(CResMgr::searchdialog::result::moduleList::copyMenu::icon());
    m_actions.copy.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.copy.result, SIGNAL(triggered()),
               this,                  SLOT(copyResult()));
    m_actions.copyMenu->addAction(m_actions.copy.result);
    m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.copy.resultWithText, SIGNAL(triggered()),
               this,                           SLOT(copyResultWithText()));
    m_actions.copyMenu->addAction(m_actions.copy.resultWithText);
    m_popup->addMenu(m_actions.copyMenu);

    m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
    m_actions.saveMenu->setIcon(CResMgr::searchdialog::result::moduleList::saveMenu::icon());
    m_actions.save.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.save.result, SIGNAL(triggered()),
               this,                  SLOT(saveResult()));
    m_actions.saveMenu->addAction(m_actions.save.result);
    m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.save.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(saveResultWithText()));
    m_actions.saveMenu->addAction(m_actions.save.resultWithText);
    m_popup->addMenu(m_actions.saveMenu);

    m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
    m_actions.printMenu->setIcon(CResMgr::searchdialog::result::moduleList::printMenu::icon());
    m_actions.print.result = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.print.result, SIGNAL(triggered()),
               this,                   SLOT(printResult()));
    m_actions.printMenu->addAction(m_actions.print.result);
    m_popup->addMenu(m_actions.printMenu);
}
示例#3
0
/** Initializes the view of this widget. */
void CSearchResultView::initView() {
    setToolTip(tr("Search result of the selected work"));
    setHeaderLabel(tr("Results"));
    setDragEnabled(true);
    setRootIsDecorated( false );
    setSelectionMode(QAbstractItemView::ExtendedSelection);

    //setup the popup menu
    m_popup = new QMenu(this);

    m_actions.copyMenu = new QMenu(tr("Copy..."), m_popup);
    m_actions.copyMenu->setIcon(CResMgr::searchdialog::result::foundItems::copyMenu::icon());

    m_actions.copy.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.copy.result, SIGNAL(triggered()),
               this,                  SLOT(copyItems()));
    m_actions.copyMenu->addAction(m_actions.copy.result);

    m_actions.copy.resultWithText = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.copy.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(copyItemsWithText()));
    m_actions.copyMenu->addAction(m_actions.copy.resultWithText);

    m_popup->addMenu(m_actions.copyMenu);

    m_actions.saveMenu = new QMenu(tr("Save..."), m_popup);
    m_actions.saveMenu->setIcon(CResMgr::searchdialog::result::foundItems::saveMenu::icon());

    m_actions.save.result = new QAction(tr("Reference only"), this);
    BT_CONNECT(m_actions.save.result, SIGNAL(triggered()),
               this,                  SLOT(saveItems()) );
    m_actions.saveMenu->addAction(m_actions.save.result);

    m_actions.save.resultWithText = new QAction(tr("Reference with text"), this);
    m_actions.saveMenu->addAction(m_actions.save.resultWithText);
    BT_CONNECT(m_actions.save.resultWithText, SIGNAL(triggered()),
               this,                          SLOT(saveItemsWithText()));
    m_popup->addMenu(m_actions.saveMenu);

    m_actions.printMenu = new QMenu(tr("Print..."), m_popup);
    m_actions.printMenu->setIcon(CResMgr::searchdialog::result::foundItems::printMenu::icon());

    m_actions.print.result = new QAction(tr("Reference with text"), this);
    BT_CONNECT(m_actions.print.result, SIGNAL(triggered()),
               this,                   SLOT(printItems()));
    m_actions.printMenu->addAction(m_actions.print.result);
    m_popup->addMenu(m_actions.printMenu);
}
void CCommentaryReadWindow::initActions() {
    CLexiconReadWindow::initActions(); //make sure the predefined actions are available
    BtActionCollection* ac = actionCollection();
    insertKeyboardActions(ac);

    ac->action("nextEntry").setEnabled(false);
    ac->action("previousEntry").setEnabled(false);

    auto const initAction = [this, ac](QString actionName,
                                       void (CCommentaryReadWindow::* slot)())
    {
        QAction & action = ac->action(std::move(actionName));
        BT_CONNECT(&action, &QAction::triggered, this, slot);
        addAction(&action);
    };

    initAction("nextBook", &CCommentaryReadWindow::nextBook);
    initAction("previousBook", &CCommentaryReadWindow::previousBook);
    initAction("nextChapter", &CCommentaryReadWindow::nextChapter);
    initAction("previousChapter", &CCommentaryReadWindow::previousChapter);
    initAction("nextVerse", &CCommentaryReadWindow::nextVerse);
    initAction("previousVerse", &CCommentaryReadWindow::previousVerse);

    QAction & qaction = ac->action(CResMgr::displaywindows::commentaryWindow::syncWindow::actionName);
    m_syncButton = &qaction;
    addAction(&qaction);

    actionCollection()->readShortcuts("Commentary shortcuts");
}
BtModuleChooserButton* BtModuleChooserBar::addButton() {
    BtModuleChooserButton* b = new BtModuleChooserButton(this, m_moduleType);
    QAction* a = addWidget(b);
    m_buttonList.append(b);

    // the button sends signals directly to the window which then signals back when the module
    // list has changed
    BT_CONNECT(b,        &BtModuleChooserButton::sigModuleAdd,
               m_window, &CReadWindow::slotAddModule);
    BT_CONNECT(b,        &BtModuleChooserButton::sigModuleReplace,
               m_window, &CReadWindow::slotReplaceModule);
    BT_CONNECT(b,        &BtModuleChooserButton::sigModuleRemove,
               m_window, &CReadWindow::slotRemoveModule);

    a->setVisible(true);
    return b;
}
BtShortcutsDialog::BtShortcutsDialog(QWidget* parent)
        : QDialog(parent), m_primaryLabel(nullptr), m_alternateLabel(nullptr), m_primaryButton(nullptr), m_alternateButton(nullptr) {
    setWindowTitle(tr("Configure shortcuts"));
    setMinimumWidth(350);

    QVBoxLayout* vLayout = new QVBoxLayout(this);
    setLayout(vLayout);

    QGridLayout* gridLayout = new QGridLayout();
    vLayout->addLayout(gridLayout);

    QString dialogTooltip = tr("Select first or second shortcut and type the shortcut with keyboard");

    m_primaryButton = new QRadioButton(tr("First shortcut"));
    m_primaryButton->setToolTip(dialogTooltip);
    m_primaryButton->setChecked(true);
    gridLayout->addWidget(m_primaryButton, 0, 0);

    m_alternateButton = new QRadioButton(tr("Second shortcut"));
    m_alternateButton->setToolTip(dialogTooltip);
    gridLayout->addWidget(m_alternateButton, 1, 0);

    m_primaryLabel = new QLabel();
    m_primaryLabel->setToolTip(dialogTooltip);
    m_primaryLabel->setMinimumWidth(100);
    m_primaryLabel->setFrameShape(QFrame::Panel);
    gridLayout->addWidget(m_primaryLabel, 0, 1);

    m_alternateLabel = new QLabel();
    m_alternateLabel->setToolTip(dialogTooltip);
    m_alternateLabel->setMinimumWidth(100);
    m_alternateLabel->setFrameShape(QFrame::Panel);
    gridLayout->addWidget(m_alternateLabel, 1, 1);

    QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    message::prepareDialogBox(buttons);
    vLayout->addWidget(buttons);

    BT_CONNECT(buttons, SIGNAL(accepted()), this, SLOT(accept()));
    BT_CONNECT(buttons, SIGNAL(rejected()), this, SLOT(reject()));
}
/** Sets the modules which are chosen in this module chooser bar. */
void BtModuleChooserBar::setModules( QStringList useModules,CSwordModuleInfo::ModuleType type, CReadWindow* window) {
    m_modules = useModules;
    m_window = window;
    m_moduleType = type;

    clear();

    adjustButtonCount(true);

    //if (!useModules.count()) return;
    for (int i = 0; i < useModules.count(); i++) {
        addButton();
    }
    if (!(m_moduleType == CSwordModuleInfo::GenericBook)) {
        addButton(); // for ADD button
    }
    updateButtonMenus();

    BT_CONNECT(m_window, &CReadWindow::sigModuleListSet,
               this,     &BtModuleChooserBar::slotBackendModulesChanged);
    BT_CONNECT(m_window, &CReadWindow::sigModuleListChanged,
               this,     &BtModuleChooserBar::slotWindowModulesChanged);
}
BtBookshelfLanguagesPage::BtBookshelfLanguagesPage(QWidget * parent)
    : BtBookshelfWizardPage(parent)
{
    // Setup UI:
    m_verticalLayout = new QVBoxLayout(this);
    m_verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
    m_languagesListView = new QListView(this);
    m_languagesListView->setObjectName(QStringLiteral("languagesListView"));
    m_verticalLayout->addWidget(m_languagesListView);

    // Create languages Model:
    m_model = new BtListModel(true, this);
    m_languagesListView->setModel(m_model);
    BT_CONNECT(m_model, &QStandardItemModel::dataChanged,
               this,    &BtBookshelfLanguagesPage::slotDataChanged);
}
void BtBookshelfWidget::initMenus() {
    // Grouping menu:
    m_groupingMenu = new BtBookshelfGroupingMenu(this);
    BT_CONNECT(m_groupingMenu,
               SIGNAL(signalGroupingOrderChanged(
                              BtBookshelfTreeModel::Grouping)),
               this,
               SLOT(slotGroupingActionTriggered(
                            BtBookshelfTreeModel::Grouping)));

    // Context menu
    m_contextMenu = new QMenu(this);
    m_contextMenu->addMenu(m_groupingMenu);
    m_contextMenu->addAction(m_showHideAction);

    // Item context menu
    m_itemContextMenu = m_contextMenu;
}
示例#10
0
BtConfigDialog::BtConfigDialog(QWidget * const parent,
                               Qt::WindowFlags const flags)
    : QDialog(parent, flags)
    , m_contentsList(new QListWidget(this))
    , m_pageWidget(new QStackedWidget(this))
{
    QHBoxLayout * const mainLayout = new QHBoxLayout(this);

    m_contentsList->setViewMode(QListView::IconMode);
    m_contentsList->setMovement(QListView::Static);
    BT_CONNECT(m_contentsList, &QListWidget::currentRowChanged,
               m_pageWidget,   &QStackedWidget::setCurrentIndex);
    mainLayout->addWidget(m_contentsList);

    m_pageLayout = new QVBoxLayout;
    mainLayout->addLayout(m_pageLayout);

    m_pageWidget->setSizePolicy(QSizePolicy::MinimumExpanding,
                                QSizePolicy::MinimumExpanding);
    m_pageLayout->addWidget(m_pageWidget);
}