void ChoiceSearchComboBox::installView(QAbstractItemView* v) { // make protected again ListViewComboBox::installView(v); //view()->setHeaderHidden(true); view()->setAlternatingRowColors(true); // create the label m_label = new DSqueezedClickLabel; m_label->setElideMode(Qt::ElideRight); // set a line edit that carries the label ProxyClickLineEdit* const lineEdit = new ProxyClickLineEdit; lineEdit->setCursor(m_label->cursor()); lineEdit->setWidget(m_label); setLineEdit(lineEdit); // connect clicks on upper area (both line edit and widget within) to showPopup connect(lineEdit, SIGNAL(leftClicked()), this, SLOT(labelClicked())); connect(m_label, SIGNAL(activated()), this, SLOT(labelClicked())); }
void MainScoreWidget::initButtonLayout() { m_stackedWidget = new QStackedWidget; ButtonLabel *cancleButton = new ButtonLabel; cancleButton->setText("取消体检"); connect(cancleButton, SIGNAL(labelClicked()), this, SIGNAL(cancleExamine())); QWidget *fixWidget = new QWidget; StaticButton *fixButton = new StaticButton(":/main/btn_fix_all"); connect(fixButton, SIGNAL(buttonClicked()), this, SIGNAL(oneFix())); ButtonLabel *reExamineButton = new ButtonLabel; reExamineButton->setText("重新体检"); connect(reExamineButton, SIGNAL(labelClicked()), this, SIGNAL(reExamine())); QVBoxLayout *fixVLayout = new QVBoxLayout; fixVLayout->addWidget(fixButton); fixVLayout->addWidget(reExamineButton); fixWidget->setLayout(fixVLayout); StaticButton *reStaticButton = new StaticButton(":/main/btn_reexamine"); connect(reStaticButton, SIGNAL(buttonClicked()), this, SIGNAL(reExamine())); m_stackedWidget->addWidget(cancleButton); m_stackedWidget->addWidget(fixWidget); m_stackedWidget->addWidget(reStaticButton); }
void BcLabel::mousePressEvent(QMouseEvent * event) { QLabel::mousePressEvent(event); if (!m_last && event->button() == Qt::LeftButton) { event->accept(); emit labelClicked(m_labId); } }
void BcLabel::keyPressEvent(QKeyEvent * event) { QLabel::keyPressEvent(event); if (!m_last && (event->key() == Qt::Key_Space || event->key() == Qt::Key_Enter)) { event->accept(); emit labelClicked(m_labId); } }
void WidgetContainerOverview::addWidget(QWidget *widget) { stackedWidget->addWidget(widget); ClickableLabel *label = new ClickableLabel("", this); connect(label, SIGNAL(clicked()), this, SLOT(labelClicked())); gl->addWidget(label, labelList.count() % 2, labelList.count() / 2); labelList.append(label); // ID is the total number(sequence number) label->setProperty(idProperty, labelList.count()); }
ClickableLabel::ClickableLabel(MainApp *gl, QMediaPlayer* p,customslider* s, int t, int i, QWidget * parent ) : QLabel(parent) { if(t==-1){ type = 0; vgl = gl; } else { // this->_player = p; // this->slider = s; // this->timestamp = t; vgl = gl; type = 1; index = i; } connect( this, SIGNAL( clicked() ), this, SLOT( labelClicked() ) ); //this->setText(text); }
void ZClickableLabel::mousePressEvent(QMouseEvent *ev) { if (ev->button() == Qt::LeftButton) labelClicked(); }
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window) { modelMap = models; QSignalMapper *signalMapper = new QSignalMapper(this); // Add main page QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout(); QHBoxLayout *placementLayout = new QHBoxLayout(); placementLayout->addWidget(createButton("Add droids", SLOT(droidButtonClicked()), this)); placementLayout->addWidget(createButton("Add structures", SLOT(structButtonClicked()), this)); placementLayout->addWidget(createButton("Add features", SLOT(featButtonClicked()), this)); mainLayout->addLayout(placementLayout); QHBoxLayout *miscLayout = new QHBoxLayout(); miscLayout->addWidget(createButton("Research all", SLOT(researchButtonClicked()), this)); miscLayout->addWidget(createButton("Show sensors", SLOT(sensorsButtonClicked()), this)); miscLayout->addWidget(createButton("Shadows", SLOT(shadowButtonClicked()), this)); miscLayout->addWidget(createButton("Fog", SLOT(fogButtonClicked()), this)); mainLayout->addLayout(miscLayout); QHBoxLayout *worldLayout = new QHBoxLayout(); worldLayout->addWidget(createButton("Show all", SLOT(deityButtonClicked()), this)); worldLayout->addWidget(createButton("Weather", SLOT(weatherButtonClicked()), this)); worldLayout->addWidget(createButton("Reveal mode", SLOT(revealButtonClicked()), this)); mainLayout->addLayout(worldLayout); QHBoxLayout *selectedPlayerLayout = new QHBoxLayout(); QLabel *selectPlayerLabel = new QLabel("Selected Player:"); QComboBox *playerComboBox = new QComboBox; for (int i = 0; i < game.maxPlayers; i++) { playerComboBox->addItem(QString::number(i)); } connect(playerComboBox, SIGNAL(activated(int)), this, SLOT(playerButtonClicked(int))); selectedPlayerLayout->addWidget(selectPlayerLabel); selectedPlayerLayout->addWidget(playerComboBox); mainLayout->addLayout(selectedPlayerLayout); QHBoxLayout *powerLayout = new QHBoxLayout(); QLabel *powerLabel = new QLabel("Power:"); QLineEdit *powerLineEdit = new QLineEdit; powerLineEdit->setText(QString::number(getPower(selectedPlayer))); connect(powerLineEdit, SIGNAL(textEdited(const QString&)), this, SLOT(powerEditing(const QString&))); connect(powerLineEdit, SIGNAL(returnPressed()), this, SLOT(powerEditingFinished())); powerLayout->addWidget(powerLabel); powerLayout->addWidget(powerLineEdit); mainLayout->addLayout(powerLayout); mainWidget->setLayout(mainLayout); tab.addTab(mainWidget, "Main"); // Add globals for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i) { QWidget *dummyWidget = new QWidget(this); QScriptEngine *engine = i.key(); QStandardItemModel *m = i.value(); m->setParent(this); // take ownership to avoid memory leaks QTreeView *view = new QTreeView(this); view->setSelectionMode(QAbstractItemView::NoSelection); view->setModel(m); QString scriptName = engine->globalObject().property("scriptName").toString(); int player = engine->globalObject().property("me").toInt32(); QLineEdit *lineEdit = new QLineEdit(this); QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *layout2 = new QHBoxLayout(); QPushButton *updateButton = new QPushButton("Update", this); QPushButton *button = new QPushButton("Run", this); connect(button, SIGNAL(pressed()), signalMapper, SLOT(map())); connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels())); signalMapper->setMapping(button, engine); editMap.insert(engine, lineEdit); // store this for slot layout->addWidget(view); layout2->addWidget(updateButton); layout2->addWidget(lineEdit); layout2->addWidget(button); layout->addLayout(layout2); dummyWidget->setLayout(layout); tab.addTab(dummyWidget, scriptName + ":" + QString::number(player)); } connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *))); // Add triggers triggerModel->setParent(this); // take ownership to avoid memory leaks triggerView.setModel(triggerModel); triggerView.resizeColumnToContents(0); triggerView.setSelectionMode(QAbstractItemView::NoSelection); triggerView.setSelectionBehavior(QAbstractItemView::SelectRows); tab.addTab(&triggerView, "Triggers"); // Add labels labelModel = createLabelModel(); labelModel->setParent(this); // take ownership to avoid memory leaks labelView.setModel(labelModel); labelView.resizeColumnToContents(0); labelView.setSelectionMode(QAbstractItemView::SingleSelection); labelView.setSelectionBehavior(QAbstractItemView::SelectRows); connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &))); QPushButton *button = new QPushButton("Show", this); connect(button, SIGNAL(pressed()), this, SLOT(labelClicked())); QVBoxLayout *labelLayout = new QVBoxLayout(this); labelLayout->addWidget(&labelView); labelLayout->addWidget(button); QWidget *dummyWidget = new QWidget(this); dummyWidget->setLayout(labelLayout); tab.addTab(dummyWidget, "Labels"); // Set up dialog QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(&tab); setLayout(layout); resize(400, 500); setSizeGripEnabled(true); show(); raise(); powerLineEdit->setFocusPolicy(Qt::StrongFocus); powerLineEdit->setFocus(); activateWindow(); }
BoardSetupDialog::BoardSetupDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f), m_wheelCurrentDelta(0), m_selectedPiece(Empty), inDrag(false) { setObjectName("BoardSetupDialog"); ui.setupUi(this); QPushButton *pasteButton = ui.buttonBox->addButton(tr("Paste FEN"), QDialogButtonBox::ActionRole); copyButton = ui.buttonBox->addButton(tr("Copy FEN"), QDialogButtonBox::ApplyRole); btCopyText = ui.buttonBox->addButton(tr("Copy Text"), QDialogButtonBox::ApplyRole); restoreLayout(); ui.boardView->configure(); ui.boardView->setFlags(BoardView::IgnoreSideToMove | BoardView::SuppressGuessMove | BoardView::AllowCopyPiece); ui.boardView->showMoveIndicator(false); ui.boardView->showCoordinates(true); m_minDeltaWheel = AppSettings->getValue("/Board/minWheelCount").toInt(); for(int piece = Empty; piece <= BlackPawn; piece++) { BoardSetupToolButton* button = new BoardSetupToolButton(this); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); button->setMinimumSize(QSize(10, 10)); button->m_piece = (Piece)piece; if(piece == Empty) { button->m_pixmap = QPixmap(0, 0); ui.buttonLayout->addWidget(button, 6, 0); } else { button->m_pixmap = ui.boardView->theme().piece(Piece(piece)); ui.buttonLayout->addWidget(button, (piece - 1) % 6, piece >= BlackKing); } connect(button, SIGNAL(signalDragStarted(QWidget*, QMouseEvent*)), this, SLOT(startDrag(QWidget*, QMouseEvent*))); connect(button, SIGNAL(signalClicked(Piece)), this, SLOT(labelClicked(Piece))); connect(this, SIGNAL(signalClearBackground(Piece)), button, SLOT(slotClearBackground(Piece))); } emit signalClearBackground(Empty); ui.buttonBoxTools->button(QDialogButtonBox::RestoreDefaults)->setText(tr("Clear")); connect(ui.buttonBoxTools->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked()), SLOT(slotClear())); connect(ui.buttonBoxTools->button(QDialogButtonBox::Reset), SIGNAL(clicked()), SLOT(slotReset())); connect(ui.boardView, SIGNAL(clicked(Square, int, QPoint, Square)), SLOT(slotSelected(Square, int))); connect(ui.boardView, SIGNAL(moveMade(Square, Square, int)), SLOT(slotMovePiece(Square, Square))); connect(ui.boardView, SIGNAL(copyPiece(Square, Square)), SLOT(slotCopyPiece(Square, Square))); connect(ui.boardView, SIGNAL(invalidMove(Square)), SLOT(slotInvalidMove(Square))); connect(ui.boardView, SIGNAL(wheelScrolled(int)), SLOT(slotChangePiece(int))); connect(ui.boardView, SIGNAL(pieceDropped(Square, Piece)), SLOT(slotDroppedPiece(Square, Piece))); connect(ui.toMoveButton, SIGNAL(clicked()), SLOT(slotToggleSide())); connect(ui.wkCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights())); connect(ui.wqCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights())); connect(ui.bkCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights())); connect(ui.bqCastleCheck, SIGNAL(stateChanged(int)), SLOT(slotCastlingRights())); connect(ui.epCombo, SIGNAL(currentIndexChanged(int)), SLOT(slotEnPassantSquare())); connect(ui.halfmoveSpin, SIGNAL(valueChanged(int)), SLOT(slotHalfmoveClock())); connect(ui.moveSpin, SIGNAL(valueChanged(int)), SLOT(slotMoveNumber())); connect(ui.btFlipBoard, SIGNAL(clicked()), ui.boardView, SLOT(flip())); ui.btFlipBoard->setCheckable(true); connect(copyButton, SIGNAL(clicked()), SLOT(slotCopyFen())); connect(pasteButton, SIGNAL(clicked()), SLOT(slotPasteFen())); connect(btCopyText, SIGNAL(clicked()), SLOT(slotCopyText())); connect(ui.btFlipVertical, SIGNAL(clicked()), SLOT(mirrorVertical())); connect(ui.btFlipHorizontal, SIGNAL(clicked()), SLOT(mirrorHorizontal())); connect(ui.btSwapColor, SIGNAL(clicked()), SLOT(swapColors())); ui.tabWidget->setCurrentIndex(0); }
ScriptDebugger::ScriptDebugger(const MODELMAP &models, QStandardItemModel *triggerModel) : QDialog(NULL, Qt::Window) { modelMap = models; QSignalMapper *signalMapper = new QSignalMapper(this); // Add globals for (MODELMAP::const_iterator i = models.constBegin(); i != models.constEnd(); ++i) { QWidget *dummyWidget = new QWidget(this); QScriptEngine *engine = i.key(); QStandardItemModel *m = i.value(); m->setParent(this); // take ownership to avoid memory leaks QTreeView *view = new QTreeView(this); view->setSelectionMode(QAbstractItemView::NoSelection); view->setModel(m); QString scriptName = engine->globalObject().property("scriptName").toString(); int player = engine->globalObject().property("me").toInt32(); QLineEdit *lineEdit = new QLineEdit(this); QVBoxLayout *layout = new QVBoxLayout(); QHBoxLayout *layout2 = new QHBoxLayout(); QPushButton *updateButton = new QPushButton("Update", this); QPushButton *button = new QPushButton("Run", this); connect(button, SIGNAL(pressed()), signalMapper, SLOT(map())); connect(updateButton, SIGNAL(pressed()), this, SLOT(updateModels())); signalMapper->setMapping(button, engine); editMap.insert(engine, lineEdit); // store this for slot layout->addWidget(view); layout2->addWidget(updateButton); layout2->addWidget(lineEdit); layout2->addWidget(button); layout->addLayout(layout2); dummyWidget->setLayout(layout); tab.addTab(dummyWidget, scriptName + ":" + QString::number(player)); } connect(signalMapper, SIGNAL(mapped(QObject *)), this, SLOT(runClicked(QObject *))); // Add triggers triggerModel->setParent(this); // take ownership to avoid memory leaks triggerView.setModel(triggerModel); triggerView.resizeColumnToContents(0); triggerView.setSelectionMode(QAbstractItemView::NoSelection); triggerView.setSelectionBehavior(QAbstractItemView::SelectRows); tab.addTab(&triggerView, "Triggers"); // Add labels labelModel = createLabelModel(); labelModel->setParent(this); // take ownership to avoid memory leaks labelView.setModel(labelModel); labelView.resizeColumnToContents(0); labelView.setSelectionMode(QAbstractItemView::SingleSelection); labelView.setSelectionBehavior(QAbstractItemView::SelectRows); connect(&labelView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(labelClickedIdx(const QModelIndex &))); QPushButton *button = new QPushButton("Show", this); connect(button, SIGNAL(pressed()), this, SLOT(labelClicked())); QVBoxLayout *labelLayout = new QVBoxLayout(this); labelLayout->addWidget(&labelView); labelLayout->addWidget(button); QWidget *dummyWidget = new QWidget(this); dummyWidget->setLayout(labelLayout); tab.addTab(dummyWidget, "Labels"); // Set up dialog QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(&tab); setLayout(layout); setSizeGripEnabled(true); show(); raise(); activateWindow(); }
void ClickableLabel::mousePressEvent( QMouseEvent * e ) { UNUSED( e ); emit labelClicked( this ); }