Example #1
0
DeviceState::DeviceState(QWidget *parent) :
    QWidget(parent), tabs(this)
{
    /* UI stuff */
    resize(500,400);
    setWindowIcon(QIcon(":/resources/windowicon.png"));
    setWindowTitle(tr("Device Settings"));

    QFormLayout* layout = new QFormLayout(this);
    layout->addWidget(&tabs);
    this->setLayout(layout);

    /* Loading the tabs */
    QScrollArea* currentArea = 0;
    QWidget* panel;

    QFile fin(":/resources/deviceoptions");
    fin.open(QFile::Text | QFile::ReadOnly);
    while(!fin.atEnd())
    {
        QString line = QString(fin.readLine());
        line = line.trimmed();

        /* Continue on a comment or an empty line */
        if(line[0] == '#' || line.length() == 0)
            continue;

        if(line[0] == '[')
        {
            QString buffer;
            for(int i = 1; line[i] != ']'; i++)
                buffer.append(line[i]);
            buffer = buffer.trimmed();

            panel = new QWidget();
            currentArea = new QScrollArea();
            layout = new QFormLayout(panel);
            currentArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
            currentArea->setWidget(panel);
            currentArea->setWidgetResizable(true);

            tabs.addTab(currentArea, buffer);

            continue;
        }

        QStringList elements = line.split(";");
        QString tag = elements[0].trimmed();
        QString title = elements[1].trimmed();
        QString type = elements[2].trimmed();
        QString defVal = elements[3].trimmed();

        elements = type.split("(");
        if(elements[0].trimmed() == "text")
        {
            QLineEdit* temp = new QLineEdit(defVal, currentArea);
            layout->addRow(title, temp);
            inputs.insert(tag, QPair<InputType, QWidget*>(Text, temp));

            temp->setSizePolicy(QSizePolicy(QSizePolicy::Preferred,
                                            QSizePolicy::Fixed));

            QObject::connect(temp, SIGNAL(textChanged(QString)),
                             this, SLOT(input()));
        }
        else if(elements[0].trimmed() == "check")
        {
            QCheckBox* temp = new QCheckBox(title, currentArea);
            layout->addRow(temp);
            if(defVal.toLower() == "true")
                temp->setChecked(true);
            else
                temp->setChecked(false);
            inputs.insert(tag, QPair<InputType, QWidget*>(Check, temp));

            QObject::connect(temp, SIGNAL(toggled(bool)),
                             this, SLOT(input()));
        }
        else if(elements[0].trimmed() == "slider")
Example #2
0
// ---------------------------------------------------------------
void PackageDialog::slotCreate()
{
  if(NameEdit->text().isEmpty()) {
    QMessageBox::critical(this, tr("Error"), tr("Please insert a package name!"));
    return;
  }

  QCheckBox *p;
  QListIterator<QCheckBox *> i(BoxList);
  if(!LibraryCheck->isChecked()) {
    int count=0;
    while(i.hasNext()){
      p = i.next();
      if(p->isChecked())
        count++;
    }
    
    if(count < 1) {
      QMessageBox::critical(this, tr("Error"), tr("Please choose at least one project!"));
      return;
    }
  }

  QString s(NameEdit->text());
  QFileInfo Info(s);
  if(Info.extension().isEmpty())
    s += ".qucs";
  NameEdit->setText(s);

  QFile PkgFile(s);
  if(PkgFile.exists())
    if(QMessageBox::information(this, tr("Info"),
          tr("Output file already exists!")+"\n"+tr("Overwrite it?"),
          tr("&Yes"), tr("&No"), 0,1,1))
      return;

  if(!PkgFile.open(QIODevice::ReadWrite)) {
    QMessageBox::critical(this, tr("Error"), tr("Cannot create package!"));
    return;
  }
  QDataStream Stream(&PkgFile);

  // First write header.
  char Header[HEADER_LENGTH];
  memset(Header, 0, HEADER_LENGTH);
  strcpy(Header, "Qucs package " PACKAGE_VERSION);
  PkgFile.writeBlock(Header, HEADER_LENGTH);


  // Write project files to package.
  i.toFront();
  while(i.hasNext()) {
    p = i.next();  
    if(p->isChecked()) {
      s = p->text() + "_prj";
      Stream << Q_UINT32(CODE_DIR) << s.latin1();
      s = QucsSettings.QucsHomeDir.absPath() + QDir::separator() + s;
      if(insertDirectory(s, Stream) < 0) {
        PkgFile.close();
        PkgFile.remove();
        return;
      }
      Stream << Q_UINT32(CODE_DIR_END) << Q_UINT32(0);
    }
  }

  // Write user libraries to package if desired.
  if(LibraryCheck->isChecked())
    if(insertLibraries(Stream) < 0) {
      PkgFile.close();
      PkgFile.remove();
      return;
    }

  // Calculate checksum and write it to package file.
  PkgFile.at(0);
  QByteArray Content = PkgFile.readAll();
  Q_UINT16 Checksum = qChecksum(Content.data(), Content.size());
  PkgFile.at(HEADER_LENGTH-sizeof(Q_UINT16));
  Stream << Checksum;
  PkgFile.close();

  QMessageBox::information(this, tr("Info"),
          tr("Successfully created Qucs package!"));
  accept();
}
//-------------------------------------------------------------------------------------------------
void ExchangeRate::slotShowSettings()
{
    QDialog dialSettings(this, Qt::WindowCloseButtonHint);
    QLabel *lblPrecision = new QLabel(tr("Precision:"), &dialSettings);
    QSpinBox *sbPrecision = new QSpinBox(&dialSettings);
    sbPrecision->setRange(0, 10);
    sbPrecision->setValue(iPrecision);
    QHBoxLayout *hblPrecision = new QHBoxLayout;
    hblPrecision->addWidget(lblPrecision, 0, Qt::AlignRight);
    hblPrecision->addWidget(sbPrecision, 0, Qt::AlignLeft);

    QCheckBox *chbProxy = new QCheckBox(tr("Use proxy"), &dialSettings);
    chbProxy->setChecked(bUseProxy);
    lblType = new QLabel(tr("Type:"), &dialSettings);
    cbType = new QComboBox(&dialSettings);
    cbType->addItems(QStringList("HTTP") << "SOCKS5");
    cbType->setCurrentIndex(bProxyIsSocks);
    lblServer = new QLabel(tr("Server:"), &dialSettings);
    leServer = new QLineEdit(&dialSettings);
    leServer->setText(strServer);
    lblPort = new QLabel(tr("Port:"), &dialSettings);
    sbPort = new QSpinBox(&dialSettings);
    sbPort->setRange(1, 65535);
    sbPort->setValue(iPort);
    chbAuth = new QCheckBox(tr("Authorization"), &dialSettings);
    chbAuth->setChecked(bAuth);
    lblUser = new QLabel(tr("User:"******"Password:"******"Proxy"), &dialSettings);
    QGridLayout *glProxy = new QGridLayout(gbProxy);
    glProxy->addWidget(chbProxy, 0, 1);
    glProxy->addWidget(lblType, 1, 0);
    glProxy->addWidget(cbType, 1, 1);
    glProxy->addWidget(lblServer, 2, 0);
    glProxy->addWidget(leServer, 2, 1);
    glProxy->addWidget(lblPort, 3, 0);
    glProxy->addWidget(sbPort, 3, 1);
    glProxy->addWidget(chbAuth, 4, 1);
    glProxy->addWidget(lblUser, 5, 0);
    glProxy->addWidget(leUser, 5, 1);
    glProxy->addWidget(lblPassword, 6, 0);
    glProxy->addWidget(lePassword, 6, 1);

    QPushButton *pbOk = new QPushButton(style()->standardIcon(QStyle::SP_DialogApplyButton), "OK", this);

    QVBoxLayout *vblStg = new QVBoxLayout(&dialSettings);
    vblStg->addLayout(hblPrecision);
    vblStg->addWidget(gbProxy);
    vblStg->addWidget(pbOk, 0, Qt::AlignHCenter);

    dialSettings.setFixedHeight(dialSettings.minimumSizeHint().height());

    //connects
    connect(chbProxy, SIGNAL(toggled(bool)), this, SLOT(slotToggleProxy(bool)));
    connect(chbAuth, SIGNAL(toggled(bool)), this, SLOT(slotToggleAuth(bool)));
    connect(pbOk, SIGNAL(clicked()), &dialSettings, SLOT(accept()));

    if (dialSettings.exec() == QDialog::Accepted)
    {
        iPrecision = sbPrecision->value();
        bUseProxy = chbProxy->isChecked();
        bProxyIsSocks = cbType->currentIndex();
        strServer = leServer->text();
        iPort = sbPort->value();
        bAuth = chbAuth->isChecked();
        strUser = leUser->text();
        strPassword = lePassword->text();

        if (bUseProxy)
        {
            QNetworkProxy netProxy(bProxyIsSocks ? QNetworkProxy::Socks5Proxy : QNetworkProxy::HttpProxy, strServer, iPort);
            if (bAuth)
            {
                netProxy.setUser(strUser);
                netProxy.setPassword(strPassword);
            }
            nam->setProxy(netProxy);
        }
        else
            nam->setProxy(QNetworkProxy());

        QSettings stg(strAppStg, QSettings::IniFormat);
        stg.setIniCodec("UTF-8");
        stg.beginGroup("Settings");
        stg.setValue("Precision", iPrecision);
        stg.setValue("UseProxy", bUseProxy ? "1" : "0");
        stg.setValue("ProxyType", bProxyIsSocks ? "SOCKS5" : "HTTP");
        stg.setValue("Server", strServer);
        stg.setValue("Port", QString::number(iPort));
        stg.setValue("Auth", bAuth ? "1" : "0");
        stg.setValue("User", strUser);
        stg.setValue("Password", strPassword);
        stg.endGroup();
    }
}
Example #4
0
    ServerListDialog::ServerListDialog(QWidget *parent, const char *name)
        : KDialogBase(Plain, i18n("Server List"), Ok|Close, Ok, parent, name, false)
    {
        setButtonOK(KGuiItem(i18n("C&onnect"), "connect_creating", i18n("Connect to the server"), i18n("Click here to connect to the selected IRC network and channel.")));

        QFrame* mainWidget = plainPage();

        m_serverList = new ServerListView(mainWidget);
        QWhatsThis::add(m_serverList, i18n("This shows the listof configured IRC networks. An IRC network is a collection of cooperating servers. You need only connect to one of the servers in the network to be connected to the entire IRC network. Once connected, Konversation will automatically join the channels shown. When Konversation is started for the first time, the Freenode network and the <i>#kde</i> channel are already entered for you."));
        m_serverList->setAllColumnsShowFocus(true);
        m_serverList->setRootIsDecorated(true);
        m_serverList->setResizeMode(QListView::AllColumns);
        m_serverList->addColumn(i18n("Network"));
        m_serverList->addColumn(i18n("Identity"));
        m_serverList->addColumn(i18n("Channels"));
        m_serverList->setSelectionModeExt(KListView::Extended);
        m_serverList->setShowSortIndicator(true);
        m_serverList->setSortColumn(0);
        m_serverList->setDragEnabled(true);
        m_serverList->setAcceptDrops(true);
        m_serverList->setDropVisualizer(true);
        m_serverList->header()->setMovingEnabled(false);

        m_addButton = new QPushButton(i18n("&New..."), mainWidget);
        QWhatsThis::add(m_addButton, i18n("Click here to define a new Network, including the server to connect to, and the Channels to automatically join once connected."));
        m_editButton = new QPushButton(i18n("&Edit..."), mainWidget);
        m_delButton = new QPushButton(i18n("&Delete"), mainWidget);

        QCheckBox* showAtStartup = new QCheckBox(i18n("Show at application startup"), mainWidget);
        showAtStartup->setChecked(Preferences::showServerList());
        connect(showAtStartup, SIGNAL(toggled(bool)), this, SLOT(setShowAtStartup(bool)));

        QGridLayout* layout = new QGridLayout(mainWidget, 5, 2, 0, spacingHint());

        layout->addMultiCellWidget(m_serverList, 0, 3, 0, 0);
        layout->addWidget(m_addButton, 0, 1);
        layout->addWidget(m_editButton, 1, 1);
        layout->addWidget(m_delButton, 2, 1);
        layout->addMultiCellWidget(showAtStartup, 4, 4, 0, 1);
        layout->setRowStretch(3, 10);

        m_serverList->setFocus();

        m_selectedItem = false;
        m_selectedServer = ServerSettings("");

        // Load server list
        updateServerList();

        connect(m_serverList, SIGNAL(aboutToMove()), this, SLOT(slotAboutToMove()));
        connect(m_serverList, SIGNAL(moved()), this, SLOT(slotMoved()));
        connect(m_serverList, SIGNAL(doubleClicked(QListViewItem *, const QPoint&, int)), this, SLOT(slotOk()));
        connect(m_serverList, SIGNAL(selectionChanged()), this, SLOT(updateButtons()));
        connect(m_serverList, SIGNAL(expanded(QListViewItem*)), this, SLOT(slotSetGroupExpanded(QListViewItem*)));
        connect(m_serverList, SIGNAL(collapsed(QListViewItem*)), this, SLOT(slotSetGroupCollapsed(QListViewItem*)));
        connect(m_addButton, SIGNAL(clicked()), this, SLOT(slotAdd()));
        connect(m_editButton, SIGNAL(clicked()), this, SLOT(slotEdit()));
        connect(m_delButton, SIGNAL(clicked()), this, SLOT(slotDelete()));

        updateButtons();

        KConfig* config = kapp->config();
        config->setGroup("ServerListDialog");
        QSize newSize = size();
        newSize = config->readSizeEntry("Size", &newSize);
        resize(newSize);

        m_serverList->setSelected(m_serverList->firstChild(), true);
    }
Example #5
0
NewAccountDialog::NewAccountDialog(const QList<QString>& allKeychains, const QList<QString>& selectedKeychains, QWidget* parent)
    : QDialog(parent)
{
    if (allKeychains.isEmpty()) {
        throw std::runtime_error(tr("You must first create at least one keychain.").toStdString());
    }

    keychainSet = selectedKeychains.toSet();

    QList<QString> keychains = allKeychains;
    qSort(keychains.begin(), keychains.end());

    // Buttons
    QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
                                     | QDialogButtonBox::Cancel);
    okButton = buttonBox->button(QDialogButtonBox::Ok);
    okButton->setEnabled(false);

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    // Account Name
    QLabel* nameLabel = new QLabel();
    nameLabel->setText(tr("Account Name:"));
    nameEdit = new QLineEdit();
    connect(nameEdit, &QLineEdit::textChanged, [this](const QString& /*text*/) { updateEnabled(); });

    QHBoxLayout* nameLayout = new QHBoxLayout();
    nameLayout->setSizeConstraint(QLayout::SetNoConstraint);
    nameLayout->addWidget(nameLabel);
    nameLayout->addWidget(nameEdit);

    // Keychain List Widget
    QLabel* selectionLabel = new QLabel(tr("Select keychains:"));
    keychainListWidget = new QListWidget();
    for (auto& keychain: keychains)
    {
        QCheckBox* checkBox = new QCheckBox(keychain);
        checkBox->setCheckState(selectedKeychains.count(keychain) ? Qt::Checked : Qt::Unchecked);
        connect(checkBox, &QCheckBox::stateChanged, [=](int state) { updateSelection(keychain, state); });
        QListWidgetItem* item = new QListWidgetItem();
        keychainListWidget->addItem(item);
        keychainListWidget->setItemWidget(item, checkBox);
    }

    // Minimum Signatures
    QLabel *minSigLabel = new QLabel();
    minSigLabel->setText(tr("Minimum Signatures:"));

    minSigComboBox = new QComboBox();
    minSigLineEdit = new QLineEdit();
    minSigLineEdit->setAlignment(Qt::AlignRight);
    minSigComboBox->setLineEdit(minSigLineEdit);

    QHBoxLayout* minSigLayout = new QHBoxLayout();
    minSigLayout->setSizeConstraint(QLayout::SetNoConstraint);
    minSigLayout->addWidget(minSigLabel);
    minSigLayout->addWidget(minSigComboBox);
    updateMinSigs();

    // Creation Time
    QDateTime localDateTime = QDateTime::currentDateTime();
    QLabel* creationTimeLabel = new QLabel(tr("Creation Time ") + "(" + localDateTime.timeZoneAbbreviation() + "):");
    creationTimeEdit = new QDateTimeEdit(QDateTime::currentDateTime());
    creationTimeEdit->setDisplayFormat("yyyy.MM.dd hh:mm:ss");
    creationTimeEdit->setCalendarPopup(true);
    calendarWidget = new QCalendarWidget(this);
    creationTimeEdit->setCalendarWidget(calendarWidget);

    QHBoxLayout* creationTimeLayout = new QHBoxLayout();
    creationTimeLayout->setSizeConstraint(QLayout::SetNoConstraint);
    creationTimeLayout->addWidget(creationTimeLabel);
    creationTimeLayout->addWidget(creationTimeEdit);

    // Main Layout 
    QVBoxLayout *mainLayout = new QVBoxLayout();
    mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
    mainLayout->addLayout(nameLayout);
    mainLayout->addWidget(selectionLabel);
    mainLayout->addWidget(keychainListWidget);
    mainLayout->addLayout(minSigLayout);
    mainLayout->addLayout(creationTimeLayout);
    mainLayout->addWidget(buttonBox);
    setLayout(mainLayout);
}
void
AddIntervalDialog::createClicked()
{
    const RideFile *ride = context->currentRide();
    if (!ride) {
        QMessageBox::critical(this, tr("Select Ride"), tr("No ride selected!"));
        return;
    }

    int maxIntervals = (int) countSpinBox->value();

    double windowSizeSecs = (hrsSpinBox->value() * 3600.0
                             + minsSpinBox->value() * 60.0
                             + secsSpinBox->value());

    double windowSizeMeters = (kmsSpinBox->value() * 1000.0
                             + msSpinBox->value());

    if (windowSizeSecs == 0.0) {
        QMessageBox::critical(this, tr("Bad Interval Length"),
                              tr("Interval length must be greater than zero!"));
        return;
    }

    bool byTime = typeTime->isChecked();

    QList<AddedInterval> results;
    if (methodBestPower->isChecked()) {
        if (peakPowerStandard->isChecked())
            findPeakPowerStandard(ride, results);
        else
            findBests(byTime, ride, (byTime?windowSizeSecs:windowSizeMeters), maxIntervals, results, "");
    }
    else
        findFirsts(byTime, ride, (byTime?windowSizeSecs:windowSizeMeters), maxIntervals, results);

    // clear the table
    clearResultsTable(resultsTable);

    // populate the table
    resultsTable->setRowCount(results.size());
    int row = 0;
    foreach (const AddedInterval &interval, results) {

        double secs = interval.start;
        double mins = floor(secs / 60);
        secs = secs - mins * 60.0;
        double hrs = floor(mins / 60);
        mins = mins - hrs * 60.0;

        // check box
        QCheckBox *c = new QCheckBox;
        c->setCheckState(Qt::Checked);
        resultsTable->setCellWidget(row, 0, c);

        // start time
        QString start = "%1:%2:%3";
        start = start.arg(hrs, 0, 'f', 0);
        start = start.arg(mins, 2, 'f', 0, QLatin1Char('0'));
        start = start.arg(round(secs), 2, 'f', 0, QLatin1Char('0'));

        QTableWidgetItem *t = new QTableWidgetItem;
        t->setText(start);
        t->setFlags(t->flags() & (~Qt::ItemIsEditable));
        resultsTable->setItem(row, 1, t);

        QTableWidgetItem *n = new QTableWidgetItem;
        n->setText(interval.name);
        n->setFlags(n->flags() | (Qt::ItemIsEditable));
        resultsTable->setItem(row, 2, n);

        // hidden columns - start, stop
        QString strt = QString("%1").arg(interval.start); // can't use secs as it gets modified
        QTableWidgetItem *st = new QTableWidgetItem;
        st->setText(strt);
        resultsTable->setItem(row, 3, st);

        QString stp = QString("%1").arg(interval.stop); // was interval.start+x
        QTableWidgetItem *sp = new QTableWidgetItem;
        sp->setText(stp);
        resultsTable->setItem(row, 4, sp);

        row++;
    }
QWidget* QgsCheckboxSearchWidgetWrapper::createWidget( QWidget* parent )
{
  QCheckBox* c = new QCheckBox( parent );
  c->setChecked( Qt::PartiallyChecked );
  return c;
}
Example #8
0
EditorWidget::EditorWidget(QString theme, QWidget *parent) :
	QWidget(parent),
	editor_rich_text(new EditorRichText(this)),
	editor_plain_text(new CodeEditor(this, CodeEditor::Html)),
	pag_stacked(new QStackedWidget(this)),
	m_state(Clean),
	m_initialPag(RichTextIndex)
{
	m_theme = theme;
	m_color = editor_rich_text->textColor();

	connect(editor_plain_text, SIGNAL(textChanged()), this, SLOT(plainTextChanged()));
	connect(editor_rich_text, SIGNAL(textChanged()), this, SLOT(richTextChanged()));
	connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), this, SLOT(richTextChanged()));
	connect(editor_rich_text, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(currentCharFormatChanged(QTextCharFormat)));
	connect(editor_rich_text, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()));

	list_smile = new QListWidget(this);
	list_smile->setMaximumSize(QSize(155, 16777215));
	list_smile->setMovement(QListView::Static);
	list_smile->setResizeMode(QListView::Adjust);
	list_smile->setViewMode(QListView::IconMode);
	connect(list_smile, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(list_smile_itemDoubleClicked(QListWidgetItem*)));

	toolbar_find_replace = new QWidget(this);
	toolbar_find_replace->setMinimumSize(QSize(0, 30));

	QVBoxLayout *main_layout = new QVBoxLayout(this);
	main_layout->setContentsMargins(0, 0, 0, 0);
	main_layout->setSpacing(4);

		QHBoxLayout *toolbar_layout = new QHBoxLayout();
		toolbar_layout->setContentsMargins(0, 0, 0, 0);
		toolbar_layout->setSpacing(10);

			QToolBar *toolbar_edit = new QToolBar(this);
			toolbar_edit->setMinimumSize(QSize(0, 30));
			toolbar_edit->setIconSize(QSize(20, 20));
			toolbar_edit->setStyleSheet("QToolBar{border:0px;}");
		// Save Pdf
		/*		m_pdf_action = createAction(QIcon(m_theme +"img16/pdf.png"), tr("Exportar a PDF") +"...", false, toolbar_edit);
				m_pdf_action->setPriority(QAction::LowPriority);
				m_pdf_action->setShortcut(Qt::CTRL + Qt::Key_D);
				connect(m_pdf_action, SIGNAL(triggered()), this, SLOT(on_edit_export_pdf()));
			toolbar_edit->addAction(m_pdf_action);
			toolbar_edit->addSeparator();*/
		// combos font and size
				QWidget *toolbar_font_input = new QWidget(this);
				QHBoxLayout *combofont_layout = new QHBoxLayout(toolbar_font_input);
				combofont_layout->setContentsMargins(0, 0, 2, 0);
					m_font_input = new QFontComboBox(toolbar_edit);
					connect(m_font_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font(QString)));
				combofont_layout->addWidget(m_font_input);
					m_font_size_input = new QComboBox(toolbar_edit);
					QFontDatabase font_db;
					foreach(int size, font_db.standardSizes())
						m_font_size_input->addItem(QString::number(size));
					connect(m_font_size_input, SIGNAL(activated(QString)), this, SLOT(on_edit_font_size(QString)));
				combofont_layout->addWidget(m_font_size_input);
			//	combofont_layout->setStretch(0, 1);

			toolbar_edit->addWidget(toolbar_font_input);
			toolbar_edit->addSeparator();
		// cut, copy, paste
				m_cut_action = createAction(QIcon(m_theme +"img16/edit_cut.png"), tr("Cortar"), false, toolbar_edit);
				m_cut_action->setPriority(QAction::LowPriority);
				m_cut_action->setShortcut(QKeySequence::Cut);
				connect(m_cut_action, SIGNAL(triggered()), this, SLOT(on_edit_cut()));
			toolbar_edit->addAction(m_cut_action);
				m_copy_action = createAction(QIcon(m_theme +"img16/edit_copy.png"), tr("Copiar"), false, toolbar_edit);
				m_copy_action->setPriority(QAction::LowPriority);
				m_copy_action->setShortcut(QKeySequence::Copy);
				connect(m_copy_action, SIGNAL(triggered()), this, SLOT(on_edit_copy()));
			toolbar_edit->addAction(m_copy_action);
				m_paste_action = createAction(QIcon(m_theme +"img16/edit_paste.png"), tr("Pegar"), false, toolbar_edit);
				m_paste_action->setPriority(QAction::LowPriority);
				m_paste_action->setShortcut(QKeySequence::Paste);
				connect(m_paste_action, SIGNAL(triggered()), this, SLOT(on_edit_paste()));
			toolbar_edit->addAction(m_paste_action);
			toolbar_edit->addSeparator();
		// undo, redo
				m_undo_action = createAction(QIcon(m_theme +"img16/edit_deshacer.png"), tr("Deshacer"), false, toolbar_edit);
				m_undo_action->setShortcut(QKeySequence::Undo);
				connect(m_undo_action, SIGNAL(triggered()), this, SLOT(on_edit_undo()));
			toolbar_edit->addAction(m_undo_action);
				m_redo_action = createAction(QIcon(m_theme +"img16/edit_rehacer.png"), tr("Rehacer"), false, toolbar_edit);
				m_redo_action->setPriority(QAction::LowPriority);
				m_redo_action->setShortcut(QKeySequence::Redo);
				connect(m_redo_action, SIGNAL(triggered()), this, SLOT(on_edit_redo()));
			toolbar_edit->addAction(m_redo_action);
			toolbar_edit->addSeparator();
		// bold, italic, underline, ,
				m_bold_action = createAction(QIcon(m_theme +"img16/edit_negrita.png"), tr("Negrita"), true, toolbar_edit);
				m_bold_action->setPriority(QAction::LowPriority);
				m_bold_action->setShortcut(Qt::CTRL + Qt::Key_B);
				connect(m_bold_action, SIGNAL(triggered()), this, SLOT(on_edit_bold()));
			toolbar_edit->addAction(m_bold_action);
				m_italic_action = createAction(QIcon(m_theme +"img16/edit_cursiva.png"), tr("Cursiva"), true, toolbar_edit);
				m_italic_action->setPriority(QAction::LowPriority);
				m_italic_action->setShortcut(Qt::CTRL + Qt::Key_I);
				connect(m_italic_action, SIGNAL(triggered()), this, SLOT(on_edit_italic()));
			toolbar_edit->addAction(m_italic_action);
				m_underline_action = createAction(QIcon(m_theme +"img16/edit_subrayada.png"), tr("Subrayado"), true, toolbar_edit);
				m_underline_action->setPriority(QAction::LowPriority);
				m_underline_action->setShortcut(Qt::CTRL + Qt::Key_U);
				connect(m_underline_action, SIGNAL(triggered()), this, SLOT(on_edit_underline()));
			toolbar_edit->addAction(m_underline_action);
			toolbar_edit->addSeparator();
		// align: left, center, right, justify
				QActionGroup *grp = new QActionGroup(toolbar_edit);
				connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(on_edit_text_align(QAction*)));
				if (QApplication::isLeftToRight()) {
					m_align_left_action   = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp);
					m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp);
					m_align_right_action  = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp);
				} else {
					m_align_right_action  = createAction(QIcon(m_theme +"img16/edit_text_right.png"), tr("Derecho"), true, grp);
					m_align_center_action = createAction(QIcon(m_theme +"img16/edit_text_center.png"), tr("Centro"), true, grp);
					m_align_left_action   = createAction(QIcon(m_theme +"img16/edit_text_left.png"), tr("Izquierdo"), true, grp);
				}
				m_align_justify_action = createAction(QIcon(m_theme +"img16/edit_text_justify.png"), tr("Justificado"), true, grp);
				m_align_left_action->setPriority(QAction::LowPriority);
				m_align_left_action->setShortcut(Qt::CTRL + Qt::Key_L);
				m_align_center_action->setPriority(QAction::LowPriority);
				m_align_center_action->setShortcut(Qt::CTRL + Qt::Key_E);
				m_align_right_action->setPriority(QAction::LowPriority);
				m_align_right_action->setShortcut(Qt::CTRL + Qt::Key_R);
				m_align_justify_action->setPriority(QAction::LowPriority);
				m_align_justify_action->setShortcut(Qt::CTRL + Qt::Key_J);
			toolbar_edit->addActions(grp->actions());
			toolbar_edit->addSeparator();
		// superscript, subscript
				m_valign_sup_action = createAction(QIcon(m_theme +"img16/edit_text_super.png"), tr("Superíndice"), true, toolbar_edit);
				connect(m_valign_sup_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sup()));
			toolbar_edit->addAction(m_valign_sup_action);
				m_valign_sub_action = createAction(QIcon(m_theme +"img16/edit_text_subs.png"), tr("Subíndice"), true, toolbar_edit);
				connect(m_valign_sub_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_valign_sub()));
			toolbar_edit->addAction(m_valign_sub_action);
			toolbar_edit->addSeparator();
		// image, link, color, simplify
				m_image_action = createAction(QIcon(m_theme +"img16/edit_imagen.png"), tr("Imagen"), false, toolbar_edit);
				connect(m_image_action, SIGNAL(triggered()), this, SLOT(on_edit_image()));
			toolbar_edit->addAction(m_image_action);
				m_link_action = createAction(QIcon(m_theme +"img16/edit_enlace.png"), tr("Enlace"), true, toolbar_edit);
				connect(m_link_action, SIGNAL(triggered(bool)), this, SLOT(on_edit_link(bool)));
			toolbar_edit->addAction(m_link_action);
				QPixmap pix(16, 16);
				pix.fill(Qt::black);
				m_color_action = createAction(QIcon(pix), tr("Color") +"...", false, toolbar_edit);
				connect(m_color_action, SIGNAL(triggered()), this, SLOT(on_edit_color()));
			toolbar_edit->addAction(m_color_action);
			toolbar_edit->addSeparator();
				m_simplify_richtext_action = createAction(QIcon(m_theme +"img16/edit_simplify_richtext.png"), tr("Simplificar") +" Html", true, toolbar_edit);
				m_simplify_richtext_action->setChecked(editor_rich_text->simplifyRichText());
				connect(m_simplify_richtext_action, SIGNAL(triggered(bool)), editor_rich_text, SLOT(setSimplifyRichText(bool)));
				connect(editor_rich_text, SIGNAL(simplifyRichTextChanged(bool)), m_simplify_richtext_action, SLOT(setChecked(bool)));
			toolbar_edit->addAction(m_simplify_richtext_action);

		toolbar_layout->addWidget(toolbar_edit);

			QToolBar *toolbar_opts = new QToolBar(this);
			toolbar_opts->setIconSize(QSize(20, 20));
			toolbar_opts->setMinimumSize(QSize(30, 30));
			toolbar_opts->setStyleSheet("QToolBar{border:0px;}");
				m_find_replace_text_action = createAction(QIcon(m_theme +"img16/edit_buscar.png"), tr("Buscar") +"/"+ tr("Reemplazar"), true, toolbar_opts);
				m_find_replace_text_action->setPriority(QAction::LowPriority);
				m_find_replace_text_action->setShortcut(QKeySequence::Find);
				connect(m_find_replace_text_action, SIGNAL(triggered(bool)), this, SLOT(on_show_find_replace(bool)));
			toolbar_opts->addAction(m_find_replace_text_action);
				m_rich_plain_action = createAction(QIcon(m_theme +"img16/script.png"), tr("Editor") +"/"+ tr("Código"), true, toolbar_opts);
				connect(m_rich_plain_action, SIGNAL(triggered(bool)), this, SLOT(on_show_source(bool)));
			toolbar_opts->addAction(m_rich_plain_action);
				m_smiles_action = createAction(QIcon(m_theme +"img16/smile.png"), tr("Smiles"), true, toolbar_opts);
				connect(m_smiles_action, SIGNAL(triggered(bool)), list_smile, SLOT(setVisible(bool)));
			toolbar_opts->addAction(m_smiles_action);

		toolbar_layout->addWidget(toolbar_opts);
		toolbar_layout->setStretch(0, 1);

	main_layout->addLayout(toolbar_layout);

		QHBoxLayout *edit_smiles_layout = new QHBoxLayout();
		edit_smiles_layout->setContentsMargins(0, 0, 0, 0);
		edit_smiles_layout->setSpacing(4);

			QWidget *rich_edit = new QWidget();
				QVBoxLayout *rich_edit_layout = new QVBoxLayout(rich_edit);
				rich_edit_layout->setContentsMargins(0, 0, 0, 0);
				rich_edit_layout->addWidget(editor_rich_text);
			pag_stacked->addWidget(rich_edit);

			QWidget *plain_edit = new QWidget();
				QVBoxLayout *plain_edit_layout = new QVBoxLayout(plain_edit);
				plain_edit_layout->setContentsMargins(0, 0, 0, 0);
				plain_edit_layout->addWidget(editor_plain_text);
			pag_stacked->addWidget(plain_edit);
			connect(pag_stacked, SIGNAL(currentChanged(int)), this, SLOT(pagIndexChanged(int)));

		edit_smiles_layout->addWidget(pag_stacked);
		edit_smiles_layout->addWidget(list_smile);

	main_layout->addLayout(edit_smiles_layout);

		QGridLayout *gridLayout = new QGridLayout(toolbar_find_replace);
		gridLayout->setSpacing(4);
		gridLayout->setContentsMargins(0, 0, 0, 0);
			QLabel *lb_find = new QLabel(tr("Buscar")+":", toolbar_find_replace);
		gridLayout->addWidget(lb_find, 0, 0, 1, 1);
			txt_find = new QLineEdit(toolbar_find_replace);
			txt_find->setMinimumSize(QSize(0, 24));
			connect(txt_find, SIGNAL(textChanged(QString)), this, SLOT(txtFindTextChanged(QString)));
		gridLayout->addWidget(txt_find, 0, 1, 1, 1);
			QToolButton *btnFindBack = createToolButton(QIcon(m_theme +"img16/edit_buscar_anterior.png"), tr("Buscar anterior"), toolbar_find_replace);
			btnFindBack->setShortcut(QKeySequence::FindPrevious);
			connect(btnFindBack, SIGNAL(clicked()), this, SLOT(btnFindBack_clicked()));
		gridLayout->addWidget(btnFindBack, 0, 2, 1, 1);
			QToolButton *btnFindNext = createToolButton(QIcon(m_theme +"img16/edit_buscar_siguiente.png"), tr("Buscar siguiente"), toolbar_find_replace);
			btnFindBack->setShortcut(QKeySequence::FindNext);
			connect(btnFindNext, SIGNAL(clicked()), this, SLOT(btnFindNext_clicked()));
		gridLayout->addWidget(btnFindNext, 0, 3, 1, 1);
			chkCaseSensitive = new QCheckBox(tr("Coincidir mayúsculas/minúsculas"), toolbar_find_replace);
			chkCaseSensitive->setChecked(false);
			connect(chkCaseSensitive, SIGNAL(toggled(bool)), this, SLOT(chkCaseSensitive_toggled(bool)));
		gridLayout->addWidget(chkCaseSensitive, 0, 5, 1, 1);
			QCheckBox *chkReplace = new QCheckBox(tr("Reemplazar por") +":", toolbar_find_replace);
			chkReplace->setChecked(false);
			connect(chkReplace, SIGNAL(toggled(bool)), this, SLOT(chkReplace_toggled(bool)));
		gridLayout->addWidget(chkReplace, 1, 0, 1, 1);
			txt_replace = new QLineEdit(toolbar_find_replace);
			txt_replace->setEnabled(false);
			txt_replace->setMinimumSize(QSize(0, 24));
		gridLayout->addWidget(txt_replace, 1, 1, 1, 1);
			btnReplace = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar"), toolbar_find_replace);
			btnReplace->setEnabled(false);
			connect(btnReplace, SIGNAL(clicked()), this, SLOT(btnReplace_clicked()));
		gridLayout->addWidget(btnReplace, 1, 2, 1, 1);
			btnReplaceAndNext = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar siguiente"), toolbar_find_replace);
			btnReplaceAndNext->setEnabled(false);
			connect(btnReplaceAndNext, SIGNAL(clicked()), this, SLOT(btnReplaceAndNext_clicked()));
		gridLayout->addWidget(btnReplaceAndNext, 1, 3, 1, 1);
			btnReplaceAll = createToolButton(QIcon(m_theme +"img16/edit_reemplazar.png"), tr("Reemplazar todo"), toolbar_find_replace);
			btnReplaceAll->setEnabled(false);
			connect(btnReplaceAll, SIGNAL(clicked()), this, SLOT(btnReplaceAll_clicked()));
		gridLayout->addWidget(btnReplaceAll, 1, 4, 1, 1);
			chkWholeWords = new QCheckBox(tr("Solo palabras completas"), toolbar_find_replace);
		gridLayout->addWidget(chkWholeWords, 1, 5, 1, 1);

	main_layout->addWidget(toolbar_find_replace);

