Exemplo n.º 1
0
PagePalette::PagePalette(QWidget* parent) : ScDockPalette(parent, "PagePalette", 0)
{
	m_scMW = (ScribusMainWindow*) parent;
	m_view = 0;

	setObjectName(QString::fromLocal8Bit("PagePalette"));

	QStackedWidget* stackedWidget = new QStackedWidget(this);
	stackedWidget->setObjectName(QString::fromLocal8Bit("stackedWidget"));

	PagePalette_Pages* pageWidget = new PagePalette_Pages(stackedWidget);
	pageWidget->setObjectName(QString::fromLocal8Bit("PagePalette_Pages"));
	stackedWidget->addWidget(pageWidget);

	setWidget(stackedWidget);

	connect(pageWidget, SIGNAL(gotoMasterPage(QString)), m_scMW, SLOT(editMasterPagesStart(QString)));
	
	Rebuild();
	languageChange();
}
Exemplo n.º 2
0
void interface::CreateWidgets(){
    QString name, type, title, wight, image, id, act;

    xmlItem childItem;
    xmlItem md          = xml.find(xml_root,md_metadata);
    xmlItem ifTabs      = xml.find(xml_root,md_tabs);
    xmlItem itActions   = xml.find(xml_root,md_actions);

    currentTab = 0;
    int idTab = 0;
    int idVal = 0;
    while (!ifTabs.isNull()){
        name = xml.attr(ifTabs,mda_name);
        type = xml.attr(ifTabs,mda_type);
        title = xml.attr(ifTabs,mda_title);

        QGridLayout *l = new QGridLayout(this);
        QTabWidget *root = new QTabWidget;

        l->addWidget(root);
        connect(root,SIGNAL(currentChanged(int)),this,SLOT(on_clicked_tab(int)));
        //—оздаем вкладки разделов
        childItem = xml.find(ifTabs,md_tab);

        while (!childItem.isNull()){
            name = xml.attr(childItem,mda_name);
            type = xml.attr(childItem,mda_type);
            title = xml.attr(childItem,mda_title);
            image = xml.attr(childItem,mda_image);
            QWidget *Tab = UIload.createWidget(type,root,name);
            Tab->setObjectName(name);
            QIcon ic(":/"+image);
            root->setIconSize(QSize(50,50));
            root->addTab(Tab,ic,title);

            QHBoxLayout *vb = new QHBoxLayout(Tab);

            QStackedWidget *stWidget = new QStackedWidget();
            listWindow.insert(idTab,stWidget);
            idTab++;
            //idVal = 0;

            // —оздаем левое меню
            xmlItem childrenItem = xml.find(childItem,md_left_menu,0);
            while (!childrenItem.isNull() && childrenItem.nodeName() == md_left_menu){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);

                iisTaskPanel *tskPanel = new iisTaskPanel(Tab);
                if (!wight.isEmpty())
                    tskPanel->setMinimumWidth(wight.toInt());

                vb->addWidget(tskPanel,0);
                vb->setAlignment(tskPanel,Qt::AlignLeft);
                // √руппы меню
                tskPanel->layout()->setAlignment(Qt::AlignTop);
                xmlItem xmlGr = xml.find(childrenItem,md_group);
                while (!xmlGr.isNull()){
                    name = xml.attr(xmlGr,mda_name);
                    type = xml.attr(xmlGr,mda_type);
                    title = xml.attr(xmlGr,mda_title);


                    //QGroupBox *Gr = new QGroupBox(name,prev);
                    iisTaskBox *Gr = new iisTaskBox(title);
                    tskPanel->addWidget(Gr);
                    Gr->setObjectName(name);

                    //Ёлементы меню
                    xmlItem xmlValue = xml.find(xmlGr,md_value);
                    while (!xmlValue.isNull()){
                        name    = xml.attr(xmlValue,mda_name);
                        id      = xml.attr(xmlValue,mda_id);
                        title   = xml.attr(xmlValue,mda_title);
                        act     = xml.sText(xmlValue,md_comaction);

                        iisIconLabel *val = new iisIconLabel(title);
                        val->setObjectName(name);
                        connect(val,SIGNAL(clicked()),this,SLOT(on_clicked_item()));
                        Gr->addIconLabel(val);
                        list.insert(val,idVal);

                        xmlItem iact = xml.findId(itActions,"",act);
                        xmlItem iObj, iFrm;
                        if (!iact.isNull()){
                            QString idObj = xml.sText(iact,md_objectid);
                            xmlItem tmp =  xml.firstChild(md);
                            while (!tmp.isNull()){
                                iObj = xml.findId(tmp,"",idObj);
                                tmp = xml.nextSibling(tmp);
                                if (!iObj.isNull()) break;
                            }
                        }
                        if (!iObj.isNull()){
                            QString idFrm = xml.sText(iact,md_formid);
                            iObj = xml.find(iObj,md_forms);
                            iFrm = xml.findId(iObj,"",idFrm);
                            // —оздаем форму
                            QWidget *form =eng->OpenForm(iFrm);
                            if (form){
                                stWidget->insertWidget(idVal,form);
                                idVal++;
                            }
                        }

                        xmlValue = xml.nextSibling(xmlValue);
                    }

                    xmlGr = xml.nextSibling(xmlGr);
                }
                childrenItem = xml.nextSibling(childrenItem);
            }


            // ѕрава¤ панель
            childrenItem = xml.find(childItem,md_panel);
            while (!childrenItem.isNull()){
                name = xml.attr(childrenItem,mda_name);
                type = xml.attr(childrenItem,mda_type);
                title = xml.attr(childrenItem,mda_title);
                wight = xml.attr(childrenItem,mda_width);
                if (!wight.isEmpty())
                    stWidget->setMinimumWidth(wight.toInt());
                stWidget->setObjectName(name);
                stWidget->setFrameStyle(1);
                stWidget->setFrameShadow(QFrame::Raised);
                vb->addWidget(stWidget,2);

                childrenItem = xml.nextSibling(childrenItem);
            }
            childItem = xml.nextSibling(childItem);
        }
        ifTabs = xml.nextSibling(ifTabs);
    }

}
void RackWindow::createPluginHost(int position)
{
    //layout settings widget:
    QWidget *settingsWidget = new QWidget;
    settingsWidget->setPalette(QPalette(QColor(0,0,0,160)));
    settingsWidget->setAutoFillBackground(true);

    RPushButton *leftButton = new RPushButton;
    leftButton->setObjectName("rackSettingsLeftArrowButton");
    RPushButton *rightButton = new RPushButton;
    rightButton->setObjectName("rackSettingsRightArrowButton");
    RPushButton *topButton = new RPushButton;
    topButton->setObjectName("rackSettingsTopArrowButton");
    RPushButton *bottomButton = new RPushButton;
    bottomButton->setObjectName("rackSettingsBottomArrowButton");
    RPushButton *closeButton = new RPushButton;
    closeButton->setObjectName("rackSettingsCloseButton");

    //vertical toolbar for plugin buttons:
    QToolBar *pluginHostToolBar = new QToolBar;
    pluginHostToolBar->setObjectName("rackPluginHostToolBar");
    pluginHostToolBar->setOrientation(Qt::Vertical);
    //actiongroup for exclusive handling of buttons:
    QActionGroup *ag = new QActionGroup(pluginHostToolBar);
    ag->setExclusive(true);

    RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ..."));
    addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton");

    QWidget *middleWidget = new QWidget;
    QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget);
    middleLayout->setSpacing(0);
    middleLayout->setContentsMargins(0,0,0,0);
    middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter);
    middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter);

    QGridLayout *settingsLayout = new QGridLayout(settingsWidget);
    settingsLayout->setSpacing(0);
    settingsLayout->setContentsMargins(0,0,0,0);
    settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter);
    settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight);
    settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft);
    settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight);
    settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter);
    settingsLayout->addWidget(middleWidget,1,1);

    QStackedWidget *pluginStack = new QStackedWidget;
    pluginStack->setObjectName("rackPluginStack");
    pluginStack->setAutoFillBackground(true);

    QWidget *pluginHost = new QWidget;
    pluginHost->setMinimumSize(200,80);

    QStackedLayout *overlayLayout = new QStackedLayout(pluginHost);
    overlayLayout->setStackingMode(QStackedLayout::StackAll);
    overlayLayout->addWidget(pluginStack);
    overlayLayout->addWidget(settingsWidget);
    overlayLayout->setCurrentIndex(1);

    //enter/leave settings signals:
    QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map()));
    mapperShowSettingsMode->setMapping(this, 1);
    QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map()));
    mapperHideSettingsMode->setMapping(this, 0);
    QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));
    QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));

    //create plugin host widget signals:
    QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost);
    QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft);
    mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight);
    mapperCreatePluginHost->setMapping(topButton, NewSplitterTop);
    mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
    QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));

    //load plugin signal:
    QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
    m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);

    //close plugin host signal:
    QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
    m_mapperClosePluginHost->setMapping(closeButton, pluginHost);

    //create plugin switch signalmapper
    QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
    mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
    QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));


    ////test show/hide plugin widget

    ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));


    //////


    //create plugin toolbar for mainwindow
    QToolBar *pluginToolBar = new QToolBar;
    pluginToolBar->setObjectName("rackPluginToolBar");
    pluginToolBar->setMovable(false);
    pluginToolBar->hide();
    addToolBar(Qt::BottomToolBarArea, pluginToolBar);

    //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
    pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));

    //plugin bar signals & slots:
    QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));







    //insert new pluginhost widget in splitter, create new splitter if necessary
    if (position == 0)
    {
        m_mainSplitter->addWidget(pluginHost);
        return;
    }
    QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
    QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
    QList<int> widgetsizes;
    int senderpos = parentSplitter->indexOf(senderPluginHost);
    int newposition;
    if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
    else newposition = senderpos + 1;
    switch (position + parentSplitter->orientation()) {             //horizontal=1 vertical=2
    case 0:                                                         //left   horizontal / top vertical
    case 2:                                                         //right  horizontal
    case 4:                                                         //bottom vertical
        widgetsizes = parentSplitter->sizes();
        widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
        widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
        parentSplitter->insertWidget(newposition, pluginHost);
        parentSplitter->setSizes(widgetsizes);
        break;
    case  1:                                                        //left  vertical
    case  3:                                                        //right vertical / bottom horizontal
    case -1:                                                        //top   horizontal
        if (parentSplitter->count() == 1)
        {
            parentSplitter->setOrientation(Qt::Orientation(abs(position)));
            widgetsizes = parentSplitter->sizes();
            widgetsizes.replace(0, int(widgetsizes.at(0)/2));
            widgetsizes.append(widgetsizes.at(0));
            parentSplitter->insertWidget(newposition, pluginHost);
            parentSplitter->setSizes(widgetsizes);
        }
        else if (parentSplitter->count() > 1)
        {
            RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
            QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
            QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
            widgetsizes = parentSplitter->sizes();
            parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
            newSplitter->addWidget(senderPluginHost);
            QList<int> newsizes = newSplitter->sizes();
            newsizes.replace(0, int(newsizes.at(0)/2));
            newsizes.append(newsizes.at(0));
            if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
            else newSplitter->addWidget(pluginHost);
            newSplitter->setSizes(newsizes);
            parentSplitter->setSizes(widgetsizes);
        }
        break;
    }
}