Example #1
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)));
                    }
                }
            }
        }
    }
Example #2
0
// Description:  Calculates and sets the geometry of each item in the layout,
//               based on its set position and the layout's settings and/or width.
//
void KxGridLayout::doLayout(const QRect &rect)
{
    int x = rect.x();
    int y = rect.y();
	int currentRow = 1;
	int currentColumn = 0;

	for(int i = 0; i < fNumPositions; i++) {	
		currentColumn++;
		int nextX = x + fCellWidth;

		// If columnsResizable is set to true, go to the next row if we can't fit the control within the layout's width.
		// If columnsResizable is set to false, go to the next row if we have reached the specified max number of columns.
		if((fColumnsResizable && nextX > rect.right() + 1) || (!fColumnsResizable && currentColumn > fNumberOfColumns)) {
			x = rect.x();
			y = y + fCellHeight;
			nextX = x + fCellWidth;
			currentRow++;
			currentColumn = 1;
		}

		if(fPositionToItem.contains(i)) {
			QLayoutItem *item = fPositionToItem[i];
			QWidget *w = NULL;
			if(item && (w = item->widget())) {
				// We must make sure the widget can actually fit within the allotted cell size.
				if(w->minimumWidth() > fCellWidth) {
					w->setMinimumWidth(fCellWidth);
				}
				if(w->minimumHeight() > fCellHeight) {
					w->setMinimumHeight(fCellHeight);
				}

				w->setGeometry(QRect(QPoint(x, y), QSize(fCellWidth, fCellHeight)));

				// Hide the controls that exceed the specified max number of rows
				// (we've already made sure the max number of columns won't be
				// exceeded where it matters).
				if(currentRow > fNumberOfRows) {
					w->setVisible(false);
				} else {
					w->setVisible(true);
				}
			}
		}

		x = nextX;
	}
}
Example #3
0
void ManageSystem::OnShowWidget(const int nItemValue)
{
	if (m_pCurrentWidget)
	{
		m_pCurrentWidget->setVisible(false);
	}

	if (m_mapWidget.contains(nItemValue))
	{
		QWidget* pWidget = m_mapWidget[nItemValue];
		if (pWidget)
		{
			pWidget->setVisible(true);
			m_pCurrentWidget = pWidget;
			return;
		}
	}

	//new widget
	QWidget* pWidget = NULL;
	switch (nItemValue)
	{
	case INSTRUMENTMODELVALUE:
		pWidget = new InstrumentWidget(this);
		break;
	case INSTRUMENTHARDWAREVALUE:
		pWidget = new HardwareWidget(this);
		break;
	case INSTRUMENTSOFTWAREVALUE:
		pWidget = new SoftwareWidget(this);
		break;
	case ACCOUNTCHECKVALUE:
		pWidget = new UserCheckWidget(this);
		break;
	case ACCOUNTCREATEVALUE:
		pWidget = new UserCreateWidget(this);
		break;
	default:
		if (m_pCurrentWidget)
			m_pCurrentWidget->setVisible(true);
		return;
	}

	ui.mainHorizontalLayout->addWidget(pWidget);
	pWidget->setVisible(true);
	m_pCurrentWidget = pWidget;
	m_mapWidget[nItemValue] = pWidget;
}
Example #4
0
void UIStateHelper::updateData(UIStateHelperData *data)
{
	QMap<QWidget*, UIStates>::iterator it;
	for (it = data->mWidgets.begin(); it != data->mWidgets.end(); ++it) {
		QWidget *widget = it.key();
		UIStates states = it.value();

		if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE | UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
			bool visible = isWidgetVisible(widget);
			widget->setVisible(visible);

			if (!visible) {
				/* Reset progressbar */
				QProgressBar *progressBar = dynamic_cast<QProgressBar*>(widget);
				if (progressBar) {
					progressBar->setValue(0);
				}
			}
		}

		if (states & (UISTATE_LOADING_ENABLED | UISTATE_LOADING_DISABLED | UISTATE_ACTIVE_ENABLED | UISTATE_ACTIVE_DISABLED)) {
			widget->setEnabled(isWidgetEnabled(widget));
		}
	}
}
Example #5
0
StyleEditor::StyleEditor(QWidget* parent, bool singleStyleEditor)
   : QDialog(parent), obsStyle(0)
{
   setupUi(this);
   if ( singleStyleEditor ) 
   {
      for(int i = 0; i < horizontalLayout_styles->count(); ++i)
      {
         QWidget* w = horizontalLayout_styles->itemAt(i)->widget();
         if(w)
            w->setVisible(false);
      }
      
      pushButton_new->setVisible(false);
   }

   styleListModel = new StyleListModel(styleComboBox);
   styleProxyModel = new StyleSortFilterProxyModel(styleComboBox);
   styleProxyModel->setDynamicSortFilter(true);
   styleProxyModel->setSourceModel(styleListModel);
   styleComboBox->setModel(styleProxyModel);
   
   connect( pushButton_save, SIGNAL( clicked() ), this, SLOT( save() ) );
   connect( pushButton_new, SIGNAL( clicked() ), this, SLOT( newStyle() ) );
   connect( pushButton_cancel, SIGNAL( clicked() ), this, SLOT( clearAndClose() ) );
   connect( pushButton_remove, SIGNAL( clicked() ), this, SLOT(removeStyle()) );
   connect( styleComboBox, SIGNAL(activated( const QString& )), this, SLOT( styleSelected(const QString&) ) );

   setStyle( styleListModel->at(styleComboBox->currentIndex()));
}
Example #6
0
/*! Resets the state of the widget.
	Deleting the widget automatically removes it from the layout. */