#ifndef QT_NO_CLIPBOARD
	connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
#endif

	showSource(m_initialPag == RichTextIndex ? false : true);
	showFindReplace(false);
	showSmiles(false);
	setTabStopWidth(40);

	fontChanged(editor_rich_text->font());
	colorChanged(editor_rich_text->textColor());
	alignmentChanged(editor_rich_text->alignment());
}
Example #9
0
void importDialog::afterCreateGroup()
{
    ui->stackedWidget->setCurrentIndex(ui->stackedWidget->currentIndex()+1);
    ui->btnImportar->setEnabled(true);

    MainWindow w(_empDir + "/Divisas.dbf");
    QSqlQuery q(QSqlDatabase::database("dbfEditor"));
    if(!q.exec("Select * from d_Divisas"))
    {
        QMessageBox::critical(this,"Error",q.lastError().text());
        return;
    }
    q.first();

    QSqlQueryModel * modelMoneda = new QSqlQueryModel(this);
    modelMoneda->setQuery("SELECT * FROM monedas;",QSqlDatabase::database("grupo"));

    QSqlQueryModel * modelPais = new QSqlQueryModel(this);
    modelPais->setQuery("SELECT * FROM paises;",QSqlDatabase::database("grupo"));

    QWidget* container = new QWidget(this);
    QVBoxLayout * _layout = new QVBoxLayout(container);
    do
    {
        QSqlRecord r = q.record();
        QString codigo = r.value("CCODDIV").toString().trimmed();
        QString desc = r.value("CDETDIV").toString().trimmed();

        QComboBox * combo = new QComboBox(this);
        combo->setModel(modelMoneda);
        combo->setModelColumn(1);

        QComboBox * combo2 = new QComboBox(this);
        combo2->setModel(modelPais);
        combo2->setModelColumn(1);

        QLabel * label = new QLabel(desc,this);

        QHBoxLayout * lay = new QHBoxLayout(this);

        QCheckBox * check = new QCheckBox(this);
        check->setChecked(true);

        lay->addWidget(check);
        lay->addWidget(label);
        lay->addWidget(combo);
        lay->addWidget(combo2);

        _layout->addLayout(lay);
        _combos.insert(combo,codigo);
        _combosMonedaPais.insert(combo2,codigo);
        _validDivisas.insert(combo,check);
        combo->setCurrentIndex(0);

    }while(q.next());
    _layout->addSpacerItem(new QSpacerItem(1,1,QSizePolicy::Preferred,QSizePolicy::Expanding));
    container->setLayout(_layout);
    ui->scrollArea->setWidget(container);

    w.openDb(_empDir + "/Ivas.dbf");
    if(!q.exec("Select * from d_Ivas"))
    {
        QMessageBox::critical(this,"Error",q.lastError().text());
        return;
    }
    q.first();

    QSqlQueryModel * q2 = new QSqlQueryModel(this);
    q2->setQuery("SELECT * FROM tiposiva;",QSqlDatabase::database("grupo"));

    QWidget* container2 = new QWidget(this);
    QVBoxLayout * _layout2 = new QVBoxLayout(container);
    do
    {
        QSqlRecord r = q.record();
        QString codigo = r.value("CTIPOIVA").toString().trimmed();
        QString desc = r.value("CDETIVA").toString().trimmed();

        QComboBox * combo = new QComboBox(this);
        combo->setModel(q2);
        combo->setModelColumn(2);

        QLabel * label = new QLabel(desc,this);

        QHBoxLayout * lay = new QHBoxLayout(this);

        lay->addWidget(label);
        lay->addWidget(combo);

        _layout2->addLayout(lay);
        _combos2.insert(combo,codigo);
        combo->setCurrentIndex(0);

    }while(q.next());
    _layout2->addSpacerItem(new QSpacerItem(1,1,QSizePolicy::Preferred,QSizePolicy::Expanding));
    container2->setLayout(_layout2);
    ui->scrollIva->setWidget(container2);

    w.openDb(ui->txtRutaBD->text() + "/dbf/Naciones.dbf");
    if(!q.exec("Select * from d_Naciones"))
    {
        QMessageBox::critical(this,"Error",q.lastError().text());
        return;
    }
    q.first();

    QWidget* container3 = new QWidget(this);
    QVBoxLayout * _layout3 = new QVBoxLayout(container);
    do
    {
        QSqlRecord r = q.record();
        QString codigo = r.value("CCODIGO").toString().trimmed();
        QString desc = r.value("CNOMBRE").toString().trimmed();

        QComboBox * combo = new QComboBox(this);
        combo->setModel(modelPais);
        combo->setModelColumn(1);

        QLabel * label = new QLabel(desc,this);

        QHBoxLayout * lay = new QHBoxLayout(this);

        lay->addWidget(label);
        lay->addWidget(combo);

        _layout3->addLayout(lay);
        _combos3.insert(combo,codigo);
        combo->setCurrentIndex(0);

    }while(q.next());
    _layout3->addSpacerItem(new QSpacerItem(1,1,QSizePolicy::Preferred,QSizePolicy::Expanding));
    container3->setLayout(_layout3);
    ui->scrollPaises->setWidget(container3);
}
void SettingWidget::createValueWidget()
{
    rsArgument* argument = task->getArgument(option->name);
    
    switch(option->type) {
        case G_OPTION_ARG_FILENAME:
        case G_OPTION_ARG_STRING:
        case G_OPTION_ARG_STRING_ARRAY:
        case G_OPTION_ARG_CALLBACK:
        case G_OPTION_ARG_INT:
        case G_OPTION_ARG_INT64:
        case G_OPTION_ARG_DOUBLE:
            {
                // Display text box if number of values is not restricted
                if ( option->allowedValues == NULL ) {
                    if ( option->nLines < 2 ) {
                        QLineEdit *w = new QLineEdit();
                        valueWidget = w;
                        w->setPlaceholderText(option->cli_arg_description);
                        connect(w, SIGNAL(textChanged(QString)), this, SLOT(textChanged(QString)));
                        if ( argument != NULL ) {
                            w->setText(argument->value);
                        } else if ( option->defaultValue != NULL ) {
                            w->setText(option->defaultValue);
                        }
                    } else { // create a QTextEdit field instead
                        QPlainTextEdit *w = new QPlainTextEdit();
                        valueWidget = w;
                        connect(w, SIGNAL(textChanged()), this, SLOT(textChanged()));
                        if ( argument != NULL ) {
                            w->setPlainText(argument->value);
                        } else if ( option->defaultValue != NULL ) {
                            w->setPlainText(option->defaultValue);
                        }
                        QFontMetrics m(w->font()) ;
                        int rowHeight = m.lineSpacing() ;
                        w->setFixedHeight(option->nLines * rowHeight) ;
                        w->setLineWrapMode(QPlainTextEdit::NoWrap);
                    }
                } else { // if the allowed values are restricted display radio buttons instead
                    QWidget *w = new QWidget();
                    QBoxLayout *wLayout = new QBoxLayout(QBoxLayout::TopToBottom);
                    QButtonGroup *buttonGroup = new QButtonGroup();
                    buttonGroup->setExclusive(true);
                    valueWidget = w;
                    connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(buttonClicked(int)));
                    
                    // go through all options and add a radio button for them
                    rsUIOptionValue** values = option->allowedValues;
                    for (size_t i=0; values[i] != NULL; i++ ) {
                        // add radio button
                        QRadioButton *b = new QRadioButton(QString("'")+QString(values[i]->name)+QString("'"));
                        QFont f("Arial", 12, QFont::Bold);
                        b->setFont(f);
                        buttonGroup->addButton(b, (int)i);
                        wLayout->addWidget(b);
                        
                        // set it to checked if it is the default or set value
                        b->setChecked(false);
                        if ( argument != NULL ) {
                            if ( ! strcmp(argument->value,values[i]->name) ) {
                                b->setChecked(true);
                            }
                        } else if ( ! strcmp(option->defaultValue,values[i]->name) ) {
                            b->setChecked(true);
                        }
                        
                        // add its description
                        QLabel *label = new QLabel(values[i]->description);
                        label->setIndent(22);
                        label->setWordWrap(true);
                        label->setContentsMargins(0, 0, 0, 4);
                        QFont f2("Arial", 11, QFont::Normal);
                        label->setFont(f2);
                        wLayout->addWidget(label);
                    }
                    w->setLayout(wLayout);
                }
            }
            break;
        /*
        case G_OPTION_ARG_INT:
        case G_OPTION_ARG_INT64:
            valueWidget = new QSpinBox();
            break;
        case G_OPTION_ARG_DOUBLE:
            valueWidget = new QDoubleSpinBox();
            break;
        */
        case G_OPTION_ARG_NONE:
            {
                QCheckBox *w = new QCheckBox("Enabled"); // new SwitchWidget();
                valueWidget = w;
                connect(w, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int)));
                if ( argument != NULL ) {
                    w->setCheckState(Qt::Checked);
                } else {
                    w->setCheckState(Qt::Unchecked);
                }
            }
            break;
        default:
            throw std::invalid_argument("UI argument type unknown");
    }
}
Example #11
0
OptionDlg::OptionDlg(QWidget *parent)
	: QDialog(parent)
{
	readConfigure("etc/conf.xml");
	readTargets("etc/targets.xml");

	// 创建控件
	tabWidget = new QTabWidget;
	tabGeneral = new QWidget;
	tabNetwork = new QWidget;
	tabTargets = new QWidget;
	tabWidget->addTab(tabGeneral, tr("General"));
	tabWidget->addTab(tabNetwork, tr("Network"));
	tabWidget->addTab(tabTargets, tr("Targets"));

	// tab general
	labelRecursiveLayer = new QLabel(tr("&Recursive layer:"));
	spinBoxRecursiveLayer = new QSpinBox();
	spinBoxRecursiveLayer->setValue(recursiveLayer);
	labelRecursiveLayer->setBuddy(spinBoxRecursiveLayer);

	labelMinFileSize = new QLabel(tr("&Minimum file size(Kb):"));
	spinBoxMinFileSize = new QSpinBox();
	spinBoxMinFileSize->setValue(minFileSize);
	labelMinFileSize->setBuddy(spinBoxMinFileSize);

	checkBoxSaveInSingleDir = new QCheckBox(tr("&Save targets in single directory"));
	checkBoxSaveInSingleDir->setChecked(saveInSingleDir);

	labelFileExistsAction = new QLabel(tr("&Do what when file exists:"));
	comboBoxFileExistsAction = new QComboBox();
	comboBoxFileExistsAction->addItem(tr("Overwrite"), feaOverwrite);
	comboBoxFileExistsAction->addItem(tr("Ignore"), feaIgnore);
	comboBoxFileExistsAction->setCurrentIndex(fileExistsAction);
	labelFileExistsAction->setBuddy(comboBoxFileExistsAction);

	gridLayoutGeneral = new QGridLayout();
	gridLayoutGeneral->addWidget(labelRecursiveLayer, 0, 0, 1, 1);
	gridLayoutGeneral->addWidget(spinBoxRecursiveLayer, 0, 1, 1, 1);
	gridLayoutGeneral->addWidget(labelMinFileSize, 1, 0, 1, 1);
	gridLayoutGeneral->addWidget(spinBoxMinFileSize, 1, 1, 1, 1);
	gridLayoutGeneral->addWidget(checkBoxSaveInSingleDir, 2, 0, 1, 2);
	gridLayoutGeneral->addWidget(labelFileExistsAction, 3, 0, 1, 1);
	gridLayoutGeneral->addWidget(comboBoxFileExistsAction, 3, 1, 1, 1);

	boxLayoutGeneral = new QVBoxLayout;
	boxLayoutGeneral->addLayout(gridLayoutGeneral);
	boxLayoutGeneral->addStretch();

	tabGeneral->setLayout(boxLayoutGeneral);

	// tab Network
	checkBoxUseProxy = new QCheckBox(tr("&Enable proxy"));
	checkBoxUseProxy->setChecked(useProxy);
	connect(checkBoxUseProxy, SIGNAL(stateChanged(int)), this, SLOT(useProxyOrNot(int)));

	labelHost = new QLabel(tr("&Host:"));
	editHost = new QLineEdit();
	editHost->setText(proxyHost);
	labelHost->setBuddy(editHost);

	labelPort = new QLabel(tr("&Port:"));
	spinBoxPort = new QSpinBox();
	spinBoxPort->setMaximum(65535);
	spinBoxPort->setValue(proxyPort);
	labelPort->setBuddy(spinBoxPort);

	labelUsername = new QLabel(tr("&Username:"******"Pass&word:"));
	editPassword = new QLineEdit();
	editPassword->setText(proxyPassword);
	editPassword->setEchoMode(QLineEdit::Password);
	labelPassword->setBuddy(editPassword);

	// 启用不启用代理
	useProxyOrNot(checkBoxUseProxy->checkState());

	gridLayoutNetwork = new QGridLayout();
	gridLayoutNetwork->addWidget(checkBoxUseProxy, 0, 0, 1, 2);
	gridLayoutNetwork->addWidget(labelHost, 1, 0, 1, 1);
	gridLayoutNetwork->addWidget(editHost, 1, 1, 1, 1);
	gridLayoutNetwork->addWidget(labelPort, 2, 0, 1, 1);
	gridLayoutNetwork->addWidget(spinBoxPort, 2, 1, 1, 1);
	gridLayoutNetwork->addWidget(labelUsername, 3, 0, 1, 1);
	gridLayoutNetwork->addWidget(editUsername, 3, 1, 1, 1);
	gridLayoutNetwork->addWidget(labelPassword, 4, 0, 1, 1);
	gridLayoutNetwork->addWidget(editPassword, 4, 1, 1, 1);

	boxLayoutNetwork = new QVBoxLayout;
	boxLayoutNetwork->addLayout(gridLayoutNetwork);
	boxLayoutNetwork->addStretch();

	tabNetwork->setLayout(boxLayoutNetwork);

	// tab targets
	boxLayoutTargets = new QVBoxLayout;
	int i = 1;
	foreach(Target target, targets) {
		QCheckBox *checkBoxTarget = new QCheckBox(
				QString("&%1. %2").arg(i).arg(target.desc));
		if(target.selected)
			checkBoxTarget->setChecked(true);
		boxLayoutTargets->addWidget(checkBoxTarget);
		checkBoxTargets.push_back(checkBoxTarget);
		++i;
	}
Example #12
0
void ROMSelectionDialog::refreshROMInfos() {
	QString controlROMFileName = synthProfile.controlROMFileName;
	QString pcmROMFileName = synthProfile.pcmROMFileName;

	clearButtonGroup(controlROMGroup);
	clearButtonGroup(pcmROMGroup);
	controlROMRow = -1;
	pcmROMRow = -1;

	QStringList fileFilter = ui->fileFilterCombo->itemData(ui->fileFilterCombo->currentIndex()).value<QStringList>();
	QStringList dirEntries = synthProfile.romDir.entryList(fileFilter);
	ui->romInfoTable->clearContents();
	ui->romInfoTable->setRowCount(dirEntries.size());

	int row = 0;
	for (QStringListIterator it(dirEntries); it.hasNext();) {
		QString fileName = it.next();
		FileStream file;
		if (!file.open((synthProfile.romDir.absolutePath() + QDir::separator() + fileName).toUtf8())) continue;
		const ROMInfo *romInfoPtr = ROMInfo::getROMInfo(&file);
		if (romInfoPtr == NULL) continue;
		const ROMInfo &romInfo = *romInfoPtr;

		QButtonGroup *romGroup;
		QString romType;
		switch (romInfo.type) {
			case ROMInfo::PCM:
				romType = QString("PCM");
				romGroup = &pcmROMGroup;
				if (pcmROMRow == -1) pcmROMRow = row;
				break;
			case ROMInfo::Control:
				romType = QString("Control");
				romGroup = &controlROMGroup;
				if (controlROMRow == -1) controlROMRow = row;
				break;
			case ROMInfo::Reverb:
				romType = QString("Reverb");
				romGroup = NULL;
				break;
			default:
				MT32Emu::ROMInfo::freeROMInfo(romInfoPtr);
				continue;
		}

		if (fileName == controlROMFileName) {
			controlROMRow = row;
		} else if (fileName == pcmROMFileName) {
			pcmROMRow = row;
		}

		int column = 0;
		QCheckBox *checkBox = new QCheckBox();
		if (romInfo.type != ROMInfo::Reverb) {
			romGroup->addButton(checkBox);
			romGroup->setId(checkBox, row);
		} else checkBox->setDisabled(true);
		ui->romInfoTable->setCellWidget(row, column++, checkBox);

		if (controlROMRow == row || pcmROMRow == row) {
			checkBox->setChecked(true);
		}

		QTableWidgetItem *item = new QTableWidgetItem(fileName);
		item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		ui->romInfoTable->setItem(row, column++, item);

		item = new QTableWidgetItem(QString(romInfo.shortName));
		item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		ui->romInfoTable->setItem(row, column++, item);

		item = new QTableWidgetItem(QString(romInfo.description));
		item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		ui->romInfoTable->setItem(row, column++, item);

		item = new QTableWidgetItem(romType);
		item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		ui->romInfoTable->setItem(row, column++, item);

		item = new QTableWidgetItem(QString(romInfo.sha1Digest));
		item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		ui->romInfoTable->setItem(row, column++, item);

		MT32Emu::ROMInfo::freeROMInfo(romInfoPtr);
		row++;
	}
	ui->romInfoTable->setRowCount(row);
	ui->romInfoTable->resizeColumnsToContents();
}
Example #13
0
Window::Window(QWidget *parent)
    : KMainWindow(parent)
{
    QWidget* widget = new QWidget;
    setCentralWidget(widget);
    resize(500, 400);

    m_actions
            << new QAction(KIcon("document-save"), i18n("Save"), this)
            << new QAction(i18n("Discard"), this)
            ;

    QVBoxLayout* mainLayout = new QVBoxLayout(widget);

    // KMessageWidget
    m_messageWidget = new KMessageWidget(this);
    m_messageWidget->hide();
    mainLayout->addWidget(m_messageWidget);

    // Message buttons
    {
        QGroupBox* groupBox = new QGroupBox();
        groupBox->setTitle(i18n("Show/hide message widget"));
        mainLayout->addWidget(groupBox);
        QVBoxLayout* layout = new QVBoxLayout(groupBox);

        createMessageButton(layout, i18n("Error"), SLOT(showErrorMessage()));
        createMessageButton(layout, i18n("Warning"), SLOT(showWarningMessage()));
        createMessageButton(layout, i18n("Information"), SLOT(showInformationMessage()));
        createMessageButton(layout, i18n("Positive"), SLOT(showPositiveMessage()));
    }

    // Text
    {
        QGroupBox* groupBox = new QGroupBox();
        groupBox->setTitle(i18n("Text"));
        mainLayout->addWidget(groupBox);
        QVBoxLayout* layout = new QVBoxLayout(groupBox);

        m_edit = new KTextEdit;
        m_edit->setClickMessage(i18n("Use default text"));
        layout->addWidget(m_edit);
    }

    // Options
    {
        QGroupBox* groupBox = new QGroupBox();
        groupBox->setTitle(i18n("Options"));
        mainLayout->addWidget(groupBox);
        QVBoxLayout* layout = new QVBoxLayout(groupBox);

        QCheckBox* wordwrapCheckBox = new QCheckBox(i18n("Word wrap"));
        layout->addWidget(wordwrapCheckBox);
        connect(wordwrapCheckBox, SIGNAL(toggled(bool)), m_messageWidget, SLOT(setWordWrap(bool)));

        QCheckBox* showActionsCheckBox = new QCheckBox(i18n("Show action buttons"));
        layout->addWidget(showActionsCheckBox);
        connect(showActionsCheckBox, SIGNAL(toggled(bool)), SLOT(showActions(bool)));

        QCheckBox* showCloseButtonCheckBox = new QCheckBox(i18n("Show close button"));
        showCloseButtonCheckBox->setChecked(true);
        layout->addWidget(showCloseButtonCheckBox);
        connect(showCloseButtonCheckBox, SIGNAL(toggled(bool)),m_messageWidget, SLOT(setCloseButtonVisible(bool)));

        m_animatedShowCheckBox = new QCheckBox(i18n("Animated"));
        m_animatedShowCheckBox->setChecked(true);
        layout->addWidget(m_animatedShowCheckBox);

        QLabel* iconLabel = new QLabel("Icon:");
        layout->addWidget(iconLabel);

        m_iconComboBox = new QComboBox;
        iconLabel->setBuddy(m_iconComboBox);
        QStringList names = QStringList() << QString() << "preferences-system-network" << "document-save" << "system-users";
        Q_FOREACH(const QString &name, names) {
            QIcon icon = QIcon::fromTheme(name);
            m_iconComboBox->addItem(icon, name.isEmpty() ? "none" : name);
        }
        connect(m_iconComboBox, SIGNAL(activated(int)), SLOT(setIconFromComboBox(int)));
        layout->addWidget(m_iconComboBox);
    }
Example #14
0
ACLEditor::ACLEditor(int channelid, const MumbleProto::ACL &mea, QWidget *p) : QDialog(p) {
	QLabel *l;

	bAddChannelMode = false;

	iChannel = channelid;
	Channel *pChannel = Channel::get(iChannel);
	if (pChannel == NULL) {
		g.l->log(Log::Warning, tr("Failed: Invalid channel"));
		QDialog::reject();
		return;
	}

	msg = mea;

	setupUi(this);

	if (!g.s.bExpert) {
		qtwTab->removeTab(2);
		qtwTab->removeTab(1);
		qsbChannelPosition->hide();
		qlChannelPosition->hide();
	}
	qcbChannelTemporary->hide();

	iId = mea.channel_id();
	setWindowTitle(tr("Mumble - Edit %1").arg(Channel::get(iId)->qsName));

	qleChannelName->setText(pChannel->qsName);
	if (channelid == 0) qleChannelName->setEnabled(false);

	rteChannelDescription->setText(pChannel->qsDesc);

	qsbChannelPosition->setRange(INT_MIN, INT_MAX);
	qsbChannelPosition->setValue(pChannel->iPosition);

	QGridLayout *grid = new QGridLayout(qgbACLpermissions);

	l=new QLabel(tr("Deny"), qgbACLpermissions);
	grid->addWidget(l,0,1);
	l=new QLabel(tr("Allow"), qgbACLpermissions);
	grid->addWidget(l,0,2);

	int idx=1;
	for (int i=0;i< ((iId == 0) ? 30 : 16);++i) {
		ChanACL::Perm perm = static_cast<ChanACL::Perm>(1 << i);
		QString name = ChanACL::permName(perm);

		if (! name.isEmpty()) {
			QCheckBox *qcb;
			l = new QLabel(name, qgbACLpermissions);
			grid->addWidget(l,idx,0);
			qcb=new QCheckBox(qgbACLpermissions);
			qcb->setToolTip(tr("Deny %1").arg(name));
			qcb->setWhatsThis(tr("This revokes the %1 privilege. If a privilege is both allowed and denied, it is denied.<br />%2").arg(name).arg(ChanACL::whatsThis(perm)));
			connect(qcb, SIGNAL(clicked(bool)), this, SLOT(ACLPermissions_clicked()));
			grid->addWidget(qcb,idx,1);

			qlACLDeny << qcb;


			qcb=new QCheckBox(qgbACLpermissions);
			qcb->setToolTip(tr("Allow %1").arg(name));
			qcb->setWhatsThis(tr("This grants the %1 privilege. If a privilege is both allowed and denied, it is denied.<br />%2").arg(name).arg(ChanACL::whatsThis(perm)));
			connect(qcb, SIGNAL(clicked(bool)), this, SLOT(ACLPermissions_clicked()));
			grid->addWidget(qcb,idx,2);

			qlACLAllow << qcb;

			qlPerms << perm;

			++idx;
		}
	}
Example #15
0
QWidget *ServerDialog::createPackageTab() {
    disable_lua_checkbox = new QCheckBox(tr("Disable Lua"));
    disable_lua_checkbox->setChecked(Config.DisableLua);
    disable_lua_checkbox->setToolTip(tr("The setting takes effect after reboot"));

    extension_group = new QButtonGroup;
    extension_group->setExclusive(false);

    QStringList extensions = Sanguosha->getExtensions();
    QSet<QString> ban_packages = Config.BanPackages.toSet();

    QGroupBox *box1 = new QGroupBox(tr("General package"));
    QGroupBox *box2 = new QGroupBox(tr("Card package"));

    QGridLayout *layout1 = new QGridLayout;
    QGridLayout *layout2 = new QGridLayout;
    box1->setLayout(layout1);
    box2->setLayout(layout2);

    int i = 0, j = 0;
    int row = 0, column = 0;
    foreach (QString extension, extensions) {
        const Package *package = Sanguosha->findChild<const Package *>(extension);
        if (package == NULL)
            continue;

        bool forbid_package = Config.value("ForbidPackages").toStringList().contains(extension);
        QCheckBox *checkbox = new QCheckBox;
        checkbox->setObjectName(extension);
        checkbox->setText(Sanguosha->translate(extension));
        checkbox->setChecked(!ban_packages.contains(extension) && !forbid_package);
        checkbox->setEnabled(!forbid_package);

        extension_group->addButton(checkbox);

        switch (package->getType()) {
        case Package::GeneralPack: {
                row = i / 5;
                column = i % 5;
                i++;

                layout1->addWidget(checkbox, row, column + 1);
                break;
            }
        case Package::CardPack: {
                row = j / 5;
                column = j % 5;
                j++;

                layout2->addWidget(checkbox, row, column + 1);
                break;
            }
        default:
                break;
        }
    }

    QWidget *widget = new QWidget;
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(disable_lua_checkbox);
    layout->addWidget(box1);
    layout->addWidget(box2);

    widget->setLayout(layout);
    return widget;
}
Example #16
0
/** Puts the controls that go on the second line, the workspace
*  list and save commands, on to the layout that's passed to it
*  @param lineTwo :: the layout on to which the controls will be placed
*  @param defSavs the formats to save into, sets the check boxes to be checked
*/
void SaveWorkspaces::setupLine2(
    QHBoxLayout *const lineTwo,
    const QHash<const QCheckBox *const, QString> &defSavs) {
  m_workspaces = new QListWidget();
  auto ws = AnalysisDataService::Instance().getObjectNames();
  auto it = ws.begin(), wsEnd = ws.end();
  for (; it != wsEnd; ++it) {
    Workspace *wksp = FrameworkManager::Instance().getWorkspace(*it);
    if (dynamic_cast<MatrixWorkspace *>(
            wksp)) { // only include matrix workspaces, not groups or tables
      m_workspaces->addItem(QString::fromStdString(*it));
    }
  }
  // allow users to select more than one workspace in the list
  m_workspaces->setSelectionMode(QAbstractItemView::ExtendedSelection);
  connect(m_workspaces, SIGNAL(currentRowChanged(int)), this,
          SLOT(setFileName(int)));

  QPushButton *save = new QPushButton("Save");
  connect(save, SIGNAL(clicked()), this, SLOT(saveSel()));
  QPushButton *cancel = new QPushButton("Cancel");
  connect(cancel, SIGNAL(clicked()), this, SLOT(close()));

  QCheckBox *saveNex = new QCheckBox("Nexus");
  QCheckBox *saveNIST = new QCheckBox("NIST Qxy");
  QCheckBox *saveCan = new QCheckBox("CanSAS");
  QCheckBox *saveRKH = new QCheckBox("RKH");
  QCheckBox *saveCSV = new QCheckBox("CSV");
  // link the save option tick boxes to their save algorithm
  m_savFormats.insert(saveNex, "SaveNexus");
  m_savFormats.insert(saveNIST, "SaveNISTDAT");
  m_savFormats.insert(saveCan, "SaveCanSAS1D");
  m_savFormats.insert(saveRKH, "SaveRKH");
  m_savFormats.insert(saveCSV, "SaveCSV");
  setupFormatTicks(defSavs);

  m_append = new QCheckBox("Append");

  // place controls into the layout, which places them on the form and takes
  // care of deleting them
  QVBoxLayout *ly_saveConts = new QVBoxLayout;
  ly_saveConts->addWidget(save);
  ly_saveConts->addWidget(cancel);
  ly_saveConts->addWidget(m_append);
  ly_saveConts->addStretch();

  QVBoxLayout *ly_saveFormats = new QVBoxLayout;
  ly_saveFormats->addWidget(saveNex);
  ly_saveFormats->addWidget(saveNIST);
  ly_saveFormats->addWidget(saveCan);
  ly_saveFormats->addWidget(saveRKH);
  ly_saveFormats->addWidget(saveCSV);
  QGroupBox *gb_saveForms = new QGroupBox(tr("Save Formats"));
  gb_saveForms->setLayout(ly_saveFormats);
  ly_saveConts->addWidget(gb_saveForms);

  lineTwo->addWidget(m_workspaces);
  lineTwo->addLayout(ly_saveConts);

  m_workspaces->setToolTip("Select one or more workspaces");
  const QString formatsTip =
      "Some formats support appending multiple workspaces in one file";
  gb_saveForms->setToolTip(formatsTip);
  save->setToolTip(formatsTip);
  cancel->setToolTip(formatsTip);
  saveNex->setToolTip(formatsTip);
  saveNIST->setToolTip(formatsTip);
  saveCan->setToolTip(formatsTip);
  saveRKH->setToolTip(formatsTip);
  saveCSV->setToolTip(formatsTip);
  m_append->setToolTip(formatsTip);
}
Example #17
0
void MainWindow::callOptionDialog (QVector<ConsoleInterface::optionDialogEntry> * options,bool * ret)
{
if (options->isEmpty()) return;

QVectorIterator<ConsoleInterface::optionDialogEntry> it(*options);

QDialog * d = new QDialog(this);

d->setModal(true);

QVBoxLayout * dbl = new QVBoxLayout();
d->setLayout(dbl);

QList <QWidget * > ents;

QHBoxLayout * sl;
QLabel * l;
QLineEdit * lew;
QCheckBox * chw;
QComboBox * cbl;

for(int i=0;i< (*options).size();i++)
{
sl = new QHBoxLayout();
l = new QLabel(d);
l->setText(it.next().text);
sl->addWidget(l);

if((*options)[i].type == ConsoleInterface::OPT_DEC)
{
    lew = new QLineEdit(d);
    lew->setValidator(new QIntValidator( d ));
    QString s;
    s.setNum((*options)[i].valueInt);
    lew->setText(s);
    sl->addWidget(lew);
    ents.append(lew);
}

if((*options)[i].type == ConsoleInterface::OPT_HEX)
{
    lew = new QLineEdit(d);
    lew->setValidator(new QRegExpValidator(QRegExp("([A-Fa-f0-9][A-Fa-f0-9])+"),d));
    QString s;
    s.setNum((*options)[i].valueInt,16);
    lew->setText(s);
    sl->addWidget(lew);
    ents.append(lew);
}

if((*options)[i].type == ConsoleInterface::OPT_STR)
{
    lew = new QLineEdit(d);
    lew->setValidator(NULL);
    QString s = (*options)[i].valueStr;
    lew->setText(s);
    sl->addWidget(lew);
    ents.append(lew);
}


if((*options)[i].type == ConsoleInterface::OPT_CHK)
{
    chw = new QCheckBox(d);
    chw->setChecked((*options)[i].valueInt == 0 ? false : true);
    sl->addWidget(chw);
    ents.append(chw);
}


if((*options)[i].type == ConsoleInterface::OPT_LIST)
{
cbl = new QComboBox(d);
cbl->addItems((*options)[i].variants);
sl->addWidget(cbl);
ents.append(cbl);
}




dbl->addLayout(sl);


}


QHBoxLayout * hbl = new QHBoxLayout(d);

QPushButton * obOK = new QPushButton(tr("OK"),d);
QPushButton * obCancel = new QPushButton(tr("Cancel"),d);
QPushButton * obAbort = new QPushButton(tr("Abort"),d);

connect(obOK,SIGNAL(clicked()),d,SLOT(accept()));
connect(obCancel,SIGNAL(clicked()),d,SLOT(reject()));
connect(obAbort,SIGNAL(clicked()),d,SLOT(reject()));
connect(obAbort,SIGNAL(clicked()),this,SLOT(on_stopButton_clicked()),Qt::QueuedConnection);

hbl->addStretch(10);
hbl->addWidget(obOK);
hbl->addWidget(obCancel);
hbl->addWidget(obAbort);

dbl->addLayout(hbl);


if(d->exec()==QDialog::Accepted)
{

    for(int i=0;i< (*options).size();i++)
    {
        if((*options)[i].type == ConsoleInterface::OPT_DEC)
        {
            (*options)[i].valueInt  = dynamic_cast<QLineEdit*>(ents[i])->text().toInt();
        }

        if((*options)[i].type == ConsoleInterface::OPT_HEX)
        {
            (*options)[i].valueInt  = dynamic_cast<QLineEdit*>(ents[i])->text().toInt(0,16);
        }

        if((*options)[i].type == ConsoleInterface::OPT_STR)
        {
            QString t =  dynamic_cast<QLineEdit*>(ents[i])->text();
            (*options)[i].valueStr  = t;
        }


        if((*options)[i].type == ConsoleInterface::OPT_CHK)
        {
            (*options)[i].valueInt  = dynamic_cast<QCheckBox*>(ents[i])->isChecked();
        }


        if((*options)[i].type == ConsoleInterface::OPT_LIST)
        {
            (*options)[i].valueInt  = dynamic_cast<QComboBox*>(ents[i])->currentIndex();
        }
    }

*ret =true;
}
else
{
*ret =false;
}



delete d;
}
Example #18
0
RenderOptionsDialog::RenderOptionsDialog()
    : QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
{
    setWindowOpacity(0.75);
    setWindowTitle(tr("Options (double click to flip)"));
    QGridLayout *layout = new QGridLayout;
    setLayout(layout);
    layout->setColumnStretch(1, 1);

    int row = 0;

    QCheckBox *check = new QCheckBox(tr("Dynamic cube map"));
    check->setCheckState(Qt::Unchecked);
    // Dynamic cube maps are only enabled when multi-texturing and render to texture are available.
    check->setEnabled(glActiveTexture && glGenFramebuffersEXT);
    connect(check, SIGNAL(stateChanged(int)), this, SIGNAL(dynamicCubemapToggled(int)));
    layout->addWidget(check, 0, 0, 1, 2);
    ++row;

    QPalette palette;

    // Load all .par files
    // .par files have a simple syntax for specifying user adjustable uniform variables.
    QSet<QByteArray> uniforms;
    QList<QString> filter = QStringList("*.par");
    QList<QFileInfo> files = QDir(":/res/boxes/").entryInfoList(filter, QDir::Files | QDir::Readable);

    foreach (QFileInfo fileInfo, files) {
        QFile file(fileInfo.absoluteFilePath());
        if (file.open(QIODevice::ReadOnly)) {
            while (!file.atEnd()) {
                QList<QByteArray> tokens = file.readLine().simplified().split(' ');
                QList<QByteArray>::const_iterator it = tokens.begin();
                if (it == tokens.end())
                    continue;
                QByteArray type = *it;
                if (++it == tokens.end())
                    continue;
                QByteArray name = *it;
                bool singleElement = (tokens.size() == 3); // type, name and one value
                char counter[10] = "000000000";
                int counterPos = 8; // position of last digit
                while (++it != tokens.end()) {
                    m_parameterNames << name;
                    if (!singleElement) {
                        m_parameterNames.back() += '[';
                        m_parameterNames.back() += counter + counterPos;
                        m_parameterNames.back() += ']';
                        int j = 8; // position of last digit
                        ++counter[j];
                        while (j > 0 && counter[j] > '9') {
                            counter[j] = '0';
                            ++counter[--j];
                        }
                        if (j < counterPos)
                            counterPos = j;
                    }

                    if (type == "color") {
                        layout->addWidget(new QLabel(m_parameterNames.back()));
                        bool ok;
                        ColorEdit *colorEdit = new ColorEdit(it->toUInt(&ok, 16), m_parameterNames.size() - 1);
                        m_parameterEdits << colorEdit;
                        layout->addWidget(colorEdit);
                        connect(colorEdit, SIGNAL(colorChanged(QRgb,int)), this, SLOT(setColorParameter(QRgb,int)));
                        ++row;
                    } else if (type == "float") {
                        layout->addWidget(new QLabel(m_parameterNames.back()));
                        bool ok;
                        FloatEdit *floatEdit = new FloatEdit(it->toFloat(&ok), m_parameterNames.size() - 1);
                        m_parameterEdits << floatEdit;
                        layout->addWidget(floatEdit);
                        connect(floatEdit, SIGNAL(valueChanged(float,int)), this, SLOT(setFloatParameter(float,int)));
                        ++row;
                    }
                }
Example #19
0
QString JabberSearch::condition(bool &bXSearch)
{
    bXSearch = m_bXData;
    QString res;
    if (m_bXData)
        res += "x:data";

    QObjectList *l = queryList("QLineEdit");
    QObjectListIt it( *l );
    QObject *obj;
    while ((obj = it.current()) != 0 ){
        QLineEdit *edit = static_cast<QLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ";";
            res += edit->name();
            res += "=";
            res += quoteChars(edit->text(), ";");
        }
        ++it;
    }
    delete l;

    l = queryList("QComboBox");
    QObjectListIt it1( *l );
    while ((obj = it1.current()) != 0 ){
        CComboBox *box = static_cast<CComboBox*>(obj);
        if (box->currentText().isEmpty()){
            ++it1;
            continue;
        }
        if (!res.isEmpty())
            res += ";";
        res += box->name();
        res += "=";
        res += quoteChars(box->value(), ";");
        ++it1;
    }
    delete l;

    l = queryList("QCheckBox");
    QObjectListIt it2( *l );
    while ((obj = it2.current()) != 0 ){
        QCheckBox *box = static_cast<QCheckBox*>(obj);
        if (!box->isChecked()){
            ++it2;
            continue;
        }
        if (!res.isEmpty())
            res += ";";
        res += box->name();
        res += "=1";
        ++it2;
    }
    delete l;

    l = queryList("QMultiLineEdit");
    QObjectListIt it3( *l );
    while ((obj = it3.current()) != 0 ){
        QMultiLineEdit *edit = static_cast<QMultiLineEdit*>(obj);
        if (!edit->text().isEmpty()){
            if (!res.isEmpty())
                res += ";";
            res += edit->name();
            res += "=";
            res += quoteChars(edit->text(), ";");
        }
        ++it3;
    }
    delete l;

    if (!m_key.empty()){
        if (!res.isEmpty())
            res += ";";
        res += "key=";
        res += quoteChars(QString::fromUtf8(m_key.c_str()), ";");
    }

    return res;
}
Example #20
0
void ExprParamElement::adjustForSearchType(ExprSearchType type)
{    
    // record which search type is active
    searchType = type;
    QRegExp regExp("0|[1-9][0-9]*");
    numValidator = new QRegExpValidator(regExp, this);
    QRegExp hexRegExp("[A-Fa-f0-9]*");
    hexValidator = new QRegExpValidator(hexRegExp, this);
    
    // remove all elements
    QList<QWidget*> children = internalframe->findChildren<QWidget*>();
    QWidget* child;
    QLayout * lay_out = internalframe->layout();
     while (!children.isEmpty())
    {
        child = children.takeLast();
        child->hide();
        lay_out->removeWidget(child);
        delete child;
    }
    delete lay_out;

    QHBoxLayout* hbox = createLayout();
    internalframe->setLayout(hbox);
    internalframe->setMinimumSize(320,26);

    if (isStringSearchExpression())
    {
        // set up for default of a simple input field
        QLineEdit* lineEdit = new QLineEdit(internalframe);
        lineEdit->setMinimumSize(STR_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
        lineEdit->setObjectName("param1");
        hbox->addWidget(lineEdit);
        hbox->addSpacing(9);
        QCheckBox* icCb = new QCheckBox(tr("ignore case"), internalframe);
        icCb->setObjectName("ignoreCaseCB");
	icCb->setCheckState(Qt::Checked);
	// hex search specifics: hidden case sensitivity and hex validator
	if (searchType == HashSearch) {
		icCb->hide();
		lineEdit->setValidator(hexValidator);        
	}
	hbox->addWidget(icCb);
        hbox->addStretch();
	
    } else if (searchType == DateSearch) 
    {
        QDateEdit * dateEdit = new QDateEdit(QDate::currentDate(), internalframe);
        dateEdit->setMinimumSize(DATE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        dateEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        dateEdit->setDisplayFormat(tr("dd.MM.yyyy"));
        dateEdit->setObjectName("param1");
        dateEdit->setMinimumDate(QDate(1970, 1, 1));
        dateEdit->setMaximumDate(QDate(2099, 12,31));
        hbox->addWidget(dateEdit, Qt::AlignLeft);
        hbox->addStretch();
    } else if (searchType == SizeSearch) 
    {
        QLineEdit * lineEdit = new QLineEdit(internalframe);
        lineEdit->setMinimumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setMaximumSize(SIZE_FIELDS_MIN_WIDTH, FIELDS_MIN_HEIGHT);
        lineEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        lineEdit->setObjectName("param1");
        lineEdit->setValidator(numValidator);
        hbox->addWidget(lineEdit, Qt::AlignLeft);

        QComboBox * cb = new QComboBox(internalframe);
        cb->setObjectName("unitsCb1");
        cb-> addItem(tr("KB"), QVariant(1024));
        cb->addItem(tr("MB"), QVariant(1048576));
        cb->addItem(tr("GB"), QVariant(1073741824));
        hbox->addSpacing(9);
        internalframe->layout()->addWidget(cb);
        hbox->addStretch();
    } 

    /* POP Search not implemented
    else if (searchType == PopSearch)
    {
        QLineEdit * lineEdit = new QLineEdit(elem);
        lineEdit->setObjectName("param1");
        lineEdit->setValidator(numValidator);
        elem->layout()->addWidget(lineEdit);
    }*/
    hbox->invalidate();
    internalframe->adjustSize();
    internalframe->show();
    this->adjustSize();
}
Example #21
0
QWidget* XletQueuesConfigure::buildConfigureQueueList(QWidget *parent)
{
    QWidget *root = new QWidget(parent);
    QGridLayout *layout = new QGridLayout(root);
    root->setLayout(layout);

    layout->addWidget(new QLabel(tr("Queue"), root), 0, 0, Qt::AlignLeft);
    QLabel *label_qos = new QLabel(tr("Qos - X (s)"), root);
    label_qos->setToolTip(tr(
        "This is the threshold in seconds to consider that the answer to a "
        "call was too late to be accounted as an answer of quality."));
    layout->addWidget(label_qos, 0, 1, Qt::AlignLeft);
    QLabel *label_window = new QLabel(tr("Window (s)"), root);
    label_window->setToolTip(tr(
        "The window is the period of time used to compute the statistics"));
    layout->addWidget(label_window, 0, 2, Qt::AlignLeft);

    QCheckBox *displayQueue;
    QSpinBox *spinBox;
    int row;
    int column;
    QVariantMap statConfig = b_engine->getConfig("guioptions.queuespanel").toMap();
    QString xqueueid;

    row = 1;

    QHashIterator<QString, XInfo *> i = \
        QHashIterator<QString, XInfo *>(b_engine->iterover("queues"));

    while (i.hasNext()) {
        column = 0;
        i.next();
        QueueInfo * queueinfo = (QueueInfo *) i.value();
        xqueueid = queueinfo->xid();

        displayQueue = new QCheckBox(queueinfo->queueName(), root);
        displayQueue->setProperty("xqueueid", xqueueid);
        displayQueue->setProperty("param", "visible");
        displayQueue->setChecked(statConfig.value("visible" + xqueueid, true).toBool());
        layout->addWidget(displayQueue, row, column++);
        connect(displayQueue, SIGNAL(stateChanged(int)),
                this, SLOT(changeQueueStatParam(int)));

        spinBox = new QSpinBox(root);
        spinBox->setAlignment(Qt::AlignCenter);
        spinBox->setMaximum(240);
        spinBox->setProperty("xqueueid", xqueueid);
        spinBox->setProperty("param", "xqos");
        spinBox->setValue(statConfig.value("xqos" + xqueueid, 60).toInt());
        layout->addWidget(spinBox, row, column++);
        connect(spinBox, SIGNAL(valueChanged(int)),
                this, SLOT(changeQueueStatParam(int)));

        spinBox = new QSpinBox(root);
        spinBox->setAlignment(Qt::AlignCenter);
        spinBox->setMaximum(3600*3);
        spinBox->setProperty("xqueueid", xqueueid);
        spinBox->setProperty("param", "window");
        spinBox->setValue(statConfig.value("window" + xqueueid, 3600).toInt());
        layout->addWidget(spinBox, row, column++);
        connect(spinBox, SIGNAL(valueChanged(int)),
                this, SLOT(changeQueueStatParam(int)));

        row++;
    }

    return root;
}
Example #22
0
QString GameParamBoolean::getWidgetValue(QWidget* pWidget)
{
	QCheckBox* box = (QCheckBox*) pWidget;
	return (box->checkState() == Qt::Checked) ? "True" : "False";
}
Example #23
0
QtSEnaMainWindow::QtSEnaMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::QtSEnaMainWindow) {
    _colList = NULL;
    _sistema = NULL;

    ui->setupUi(this);
    _apriFile = new QFileDialog(this);
    _g3 = new QRadioButton(this);
    _g4 = new QRadioButton(this);
    _g5 = new QRadioButton(this);
    _grigliaNumeri= new GrigliaNumeri(this);
    _integrale = new QRadioButton(this);
    _layoutConsecutivi = new QHBoxLayout(ui->consecutiviBox);
    _layoutGemelli = new QHBoxLayout(ui->gemelliBox);
    _layoutGrigliaNumeri= new QHBoxLayout(ui->numbersGridBox);
    _layoutPari = new QHBoxLayout(ui->pariBox);
    _printer = NULL;
    _printDialog = new QPrintDialog(this);
    _progressDialog = new QProgressDialog();
    _salvaFile = new QFileDialog(this);
    _toolBar = new QToolBar(this);

    for (quint8 i = 0; i <= _NUMERO_ELEMENTI_COLONNA; i++) {
        QCheckBox *elementoPari = new QCheckBox();
        QCheckBox *elementoConsecutivi = new QCheckBox();
        QCheckBox *elementoGemelli = new QCheckBox();
        elementoConsecutivi->setChecked(true);
        elementoConsecutivi->setText(QString("%1").arg(i));
        elementoGemelli->setChecked(true);
        elementoGemelli->setText(QString("%1").arg(i));
        elementoPari->setChecked(true);
        elementoPari->setText(QString("%1").arg(i));
        _consecutivi.append(elementoConsecutivi);
        _gemelli.append(elementoGemelli);
        _pari.append(elementoPari);
        _layoutConsecutivi->addWidget(_consecutivi.at(i));
        _layoutGemelli->addWidget(_gemelli.at(i));
        _layoutPari->addWidget(_pari.at(i));
    }

    QStringList sFileFilters;
    sFileFilters << "Sistemi QtSEna (*.sen *.SEN)";
    _apriFile->setWindowTitle("Apri Sistema Salvato");
    _apriFile->setNameFilters(sFileFilters);
    _g3->setText("G3");
    _g3->setEnabled(false);
    _g4->setText("G4");
    _g4->setEnabled(false);
    _g5->setText("G5");
    _g5->setEnabled(false);
    _integrale->setChecked(true);
    _integrale->setText("Integrale");
    _layoutGrigliaNumeri->addWidget(_grigliaNumeri);
    _salvaFile->setWindowTitle("Salva Sistema Corrente");
    _salvaFile->setNameFilters(sFileFilters);
    _salvaFile->setAcceptMode(QFileDialog::AcceptSave);
    ui->actionG3->setEnabled(false);
    ui->actionG4->setEnabled(false);
    ui->actionG5->setEnabled(false);
    ui->actionIntegrale->setChecked(true);
    ui->actionPreferenze->setEnabled(false);
    ui->actionStampaColonne->setEnabled(false);
    addToolBar(_toolBar);
    _toolBar->addAction(ui->actionApri);
    _toolBar->addAction(ui->actionSalva);
    _toolBar->addSeparator();
    _toolBar->addAction(ui->actionSistema);
    _toolBar->addSeparator();
    _toolBar->addWidget(_integrale);
    _toolBar->addWidget(_g5);
    _toolBar->addWidget(_g4);
    _toolBar->addWidget(_g3);

    connect(_grigliaNumeri, SIGNAL(aggiornato(int)), this, SLOT(aggiorna()));
    connect(&watcher, SIGNAL(finished()), _progressDialog, SLOT(cancel()));
    connect(ui->actionApri, SIGNAL(triggered()), _apriFile, SLOT(exec()));
    connect(ui->actionSalva, SIGNAL(triggered()), _salvaFile, SLOT(exec()));
    connect(_apriFile, SIGNAL(accepted()), this, SLOT(apri()));
    connect(_salvaFile, SIGNAL(accepted()), this, SLOT(salva()));
    connect(_g3, SIGNAL(clicked()), this, SLOT(on_actionG3_activated()));
    connect(_g4, SIGNAL(clicked()), this, SLOT(on_actionG4_activated()));
    connect(_g5, SIGNAL(clicked()), this, SLOT(on_actionG5_activated()));
    connect(_integrale, SIGNAL(clicked()), this, SLOT(on_actionIntegrale_activated()));+
    connect(ui->actionStampaSchedine, SIGNAL(triggered()), _printDialog, SLOT(exec()));
    connect(_printDialog, SIGNAL(accepted()), this, SLOT(stampaSchedina()));
    aggiorna();
}
AllPlotWindow::AllPlotWindow(MainWindow *mainWindow) :
    QWidget(mainWindow), current(NULL), mainWindow(mainWindow), active(false), stale(true)
{
    boost::shared_ptr<QSettings> settings = GetApplicationSettings();
    QVBoxLayout *vlayout = new QVBoxLayout;

    QHBoxLayout *showLayout = new QHBoxLayout;
    QLabel *showLabel = new QLabel(tr("Show:"), this);
    showLayout->addWidget(showLabel);

    showStack = new QCheckBox(tr("Stacked view"), this);

    if (settings->value(GC_RIDE_PLOT_STACK).toInt())
        showStack->setCheckState(Qt::Checked);
    else
        showStack->setCheckState(Qt::Unchecked);
    showLayout->addWidget(showStack);

    stackWidth = 15;

    QLabel *labelspacer = new QLabel(this);
    labelspacer->setFixedWidth(5);
    showLayout->addWidget(labelspacer);

    stackZoomUp = new QwtArrowButton(1, Qt::UpArrow,this);
    stackZoomUp->setFixedHeight(15);
    stackZoomUp->setFixedWidth(15);
    stackZoomUp->setEnabled(false);
    stackZoomUp->setContentsMargins(0,0,0,0);
    stackZoomUp->setFlat(true);
    showLayout->addWidget(stackZoomUp);

    stackZoomDown = new QwtArrowButton(1, Qt::DownArrow,this);
    stackZoomDown->setFixedHeight(15);
    stackZoomDown->setFixedWidth(15);
    stackZoomDown->setEnabled(false);
    stackZoomDown->setContentsMargins(0,0,0,0);
    stackZoomDown->setFlat(true);
    showLayout->addWidget(stackZoomDown);

    QCheckBox *showGrid = new QCheckBox(tr("Grid"), this);
    showGrid->setCheckState(Qt::Checked);
    showLayout->addWidget(showGrid);

    showHr = new QCheckBox(tr("Heart Rate"), this);
    showHr->setCheckState(Qt::Checked);
    showLayout->addWidget(showHr);

    showSpeed = new QCheckBox(tr("Speed"), this);
    showSpeed->setCheckState(Qt::Checked);
    showLayout->addWidget(showSpeed);

    showCad = new QCheckBox(tr("Cadence"), this);
    showCad->setCheckState(Qt::Checked);
    showLayout->addWidget(showCad);

    showAlt = new QCheckBox(tr("Altitude"), this);
    showAlt->setCheckState(Qt::Checked);
    showLayout->addWidget(showAlt);

    showPower = new QComboBox();
    showPower->addItem(tr("Power + shade"));
    showPower->addItem(tr("Power - shade"));
    showPower->addItem(tr("No Power"));
    showLayout->addWidget(showPower);

    // shade zones defaults will come in with a
    // future patch. For now we have place holder
    // to update when new config arrives
    if (true) showPower->setCurrentIndex(0);
    else showPower->setCurrentIndex(1);

    QHBoxLayout *smoothLayout = new QHBoxLayout;
    QComboBox *comboDistance = new QComboBox();
    comboDistance->addItem(tr("X Axis Shows Time"));
    comboDistance->addItem(tr("X Axis Shows Distance"));
    smoothLayout->addWidget(comboDistance);

    QLabel *smoothLabel = new QLabel(tr("Smoothing (secs)"), this);
    smoothLineEdit = new QLineEdit(this);
    smoothLineEdit->setFixedWidth(40);

    smoothLayout->addWidget(smoothLabel);
    smoothLayout->addWidget(smoothLineEdit);
    smoothSlider = new QSlider(Qt::Horizontal);
    smoothSlider->setTickPosition(QSlider::TicksBelow);
    smoothSlider->setTickInterval(10);
    smoothSlider->setMinimum(1);
    smoothSlider->setMaximum(600);
    smoothLineEdit->setValidator(new QIntValidator(smoothSlider->minimum(),
                                                   smoothSlider->maximum(),
                                                   smoothLineEdit));
    smoothLayout->addWidget(smoothSlider);

    allPlot = new AllPlot(this, mainWindow);
    smoothSlider->setValue(allPlot->smooth);
    smoothLineEdit->setText(QString("%1").arg(allPlot->smooth));

    allZoomer = new QwtPlotZoomer(allPlot->canvas());
    allZoomer->setRubberBand(QwtPicker::RectRubberBand);
    allZoomer->setRubberBandPen(GColor(CPLOTSELECT));
    allZoomer->setSelectionFlags(QwtPicker::DragSelection
                                 | QwtPicker::CornerToCorner);
    allZoomer->setTrackerMode(QwtPicker::AlwaysOff);
    allZoomer->setEnabled(true);

    // TODO: Hack for OS X one-button mouse
    // allZoomer->initMousePattern(1);

    // RightButton: zoom out by 1
    // Ctrl+RightButton: zoom out to full size
    allZoomer->setMousePattern(QwtEventPattern::MouseSelect2,
                               Qt::RightButton, Qt::ControlModifier);
    allZoomer->setMousePattern(QwtEventPattern::MouseSelect3,
                               Qt::RightButton);

    allPanner = new QwtPlotPanner(allPlot->canvas());
    allPanner->setMouseButton(Qt::MidButton);

    // TODO: zoomer doesn't interact well with automatic axis resizing

    // tooltip on hover over point
    allPlot->tooltip = new LTMToolTip(QwtPlot::xBottom, QwtPlot::yLeft,
                               QwtPicker::PointSelection,
                               QwtPicker::VLineRubberBand,
                               QwtPicker::AlwaysOn,
                               allPlot->canvas(),
                               "");
    allPlot->tooltip->setSelectionFlags(QwtPicker::PointSelection | QwtPicker::RectSelection | QwtPicker::DragSelection);
    allPlot->tooltip->setRubberBand(QwtPicker::VLineRubberBand);
    allPlot->tooltip->setMousePattern(QwtEventPattern::MouseSelect1, Qt::LeftButton, Qt::ShiftModifier);
    allPlot->tooltip->setTrackerPen(QColor(Qt::black));
    QColor inv(Qt::white);
    inv.setAlpha(0);
    allPlot->tooltip->setRubberBandPen(inv);
    allPlot->tooltip->setEnabled(true);

    allPlot->_canvasPicker = new LTMCanvasPicker(allPlot);
    connect(allPlot->_canvasPicker, SIGNAL(pointHover(QwtPlotCurve*, int)), allPlot, SLOT(pointHover(QwtPlotCurve*, int)));
    connect(allPlot->tooltip, SIGNAL(moved(const QPoint &)), this, SLOT(plotPickerMoved(const QPoint &)));
    connect(allPlot->tooltip, SIGNAL(appended(const QPoint &)), this, SLOT(plotPickerSelected(const QPoint &)));

    QwtPlotMarker* allMarker1 = new QwtPlotMarker();
    allMarker1->setLineStyle(QwtPlotMarker::VLine);
    allMarker1->attach(allPlot);
    allMarker1->setLabelAlignment(Qt::AlignTop|Qt::AlignRight);
    allPlot->allMarker1=allMarker1;

    QwtPlotMarker* allMarker2 = new QwtPlotMarker();
    allMarker2->setLineStyle(QwtPlotMarker::VLine);
    allMarker2->attach(allPlot);
    allMarker2->setLabelAlignment(Qt::AlignTop|Qt::AlignRight);
    allPlot->allMarker2=allMarker2;

    //
    // stack view
    //
    stackFrame = new QScrollArea();
    stackFrame->hide();
    stackPlotLayout = new QVBoxLayout();
    stackWidget = new QWidget();
    stackWidget->setLayout(stackPlotLayout);
    stackFrame->setWidgetResizable(true);
    stackFrame->setWidget(stackWidget);

    //
    // allPlot view
    //
    QVBoxLayout *allPlotLayout = new QVBoxLayout;
    allPlotFrame = new QScrollArea();

    spanSlider = new QxtSpanSlider(Qt::Horizontal);
    spanSlider->setHandleMovementMode(QxtSpanSlider::NoOverlapping);
    spanSlider->setLowerValue(0);
    spanSlider->setUpperValue(15);

    QFont small;
    small.setPointSize(6);

    scrollLeft = new QPushButton("<");
    scrollLeft->setFont(small);
    scrollLeft->setAutoRepeat(true);
    scrollLeft->setFixedHeight(16);
    scrollLeft->setFixedWidth(16);
    scrollLeft->setContentsMargins(0,0,0,0);

    scrollRight = new QPushButton(">");
    scrollRight->setFont(small);
    scrollRight->setAutoRepeat(true);
    scrollRight->setFixedHeight(16);
    scrollRight->setFixedWidth(16);
    scrollRight->setContentsMargins(0,0,0,0);

#ifdef Q_OS_MAC
    // BUG in QMacStyle and painting of spanSlider
    // so we use a plain style to avoid it, but only
    // on a MAC, since win and linux are fine
    QCleanlooksStyle *style = new QCleanlooksStyle();
    spanSlider->setStyle(style);
    scrollLeft->setStyle(style);
    scrollRight->setStyle(style);
#endif

    fullPlot = new AllPlot(this, mainWindow);
    fullPlot->grid->enableY(false);
    fullPlot->setCanvasBackground(GColor(CPLOTTHUMBNAIL));
    fullPlot->setCanvasLineWidth(0);
    fullPlot->enableAxis(QwtPlot::yLeft, false);
    fullPlot->enableAxis(QwtPlot::yLeft2, false);
    fullPlot->enableAxis(QwtPlot::yRight, false);
    fullPlot->enableAxis(QwtPlot::yRight2, false);
    fullPlot->enableAxis(QwtPlot::xBottom, false);
    fullPlot->legend()->clear();
    //fullPlot->setTitle("");
    fullPlot->setContentsMargins(0,0,0,0);

    allPlotLayout->addWidget(allPlot);
    allPlotFrame->setLayout(allPlotLayout);

    // controls...
    controlsLayout = new QGridLayout;
    controlsLayout->addWidget(fullPlot, 0,1);
    controlsLayout->addWidget(spanSlider, 1,1);
    controlsLayout->addWidget(scrollLeft,1,0);
    controlsLayout->addWidget(scrollRight,1,2);
    controlsLayout->setRowStretch(0, 10);
    controlsLayout->setRowStretch(1, 1);
    controlsLayout->setContentsMargins(0,0,0,0);
#ifdef Q_OS_MAC
    // macs  dpscing is weird
    //controlsLayout->setSpacing(5);
#else
    controlsLayout->setSpacing(0);
#endif

    vlayout->addWidget(allPlotFrame);
    vlayout->addWidget(stackFrame);
    vlayout->addLayout(controlsLayout);
    vlayout->addLayout(showLayout);
    vlayout->addLayout(smoothLayout);
    vlayout->setStretch(0,100);
    vlayout->setStretch(1,100);
    vlayout->setStretch(2,15);
    vlayout->setStretch(3,1);
    vlayout->setStretch(4,1);
    vlayout->setSpacing(1);
    setLayout(vlayout);

    // common controls
    connect(showPower, SIGNAL(currentIndexChanged(int)), this, SLOT(setShowPower(int)));
    connect(showHr, SIGNAL(stateChanged(int)), this, SLOT(setShowHr(int)));
    connect(showSpeed, SIGNAL(stateChanged(int)), this, SLOT(setShowSpeed(int)));
    connect(showCad, SIGNAL(stateChanged(int)), this, SLOT(setShowCad(int)));
    connect(showAlt, SIGNAL(stateChanged(int)), this, SLOT(setShowAlt(int)));
    connect(showGrid, SIGNAL(stateChanged(int)), this, SLOT(setShowGrid(int)));
    connect(showStack, SIGNAL(stateChanged(int)), this, SLOT(showStackChanged(int)));
    connect(comboDistance, SIGNAL(currentIndexChanged(int)), this, SLOT(setByDistance(int)));
    connect(smoothSlider, SIGNAL(valueChanged(int)), this, SLOT(setSmoothingFromSlider()));
    connect(smoothLineEdit, SIGNAL(editingFinished()), this, SLOT(setSmoothingFromLineEdit()));

    // normal view
    connect(spanSlider, SIGNAL(lowerPositionChanged(int)), this, SLOT(zoomChanged()));
    connect(spanSlider, SIGNAL(upperPositionChanged(int)), this, SLOT(zoomChanged()));

    // stacked view
    connect(stackZoomUp, SIGNAL(clicked()), this, SLOT(setStackZoomUp()));
    connect(stackZoomDown, SIGNAL(clicked()), this, SLOT(setStackZoomDown()));
    connect(scrollLeft, SIGNAL(clicked()), this, SLOT(moveLeft()));
    connect(scrollRight, SIGNAL(clicked()), this, SLOT(moveRight()));

    // GC signals
    connect(mainWindow, SIGNAL(rideSelected()), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(rideDirty()), this, SLOT(rideSelected()));
    connect(mainWindow, SIGNAL(zonesChanged()), this, SLOT(zonesChanged()));
    connect(mainWindow, SIGNAL(intervalsChanged()), this, SLOT(intervalsChanged()));
    connect(mainWindow, SIGNAL(intervalSelected()), this, SLOT(intervalSelected()));
    connect(mainWindow, SIGNAL(configChanged()), allPlot, SLOT(configChanged()));
    connect(mainWindow, SIGNAL(configChanged()), this, SLOT(configChanged()));
}
Example #25
0
int main(int argc, char **argv)
{
    //! [0]
    QApplication app(argc, argv);
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    if (!graph->hasContext()) {
        QMessageBox msgBox;
        msgBox.setText("Couldn't initialize the OpenGL context.");
        msgBox.exec();
        return -1;
    }

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    //! [1]

    widget->setWindowTitle(QStringLiteral("A Cosine Wave"));

    //! [4]
    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));
    themeList->setCurrentIndex(6);

    QPushButton *labelButton = new QPushButton(widget);
    labelButton->setText(QStringLiteral("Change label style"));

    QCheckBox *smoothCheckBox = new QCheckBox(widget);
    smoothCheckBox->setText(QStringLiteral("Smooth dots"));
    smoothCheckBox->setChecked(true);

    QComboBox *itemStyleList = new QComboBox(widget);
    itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere));
    itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube));
    itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal));
    itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint));
    itemStyleList->setCurrentIndex(0);

    QPushButton *cameraButton = new QPushButton(widget);
    cameraButton->setText(QStringLiteral("Change camera preset"));

    QPushButton *itemCountButton = new QPushButton(widget);
    itemCountButton->setText(QStringLiteral("Toggle item count"));

    QCheckBox *backgroundCheckBox = new QCheckBox(widget);
    backgroundCheckBox->setText(QStringLiteral("Show background"));
    backgroundCheckBox->setChecked(true);

    QCheckBox *gridCheckBox = new QCheckBox(widget);
    gridCheckBox->setText(QStringLiteral("Show grid"));
    gridCheckBox->setChecked(true);

    QComboBox *shadowQuality = new QComboBox(widget);
    shadowQuality->addItem(QStringLiteral("None"));
    shadowQuality->addItem(QStringLiteral("Low"));
    shadowQuality->addItem(QStringLiteral("Medium"));
    shadowQuality->addItem(QStringLiteral("High"));
    shadowQuality->addItem(QStringLiteral("Low Soft"));
    shadowQuality->addItem(QStringLiteral("Medium Soft"));
    shadowQuality->addItem(QStringLiteral("High Soft"));
    shadowQuality->setCurrentIndex(4);

    QFontComboBox *fontList = new QFontComboBox(widget);
    fontList->setCurrentFont(QFont("Arial"));
    //! [4]

    //! [5]
    vLayout->addWidget(labelButton, 0, Qt::AlignTop);
    vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
    vLayout->addWidget(itemCountButton, 0, Qt::AlignTop);
    vLayout->addWidget(backgroundCheckBox);
    vLayout->addWidget(gridCheckBox);
    vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop);
    vLayout->addWidget(new QLabel(QStringLiteral("Change dot style")));
    vLayout->addWidget(itemStyleList);
    vLayout->addWidget(new QLabel(QStringLiteral("Change theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")));
    vLayout->addWidget(shadowQuality);
    vLayout->addWidget(new QLabel(QStringLiteral("Change font")));
    vLayout->addWidget(fontList, 1, Qt::AlignTop);
    //! [5]

    //! [2]
    ScatterDataModifier *modifier = new ScatterDataModifier(graph);
    //! [2]

    //! [6]
    QObject::connect(cameraButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changePresetCamera);
    QObject::connect(labelButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changeLabelStyle);
    QObject::connect(itemCountButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::toggleItemCount);

    QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setBackgroundEnabled);
    QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setGridEnabled);
    QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setSmoothDots);

    QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged,
                     backgroundCheckBox, &QCheckBox::setChecked);
    QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged,
                     gridCheckBox, &QCheckBox::setChecked);
    QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeStyle(int)));

    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeTheme(int)));

    QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeShadowQuality(int)));

    QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality,
                     &QComboBox::setCurrentIndex);
    QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier,
                     &ScatterDataModifier::shadowQualityUpdatedByVisual);

    QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier,
                     &ScatterDataModifier::changeFont);

    QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList,
                     &QFontComboBox::setCurrentFont);
    //! [6]

    //! [3]
    widget->show();
    return app.exec();
    //! [3]
}
Example #26
0
Test::Test( QWidget* parent, const char *name )
  :QVBox( parent, name ), mChange(0), mLeftWidget(0), mRightWidget(0),
  mLeftPopup( false ), mRightPopup( false ), mTabbarContextPopup( false ), mContextPopup( false )

