Example #1
0
bool QAquaAnimate::addWidget(QWidget *w) 
{
    if(focusable(w)) {
	if(w->hasFocus()) 
	    setFocusWidget(w);
	w->installEventFilter(this);
    }
    if(w == d->defaultButton || d->progressBars.contains((QProgressBar*)w)) //already knew of it
	return FALSE;

    if(w->inherits("QPushButton")){
        QPushButton * btn = (QPushButton *) w;
        if(btn->isDefault() || (btn->autoDefault() && btn->hasFocus())){
	    d->defaultButton = btn;
            btn->installEventFilter(this);
            if(btn->isVisible() && d->buttonTimerId == -1) 
                d->buttonTimerId = startTimer(50);
        }
	return TRUE;
    } else if(w->inherits("QProgressBar")){
	w->installEventFilter(this);
	QObject::connect(w, SIGNAL(destroyed(QObject*)), this, SLOT(objDestroyed(QObject*)));
	if(w->isVisible() && d->progressTimerId == -1) {
	    d->progressBars.append((QProgressBar*)w);
	    d->progressTimerId = startTimer(50);
	}
	return TRUE;
    } else if(w->inherits("QListView")) {
Example #2
0
void Question_widget::update_buttons() {
  if (ui->frame->width() < 1) return; //can't align buttons without having widget size
  foreach(QPushButton* b, buttons_widgets) {
    b->deleteLater();
  }
  buttons_widgets.clear();
  int button_width = 0;
  for(int i = 0; i < buttons.count(); i++) {
    Button_settings s = buttons[i];
    QPushButton* b = new QPushButton(tr("%1) %2").arg(s.number < 0? i+1 : s.number).arg(s.caption), this);
    //b->setEnabled(s.enabled);
    b->setStyleSheet("text-align: left; padding: 3px");
    int w = b->sizeHint().width();
    if (w > button_width) button_width = w;
    connect(b, SIGNAL(clicked()), this, SLOT(slot_button_clicked()));
    b->installEventFilter(this);
    buttons_widgets << b;
  }
  int margin_left, margin_right;
  ui->frame_layout->getContentsMargins(&margin_left, 0, &margin_right, 0);
  int columns = (ui->frame->width() - margin_left - margin_right + ui->buttons_layout->horizontalSpacing())
      / (button_width + ui->buttons_layout->horizontalSpacing());
  qDebug() << ui->frame->width() << button_width << columns;
  if (columns < 1) columns = 1;
  for(int i = 0; i < buttons_widgets.count(); i++) {
    QPushButton* b = buttons_widgets[i];
    b->setFixedWidth(button_width);
    ui->buttons_layout->addWidget(b, i / columns, i % columns);
  }
  for(int i = 0; i < columns; i++) {
    ui->buttons_layout->setColumnStretch(i, 0);
  }
  ui->buttons_layout->setColumnStretch(columns, 1);
}
Example #3
0
void FindArticeDialog::CreateVirtualKeyboard()
{
    glKeyboard = new QGridLayout();
    signalMapper = new QSignalMapper(this);
    QStringList slButtonText;
    slButtonText <<"А"<<"Б"<<"В"<<"Г"<<"Д"<<"Е"<<"Ж"<<"З"<<"И"<<"Й"<<"К"<<"Л"<<"М"<<"Н"<<"О";
    slButtonText <<"П"<<"Р"<<"С"<<"Т"<<"У"<<"Ф"<<"Х"<<"Ц"<<"Ч"<<"Ш"<<"Щ"<<"Ъ"<<"Ы"<<"Ь"<<"Э"<<"Ю"<<"Я";

    slButtonText<<"Пробел"<<"<-"<<"Очистить";

    int row, col;
    QWidget *prevTabOrder = ui->tvArticle;
    for (int i= 0;i<slButtonText.size();i++)
    {
        QPushButton *b = new QPushButton(this);
        b->setText(slButtonText.at(i));
        col=i%10; row=i/10;
        b->setProperty("row",row);
        b->setProperty("col",col);
        b->setObjectName("QPushButton_"+QString::number(row)+"_"+QString::number(col));
        b->installEventFilter(this);
        setTabOrder(prevTabOrder,b);
        prevTabOrder = b;
        connect(b, SIGNAL(clicked()), signalMapper, SLOT(map()));
        signalMapper->setMapping(b, b->text());
        glKeyboard->addWidget(b,row,col);
        if(b->text()=="Очистить")
        {
            b->setShortcut(QKeySequence("Del"));
        }
        else
            if(b->text()=="<-")
            {
                b->setShortcut(QKeySequence("Backspace"));
            }
            else
            {
                b->setShortcut(QKeySequence(b->text()));
            }

    }

    connect(signalMapper, SIGNAL(mapped(const QString &)),
                 this, SLOT(VirtualKeyPressed(const QString &)));

    ui->groupBox_2->setLayout(glKeyboard);

    QPushButton* FirstButton = ui->groupBox_2->findChild<QPushButton *>("QPushButton_0_0");
    if (FirstButton)
    {
        FirstButton->setFocus();
    }

}
Example #4
0
//------------------------------------------------------------------------------
void ctkFileDialogPrivate::observeAcceptButton()
{
  Q_Q(ctkFileDialog);
  QPushButton* button = this->acceptButton();
  Q_ASSERT(button);
  this->AcceptButtonState =
    button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
  // TODO: catching the event of the enable state is not enough, if the user
  // double click on the file, the dialog will be accepted, that event should
  // be intercepted as well
  button->installEventFilter(q);
}
Example #5
0
int main(int argc, char* argv[])
{
    QApplication app(argc, argv);

    MyLabel window;
    QPushButton* button = new QPushButton("Joku teksti", &window);

    MyFilter filter;
    button->installEventFilter(&filter);

    window.show();

    return QApplication::exec();
}
Example #6
0
//------------------------------------------------------------------------------
void ctkFileDialogPrivate::init()
{
    Q_Q(ctkFileDialog);
    QPushButton* button = this->acceptButton();
    Q_ASSERT(button);
    this->AcceptButtonState =
        button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
    // TODO: catching the event of the enable state is not enough, if the user
    // double click on the file, the dialog will be accepted, that event should
    // be intercepted as well
    button->installEventFilter(q);

    QObject::connect(this->listView()->selectionModel(),
                     SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
                     q, SLOT(onSelectionChanged()));
}
Example #7
0
void MyTabBar::addTab(QIcon icon)
{
    QPushButton *btn = new QPushButton;
    btn->setIcon(icon);
    btn->setIconSize(QSize(40, 40));
    btn->setStyleSheet(QString("border: none;"));
    layout->addWidget(btn);

    btn->setStyleSheet("border:none; background-color: qlineargradient(spread:pad, x1:1, y1:0.852, x2:1, y2:0, stop:0.0852273 rgba(102, 149, 255, 255), stop:0.454545 rgba(248, 209, 88, 255), stop:1 rgba(61, 235, 151, 255));");

    if(currentSelectedTabIndex == -1)
    {
        currentSelectedTabIndex = 0;
         btn->setStyleSheet("border:none; background-color: qconicalgradient(cx:0.5, cy:0.5, angle:339.4, stop:0.0319149 rgba(136, 106, 22, 255), stop:0.125532 rgba(166, 140, 41, 255), stop:0.221277 rgba(204, 181, 74, 255), stop:0.280851 rgba(235, 219, 102, 255), stop:0.412766 rgba(245, 236, 112, 255), stop:0.514894 rgba(209, 190, 76, 255), stop:0.57 rgba(187, 156, 51, 255), stop:0.635 rgba(168, 142, 42, 255), stop:0.695 rgba(202, 174, 68, 255), stop:0.75 rgba(218, 202, 86, 255), stop:0.815 rgba(208, 187, 73, 255), stop:0.88 rgba(187, 156, 51, 255), stop:0.96383 rgba(137, 108, 26, 255));");
    }

    btn->installEventFilter(this);

    vecTabs.push_back(btn);
}
Example #8
0
dlgStdPad::dlgStdPad(_cfg_port *cfg_port, QWidget *parent = 0) : QDialog(parent) {
	QFont f9, f8;

	f9.setPointSize(9);
	f9.setWeight(QFont::Light);
	f8.setPointSize(8);
	f8.setWeight(QFont::Light);

	memset(&data, 0x00, sizeof(data));
	memcpy(&data.cfg, cfg_port, sizeof(_cfg_port));

	setupUi(this);

	setFont(parent->font());

	groupBox_controller->setTitle(tr("Controller %1 : Standard Pad").arg(cfg_port->id));
	tabWidget->setCurrentIndex(JOYSTICK);
	combo_id_init();

	for (int a = KEYBOARD; a <= JOYSTICK; a++) {
		QPlainTextEdit *txt;
		QPushButton *bt;

		txt = findChild<QPlainTextEdit *>("plainTextEdit_" + SPT(a) + "_info");

		if (txt->font().pointSize() > 9) {
			txt->setFont(f9);
		}

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Sequence");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_in_sequence_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Unset_all");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_unset_all_clicked(bool)));

		bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_Defaults");
		bt->setProperty("myType", QVariant(a));
		connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_defaults_clicked(bool)));

		for (int b = BUT_A; b < MAX_STD_PAD_BUTTONS; b++) {
			int vbutton = b + (a * MAX_STD_PAD_BUTTONS);
			QPushButton *unset;

			bt = findChild<QPushButton *>("pushButton_" + SPT(a) + "_" + SPB(b));
			unset = findChild<QPushButton *>("pushButton_" + SPT(a) + "_unset_" + SPB(b));

			if (bt->font().pointSize() > 9) {
				bt->setFont(f9);
			}
			if (unset->font().pointSize() > 8) {
				unset->setFont(f8);
			}

			if (a == KEYBOARD) {
				bt->setText(inpObject::kbd_keyval_to_name(data.cfg.port.input[a][b]));
			} else {
				bt->setText(uQString(jsv_to_name(data.cfg.port.input[a][b])));
			}

			bt->installEventFilter(this);
			bt->setProperty("myVbutton", QVariant(vbutton));
			unset->setProperty("myVbutton", QVariant(vbutton));

			connect(bt, SIGNAL(clicked(bool)), this, SLOT(s_input_clicked(bool)));
			connect(unset, SIGNAL(clicked(bool)), this, SLOT(s_unset_clicked(bool)));
		}
	}

	{
		comboBox_Controller_type->addItem(tr("Auto"));
		comboBox_Controller_type->addItem(tr("Original"));
		comboBox_Controller_type->addItem(tr("3rd-party"));
		comboBox_Controller_type->setCurrentIndex(data.cfg.port.type_pad);
		connect(comboBox_Controller_type, SIGNAL(activated(int)), this,
				SLOT(s_combobox_controller_type_activated(int)));
	}

	for (int i = TURBOA; i <= TURBOB; i++) {
		QSlider *tb = findChild<QSlider *>("horizontalSlider_" + SPB(i + TRB_A));
		QLabel *label = findChild<QLabel *>("label_value_slider_" + SPB(i + TRB_A));

		tb->setRange(1, TURBO_BUTTON_DELAY_MAX);
		tb->setProperty("myTurbo", QVariant(i));
		tb->setValue(data.cfg.port.turbo[i].frequency);
		connect(tb, SIGNAL(valueChanged(int)), this, SLOT(s_slider_td_value_changed(int)));

		label->setFixedWidth(label->sizeHint().width());
		td_update_label(i, data.cfg.port.turbo[i].frequency);
	}

	pushButton_Apply->setProperty("myPointer", QVariant::fromValue(((void *)cfg_port)));
	connect(pushButton_Apply, SIGNAL(clicked(bool)), this, SLOT(s_apply_clicked(bool)));
	connect(pushButton_Discard, SIGNAL(clicked(bool)), this, SLOT(s_discard_clicked(bool)));

	setAttribute(Qt::WA_DeleteOnClose);
	setFixedSize(width(), height());

	setFocusPolicy(Qt::StrongFocus);
	groupBox_controller->setFocus(Qt::ActiveWindowFocusReason);

	data.joy.timer = new QTimer(this);
	connect(data.joy.timer, SIGNAL(timeout()), this, SLOT(s_pad_joy_read_timer()));

	data.seq.timer = new QTimer(this);
	connect(data.seq.timer, SIGNAL(timeout()), this, SLOT(s_pad_in_sequence_timer()));

	installEventFilter(this);
}