Esempio n. 1
0
void StartMenu::SortScrollArea(QScrollArea *area){
  //qDebug() << "Sorting Scroll Area:";
  //Sort all the items in the scroll area alphabetically
  QLayout *lay = area->widget()->layout();
  QStringList items;
  for(int i=0; i<lay->count(); i++){
    items << lay->itemAt(i)->widget()->whatsThis();
  }
  
  items.sort();
  //qDebug() << " - Sorted Items:" << items;
  for(int i=0; i<items.length(); i++){
    if(items[i].isEmpty()){ continue; }
    //QLayouts are weird in that they can only add items to the end - need to re-insert almost every item
    for(int j=0; j<lay->count(); j++){
      //Find this item
      if(lay->itemAt(j)->widget()->whatsThis()==items[i]){
	//Found it - now move it if necessary
	//qDebug() << "Found Item:" << items[i] << i << j;
	lay->addItem( lay->takeAt(j) );
	break;
      }
    }
  }
}
void TestController::unload() {
    //Inputs
    QLayout* layout = getView().getUi().grx_test_inputs->layout();

    for (int i = layout->count() - 1; i >= 0; --i) {
        QLayoutItem* item = layout->itemAt(i);
        GuiGrapher* g = dynamic_cast<GuiGrapher*> (item->widget());
        if (g) {
            QObject::disconnect(g, SIGNAL(onChangeInputValue()), this,
                                SLOT(onInputValueChanged()));
        }
        layout->removeItem(item);
        delete item->widget();
        delete item;
    }

    //Rules
    getView().getUi().lsw_test_rules->clear();
    getView().getUi().lsw_test_rules_activation->clear();

    //Outputs
    layout = getView().getUi().grx_test_outputs->layout();
    for (int i = layout->count() - 1; i >= 0; --i) {
        QLayoutItem* item = layout->itemAt(i);
        GuiGrapher* g = dynamic_cast<GuiGrapher*> (item->widget());
        if (g) {
            QObject::disconnect(this, SIGNAL(forceUpdate()), g, SLOT(updateUi()));
        }
        layout->removeItem(item);
        delete item->widget();
        delete item;
    }
}
Esempio n. 3
0
void StartupView::showDetailsForItem( const QModelIndex & index )
{
  QLayout * layout = m_projectDetailView->layout();

  for( int i = 0; i < layout->count(); i++ )
  {
    delete layout->itemAt(i)->widget();
    layout->removeItem(layout->itemAt(i));
  }

  QString name = m_templateListModel->data(index,Qt::ToolTipRole).toString();

  QString description = m_templateListModel->data(index,Qt::WhatsThisRole).toString();

  if( ! name.isEmpty() )
  {
    auto nameLabel = new QLabel(name);

    nameLabel->setStyleSheet("QLabel { font: bold }");

    layout->addWidget(nameLabel);
  }

  if( ! description.isEmpty() )
  {
    auto descriptionLabel = new QTextEdit(description);
    
    descriptionLabel->setStyleSheet("QTextEdit { border: none; }");
    
    descriptionLabel->setReadOnly(true);

    layout->addWidget(descriptionLabel);
  }

}
Esempio n. 4
0
void MainWindow::changeScreen(QWidget* screen){
	mCurrentScreen = screen;

	QLayout* layout = ui.screenContainer->layout();
	layout->removeWidget(layout->itemAt(0)->widget());
	layout->addWidget(mCurrentScreen);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_layout_at (const v8::Arguments &Args) {

   v8::HandleScope scope;
   V8Value result = v8::Undefined ();

   JsModuleUiV8QtBasic *self = _to_self (Args);
   if (self) {

      QLayout *layout = self->v8_to_qobject<QLayout> (Args.This ());
      if (layout) {

         if (Args.Length () > 0) {

            QWidget *widget = layout->itemAt (v8_to_int32 (Args[0]))->widget ();
            if (widget) {

               result = self->create_v8_qwidget (widget);
            }
         }
      }
   }

   return scope.Close (result);
}
Esempio n. 6
0
void GPhidgetManagerWidget::UpdateSubDevicesWidgetList()
{
	GPhidgetManager* pPhidMan = qobject_cast<GPhidgetManager*>(Device());
	QLayout *pLayout = layout();
	if(!pPhidMan || !pLayout)
		return;
	QList<GDevice*> oldList = m_ListDev;
	m_ListDev = pPhidMan->m_SerialPhidgetModules.values();
	// make a list of new items in the m_ListDev
	QList<GDevice*> newDevicesInList = m_ListDev;
	foreach(GDevice* pDev, m_ListDev)
		if(oldList.contains(pDev))
			newDevicesInList.removeOne(pDev);
	// make a list of items that are gone from the m_ListDev
	QList<GDevice*> goneDevicesInList = oldList;
	foreach(GDevice* pDev, oldList)
		if(m_ListDev.contains(pDev))
			goneDevicesInList.removeOne(pDev);

	// lets delete the gone's and create the new's
	foreach(GDevice* pDev, goneDevicesInList) {
		for (int i = 0; i < pLayout->count(); ++i) {
			GDeviceWidget* pWid = qobject_cast<GDeviceWidget*>(pLayout->itemAt(i)->widget());
			if(pWid && goneDevicesInList.contains(pWid->Device())) {
				pLayout->removeWidget(pWid);
				delete pWid;
			}
		}
	}
	foreach(GDevice* pDev, newDevicesInList) {
		GDeviceWidget* subDevWidget = pDev->ProvideNewDeviceGroupBox(this);
		pLayout->addWidget(subDevWidget);
	}
void QToolBar::setIconSize(const QSize &iconSize)
{
    Q_D(QToolBar);
    QSize sz = iconSize;
    if (!sz.isValid()) {
        QMainWindow *mw = qobject_cast<QMainWindow *>(parentWidget());
        if (mw && mw->layout()) {
            QLayout *layout = mw->layout();
            int i = 0;
            QLayoutItem *item = 0;
            do {
                item = layout->itemAt(i++);
                if (item && (item->widget() == this))
                    sz = mw->iconSize();
            } while (!sz.isValid() && item != 0);
        }
    }
    if (!sz.isValid()) {
        const int metric = style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, this);
        sz = QSize(metric, metric);
    }
    if (d->iconSize != sz) {
        d->iconSize = sz;
        setMinimumSize(0, 0);
        emit iconSizeChanged(d->iconSize);
    }
    d->explicitIconSize = iconSize.isValid();

    d->layout->invalidate();
}
Esempio n. 8
0
// Writes the user input from the form into the oc_auth_form structs we got from
// libopenconnect, and wakes the worker thread up to try to log in and obtain a
// cookie with this data
void OpenconnectAuthWidget::formLoginClicked()
{
    Q_D(OpenconnectAuthWidget);

    const int lastIndex = d->ui.loginBoxLayout->count() - 1;
    QLayout *layout = d->ui.loginBoxLayout->itemAt(d->passwordFormIndex)->layout();
    struct oc_auth_form *form = (struct oc_auth_form *) d->ui.loginBoxLayout->itemAt(lastIndex)->widget()->property("openconnect_form").value<quintptr>();

    for (int i = 0; i < layout->count(); i++) {
        QLayoutItem *item = layout->itemAt(i);
        QWidget *widget = item->widget();
        if (widget && widget->property("openconnect_opt").isValid()) {
            struct oc_form_opt *opt = (struct oc_form_opt *) widget->property("openconnect_opt").value<quintptr>();
            const QString key = QString("form:%1:%2").arg(QLatin1String(form->auth_id)).arg(QLatin1String(opt->name));
            if (opt->type == OC_FORM_OPT_PASSWORD || opt->type == OC_FORM_OPT_TEXT) {
                QLineEdit *le = qobject_cast<QLineEdit*>(widget);
                QByteArray text = le->text().toUtf8();
                openconnect_set_option_value(opt, text.data());
                if (opt->type == OC_FORM_OPT_TEXT) {
                    d->secrets.insert(key, le->text());
                } else {
                    d->tmpSecrets.insert(key, le->text());
                }
            } else if (opt->type == OC_FORM_OPT_SELECT) {
                QComboBox *cbo = qobject_cast<QComboBox*>(widget);
                QByteArray text = cbo->itemData(cbo->currentIndex()).toString().toAscii();
                openconnect_set_option_value(opt, text.data());
                d->secrets.insert(key,cbo->itemData(cbo->currentIndex()).toString());
            }
        }
    }

    deleteAllFromLayout(d->ui.loginBoxLayout);
    d->workerWaiting.wakeAll();
}
Esempio n. 9
0
AskColorDialog::AskColorDialog(QColor initial, QWidget *parent) :
	QColorDialog(initial, parent)
{
	hexcode = new QLineEdit( this);
	hexcode->setMaxLength(9);
	QLayout *layout = this->layout();

	// find a nice spot in the layout...
	for (int k=0; k<2; k++) if (layout) {
		for (int i=2; i>=0; i--) {
			QLayoutItem *test = layout->itemAt(i);
			if (test) if (test->layout()) {
				layout = test->layout();
				//qDebug("ok %d (%d)",i,k);
				break;
			}
		}
	}

	if (layout) layout->addWidget(hexcode);

	connect(hexcode,SIGNAL(textEdited(QString)),this,SLOT(setHex()));
	connect(this,SIGNAL(currentColorChanged(QColor)),this,SLOT(updateHex()));


	setOption(ShowAlphaChannel, true);
	updateHex();
	setHex();
}
Esempio n. 10
0
ActivityWidget::ActivityWidget(const QString& activity, QWidget* parent)
    : QWidget(parent)
    , m_ui(new Ui::ActivityWidget)
    , m_profilesConfig(KSharedConfig::openConfig("powermanagementprofilesrc", KConfig::SimpleConfig | KConfig::CascadeConfig))
    , m_activity(activity)
    , m_activityConsumer(new KActivities::Consumer(this))
    , m_actionEditWidget(new ActionEditWidget(QString("Activities/%1/SeparateSettings").arg(activity)))
{
    m_ui->setupUi(this);

    m_ui->separateSettingsLayout->addWidget(m_actionEditWidget);

    for (int i = 0; i < m_ui->specialBehaviorLayout->count(); ++i) {
        QWidget *widget = m_ui->specialBehaviorLayout->itemAt(i)->widget();
        if (widget) {
            widget->setVisible(false);
            connect(m_ui->specialBehaviorRadio, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)));
        } else {
            QLayout *layout = m_ui->specialBehaviorLayout->itemAt(i)->layout();
            if (layout) {
                for (int j = 0; j < layout->count(); ++j) {
                    QWidget *widget = layout->itemAt(j)->widget();
                    if (widget) {
                        widget->setVisible(false);
                        connect(m_ui->specialBehaviorRadio, SIGNAL(toggled(bool)), widget, SLOT(setVisible(bool)));
                    }
                }
            }
        }
    }
