void AddPluginDialog::emitPluginSelected()
{
    QListWidget* pluginList = ui->pluginList;
    if (pluginList->currentItem() && pluginList->currentItem()->isSelected())
    {
        LXQt::PluginInfo plugin = mPlugins.at(pluginList->currentItem()->data(INDEX_ROLE).toInt());
        emit pluginSelected(plugin);
    }
}
void OperationsDelegate::setEditorData(QWidget *editor,
                                       const QModelIndex &index) const
      {
      const QVariant value = index.data(Qt::EditRole);
      if (value.type() == QVariant::StringList) {
            QListWidget *lw = qobject_cast<QListWidget *>(editor);
            const auto items = lw->findItems(index.data(Qt::DisplayRole).toString(), Qt::MatchExactly);
            if (!items.empty())
                  lw->setCurrentItem(items.first());
            else
                  lw->setCurrentItem(lw->item(0));

            const int extraWidth = 25;
            const int extraHeight = 6;
            lw->setMinimumWidth(lw->sizeHintForColumn(0) + extraWidth);
                        // to prevent possible hiding bottom part of the list
            const int h = lw->count() * (lw->visualItemRect(lw->currentItem()).height() + extraHeight);
            const int y = (lw->parentWidget() && (lw->parentWidget()->rect().bottom() < lw->y() + h))
                        ? lw->parentWidget()->rect().bottom() - h - extraHeight : lw->y();
            lw->setGeometry(lw->x(), y, lw->width(), h);
                        // now lw can be partially hidden behind the tree view
                        // if tree view has small rect, so set parent of lw
                        // to app window and map coordinates accordingly to leave lw in place
            const auto globalCoord = lw->parentWidget()->mapToGlobal(lw->geometry().topLeft());
            lw->setParent(appWindow);
            const auto newLocalCoord = appWindow->mapFromGlobal(globalCoord);
            lw->setGeometry(newLocalCoord.x(), newLocalCoord.y(), lw->width(), h);
            }
      else        // single value
            QStyledItemDelegate::setEditorData(editor, index);
      }
