Example #1
0
/*
 * Path is not saved in linux without installer - added workspace to properties dialog.
 */
NewProject::NewProject(QWidget *parent) : QDialog(parent)
{
    mypath = getCurrentPath();
    path = new QLineEdit(mypath,this);
    path->setToolTip(tr("Directory for new project."));

    QPushButton *btnBrowsePath = new QPushButton(this);
    btnBrowsePath->setText(tr("Browse"));

    name = new QLineEdit(this);
    name->setToolTip(tr("New project name and sub-directory."));
    connect(name,SIGNAL(textChanged(QString)),this,SLOT(nameChanged()));

    path->setText(mypath+name->text());
    QLabel *pathLabel = new QLabel(tr("Workspace"));
    QLabel *nameLabel = new QLabel(tr("Project Name"));

    QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
    connect(btnBrowsePath, SIGNAL(clicked()), this, SLOT(browsePath()));
    connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    okButton = (QPushButton*) buttonBox->buttons().at(0);
    cancelButton = (QPushButton*) buttonBox->buttons().at(1);
    if(okButton->text().contains("cancel",Qt::CaseInsensitive)) {
        okButton = (QPushButton*) buttonBox->buttons().at(1);
        cancelButton = (QPushButton*) buttonBox->buttons().at(1);
    }

    QLabel *create = new QLabel(this);
    create->setText(tr("Creating a new project:"));
    create->setFont(QFont(this->font().family(),this->font().pointSize()*1.5,QFont::Bold));
    QLabel *inst = new QLabel(this);
    inst->setText(tr(" 1) Choose project workspace.\n 2) Set project name.\n\n" \
            "A project folder with project name will be created in the workspace.\n" \
            "The new folder will have a main .c file and a .side project file.\n"));

    QVBoxLayout *blay = new QVBoxLayout(this);
    QGridLayout *layout = new QGridLayout();
    layout->addWidget(path,0,1,1,1); // tab order for widgets is according to add order
    layout->addWidget(name,1,1,1,1);
    layout->addWidget(btnBrowsePath,0,2,1,1);
    layout->addWidget(nameLabel,1,0,1,1);
    layout->addWidget(pathLabel,0,0,1,1);

    blay->addWidget(create);
    blay->addWidget(inst);
    blay->addLayout(layout);
    blay->addWidget(new QLabel(this));
    blay->addWidget(buttonBox);
    setLayout(blay);
    buttonBox->setFocus();

    int fontSize = path->fontInfo().pixelSize();
    setMinimumWidth(mypath.length()*fontSize+100);
    setWindowFlags(Qt::Tool);
}
void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled())
                        pb->click();
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
Example #3
0
QAbstractButton * GTUtilsPrimerLibrary::getButton(HI::GUITestOpStatus &os, Button button) {
    QDialogButtonBox *box = GTUtilsDialog::buttonBox(os, GTWidget::findWidget(os, "PrimerLibraryWidget"));
    switch (button) {
        case Add:
            return box->buttons()[1];
        case Edit:
            return box->buttons()[2];
        case Close:
            return box->button(QDialogButtonBox::Close);
        case Remove:
            return box->buttons()[3];
        case Import:
            return box->buttons()[4];
        case Export:
            return box->buttons()[5];
        default:
            return NULL;
    }
}
Example #4
0
void TaskView::keyPressEvent(QKeyEvent* ke)
{
    if (ActiveCtrl && ActiveDialog) {
        if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
            // get all buttons of the complete task dialog
            QList<QPushButton*> list = this->findChildren<QPushButton*>();
            for (int i=0; i<list.size(); ++i) {
                QPushButton *pb = list.at(i);
                if (pb->isDefault() && pb->isVisible()) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
        else if (ke->key() == Qt::Key_Escape) {
            // get only the buttons of the button box
            QDialogButtonBox* box = ActiveCtrl->standardButtons();
            QList<QAbstractButton*> list = box->buttons();
            for (int i=0; i<list.size(); ++i) {
                QAbstractButton *pb = list.at(i);
                if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
                    if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
                        // #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
                        QPoint pos = QCursor::pos();
                        QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
                        pb->click();
#if defined(FC_OS_MACOSX)
                        QCursor::setPos(pos);
#endif
                    }
                    return;
                }
            }
        }
    }
    else {
        QScrollArea::keyPressEvent(ke);
    }
}
Example #5
0
/**
  * @brief the current tab changed
  */
void OpenNIC::tabChanged(int tab)
{
	QDialogButtonBox* buttonBox = ui->buttonBox;
	QList<QAbstractButton *> buttons = buttonBox->buttons();
	for(int n=0; n < buttons.count(); n++)
	{
		QAbstractButton* button = buttons.at(n);
		if (buttonBox->buttonRole(button) == QDialogButtonBox::ApplyRole || buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
		{
			if ( tab == 1 || tab == 5 )
			{
				button->setEnabled(true);
			}
			else
			{
				button->setEnabled(false);
			}
		}
	}
}
Example #6
0
void shortcuts::setStandardKeys(QWidget* widget)
{
  if (!widget)
    return;

  // Add standard shortcuts to applicable buttons
  bool hasShortcut = false;
  QPushButton* button;

  // For Save
  button = widget->findChild<QPushButton*>("_save");
  if (button)
  {
    button->setShortcut(QKeySequence::Save);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_post");
    if (button)
    {
      button->setShortcut(QKeySequence::Save);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }
  if (!hasShortcut)
  {
    QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
    if (bb)
    {
      QList<QAbstractButton*> buttons =  bb->buttons();
      for (int i = 0; i < buttons.size(); ++i)
      {
        QAbstractButton *bbutton = buttons.at(i);
        QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
        if (btnrole == QDialogButtonBox::AcceptRole)
        {
          bbutton->setShortcut(QKeySequence::Save);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
        else if (btnrole == QDialogButtonBox::RejectRole)
        {
          bbutton->setShortcut(QKeySequence::Close);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
      }
    }
  }

  // For Close
  hasShortcut = false;
  button = widget->findChild<QPushButton*>("_close");
  if (button)
  {
    button->setShortcut(QKeySequence::Close);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_cancel");
    if (button)
    {
      button->setShortcut(QKeySequence::Close);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }

  // For New
  button = widget->findChild<QPushButton*>("_new");
  if (button)
  {
    button->setShortcut(QKeySequence::New);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Print
  button = widget->findChild<QPushButton*>("_print");
  if (button)
  {
    button->setShortcut(QKeySequence::Print);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Query
  button = widget->findChild<QPushButton*>("_query");
  if (button)
  {
    button->setShortcut(QKeySequence::Refresh);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // Page up/down for tab widgets
  QTabWidget* tab = widget->findChild<QTabWidget*>();
  if (tab)
  {
    TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget);
    QAction* pagedownAct = new QAction(tab);
    pagedownAct->setShortcut(QKeySequence::MoveToNextPage);
    pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown()));
    tab->addAction(pagedownAct);

    QAction* pageupAct = new QAction(tab);
    pageupAct->setShortcut(QKeySequence::MoveToPreviousPage);
    pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp()));
    tab->addAction(pageupAct);
  }
}