bool MTPageNym_AltLocation::deleteSingleContactItem(GroupBoxContactItems * pGroupBox, QWidget * pWidget)
{
    if (nullptr == pGroupBox || nullptr == pWidget)
        return false;

    // We have to remove the radio button from the buttongroup.
    QLayout * pItemLayout = pWidget->layout(); // Combo, Line Edit, Radio, Delete

    if (nullptr != pItemLayout)
    {
        const int nIndexRadioBtn  = 2; // todo hardcoding.
        QWidget * pRadioBtnWidget = pItemLayout->itemAt(nIndexRadioBtn)->widget();

        if (nullptr != pRadioBtnWidget)
        {
            QRadioButton * pRadioBtn = dynamic_cast<QRadioButton *>(pRadioBtnWidget);
            if (nullptr != pRadioBtn)
            {
                pGroupBox->removeRadioButton(pRadioBtn);
            }
        }
    }
    // --------------------------------------
    pGroupBox->layout()->removeWidget(pWidget);

    pWidget->setParent(nullptr);
    pWidget->disconnect();
    pWidget->deleteLater();

    PrepareOutputData();

    return true;
}
Esempio n. 12
0
void NLayoutPrototype::setSpacingAt(int index, int spacing)
{
	QLayout *layout = qscriptvalue_cast<QLayout *>(thisObject());
	if (layout) {
		layout->removeItem(layout->itemAt(index));
		dynamic_cast<QBoxLayout *>(layout)->insertSpacing(index, spacing);
	}
}
//! [0]
static void paintLayout(QPainter *painter, QLayoutItem *item)
{
    QLayout *layout = item->layout();
    if (layout) {
        for (int i = 0; i < layout->count(); ++i)
            paintLayout(painter, layout->itemAt(i));
    }
    painter->drawRect(item->geometry());
}
// Never used.
// Get the widget in the last group box at the position 'pos'.
QWidget *PinConfig::outWidgetAt(int pos)
{
    QLayout *groupBoxLayout = this->subConfigGroupBox->layout();
    if (!groupBoxLayout)
        return NULL;
    QLayoutItem *layoutItem = groupBoxLayout->itemAt(pos);
    if (!layoutItem)
        return NULL;
    return layoutItem->widget();
}
Esempio n. 15
0
    /**
     * Slot called when the user wants to see the dialog for selecting
     * what columns are visible in the tables of peaks.
     */
    void PeaksViewer::showPeaksTableColumnOptions()
    {
      std::set<QString> areShown;

      // get the list of all the columns that are already shown
      QLayout* layout = this->layout();
      const int size = layout->count();
      for(int i = 0; i < size; ++i)
      {
        auto item = layout->itemAt(i);
        if(auto widget = item->widget())
        {
          if (auto table = dynamic_cast<PeaksWorkspaceWidget *>(widget))
          {
            auto shown = table->getShownColumns();
            areShown.insert(shown.begin(), shown.end());
          }
        }
      }

      // show the dialog box
      PeaksTableColumnsDialog dialog(this);
      dialog.setVisibleColumns(areShown);
      dialog.exec();
      auto result = static_cast<QDialog::DialogCode>(dialog.result());
      if (result != QDialog::DialogCode::Accepted)
        return;

      // set what columns to show
      auto toShow = dialog.getVisibleColumns();
      for(int i = 0; i < size; ++i)
      {
        auto item = layout->itemAt(i);
        if(auto widget = item->widget())
        {
          if (auto table = dynamic_cast<PeaksWorkspaceWidget *>(widget))
          {
            table->setShownColumns(toShow);
          }
        }
      }
    }