{
  resize( 600,300 );

  mWidget = new KTabWidget( this );
  mWidget->addTab( new QLabel( "Testlabel 1", mWidget ), "One" );
  mWidget->addTab( new QLabel( "Testlabel 2", mWidget ), "Two" );
  mWidget->addTab( new QWidget( mWidget), SmallIcon( "konsole" ), "Three" );
  mWidget->addTab( new QWidget( mWidget), "Four" );
  mWidget->setTabColor( mWidget->page(0), Qt::red );
  mWidget->setTabColor( mWidget->page(1), Qt::blue );

  connect( mWidget, SIGNAL( currentChanged( QWidget * ) ), SLOT( currentChanged( QWidget * ) ) );
  connect( mWidget, SIGNAL( contextMenu( QWidget *, const QPoint & )), SLOT(contextMenu( QWidget *, const QPoint & )));
  connect( mWidget, SIGNAL( contextMenu( const QPoint & )), SLOT(tabbarContextMenu( const QPoint & )));
  connect( mWidget, SIGNAL( mouseDoubleClick( QWidget * )), SLOT(mouseDoubleClick( QWidget * )));
  connect( mWidget, SIGNAL( mouseMiddleClick() ), SLOT(addTab() ));
  connect( mWidget, SIGNAL( mouseMiddleClick( QWidget * )), SLOT(mouseMiddleClick( QWidget * )));
  connect( mWidget, SIGNAL( closeRequest( QWidget * )), SLOT(mouseMiddleClick( QWidget * )));
  connect( mWidget, SIGNAL( testCanDecode(const QDragMoveEvent *, bool & )), SLOT(testCanDecode(const QDragMoveEvent *, bool & )));
  connect( mWidget, SIGNAL( receivedDropEvent( QDropEvent * )), SLOT(receivedDropEvent( QDropEvent * )));
  connect( mWidget, SIGNAL( receivedDropEvent( QWidget *, QDropEvent * )), SLOT(receivedDropEvent( QWidget *, QDropEvent * )));
  connect( mWidget, SIGNAL( initiateDrag( QWidget * )), SLOT(initiateDrag( QWidget * )));
  connect( mWidget, SIGNAL( movedTab( int, int )), SLOT(movedTab( int, int )));
  mWidget->setTabReorderingEnabled( true );

  QWidget * grid = new QWidget(this);
  QGridLayout * gridlayout = new QGridLayout( grid, 5, 2 );

  QPushButton * addTab = new QPushButton( "Add Tab", grid );
  gridlayout->addWidget( addTab, 0, 0 );
  connect( addTab, SIGNAL( clicked() ), SLOT( addTab() ) );

  QPushButton * removeTab = new QPushButton( "Remove Current Tab", grid );
  gridlayout->addWidget( removeTab, 0, 1 );
  connect( removeTab, SIGNAL( clicked() ), SLOT( removeCurrentTab() ) );

  mLeftButton = new QCheckBox( "Show left button", grid );
  gridlayout->addWidget( mLeftButton, 1, 0 );
  connect( mLeftButton, SIGNAL( toggled(bool) ), SLOT( toggleLeftButton(bool) ) );
  mLeftButton->setChecked(true);

  QCheckBox * leftPopup = new QCheckBox( "Enable left popup", grid );
  gridlayout->addWidget( leftPopup, 2, 0 );
  connect( leftPopup, SIGNAL( toggled(bool) ), SLOT( toggleLeftPopup(bool) ) );
  leftPopup->setChecked(true);

  mRightButton = new QCheckBox( "Show right button", grid );
  gridlayout->addWidget( mRightButton, 1, 1 );
  connect( mRightButton, SIGNAL( toggled(bool) ), SLOT( toggleRightButton(bool) ) );
  mRightButton->setChecked(true);

  QCheckBox * rightPopup = new QCheckBox( "Enable right popup", grid );
  gridlayout->addWidget( rightPopup, 2, 1 );
  connect( rightPopup, SIGNAL( toggled(bool) ), SLOT( toggleRightPopup(bool) ) );
  rightPopup->setChecked(true);

  mTabsBottom = new QCheckBox( "Show tabs at bottom", grid );
  gridlayout->addWidget( mTabsBottom, 3, 0 );
  connect( mTabsBottom, SIGNAL( toggled(bool) ), SLOT( toggleTabPosition(bool) ) );

  QCheckBox * tabshape = new QCheckBox( "Triangular tab shape", grid );
  gridlayout->addWidget( tabshape, 3, 1 );
  connect( tabshape, SIGNAL( toggled(bool) ), SLOT( toggleTabShape(bool) ) );

  QCheckBox *tabClose = new QCheckBox( "Close button on icon hover", grid );
  gridlayout->addWidget( tabClose, 4, 0 );
  connect( tabClose, SIGNAL( toggled(bool) ), SLOT( toggleCloseButtons(bool) ) );
  tabClose->setChecked(true);

  QCheckBox * showlabels = new QCheckBox( "Show labels", grid );
  gridlayout->addWidget( showlabels, 4, 1 );
  connect( showlabels, SIGNAL( toggled(bool) ), this, SLOT( toggleLabels(bool) ) );
}
Example #27
0
// ---------------------------------------------------------------
void LibraryDialog::slotCreateNext()
{
  if(NameEdit->text().isEmpty()) {
    QMessageBox::critical(this, tr("Error"), tr("Please insert a library name!"));
    return;
  }

  int count=0;
  QCheckBox *p;
  QListIterator<QCheckBox *> i(BoxList);
  while(i.hasNext()){
    p = i.next();
    if(p->isChecked()) {
      SelectedNames.append(p->text());
      Descriptions.append("");
      count++;
    }
  }

  if(count < 1) {
    QMessageBox::critical(this, tr("Error"), tr("Please choose at least one subcircuit!"));
    return;
  }

  LibDir = QDir(SwieeSettings.SwieeHomeDir);
  if(!LibDir.cd("user_lib")) { // user library directory exists ?
    if(!LibDir.mkdir("user_lib")) { // no, then create it
      QMessageBox::warning(this, tr("Warning"),
                   tr("Cannot create user library directory !"));
      return;
    }
    LibDir.cd("user_lib");
  }

  LibFile.setName(SwieeSettings.LibDir + NameEdit->text() + ".lib");
  if(LibFile.exists()) {
    QMessageBox::critical(this, tr("Error"), tr("A system library with this name already exists!"));
    return;
  }

  LibFile.setName(LibDir.absFilePath(NameEdit->text()) + ".lib");
  if(LibFile.exists()) {
    QMessageBox::critical(this, tr("Error"), tr("A library with this name already exists!"));
    return;
  }

  if (checkDescr->checkState() == Qt::Checked){
    // user enter descriptions
    stackedWidgets->setCurrentIndex(1);  // subcircuit description view

    checkedCktName->setText(SelectedNames[0]);
    textDescr->setText(Descriptions[0]);

    if (SelectedNames.count() == 1){
        prevButt->setDisabled(true);
        nextButt->setDisabled(true);
        createButt->setEnabled(true);
      }
  }
  else {
      // save whitout description
      emit slotSave();
  }
}
Example #28
0
void QgsSnappingDialog::update()
{
  if ( !mMapCanvas )
    return;

  QSettings myQsettings;
  bool myDockFlag = myQsettings.value( "/qgis/dockSnapping", false ).toBool();

  double defaultSnappingTolerance = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance", 0 ).toDouble();
  int defaultSnappingUnit = myQsettings.value( "/qgis/digitizing/default_snapping_tolerance_unit", 0 ).toInt();
  QString defaultSnappingString = myQsettings.value( "/qgis/digitizing/default_snap_mode", "to vertex" ).toString();

  int defaultSnappingStringIdx = 0;
  if ( defaultSnappingString == "to vertex" )
  {
    defaultSnappingStringIdx = 0;
  }
  else if ( defaultSnappingString == "to segment" )
  {
    defaultSnappingStringIdx = 1;
  }
  else //to vertex and segment
  {
    defaultSnappingStringIdx = 2;
  }

  bool layerIdListOk, enabledListOk, toleranceListOk, toleranceUnitListOk, snapToListOk, avoidIntersectionListOk;
  QStringList layerIdList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingList", &layerIdListOk );
  QStringList enabledList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingEnabledList", &enabledListOk );
  QStringList toleranceList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceList", & toleranceListOk );
  QStringList toleranceUnitList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnappingToleranceUnitList", & toleranceUnitListOk );
  QStringList snapToList = QgsProject::instance()->readListEntry( "Digitizing", "/LayerSnapToList", &snapToListOk );
  QStringList avoidIntersectionsList = QgsProject::instance()->readListEntry( "Digitizing", "/AvoidIntersectionsList", &avoidIntersectionListOk );

  mLayerTreeWidget->clear();

  QMap< QString, QgsMapLayer *> mapLayers = QgsMapLayerRegistry::instance()->mapLayers();
  QMap< QString, QgsMapLayer *>::iterator it;
  for ( it = mapLayers.begin(); it != mapLayers.end() ; ++it )
  {
    QgsVectorLayer *currentVectorLayer = qobject_cast<QgsVectorLayer *>( it.value() );
    if ( !currentVectorLayer || currentVectorLayer->geometryType() == QGis::NoGeometry )
      continue;

    //snap to layer yes/no
    QTreeWidgetItem *item = new QTreeWidgetItem( mLayerTreeWidget );

    QCheckBox *cbxEnable = new QCheckBox( mLayerTreeWidget );
    mLayerTreeWidget->setItemWidget( item, 0, cbxEnable );
    item->setData( 0, Qt::UserRole, currentVectorLayer->getLayerID() );

    item->setText( 1, currentVectorLayer->name() );

    //snap to vertex/ snap to segment
    QComboBox *cbxSnapTo = new QComboBox( mLayerTreeWidget );
    cbxSnapTo->insertItem( 0, tr( "to vertex" ) );
    cbxSnapTo->insertItem( 1, tr( "to segment" ) );
    cbxSnapTo->insertItem( 2, tr( "to vertex and segment" ) );
    cbxSnapTo->setCurrentIndex( defaultSnappingStringIdx );
    mLayerTreeWidget->setItemWidget( item, 2, cbxSnapTo );

    //snapping tolerance
    QLineEdit *leTolerance = new QLineEdit( mLayerTreeWidget );
    QDoubleValidator *validator = new QDoubleValidator( leTolerance );
    leTolerance->setValidator( validator );
    leTolerance->setText( QString::number( defaultSnappingTolerance, 'f' ) );

    mLayerTreeWidget->setItemWidget( item, 3, leTolerance );

    //snap to vertex/ snap to segment
    QComboBox *cbxUnits = new QComboBox( mLayerTreeWidget );
    cbxUnits->insertItem( 0, tr( "map units" ) );
    cbxUnits->insertItem( 1, tr( "pixels" ) );
    cbxUnits->setCurrentIndex( defaultSnappingUnit );
    mLayerTreeWidget->setItemWidget( item, 4, cbxUnits );

    QCheckBox *cbxAvoidIntersection = 0;
    if ( currentVectorLayer->geometryType() == QGis::Polygon )
    {
      cbxAvoidIntersection = new QCheckBox( mLayerTreeWidget );
      mLayerTreeWidget->setItemWidget( item, 5, cbxAvoidIntersection );
    }

    int idx = layerIdList.indexOf( currentVectorLayer->getLayerID() );
    if ( idx < 0 )
    {
      // no settings for this layer yet
      continue;
    }

    cbxEnable->setChecked( enabledList[ idx ] == "enabled" );

    int snappingStringIdx = 0;
    if ( snapToList[idx] == "to_vertex" )
    {
      snappingStringIdx = 0;
    }
    else if ( snapToList[idx] == "to_segment" )
    {
      snappingStringIdx = 1;
    }
    else //to vertex and segment
    {
      snappingStringIdx = 2;
    }
    cbxSnapTo->setCurrentIndex( snappingStringIdx );
    leTolerance->setText( QString::number( toleranceList[idx].toDouble(), 'f' ) );
    cbxUnits->setCurrentIndex( toleranceUnitList[idx].toInt() );
    if ( cbxAvoidIntersection )
    {
      cbxAvoidIntersection->setChecked( avoidIntersectionsList.contains( currentVectorLayer->getLayerID() ) );
    }
  }

  // read the digitizing settings
  int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );
  if ( topologicalEditing != 0 )
  {
    cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Checked );
  }
  else
  {
    cbxEnableTopologicalEditingCheckBox->setCheckState( Qt::Unchecked );
  }

  if ( myDockFlag )
  {
    for ( int i = 0; i < mLayerTreeWidget->topLevelItemCount(); ++i )
    {
      QTreeWidgetItem *item = mLayerTreeWidget->topLevelItem( i );
      connect( mLayerTreeWidget->itemWidget( item, 0 ), SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
      connect( mLayerTreeWidget->itemWidget( item, 2 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );
      connect( mLayerTreeWidget->itemWidget( item, 3 ), SIGNAL( textEdited( const QString ) ), this, SLOT( apply() ) );
      connect( mLayerTreeWidget->itemWidget( item, 4 ), SIGNAL( currentIndexChanged( int ) ), this, SLOT( apply() ) );

      QCheckBox *cbxAvoidIntersection = qobject_cast<QCheckBox*>( mLayerTreeWidget->itemWidget( item, 5 ) );
      if ( cbxAvoidIntersection )
      {
        connect( cbxAvoidIntersection, SIGNAL( stateChanged( int ) ), this, SLOT( apply() ) );
      }
    }
  }
}
Example #29
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
    selectInteractor(0), newLineItemInteractor(0),
    newRectItemInteractor(0), newTextItemInteractor(0) {

    setObjectName(QStringLiteral("MainWindow"));
    resize(1024, 768);

    graphicsSheet = new GraphicsSheet(this);

    QList<QString> itemClasses = graphicsSheet->getSupportedItemClasses();
    qDebug() << "Item classes supported by the graphics sheet:";
    qDebug() << itemClasses;

    QGraphicsDropShadowEffect* shadow = new QGraphicsDropShadowEffect(graphicsSheet);
    shadow->setBlurRadius(20);
    shadow->setColor(QColor(0xa0, 0xa0, 0xa0));
    graphicsSheet->setGraphicsEffect(shadow);

    graphicsSheet->setScaleBackground(QColor(0xFF, 0xFF, 0xF8));

    QLayout* layout = new ScrollAreaLayout();
    layout->addWidget(graphicsSheet);

    QWidget *centralwidget = new QWidget(this);
    centralwidget->setLayout(layout);
    setCentralWidget(centralwidget);

/*****************************************************************************/
    menubar = new QMenuBar(this);
    menubar->setObjectName(QStringLiteral("menubar"));
    menubar->setGeometry(QRect(0, 0, 401, 21));
    setMenuBar(menubar);

    statusbar = new QStatusBar(this);
    statusbar->setObjectName(QStringLiteral("statusbar"));
    setStatusBar(statusbar);

    toolBar = new QToolBar(this);
    toolBar->setObjectName(QStringLiteral("toolBar"));
    addToolBar(Qt::TopToolBarArea, toolBar);
/*****************************************************************************/

/* Initialize zoom, scale, and paper formats */
    graphicsSheet->addScale("1:10",  0.1);
    graphicsSheet->addScale("1:5",   0.2);
    graphicsSheet->addScale("1:2",   0.5);
    graphicsSheet->addScale("1:1",   1.0);
    graphicsSheet->addScale("2:1",   2.0);
    graphicsSheet->addScale("5:1",   5.0);
    graphicsSheet->addScale("10:1", 10.0);

    LabelledComboBox* scaleWidget = new LabelledComboBox(toolBar, "Scale: ");
    scaleWidget->getComboBox()->addItems(graphicsSheet->getScaleNames());
    toolBar->addWidget(scaleWidget);
    QObject::connect(scaleWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setScale(int)));

    graphicsSheet->addZoom("50%",  0.5);
    graphicsSheet->addZoom("75%",  0.75);
    graphicsSheet->addZoom("100%", 1.0);
    graphicsSheet->addZoom("125%", 1.25);
    graphicsSheet->addZoom("150%", 1.5);
    graphicsSheet->addZoom("200%", 2.0);

    LabelledComboBox* zoomWidget = new LabelledComboBox(toolBar, "Zoom: ");
    zoomWidget->getComboBox()->addItems(graphicsSheet->getZoomNames());
    toolBar->addWidget(zoomWidget);
    QObject::connect(zoomWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setZoom(int)));

    graphicsSheet->setUnit("mm");
    graphicsSheet->addSize("DIN A3", QSizeF(297.0, 420.0));
    graphicsSheet->addSize("DIN A4", QSizeF(210.0, 297.0));
    graphicsSheet->addSize("Letter", QSizeF(215.9, 279.4));
    graphicsSheet->addSize("DIN A5", QSizeF(148.0, 210.0));

    LabelledComboBox* sizeWidget = new LabelledComboBox(toolBar, "Sheet Size: ");
    sizeWidget->getComboBox()->addItems(graphicsSheet->getSizeNames());
    toolBar->addWidget(sizeWidget);
    QObject::connect(sizeWidget->getComboBox(), SIGNAL(currentIndexChanged(int)),
                     graphicsSheet, SLOT(setSize(int)));

    QCheckBox* checkbox = new QCheckBox("Landscape", toolBar);
    toolBar->addWidget(checkbox);
    QObject::connect(checkbox, SIGNAL(stateChanged(int)),
                     graphicsSheet, SLOT(setDirection(int)));

    QIcon icon;
    icon.addFile(QStringLiteral(":/Icons/file-load.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionLoad = new QAction(icon, "Load drawing ...", this);
    toolBar->addAction(actionLoad);
    QObject::connect(actionLoad, SIGNAL(triggered()), this, SLOT(doActionLoad()));

    QIcon icon2;
    icon2.addFile(QStringLiteral(":/Icons/file-save.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSave = new QAction(icon2, "Save drawing", this);
    toolBar->addAction(actionSave);
    QObject::connect(actionSave, SIGNAL(triggered()), this, SLOT(doActionSave()));

    QIcon icon3;
    icon3.addFile(QStringLiteral(":/Icons/file-save-as.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSaveAs = new QAction(icon3, "Save drawing as ...", this);
    toolBar->addAction(actionSaveAs);
    QObject::connect(actionSaveAs, SIGNAL(triggered()), this, SLOT(doActionSaveAs()));

    QIcon icon4;
    icon4.addFile(QStringLiteral(":/Icons/object-select.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionSelect = new QAction(icon4, "Edit object", this);
    actionSelect->setCheckable(true);
    toolBar->addAction(actionSelect);
    QObject::connect(actionSelect, SIGNAL(triggered()), this, SLOT(doActionSelect()));

    QIcon icon5;
    icon5.addFile(QStringLiteral(":/Icons/object-newline.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewLineItem = new QAction(icon5, "New line", this);
    actionNewLineItem->setCheckable(true);
    toolBar->addAction(actionNewLineItem);
    QObject::connect(actionNewLineItem, SIGNAL(triggered()), this, SLOT(doActionNewLineItem()));

    QIcon icon6;
    icon6.addFile(QStringLiteral(":/Icons/object-newrect.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewRectItem = new QAction(icon6, "New rectangle", this);
    actionNewRectItem->setCheckable(true);
    toolBar->addAction(actionNewRectItem);
    QObject::connect(actionNewRectItem, SIGNAL(triggered()), this, SLOT(doActionNewRectItem()));

    QIcon icon7;
    icon7.addFile(QStringLiteral(":/Icons/object-newtext.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewTextItem = new QAction(icon7, "New text rectangle", this);
    actionNewTextItem->setCheckable(true);
    toolBar->addAction(actionNewTextItem);
    QObject::connect(actionNewTextItem, SIGNAL(triggered()), this, SLOT(doActionNewTextItem()));

    QIcon icon8;
    icon8.addFile(QStringLiteral(":/Icons/object-newcircle.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewCircleItem = new QAction(icon8, "New circle", this);
    actionNewCircleItem->setCheckable(true);
    toolBar->addAction(actionNewCircleItem);
    QObject::connect(actionNewCircleItem, SIGNAL(triggered()), this, SLOT(doActionNewCircleItem()));

    QIcon icon9;
    icon9.addFile(QStringLiteral(":/Icons/object-newellipse.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewEllipseItem = new QAction(icon9, "New ellipse", this);
    actionNewEllipseItem->setCheckable(true);
    toolBar->addAction(actionNewEllipseItem);
    QObject::connect(actionNewEllipseItem, SIGNAL(triggered()), this, SLOT(doActionNewEllipseItem()));

    QIcon icon10;
    icon10.addFile(QStringLiteral(":/Icons/object-newbezier.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionNewBezierItem = new QAction(icon10, "New bezier curve", this);
    actionNewBezierItem->setCheckable(true);
    toolBar->addAction(actionNewBezierItem);
    QObject::connect(actionNewBezierItem, SIGNAL(triggered()), this, SLOT(doActionNewBezierItem()));

    QIcon icon11;
    icon11.addFile(QStringLiteral(":/Icons/object-delete.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionDeleteItem = new QAction(icon11, "Delete selected objects", this);
    toolBar->addAction(actionDeleteItem);
    QObject::connect(actionDeleteItem, SIGNAL(triggered()), graphicsSheet, SLOT(deleteSelectedItems()));

    QIcon icon12;
    icon12.addFile(QStringLiteral(":/Icons/edit-redo.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionRedo = new QAction(icon12, "Redo last undone action", this);
    toolBar->addAction(actionRedo);
    QObject::connect(actionRedo, SIGNAL(triggered()), this, SLOT(doActionRedo()));

    QIcon icon13;
    icon13.addFile(QStringLiteral(":/Icons/edit-undo.png"), QSize(), QIcon::Normal, QIcon::Off);
    actionUndo = new QAction(icon13, "Undo last action", this);
    toolBar->addAction(actionUndo);
    QObject::connect(actionUndo, SIGNAL(triggered()), this, SLOT(doActionUndo()));

    QActionGroup* actionGroup = new QActionGroup(this);
    actionGroup->addAction(actionSelect);
    actionGroup->addAction(actionNewLineItem);
    actionGroup->addAction(actionNewRectItem);
    actionGroup->addAction(actionNewTextItem);
    actionGroup->addAction(actionNewCircleItem);
    actionGroup->addAction(actionNewEllipseItem);
    actionGroup->addAction(actionNewBezierItem);
    actionSelect->setChecked(true);

#if 0
    QAction* actionInfo = new QAction("Info", this);
    toolBar->addAction(actionInfo);
    QObject::connect(actionInfo, SIGNAL(triggered(bool)),
                     this, SLOT(printInfo()));

    QAction* actionRotate = new QAction("Rotate", this);
    toolBar->addAction(actionRotate);
    QObject::connect(actionRotate, SIGNAL(triggered(bool)),
                     this, SLOT(rotateItem()));

    QAction* actionResize = new QAction("ResizeHandle", this);
    toolBar->addAction(actionResize);
    QObject::connect(actionResize, SIGNAL(triggered(bool)),
                     this, SLOT(resizeItem()));
#endif

    zoomWidget->getComboBox()->setCurrentIndex(2);
    sizeWidget->getComboBox()->setCurrentIndex(3);
    scaleWidget->getComboBox()->setCurrentIndex(2);
    checkbox->setChecked(true);

/*****************************************************************************/

    GraphicsScene* scene = dynamic_cast<GraphicsScene*>(graphicsSheet->scene());
    QObject::connect(scene, SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
    scene->loadFromFile("sample.drw");

    selectInteractor = new EditItemInteractor();

    newLineItemInteractor = graphicsSheet->createNewItemInteractor("LineItem");
    QObject::connect(newLineItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newRectItemInteractor = graphicsSheet->createNewItemInteractor("RectItem");
    QObject::connect(newRectItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newTextItemInteractor = graphicsSheet->createNewItemInteractor("TextItem");
    QObject::connect(newTextItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newCircleItemInteractor = graphicsSheet->createNewItemInteractor("CircleItem");
    QObject::connect(newCircleItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newEllipseItemInteractor = graphicsSheet->createNewItemInteractor("EllipseItem");
    QObject::connect(newEllipseItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));
    newBezierItemInteractor = graphicsSheet->createNewItemInteractor("BezierItem");
    QObject::connect(newBezierItemInteractor, SIGNAL(editDone()), this, SLOT(toggleActionSelect()));

    graphicsSheet->setInteractor(selectInteractor);
    graphicsSheet->setSnapper(new EdgeSnapper(new GridSnapper()));

    propertyEditor = new ObjectController();
    QDockWidget* propertiesDock = new QDockWidget(this);
    propertiesDock->setObjectName(QStringLiteral("propertiesDock"));
    propertiesDock->setFeatures(QDockWidget::DockWidgetFloatable|QDockWidget::DockWidgetMovable);
    propertiesDock->setWindowTitle("Item properties");
    propertiesDock->setWidget(propertyEditor);
    addDockWidget(static_cast<Qt::DockWidgetArea>(2), propertiesDock);
}
Example #30
0
IBLWindow::IBLWindow( ParameterWindow* paramWindow )
{
    glWidget = new IBLWidget( this, paramWindow->getBRDFList() );

    connect( paramWindow, SIGNAL(incidentDirectionChanged(float,float)), glWidget, SLOT(incidentDirectionChanged(float,float)) );
    connect( paramWindow, SIGNAL(brdfListChanged(std::vector<brdfPackage>)), glWidget, SLOT(brdfListChanged(std::vector<brdfPackage>)) );

    
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(QWidget::createWindowContainer(glWidget));


    FloatVarWidget* fv;
        
#if 0
        fv = new FloatVarWidget("Brightness", 0, 100.0, 1.0);
        connect(fv, SIGNAL(valueChanged(float)), glWidget, SLOT(brightnessChanged(float)));
        mainLayout->addWidget(fv);
#endif

    QHBoxLayout *buttonLayout = new QHBoxLayout;
    mainLayout->addLayout(buttonLayout);

    
    iblCombo = new QComboBox();
    iblCombo->setMinimumWidth( 100 );
    connect( iblCombo, SIGNAL(activated(int)), glWidget, SLOT(renderingModeChanged(int)) );
    buttonLayout->addWidget( iblCombo );
    

    QCheckBox* keepAddingSamplesCheckbox = new QCheckBox( "Keep Sampling" );
    keepAddingSamplesCheckbox->setChecked(true);
    connect( keepAddingSamplesCheckbox, SIGNAL(stateChanged(int)), glWidget, SLOT(keepAddingSamplesChanged(int)) );
    buttonLayout->addWidget(keepAddingSamplesCheckbox);
    
    
    // add the change probe button
    QPushButton* probeButton = new QPushButton();
    QPixmap* probePixmap = new QPixmap( (getImagesPath() + "imageSmall.png").c_str() );
    probeButton->setIconSize( QSize(probePixmap->width(), probePixmap->height()) );
    probeButton->setIcon( QIcon(*probePixmap) );
    probeButton->setFixedWidth( 30 );
    probeButton->setFixedHeight( 24 );
    probeButton->setToolTip( "Switch Environment Probe" );
    connect( probeButton, SIGNAL(clicked()), this, SLOT(loadIBLButtonClicked()) );
    buttonLayout->addWidget( probeButton );
    
    
    // add the change model button
    QPushButton* modelButton = new QPushButton();
    QPixmap* modelPixmap = new QPixmap( (getImagesPath() + "modelSmall.png").c_str() );
    modelButton->setIconSize( QSize(probePixmap->width(), modelPixmap->height()) );
    modelButton->setIcon( QIcon(*modelPixmap) );
    modelButton->setFixedWidth( 30 );
    modelButton->setFixedHeight( 24 );
    modelButton->setToolTip( "Switch Model" );
    connect( modelButton, SIGNAL(clicked()), this, SLOT(loadModelButtonClicked()) );
    buttonLayout->addWidget( modelButton );
    
    
    fv = new FloatVarWidget("Gamma", 1.0, 5.0, 2.2);
    connect(fv, SIGNAL(valueChanged(float)), glWidget, SLOT(gammaChanged(float)));
    mainLayout->addWidget(fv);
    
    fv = new FloatVarWidget("Exposure", -12.0, 12.0, 0.0);
    connect(fv, SIGNAL(valueChanged(float)), glWidget, SLOT(exposureChanged(float)));
    mainLayout->addWidget(fv);


    setLayout(mainLayout);
    
    setWindowTitle( "Lit Sphere" );

    probeFileDialog =  new QFileDialog(this, "Open Cube Map", "", "Ptex Cube Maps (*.penv *.ptex *.ptx)");
    probeFileDialog->setFileMode(QFileDialog::ExistingFile);

    modelFileDialog =  new QFileDialog(this, "Open Model", "", "OBJ files (*.obj)");
    modelFileDialog->setFileMode(QFileDialog::ExistingFile);
}