void NetworksWidget::reset(){
	//Clean up widgets that were scheduled to be deleted during the previous event cycle
	foreach(QWidget* widget , cleanUpList)
		widget->deleteLater();
	cleanUpList.clear();

	//Remove no networks label if it exists
	if(networkInfoMap.size() == 0){
		QLayoutItem* item = gridLayout->itemAtPosition(0, 0);
		if(item != 0){
			delete item->widget();
		}
		return;
	}

	//Remove list of networks
	for(int rowIndx=0; rowIndx<networkInfoMap.size(); ++rowIndx){
		for(int colIndx = 0; colIndx < numCols; ++colIndx){
			QLayoutItem* item = gridLayout->itemAtPosition(rowIndx, colIndx);
			if(item != 0){
				QWidget* tmpWidget = item->widget();
				tmpWidget->setVisible(false);
				gridLayout->removeWidget(tmpWidget);
				cleanUpList.append(tmpWidget);
			}
		}
	}
	networkInfoMap.clear();
}
Example #7
0
void MapBox::setDisplayMode(DisplayMode mode) {
    if (m_displayMode == mode)
        return;

    m_displayMode = mode;

    QWidget * newWidget;

    switch (m_displayMode) {
        case DisplayMap:
            newWidget = m_qgv;
            break;

        case DisplayOptions:
            newWidget = m_optionsWidget;
            break;

        default:
            newWidget = 0;
    }

    // remove all current widgets
    while (QLayoutItem * item = layout()->takeAt(0)) {
        item->widget()->setVisible(false);
    }

    // add the new widget
    if (newWidget) {
        layout()->addWidget(newWidget);
        newWidget->setVisible(true);
    }
    resizeEvent(0);
}
Example #8
0
void PageClientQWidget::setWidgetVisible(Widget* widget, bool visible)
{
    QWidget* qtWidget = qobject_cast<QWidget*>(widget->platformWidget());
    if (!qtWidget)
        return;
    qtWidget->setVisible(visible);
}
//-----------------------------------------------------------------------------
void ctkCollapsibleGroupBox::expand(bool _expand)
{
  if (!_expand)
    {
    this->OldSize = this->size();
    }

  QObjectList childList = this->children();
  for (int i = 0; i < childList.size(); ++i) 
    {
    QObject *o = childList.at(i);
    if (o && o->isWidgetType()) 
      {
      QWidget *w = static_cast<QWidget *>(o);
      if ( w )
        {
        w->setVisible(_expand);
        }
      }
    }
  
  if (_expand)
    {
    this->setMaximumHeight(this->MaxHeight);
    this->resize(this->OldSize);
    }
  else
    {
    this->MaxHeight = this->maximumHeight();
    this->setMaximumHeight(22);
    }
}
Example #10
0
void KPageTabbedView::layoutChanged()
{
  // save old position
  int pos = mTabWidget->currentIndex();

  // clear tab bar
  int count = mTabWidget->count();
  for ( int i = 0; i < count; ++i ) {
    mTabWidget->removeTab( 0 );
  }

  if ( !model() )
    return;

  // add new tabs
  for ( int i = 0; i < model()->rowCount(); ++i ) {
    const QString title = model()->data( model()->index( i, 0 ) ).toString();
    const QIcon icon = model()->data( model()->index( i, 0 ), Qt::DecorationRole ).value<QIcon>();
    QWidget *page = qvariant_cast<QWidget*>( model()->data( model()->index( i, 0 ), KPageModel::WidgetRole ) );
    if (page) {
        QWidget *widget = new QWidget(this);
        QVBoxLayout *layout = new QVBoxLayout(widget);
        widget->setLayout(layout);
        layout->addWidget(page);
        page->setVisible(true);
        mTabWidget->addTab( widget, icon, title );
    }
  }

  mTabWidget->setCurrentIndex( pos );
}
Example #11
0
void TupConfigurationArea::hideConfigurator()
{
    QWidget *widget = this->widget();

    if (widget && !isFloating ()) {
        // widget->setMinimumWidth(10);
        widget->setVisible(false);
        setFeatures(QDockWidget::NoDockWidgetFeatures);

        // =================

        QPalette pal = palette();
        pal.setBrush(QPalette::Background, pal.button());
        setPalette(pal);
        setAutoFillBackground(true);

        //==================

        for (int i = 0; i < 2; ++i) 
             qApp->processEvents();

        shrink();

        if (!k->toolTipShowed) {
            QToolTip::showText (k->mousePos, tr("Cursor here for expand"), this);
            k->toolTipShowed = true;
        }
    }

    k->mousePos = QCursor::pos();
}
Example #12
0
QWidget* MainWindow::setupSidePanel()
{
    QWidget *panel = new QWidget(this);
    panel->setLayout(new QVBoxLayout);
    panel->setVisible(false);

    // add sidebar
    SidedockWidget* sideDock = new SidedockWidget(panel);
    addToolBar(Qt::RightToolBarArea, sideDock->toolbar());
    panel->layout()->addWidget(sideDock);

    // add widgets to dock
    // document property widgets
    DocumentTypesWidget *documentTypesWidget = new DocumentTypesWidget(panel);
    connect(this, &MainWindow::graphDocumentChanged, documentTypesWidget, &DocumentTypesWidget::setDocument);
    sideDock->addDock(documentTypesWidget, i18n("Element Types"), QIcon::fromTheme("document-properties"));
    if (m_currentProject && m_currentProject->activeGraphDocument()) {
        documentTypesWidget->setDocument(m_currentProject->activeGraphDocument());
    }

    // Project Journal
    m_journalWidget = new JournalEditorWidget(panel);
    sideDock->addDock(m_journalWidget, i18nc("@title", "Journal"), QIcon::fromTheme("story-editor"));

    // Rocs scripting API documentation
    ScriptApiWidget* apiDoc = new ScriptApiWidget(panel);
    sideDock->addDock(apiDoc, i18nc("@title", "Scripting API"), QIcon::fromTheme("documentation"));

    return panel;
}
static QWidget *createWidget(QWidget *parent = 0)
{
    QWidget *w = new QWidget(parent);
    w->setLayout(new QHBoxLayout);
    w->setVisible(true);
    w->layout()->setMargin(0);
    return w;
}
Example #14
0
NoteDialog::NoteDialog(Note *note) : QWidget()
{
    setWindowTitle(note == 0 ? "Nouvelle note" : note->title());

    // Récupération des options
    m_settings = new QSettings("yellownote.ini", QSettings::IniFormat);

    // Création des champs title et content
    m_noteEdit = new NoteEdit(m_settings, this);

    m_note = note;

    // Assignation du dialog à la note
    attachToNote();

    // Si on est en modification, on remplit les champs
    if (note != 0)
    {
        m_noteEdit->update(note->title(), note->content());
    }

    QAction *actionInfos = new QAction("&Infos", this);
    actionInfos->setIcon(QIcon(":/note/infos"));
    actionInfos->setIconText("Infos");
    connect(actionInfos, SIGNAL(triggered()), this, SLOT(infos()));

    m_actionDelete = new QAction("&Supprimer", this);
    m_actionDelete->setIcon(QIcon(":/note/delete"));
    m_actionDelete->setIconText("Supprimer");
    connect(m_actionDelete, SIGNAL(triggered()), this, SLOT(deleteMe()));

    QWidget *spacerWidget = new QWidget(this);
    spacerWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    spacerWidget->setVisible(true);

    QToolBar *toolBar = new QToolBar;
    toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    toolBar->addWidget(spacerWidget);
    toolBar->addAction(actionInfos);
    toolBar->addAction(m_actionDelete);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(toolBar);
    mainLayout->addWidget(m_noteEdit);
    setLayout(mainLayout);

    // Réassignation de la taille de la fenêtre
    if (m_settings->contains("note/size"))
    {
        resize(m_settings->value("note/size").toSize());
    }

    // Donne le focus à la fenêtre (quand elle est créée
    // depuis un raccouri clavier global)
    setFocus();
}
Example #15
0
void XMainWindow::showMe(bool v)
{
  QWidget *target = parentWidget() == 0 ? this : parentWidget();

  if (v)
    target->setWindowState(target->windowState() & ~Qt::WindowMinimized);

  target->setVisible(v);
}
Example #16
0
void MailFieldsWidget::showLayoutWidgets(QLayout* layout, bool show)
  {
  for(int i = 0; i < layout->count(); ++i)
    {
    QLayoutItem* li = layout->itemAt(i);
    QWidget* w = li->widget();
    w->setVisible(show);
    }
  }