void KoLineEditAction::setVisible(bool showAction)
{
    QLayout* currentLayout = defaultWidget()->layout();

    this->QAction::setVisible(showAction);

    for(int i=0;i<currentLayout->count();i++) {
        currentLayout->itemAt(i)->widget()->setVisible(showAction);
    }
    defaultWidget()->setVisible(showAction);
}
Esempio n. 17
0
QLayout *LayoutInfo::internalLayout(const QWidget *widget)
{
    QLayout *widgetLayout = widget->layout();
    if (widgetLayout && widget->inherits("Q3GroupBox")) {
        if (widgetLayout->count()) {
            widgetLayout = widgetLayout->itemAt(0)->layout();
        } else {
            widgetLayout = 0;
        }
    }
    return widgetLayout;
}
Esempio n. 18
0
void LayoutAlignmentCommand::applyAlignment(const QDesignerFormEditorInterface *core, QWidget *w, Qt::Alignment a)
{
    // Find layout and apply to item
    QLayout *layout;
    LayoutInfo::laidoutWidgetType(core, w, 0, &layout);
    if (layout) {
        const int index = layout->indexOf(w);
        if (index >= 0) {
            layout->itemAt(index)->setAlignment(a);
            layout->update();
        }
    }
}
Esempio n. 19
0
bool CategoryWidget::cycleContacts(FriendWidget* activeChatroomWidget, bool forward)
{
    int index = -1;
    QLayout* currentLayout = nullptr;

    FriendWidget* friendWidget = qobject_cast<FriendWidget*>(activeChatroomWidget);
    if (friendWidget == nullptr)
        return false;

    currentLayout = listLayout->getLayoutOnline();
    index = listLayout->indexOfFriendWidget(friendWidget, true);
    if (index == -1)
    {
        currentLayout = listLayout->getLayoutOffline();
        index = listLayout->indexOfFriendWidget(friendWidget, false);
    }

    index += forward ? 1 : -1;
    for (;;)
    {
        // Bounds checking.
        if (index < 0)
        {
            if (currentLayout == listLayout->getLayoutOffline())
                currentLayout = listLayout->getLayoutOnline();
            else
                return false;

            index = currentLayout->count() - 1;
            continue;
        }
        else if (index >= currentLayout->count())
        {
            if (currentLayout == listLayout->getLayoutOnline())
                currentLayout = listLayout->getLayoutOffline();
            else
                return false;

            index = 0;
            continue;
        }

        GenericChatroomWidget* chatWidget = qobject_cast<GenericChatroomWidget*>(currentLayout->itemAt(index)->widget());
        if (chatWidget != nullptr)
            emit chatWidget->chatroomWidgetClicked(chatWidget);
        return true;
    }

    return false;
}
void PinConfig::clearOutConfig()
{
    QLayout *groupBoxLayout = this->subConfigGroupBox->layout();

    if (!groupBoxLayout)
        return;
    while (!groupBoxLayout->isEmpty())
    {
        QWidget *widget = groupBoxLayout->itemAt(0)->widget();
        groupBoxLayout->removeWidget(widget);
        delete widget;
    }
    delete groupBoxLayout;
}
Esempio n. 21
0
void LayoutDumper::dumpWidgetAndChildren(QDebug& os, const QWidget* w,
                                         int level)
{
    QString padding;
    for (int i = 0; i <= level; i++) {
        padding += "    ";  // 4 spaces per level
    }

    QLayout* layout = w->layout();
    QList<QWidget*> dumped_children;
    if (layout && !layout->isEmpty()) {
        os << padding << "Layout: " << getLayoutInfo(layout);

        QBoxLayout* box_layout = dynamic_cast<QBoxLayout*>(layout);
        if (box_layout) {
            os << ", spacing " <<  box_layout->spacing();
        }
        os << ":\n";

        int num_items = layout->count();
        for (int i = 0; i < num_items; i++) {
            QLayoutItem* layout_item = layout->itemAt(i);
            QString item_info = getLayoutItemInfo(layout_item);
            if (!item_info.isEmpty()) {
                os << padding << "- " << item_info << "\n";
            }

            QWidgetItem* wi = dynamic_cast<QWidgetItem*>(layout_item);
            if (wi && wi->widget()) {
                dumpWidgetAndChildren(os, wi->widget(), level + 1);
                dumped_children.push_back(wi->widget());
            }
        }
    }

    // now output any child widgets that weren't dumped as part of the layout
    QList<QWidget*> widgets = w->findChildren<QWidget*>(
                QString(), Qt::FindDirectChildrenOnly);
    QList<QWidget*> undumped_children;
    foreach (QWidget* child, widgets) {
        if (dumped_children.indexOf(child) == -1) {
            undumped_children.push_back(child);
        }
    }

    if (!undumped_children.empty()) {
        os << padding << "Non-layout children:\n";
        foreach (QWidget* child, undumped_children) {
            dumpWidgetAndChildren(os, child, level + 1);
        }
Esempio n. 22
0
 /**
  * Hide this view.
  */
 void PeaksViewer::hide() 
 {
   QLayout* layout = this->layout();
   const int size = layout->count();
   for(int i = 0; i < size; ++i)
   {
     auto item = layout->itemAt(i);
     if(auto widget = item->widget())
     {
       // This is important, otherwise the removed widgets sit around on the layout.
       widget->hide();
     }
   }
   QWidget::hide();
 }
Esempio n. 23
0
void LXQtGroupPopup::closeTimerSlot()
{
    bool button_has_dnd_hover = false;
    QLayout* l = layout();
    for (int i = 0; l->count() > i; ++i)
    {
        LXQtTaskButton const * const button = dynamic_cast<LXQtTaskButton const *>(l->itemAt(i)->widget());
        if (0 != button && button->hasDragAndDropHover())
        {
            button_has_dnd_hover = true;
            break;
        }
    }
    if (!button_has_dnd_hover)
        close();
}
Esempio n. 24
0
/*******************************************************************************
 *	Slot function. Reports the listbox item is activated.
 * ****************************************************************************/
void DialogBox::ListboxItemActivated(const QModelIndex& index)
{
	Listbox* list=(Listbox*)sender();
	QLayout* layout;
	QWidget* label;

	if( (layout=FindLayout(list)) && (label=layout->itemAt(0)->widget()) )
		{
			const char* objectname=label->objectName().toLocal8Bit().constData();

			if(objectname[0])
				{
					fprintf(output, "%s=", objectname);
					fprintf(output, "%s\n", index.data().toString().toLocal8Bit().constData());
					fflush(output);
				}
		}
}
Esempio n. 25
0
/*******************************************************************************
 *	Slot function. Reports the current item of the combobox is changed.
 * ****************************************************************************/
void DialogBox::ComboboxItemSelected(int index)
{
	QComboBox* list=(QComboBox*)sender();
	QLayout* layout;
	QWidget* label;

	if( (layout=FindLayout(list)) && (label=layout->itemAt(0)->widget()) )
		{
			const char* objectname=label->objectName().toLocal8Bit().constData();

			if(objectname[0])
				{
					fprintf(output, "%s=", objectname);
					fprintf(output, "%s\n", list->itemText(index).toLocal8Bit().constData());
					fflush(output);
				}
		}
}
Esempio n. 26
0
/*******************************************************************************
 *	Slot function. Reports the current item of the listbox is changed.
 * ****************************************************************************/
void DialogBox::ListboxItemSelected(QListWidgetItem* current)
{
	Listbox* list=(Listbox*)sender();
	QLayout* layout;
	QWidget* label;

	if( (layout=FindLayout(list)) && (label=layout->itemAt(0)->widget()) )
		{
			const char* objectname=label->objectName().toLocal8Bit().constData();

			if(objectname[0])
				{
					fprintf(output, "%s=", objectname);
					fprintf(output, "%s\n", current?current->text().toLocal8Bit().constData():"");
					fflush(output);
				}
		}
}
Esempio n. 27
0
void QwtLegend::updateTabOrder()
{
    QLayout *contentsLayout = d_data->view->contentsWidget->layout();
    if ( contentsLayout )
    {
        // set tab focus chain

        QWidget *w = NULL;

        for ( int i = 0; i < contentsLayout->count(); i++ )
        {
            QLayoutItem *item = contentsLayout->itemAt( i );
            if ( w && item->widget() )
                QWidget::setTabOrder( w, item->widget() );

            w = item->widget();
        }
    }
}
Esempio n. 28
0
// Find out alignment and return whether command is enabled.
Qt::Alignment LayoutAlignmentCommand::alignmentOf(const QDesignerFormEditorInterface *core, QWidget *w, bool *enabledIn)
{
    bool managed;
    QLayout *layout;

    if (enabledIn)
        *enabledIn = false;
    // Can only work on a managed layout
    const LayoutInfo::Type type = LayoutInfo::laidoutWidgetType(core, w, &managed, &layout);
    const bool enabled = layout && managed &&
                         (type == LayoutInfo::HBox || type == LayoutInfo::VBox
                          || type == LayoutInfo::Grid);
    if (!enabled)
        return Qt::Alignment(0);
    // Get alignment
    const int index = layout->indexOf(w);
    Q_ASSERT(index >= 0);
    if (enabledIn)
        *enabledIn = true;
    return layout->itemAt(index)->alignment();
}
Esempio n. 29
0
void VideoWidget::SetSceneControl(BaseSceneController *sceneControlIn)
{
    //Remove previous scene button controls
    while(this->ui->annotationTools->count()>0)
    {
        //This item usually corresponds to the widget generated by the control factory
        QLayoutItem *item = this->ui->annotationTools->itemAt(0);
        QWidget *custom = item->widget();
        assert(custom!=NULL);
        cout << custom->metaObject()->className() << endl;

        //Also iterate through to get child widgets and directly close and remove them
        QLayout *wlayout = custom->layout();
        assert(wlayout!=NULL);
        while(wlayout->count())
        {
            int test = wlayout->count();
            QLayoutItem *citem = wlayout->itemAt(0);
            QWidget *childw = citem->widget();
            assert(childw!=NULL);
            childw->close();
            wlayout->removeItem(citem);
            delete childw;
        }

        custom->close();
        this->ui->annotationTools->removeItem(item);
        delete custom;
    }

    //Remove previous menu controls

    //Clear previous scene
    QGraphicsScene *oldScene = this->ui->graphicsView->scene();
    if(oldScene!=NULL) oldScene->clear();

    //Activate new scene button controls
    this->sceneControl = sceneControlIn;
    if(this->sceneControl!=NULL)
    {
        MouseGraphicsScene *scene = this->sceneControl->GetScene();
        if(scene != NULL)
        {
            this->ui->graphicsView->setScene(scene);
            this->sceneControl->Redraw();
            this->SetRawScale(0.3);
        }
        else
            this->ui->graphicsView->setScene(NULL);

        QWidget *controls = this->sceneControl->ControlsFactory(this);
        if(controls!=NULL)
            this->ui->annotationTools->addWidget(controls);
    }
    else
    {
        this->ui->graphicsView->setScene(NULL);
        this->SetSceneControl(new class LogoSceneController(this));
    }

}
Esempio n. 30
0
void ContentDialog::cycleContacts(bool forward, bool loop)
{
    Settings::getInstance().getGroupchatPosition();

    int index;
    QLayout* currentLayout;
    if (activeChatroomWidget->getFriend())
    {
        currentLayout = friendLayout->getLayoutOnline();
        index = friendLayout->indexOfFriendWidget(activeChatroomWidget, true);
        if (index == -1)
        {
            currentLayout = friendLayout->getLayoutOffline();
            index = friendLayout->indexOfFriendWidget(activeChatroomWidget, false);
        }
    }
    else
    {
        currentLayout = groupLayout.getLayout();
        index = groupLayout.indexOfSortedWidget(activeChatroomWidget);
    }

    if (!loop && index == currentLayout->count() - 1)
    {
        bool groupsOnTop = Settings::getInstance().getGroupchatPosition();
        bool offlineEmpty = friendLayout->getLayoutOffline()->count() == 0;
        bool onlineEmpty = offlineEmpty && ((friendLayout->getLayoutOnline()->count() == 0 && groupsOnTop) || !groupsOnTop);
        bool groupsEmpty = offlineEmpty && ((groupLayout.getLayout()->count() == 0 && !groupsOnTop) || groupsOnTop);

        if ((currentLayout == friendLayout->getLayoutOffline())
            || (currentLayout == friendLayout->getLayoutOnline() && groupsEmpty)
            || (currentLayout == groupLayout.getLayout() && onlineEmpty))
        {
            forward = !forward;
        }
    }

    index += forward ? 1 : -1;

    for (;;)
    {
        // Bounds checking.
        if (index < 0)
        {
            currentLayout = nextLayout(currentLayout, forward);
            index = currentLayout->count() - 1;
            continue;
        }
        else if (index >= currentLayout->count())
        {
            currentLayout = nextLayout(currentLayout, forward);
            index = 0;
            continue;
        }

        GenericChatroomWidget* chatWidget = dynamic_cast<GenericChatroomWidget*>(currentLayout->itemAt(index)->widget());

        if (chatWidget != nullptr && chatWidget != activeChatroomWidget)
            onChatroomWidgetClicked(chatWidget, false);

        return;
    }
}