Ejemplo n.º 1
0
void PreferencesDialog::updatePreferencesWidget(const QModelIndex &pNewIndex,
                                                const QModelIndex &pOldIndex)
{
    Q_UNUSED(pOldIndex)

    // Check whether we are dealing with a plugin category

    QStandardItem *item = mModel->itemFromIndex(pNewIndex);
    bool isPluginCategory = mCategoryItems.values().contains(item);

    mResetButton->setEnabled(!isPluginCategory);

    if (isPluginCategory) {
        // We are dealing with a plugin category, so retrieve and set its name
        // and description

        mPluginCategoryWidget->setCategory(item->text());
        mPluginCategoryWidget->setDescription(tr("%1.").arg(formatMessage(pluginCategoryDescription(mItemCategories.value(item)))));

        mGui->stackedWidget->setCurrentWidget(mPluginCategoryWidget);
    } else {
        // We are dealing with our general or a plugin's preferences, so show
        // them

        mGui->stackedWidget->setCurrentWidget(mItemPreferencesWidgets.value(item));
    }

    // Make sure that the current widget has no layout margin (so that not only
    // we don't waste space, but also developers don't have to worry about the
    // layout margin of their preferences widget, assuming it has a layout)

    QLayout *widgetLayout = mGui->stackedWidget->currentWidget()->layout();

    if (widgetLayout != nullptr) {
        widgetLayout->setContentsMargins(QMargins());
    }

    // Make sure that we are big enough to show our contents

    adjustWidgetSize(this);
}
Ejemplo n.º 2
0
KexiFormView::KexiFormView(QWidget *parent, bool dbAware)
        : KexiDataAwareView(parent)
        , d(new Private)
{
    Q_UNUSED(dbAware);
    d->delayedFormContentsResizeOnShow = 0;
//! @todo remove?
    setSortedProperties(true);

    d->scrollView = new KexiFormScrollView(         // will be added to layout
        this, viewMode() == Kexi::DataViewMode);   // in KexiDataAwareView::init()

    initForm();

    if (viewMode() == Kexi::DesignViewMode) {
        connect(form(), SIGNAL(propertySetSwitched()), this, SLOT(slotPropertySetSwitched()));
        connect(form(), SIGNAL(modified(bool)), this, SLOT(setDirty(bool)));
        connect(d->scrollView, SIGNAL(resized()), this, SLOT(setFormModified()));

        connect(d->dbform, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)),
                this, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*)));
        connect(d->dbform, SIGNAL(handleDropEvent(QDropEvent*)),
                this, SLOT(slotHandleDropEvent(QDropEvent*)));

        // action stuff
        plugSharedAction("formpart_taborder", form(), SLOT(editTabOrder()));
        plugSharedAction("formpart_adjust_size", form(), SLOT(adjustWidgetSize()));
//! @todo add formpart_pixmap_collection action
//! @todo add formpart_connections action

        plugSharedAction("edit_copy", form(), SLOT(copyWidget()));
        plugSharedAction("edit_cut", form(), SLOT(cutWidget()));
        plugSharedAction("edit_paste", form(), SLOT(pasteWidget()));
        plugSharedAction("edit_delete", form(), SLOT(deleteWidget()));
        plugSharedAction("edit_select_all", form(), SLOT(selectAll()));
        plugSharedAction("formpart_clear_contents", form(), SLOT(clearWidgetContent()));
        plugSharedAction("edit_undo", form(), SLOT(undo()));
        plugSharedAction("edit_redo", form(), SLOT(redo()));

//! @todo add formpart_layout_menu action
        plugSharedAction("formpart_layout_hbox", form(), SLOT(layoutHBox()));
        plugSharedAction("formpart_layout_vbox", form(), SLOT(layoutVBox()));
        plugSharedAction("formpart_layout_grid", form(), SLOT(layoutGrid()));
#ifdef KEXI_SHOW_SPLITTER_WIDGET
        plugSharedAction("formpart_layout_hsplitter", form(), SLOT(layoutHSplitter()));
        plugSharedAction("formpart_layout_vsplitter", form(), SLOT(layoutVSplitter()));
#endif
        plugSharedAction("formpart_break_layout", form(), SLOT(breakLayout()));

        plugSharedAction("formpart_format_raise", form(), SLOT(bringWidgetToFront()));
        plugSharedAction("formpart_format_lower", form(), SLOT(sendWidgetToBack()));

        plugSharedAction("other_widgets_menu", form(), 0);
        setAvailable("other_widgets_menu", true);

        plugSharedAction("formpart_align_menu", form(), 0);
        plugSharedAction("formpart_align_to_left", form(), SLOT(alignWidgetsToLeft()));
        plugSharedAction("formpart_align_to_right", form(), SLOT(alignWidgetsToRight()));
        plugSharedAction("formpart_align_to_top", form(), SLOT(alignWidgetsToTop()));
        plugSharedAction("formpart_align_to_bottom", form(), SLOT(alignWidgetsToBottom()));
        plugSharedAction("formpart_align_to_grid", form(), SLOT(alignWidgetsToGrid()));

        plugSharedAction("formpart_adjust_size_menu", form(), 0);
        plugSharedAction("formpart_adjust_to_fit", form(), SLOT(adjustWidgetSize()));
        plugSharedAction("formpart_adjust_size_grid", form(), SLOT(adjustSizeToGrid()));
        plugSharedAction("formpart_adjust_height_small", form(),  SLOT(adjustHeightToSmall()));
        plugSharedAction("formpart_adjust_height_big", form(), SLOT(adjustHeightToBig()));
        plugSharedAction("formpart_adjust_width_small", form(), SLOT(adjustWidthToSmall()));
        plugSharedAction("formpart_adjust_width_big", form(), SLOT(adjustWidthToBig()));

        plugSharedAction("format_font", form(), SLOT(changeFont()));

        // - setup local actions
        QList<QAction*> viewActions;
        QAction* a;
        a = form()->action("edit_undo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        a = form()->action("edit_redo");
        a->setProperty("iconOnly", true);
        viewActions << a;
        setViewActions(viewActions);
    }