Example #17
0
/*!
  \brief Update the entries for an item

  \param itemInfo Info for an item
  \param data List of legend entry attributes for the item
 */
void QwtLegend::updateLegend( const QVariant &itemInfo, 
    const QList<QwtLegendData> &data )
{
    QList<QWidget *> widgetList = legendWidgets( itemInfo );

    if ( widgetList.size() != data.size() )
    {
        QLayout *contentsLayout = d_data->view->contentsWidget->layout();

        while ( widgetList.size() > data.size() )
        {
            QWidget *w = widgetList.takeLast();

            contentsLayout->removeWidget( w );

            // updates might be triggered by signals from the legend widget
            // itself. So we better don't delete it here.

            w->hide();
            w->deleteLater();
        }

        for ( int i = widgetList.size(); i < data.size(); i++ )
        {
            QWidget *widget = createWidget( data[i] );

            if ( contentsLayout )
                contentsLayout->addWidget( widget );

            if ( isVisible() )
            {
                // QLayout does a delayed show, with the effect, that
                // the size hint will be wrong, when applications
                // call replot() right after changing the list
                // of plot items. So we better do the show now.

                widget->setVisible( true );
            }

            widgetList += widget;
        }

        if ( widgetList.isEmpty() )
        {
            d_data->itemMap.remove( itemInfo );
        }
        else
        {
            d_data->itemMap.insert( itemInfo, widgetList );
        }

        updateTabOrder();
    }
    
    for ( int i = 0; i < data.size(); i++ )
        updateWidget( widgetList[i], data[i] );
}
void KitOptionsPageWidget::kitSelectionChanged()
{
    QModelIndex current = currentIndex();
    QWidget *newWidget = m_model->widget(current);
    if (newWidget == m_currentWidget)
        return;

    if (m_currentWidget)
        m_currentWidget->setVisible(false);

    m_currentWidget = newWidget;

    if (m_currentWidget) {
        m_currentWidget->setVisible(true);
        m_kitsView->scrollTo(current);
    }
    updateState();
}
Example #19
0
void GuiPanel::setHbEditVisible(int vis){
  QObjectList ol = ui->hitboxEdit->children();
  for (int i=0; i<ol.size(); i++) {
      //QObject &o (ol[i]);
      if (ol[i]->isWidgetType()) {
		QWidget* w = qobject_cast<QWidget*>(ol[i]);
        if (w!=ui->editHbActive) w->setVisible(vis);
      }
  }
}
Example #20
0
QWidget * Tab::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QWidget *tab = new QWidget(parent);
    tab->setEnabled(enabled);
    tab->setVisible(visible);
    tab->setStyleSheet(QString::fromStdString(style));
    LayoutWidget::createQtWidget(proxy, uiproxy, tab);
    setQWidget(tab);
    setProxy(proxy);
    return tab;
}
Example #21
0
int main(int argc, char* argv[]) {
  QApplication app(argc, argv);

  QMainWindow* window = new QMainWindow();

  QQuickView* view = new QQuickView();
  QWidget* container = QWidget::createWindowContainer(view, window);
  view->setSource(QUrl::fromLocalFile("widget.qml"));
  container->setVisible(true);
  window->show();
  return app.exec();
}
//-----------------------------------------------------------------------------
void ctkCollapsibleGroupBox::childEvent(QChildEvent* c)
{
  if(c && c->type() == QEvent::ChildAdded)
    {
    if (c->child() && c->child()->isWidgetType())
      {
      QWidget *w = static_cast<QWidget*>(c->child());
      w->setVisible(this->isChecked());
      }
    }
  QGroupBox::childEvent(c);
}
Example #23
0
void VstPlugin::toggleEditorVisibility( int visible )
{
	QWidget* w = editor();
	if ( ! w ) {
		return;
	}

	if ( visible < 0 ) {
		visible = ! w->isVisible();
	}
	w->setVisible( visible );
}
Example #24
0
int main(int argc,char **argv)
{

    /*	1.建立QT应用	*/
    QApplication app(argc,argv);

    /* 使中文正常显示	*/
    QTextCodec *codec=QTextCodec::codecForName("gb2312");
    QTextCodec::setCodecForTr(codec);

    /*	2.建立窗体		*/
    QWidget win;

    /*	3.调用窗体方法控制窗体		*/
    //窗体大小400*300
    win.resize(400,300);
    //居中显示
    win.move((1024-400)/2,(768-300)/2);

    //添加button 在窗体中
    QPushButton btn("OK",&win);
    btn.resize(100,30);
    btn.move(100,100);

    // 	添加QLineEdit对象		在窗体中
    //	使中文正常显示
    QLineEdit le(QObject::tr("你好"),&win);
    le.resize(50,50);
    le.move(20,20);

    MySlots myslo;
    /* 点击按钮弹出一个messagebox
    QObject::connect(
    	&btn,//信号发送者
    	SIGNAL(clicked()),//发送的信号
    	&myslo,//信号发送的槽函数的对象
    	SLOT(handle())//槽函数
    );
    */

    /* 点击按钮退出窗体	*/
    QObject::connect(
        &btn,//信号发送者
        SIGNAL(clicked()),//发送的信号
        &app,//信号发送的槽函数的对象
        SLOT(quit())//槽函数
    );

    win.setVisible(true);
    /*	4.等待所有窗体子线程终止	*/
    return app.exec();

}
Example #25
0
//-----------------------------------------------------------------------------
void ctkCollapsibleButton::childEvent(QChildEvent* c)
{
  if(c && c->type() == QEvent::ChildAdded)
    {
    if (c->child() && c->child()->isWidgetType())
      {
      QWidget *w = static_cast<QWidget*>(c->child());
      w->setVisible(!ctk_d()->Collapsed);
      }
    }
  QWidget::childEvent(c);
}
Example #26
0
QWidget * Group::createQtWidget(Proxy *proxy, UIProxy *uiproxy, QWidget *parent)
{
    QWidget *groupBox = flat ?
        new QWidget(parent) :
        new QGroupBox(parent);
    groupBox->setEnabled(enabled);
    groupBox->setVisible(visible);
    groupBox->setStyleSheet(QString::fromStdString(style));
    LayoutWidget::createQtWidget(proxy, uiproxy, groupBox);
    setQWidget(groupBox);
    setProxy(proxy);
    return groupBox;
}
void ExpanderButton::nextCheckState()
{
	_expanded = !_expanded;
	setIcon(_expanded ? _expandedIcon : _contractedIcon);

	QObjectList siblings = this->parentWidget()->children();

	for (QObjectList::Iterator itr = siblings.begin(); itr != siblings.end(); itr++) {
		QWidget* w = dynamic_cast<QWidget*>(*itr);
        if (w != NULL && w != this)
			w->setVisible(_expanded);
	}
}
Example #28
0
void MainWindow::addNotificationBrowser(IView * notificationBrowser)
{
	QWidget* notificationWidget = dynamic_cast<QWidget*>(notificationBrowser);
	if (notificationWidget) {
		notificationWidget->updateGeometry();

		ui->notificationTab->layout()->addWidget(notificationWidget);

		notificationWidget->setVisible(1);
	}

	//createIntroductionWizard();
}
Example #29
0
KPageTabbedView::~KPageTabbedView()
{
  if (model()) {
    for ( int i = 0; i < mTabWidget->count(); ++i ) {
        QWidget *page = qvariant_cast<QWidget*>( model()->data( model()->index( i, 0 ), KPageModel::WidgetRole ) );

        if (page) {
            page->setVisible(false);
            page->setParent(0); // reparent our children before they are deleted
        }
    }
  }
}
Example #30
0
void BaseTrackView::setLayoutWidgetsVisibility(QLayout *layout, bool visible)
{
    for (int i = 0; i < layout->count(); ++i) {
        QLayoutItem *item = layout->itemAt(i);
        if (item->layout()) {
            setLayoutWidgetsVisibility(item->layout(), visible);
        } else {
            QWidget *widget = item->widget();
            if (widget)
                widget->setVisible(visible);
        }
    }
}