Beispiel #3
0
void MainWindow::DisplayProcess()
{
  QListWidget* list = this->ui.procListWidget;

  QListWidgetItem* current = list->currentItem();
  if (current == NULL)
    return;

  this->ui.procIdText->setText(current->text());

  Process* process = this->model->getProcess(current->text().toInt());
  if (process != NULL)
  {
    if(strlen(process->name) == 0x00)
    {
      this->window->setWindowTitle(QApplication::translate("window",
              "Process Watch Dog", 0, QApplication::UnicodeUTF8));
    }
    else
    {
      this->window->setWindowTitle(QString("Application: [%1]").arg(process->name));
    }
    UpdateProcessStatusIcon(process);
  }
}
Beispiel #4
0
void LairTool::view3d(){
    QListWidget* list = getCurrentBuildingList();

    if (list == NULL)
        return;

    QListWidgetItem* item = list->currentItem();

    if (item == NULL)
        return;

    QString file = item->text();

    if (file.isEmpty())
        return;

    int idx = file.lastIndexOf("/");

    if (idx < 0)
        return;

    file = file.insert(idx + 1, "shared_");

    MainWindow::instance->startSwgOSG(file);
}
Beispiel #5
0
QString QtopiaInputDialog::getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &list,
                                   int current, bool *ok)
{
    QListWidget *listWidget = new QListWidget;
    listWidget->addItems(list);
    listWidget->setCurrentRow(current);
    listWidget->setFrameShadow(QFrame::Plain);

    QtopiaInputDialog dlg(parent, title, label, listWidget);
    bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted);
    if (ok)
        *ok = accepted;
    if (listWidget->currentItem())
        return listWidget->currentItem()->text();
    else
        return QString();
}
Beispiel #6
0
void tst_QMenu::widgetActionFocus()
{
    //test if the focus is correctly handled with a QWidgetAction
    QMenu m;
    QListWidget *l = new QListWidget(&m);
    for (int i = 1; i<3 ; i++)
        l->addItem(QString("item%1").arg(i));
    QWidgetAction *wa = new QWidgetAction(&m);
    wa->setDefaultWidget(l);
    m.addAction(wa);
    m.setActiveAction(wa);
    l->setFocus(); //to ensure it has primarily the focus
    QAction *menuitem1=m.addAction("menuitem1");
    QAction *menuitem2=m.addAction("menuitem2");

    m.popup(QPoint());

    QVERIFY(m.isVisible());
    QVERIFY(l->hasFocus());
    QVERIFY(l->currentItem());
    QCOMPARE(l->currentItem()->text(), QString("item1"));

    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
    QVERIFY(l->currentItem());
    QCOMPARE(l->currentItem()->text(), QString("item2"));

    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
    QVERIFY(m.hasFocus());
    QCOMPARE(m.activeAction(), menuitem1);

    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Down);
    QVERIFY(m.hasFocus());
    QCOMPARE(m.activeAction(), menuitem2);

    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Up);
    QVERIFY(m.hasFocus());
    QCOMPARE(m.activeAction(), menuitem1);

    QTest::keyClick(QApplication::focusWidget(), Qt::Key_Up);
    QVERIFY(l->hasFocus());
    QCOMPARE(m.activeAction(), (QAction *)wa);
}
Beispiel #7
0
void MainWindow::createMap(QString path, int bgWidth, int bgHeight, QString mapName, int mapStep, bool isImage) {
    QListWidget *tokenList = ui->tokenPage->getUi()->m_tokenList;
    TokenItem *currentTokenItem = dynamic_cast<TokenItem*>(tokenList->currentItem());

    bool isMj = (m_User->getRole() == Role::ROLE_MJ);
    Map *map = new Map(isImage, mapName, path, bgWidth, bgHeight, currentTokenItem, mapStep, isMj);

    // Add Map to the database
    RepositoryManager::s_MapRepository.insertMap(map);

    // Initialize and open map
    openMap(map, true);
}
void MainWindow::onAssistantItemSelectionChanged()
{
    QListWidget* widget = qobject_cast<QListWidget*>(m_assistantToolBox->currentWidget());
    if (widget) {
        QListWidgetItem* item = widget->currentItem();
        if (item) {
            QString notes = item->data(ASSISTANT_ITEM_NOTES_ROLE).toString();
            m_assistantPreviewNotes->setText(notes.isEmpty() ?
                                                 tr("Code:") :
                                                 tr("Notes:<br>%1<br>Code:").arg(notes));
            m_assistantCodePreview->setPlainText(item->data(ASSISTANT_ITEM_DATA_ROLE).toString());
        }
    }
}
Beispiel #9
0
void ItemOrderList::insertItem(const QString &label, bool checked, bool highlight, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    QListWidgetItem *listItem = new QListWidgetItem(icon, label);
    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    setItemHighlight(listItem, highlight);

    m_items[listItem] = ItemWidgetPair(item);

    // Resize list to minimal size.
    const int w = list->sizeHintForColumn(0)
                + list->verticalScrollBar()->sizeHint().width() + 4;
    list->setMaximumWidth(w);

    if ( list->currentItem() == NULL )
        list->setCurrentRow(row);
}
Beispiel #10
0
void ItemOrderList::insertItem(const QString &label, bool checked, const QIcon &icon,
                               const ItemPtr &item, int targetRow)
{
    QListWidget *list = ui->listWidgetItems;
    auto listItem = new QListWidgetItem(icon, label);
    listItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
    m_items[listItem] = ItemWidgetPair(item, checked);

    const int row = targetRow >= 0 ? qMin(list->count(), targetRow) : list->count();
    list->insertItem(row, listItem);

    // Resize list to minimal size.
    if ( !isVisible() ) {
        const int w = list->sizeHintForColumn(0)
                    + list->verticalScrollBar()->sizeHint().width() + 4;
        list->resize( w, list->height() );
    }

    if ( list->currentItem() == nullptr )
        list->setCurrentRow(row);
}
Beispiel #11
0
void Configurator::saveSettings()
{
    QListWidget* listWidget = qobject_cast<QListWidget*>( _sections->currentWidget() );
	if( 0 != listWidget )
		saveItem( listWidget->currentItem() );

	// cheking if we can open file for writing
	QFile configurationFile( _configurationFileName );
	if( false == configurationFile.open(QIODevice::WriteOnly) )
		return;

	// saving content
	QTextStream textStream( &configurationFile );

	_domDocument.save( textStream, 4 );

	configurationFile.close();

	emit configurationChanged();

	accept();
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_list_widget_current_item (const v8::Arguments &Args) {

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

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

      QListWidget *lw = self->v8_to_qobject<QListWidget> (Args.This ());
      if (lw) {

         QListWidgetItem *item = lw->currentItem ();
         if (item) {

            result = self->create_v8_qlistwidgetitem (item);
         }
      }
   }

   return scope.Close (result);
}
AboutPlugins::AboutPlugins( Config *_config, QWidget* parent, Qt::WFlags f )
    : KDialog( parent, f ),
    config( _config ),
    currentPlugin( 0 )
{
    setCaption( i18n("About plugins") );
    setWindowIcon( KIcon("preferences-plugin") );
    setButtons( KDialog::Close );
    setButtonFocus( KDialog::Close );

    QWidget *widget = new QWidget( this );
    setMainWidget( widget );
    QHBoxLayout *box = new QHBoxLayout( widget );

    QVBoxLayout *pluginListBox = new QVBoxLayout( widget );
    box->addLayout( pluginListBox );

    QLabel *installedPlugins = new QLabel( i18n("Installed plugins:"), this );
    pluginListBox->addWidget( installedPlugins );

    QListWidget *pluginsList = new QListWidget( this );
    pluginListBox->addWidget( pluginsList );
    connect( pluginsList, SIGNAL(currentTextChanged(const QString&)), this, SLOT(currentPluginChanged(const QString&)) );

    QStringList pluginNames;
    QList<CodecPlugin*> codecPlugins = config->pluginLoader()->getAllCodecPlugins();
    for( int i=0; i<codecPlugins.count(); i++ )
    {
        pluginNames += codecPlugins.at(i)->name();
    }
    pluginNames.sort();
    pluginsList->addItems( pluginNames );

    pluginNames.clear();
    QList<FilterPlugin*> filterPlugins = config->pluginLoader()->getAllFilterPlugins();
    for( int i=0; i<filterPlugins.count(); i++ )
    {
        pluginNames += filterPlugins.at(i)->name();
    }
    pluginNames.sort();
    pluginsList->addItems( pluginNames );

    pluginNames.clear();
    QList<ReplayGainPlugin*> replaygainPlugins = config->pluginLoader()->getAllReplayGainPlugins();
    for( int i=0; i<replaygainPlugins.count(); i++ )
    {
        pluginNames += replaygainPlugins.at(i)->name();
    }
    pluginNames.sort();
    pluginsList->addItems( pluginNames );

    pluginNames.clear();
    QList<RipperPlugin*> ripperPlugins = config->pluginLoader()->getAllRipperPlugins();
    for( int i=0; i<ripperPlugins.count(); i++ )
    {
        pluginNames += ripperPlugins.at(i)->name();
    }
    pluginNames.sort();
    pluginsList->addItems( pluginNames );

    pluginsList->setFixedWidth( 180 );

    box->addSpacing( 10 );

    QVBoxLayout *pluginInfoBox = new QVBoxLayout( widget );
    box->addLayout( pluginInfoBox );

    aboutPluginLabel = new QLabel( this );
    aboutPluginLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    aboutPluginLabel->setWordWrap( true );
    aboutPluginLabel->setTextFormat( Qt::RichText );
    pluginInfoBox->addWidget( aboutPluginLabel );
    connect( aboutPluginLabel, SIGNAL(linkActivated(const QString&)), this, SLOT(showProblemInfo(const QString&)) );

    pluginInfoBox->addStretch();

    QHBoxLayout *configurePluginBox = new QHBoxLayout( widget );
    pluginInfoBox->addLayout( configurePluginBox );
    configurePlugin = new KPushButton( KIcon("configure"), "", widget );
    configurePlugin->hide();
    configurePluginBox->addWidget( configurePlugin );
    configurePluginBox->addStretch();
    connect( configurePlugin, SIGNAL(clicked()), this, SLOT(configurePluginClicked()) );

    pluginsList->setCurrentRow(0);
    QListWidgetItem *currentItem = pluginsList->currentItem();
    if( currentItem )
    {
        currentPluginChanged( currentItem->text() );
    }

    setInitialSize( QSize(500,300) );
    KSharedConfig::Ptr conf = KGlobal::config();
    KConfigGroup group = conf->group( "AboutPlugins" );
    restoreDialogSize( group );
}
Beispiel #14
0
void SvgCanvas::actionExport_to_callback()
{
	QDialog dialog;
	ExportToDialog export_to_dialog;
	export_to_dialog.setupUi(&dialog);
	QListWidget *list = export_to_dialog.formats_listWidget;
	QListWidgetItem *item;
	//Pixmaps formats
	QList<QByteArray> formats=QImageWriter::supportedImageFormats();
	for(int i=0;i<formats.size();i++)
	{
		QString text(formats[i]);
		item=new QListWidgetItem(text,list);
		item->setData(1,QVariant(PIXMAP));
	}
	//Vector formats
	formats= QPicture::outputFormats();
	for(int i=0;i<formats.size();i++)
	{
		QString text(formats[i]);
		item=new QListWidgetItem(text,list);
		item->setData(1,QVariant(PICTURE));
	}
	
	item=new QListWidgetItem("ps",list);
	item->setData(1,QVariant(PRINTER));
	
	item=new QListWidgetItem("pdf",list);
	item->setData(1,QVariant(PDF));
	
	item=new QListWidgetItem("svg",list);
	item->setData(1,QVariant(SVG));
	
	int ok=dialog.exec();
	if(ok==QDialog::Rejected) return;
	
	item =list->currentItem();
	int format=item->data(1).toInt();
	
	QPainter plot;
	switch(format)
	{
		case PIXMAP:
		{
			bool ok;
			int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
			if(!ok) return;
			h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
			if(!ok) return;
			QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
			if(s.isEmpty()) return;
			QImage image(w,h,QImage::Format_RGB32);
			plot.begin(&image);
			svg_plot->renderer()->render(&plot);
			plot.end();
			image.save(s,item->data(0).toString().toLocal8Bit().data());
		}
		break;
		case PICTURE:
		{
			bool ok;
			int h, w = QInputDialog::getInteger(this, tr("Width"), tr("Width:"), 300, 0, 2147483647, 1, &ok);
			if(!ok) return;
			h=QInputDialog::getInteger(this, tr("Height"), tr("Height:"), 200, 0, 2147483647, 1, &ok);
			if(!ok) return;
			QString s = QFileDialog::getSaveFileName(this, "Choose a filename to save");
			if(s.isEmpty()) return;
			QPicture image;
			const QRect r(0,0,w,h);
			image.setBoundingRect(r);
			plot.begin(&image);
			svg_plot->renderer()->render(&plot);
			plot.end();
			image.save(s,item->data(0).toString().toLocal8Bit().data());
		}
		break;
		case PRINTER:
		{
			QPrinter p;
			QPrintDialog printDialog(&p, this);
			if (printDialog.exec() != QDialog::Accepted) return;
			plot.begin(&p);
			svg_plot->renderer()->render(&plot);
			plot.end();
		}
		break;
		case PDF:
		{
			QPrinter p;
			QPrintDialog printDialog(&p, this);
			p.setOutputFormat(QPrinter::PdfFormat);
			if (printDialog.exec() != QDialog::Accepted) return;
			
			plot.begin(&p);
			svg_plot->renderer()->render(&plot);
			plot.end();
		}
		break;
		case SVG:
		{
			QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"), "", tr("*.svg"));
			QSvgGenerator p;
			p.setFileName(fileName);
			plot.begin(&p);
			svg_plot->renderer()->render(&plot);
			plot.end();
		}
	}
}