bool TCore::list() { enum ControlSymbols { I = 0x01, F,//0x02 HEX,//0x03 }; const qint8 id = 3; QByteArray data(56,0); qint8 oper1 = id; moveWidget(id, LIST, 200, 10, 200, 300); memcpy(data.data(), &oper1, 1); oper1 = MainWindow::LIST; memcpy(data.data()+1, &oper1, 1); oper1 = MainWindow::VALUE; memcpy(data.data()+2, &oper1, 1); qint32 value1 = 13; oper1 = I; memcpy(data.data()+3, &oper1, 1); memcpy(data.data()+4, &value1, 4); memcpy(data.data()+8, "th pickaninny toward to sea...; ", 32); float valueF = 3.14; oper1 = F; memcpy(data.data()+40, &oper1, 1); memcpy(data.data()+41, &valueF, 4); memcpy(data.data()+45, " - pi.", 6); oper1 = HEX; memcpy(data.data()+51, &oper1, 1); value1 = 21; memcpy(data.data()+52, &value1, 4); sendDatagram(address, remoutePort, data); return true; }
bool TCore::dock() { enum ControlSymbols { ADD_ITEM = 0, SET_TITLE, }; const qint8 id = 8; moveWidget(id, DOCK, 700, 20, 300, 300); QByteArray datagram, data(9,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = DOCK; memcpy(data.data()+1, &oper1, 1); oper1 = VALUE; memcpy(data.data()+2, &oper1, 1); oper1 = SET_TITLE; memcpy(data.data()+3, &oper1, 1); memcpy(data.data()+4, "title", 5); sendDatagram(address, remoutePort, data); data.resize(7); oper1 = ADD_ITEM; memcpy(data.data()+3, &oper1, 1); oper1 = 1; memcpy(data.data()+4, &oper1, 1); oper1 = 6; memcpy(data.data()+5, &oper1, 1); oper1 = 3; memcpy(data.data()+6, &oper1, 1); sendDatagram(address, remoutePort, data); return true; }
bool TCore::labelI_and_hide() { const qint8 id = 2; static qint32 value = 0; value++; moveWidget(id, LABELI, 10, 300, 100, 30); QByteArray datagram, data(14,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = MainWindow::LABELI; memcpy(data.data()+1, &oper1, 1); oper1 = MainWindow::VALUE; memcpy(data.data()+2, &oper1, 1); memcpy(data.data()+3, &value, 4); sendDatagram(address, remoutePort, data); if(value % 4) { QByteArray datagram, data(7,0); //show/hide oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = LABELI; memcpy(data.data()+1, &oper1, 1); oper1 = SHOW; memcpy(data.data()+2, &oper1, 1); oper1 = 2;//hide memcpy(data.data()+3, &oper1, 4); sendDatagram(address, remoutePort, data); } return true; }
bool TCore::led() { enum ControlSymbols { NAME = 0x00, STATE,//0x01 }; enum States { OFF = 0x00, OK,//0x01 WARNING,//0x02 ALARM,//0x03 }; const qint8 id = 6; static qint8 value = 0; moveWidget(id, LED, 600, 100, 100, 30); QByteArray datagram, data(17,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = LED; memcpy(data.data()+1, &oper1, 1); oper1 = VALUE; memcpy(data.data()+2, &oper1, 1); oper1 = NAME; memcpy(data.data()+3, &oper1, 1); memcpy(data.data()+4, "state of word", 13); sendDatagram(address, remoutePort, data); data.resize(5); oper1 = STATE; memcpy(data.data()+3, &oper1, 1); memcpy(data.data()+4, &value, 1); sendDatagram(address, remoutePort, data); if(++value > 0x03)value = 0; return true; }
void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleIndex) { CircleWidget* circleWidget = CircleWidget::getFromID(circleIndex); if (circleWidget == nullptr) moveWidget(w, s, true); else circleWidget->addFriendWidget(w, s); }
void FriendListWidget::addFriendWidget(FriendWidget* w, Status s, int circleIndex) { CircleWidget* circleWidget = CircleWidget::getFromID(circleIndex); if (circleWidget == nullptr) moveWidget(w, s, true); else circleWidget->addFriendWidget(w, s); connect(w, &FriendWidget::friendWidgetRenamed, this, &FriendListWidget::onFriendWidgetRenamed); }
void ImageWidget::mouseMoveEvent(QMouseEvent *e) { if (!move) return; //QPoint g = e->pos() - point; //point = e->pos(); emit moveWidget(e->pos(), point); }
bool TCore::enterI() { const qint8 id = 10; static bool go = true; if(go) { moveWidget(id, ENTER_INT, 600, 400, 80, 40); //go = false; } return true; }
bool TCore::enterF() { const qint8 id = 4; static bool go = true; if(go) { moveWidget(id, ENTER_FLOAT, 500, 400, 80, 40); //go = false; } return true; }
bool TCore::label_and_move() { const qint8 id = 0; static qint32 move = 0; if(++move > 100)move = 0; moveWidget(id, LABEL, move*10, 100, 100, 30); QByteArray datagram, data(14,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = MainWindow::LABEL; memcpy(data.data()+1, &oper1, 1); oper1 = MainWindow::VALUE; memcpy(data.data()+2, &oper1, 1); memcpy(data.data()+3, "Hello, word!", 11); sendDatagram(address, remoutePort, data); return true; }
bool TCore::dial() { const qint8 id = 7; static qint32 value = 0; moveWidget(id, ANALOG_DIAL, 500, 500, 100, 100); QByteArray datagram, data(7,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = ANALOG_DIAL; memcpy(data.data()+1, &oper1, 1); oper1 = VALUE; memcpy(data.data()+2, &oper1, 1); memcpy(data.data()+3, &value, 4); sendDatagram(address, remoutePort, data); if(++value > 100)value = 0; return true; }
bool TCore::graph() { enum CommandTypes { ADD_KOORD = 0, SETXTITLE, SETYTITLE, }; //graphbody set val const qint8 id = 5; static float t = 0; if(!t) moveWidget(id, GRAPH, 460, 300, 300, 300); t += 0.1; QByteArray data(12,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = GRAPH; memcpy(data.data()+1, &oper1, 1); oper1 = VALUE; memcpy(data.data()+2, &oper1, 1); static qint32 value = 0; oper1 = ADD_KOORD; memcpy(data.data()+3, &oper1, 1); value = 10*t*cos(t); memcpy(data.data()+4, &value, 4); value = 10*t*sin(t); memcpy(data.data()+8, &value, 4); /*value = t; memcpy(data.data()+12, &value, 4); value = cos(t); memcpy(data.data()+16, &value, 4);*/ sendDatagram(address, remoutePort, data); //graphbody set title data.resize(12); oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = GRAPH; memcpy(data.data()+1, &oper1, 1); oper1 = VALUE; memcpy(data.data()+2, &oper1, 1); qint8 oper2 = SETXTITLE; memcpy(data.data()+3, &oper2, 1); memcpy(data.data()+4, "x values", 8); sendDatagram(address, remoutePort, data); return true; }
bool TCore::labelF() { const qint8 id = 1; static float value = 13.5; value += 0.1; moveWidget(id, LABELF, 10, 200, 100, 30); QByteArray datagram, data(7,0); qint8 oper1 = id; memcpy(data.data(), &oper1, 1); oper1 = MainWindow::LABELF; memcpy(data.data()+1, &oper1, 1); oper1 = MainWindow::VALUE; memcpy(data.data()+2, &oper1, 1); memcpy(data.data()+3, &value, 4); sendDatagram(address, remoutePort, data); return true; }
void NcWidgetData::handleMouseMoveEvent( QMouseEvent* event ) { if ( mLeftButtonPressed ) { if ( d->mWidgetResizable && mPressedMousePos.onEdges ) { resizeWidget( event->globalPos() ); } else if ( d->mWidgetMovable ) { moveWidget( event->globalPos() ); } } else if ( d->mWidgetResizable ) { updateCursorShape( event->globalPos() ); } }
void FriendListWidget::dropEvent(QDropEvent* event) { if (event->mimeData()->hasFormat("friend")) { int friendId = event->mimeData()->data("friend").toInt(); Friend* f = FriendList::findFriend(friendId); assert(f != nullptr); FriendWidget* widget = f->getFriendWidget(); assert(widget != nullptr); // Update old circle after moved. CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(f->getToxId())); moveWidget(widget, f->getStatus(), true); if (circleWidget != nullptr) circleWidget->updateStatus(); } }
bool TCore::lcd_label() { enum ControlSymbols { I = 0x01, F,//0x02 HEX,//0x03 }; const qint8 id = 9; QByteArray data(7,0); qint8 oper1 = id; moveWidget(id, LCD_LABEL, 10, 500, 200, 100); memcpy(data.data(), &oper1, 1); oper1 = MainWindow::LCD_LABEL; memcpy(data.data()+1, &oper1, 1); oper1 = MainWindow::VALUE; memcpy(data.data()+2, &oper1, 1); static float value = 13.4; value += 0.4; memcpy(data.data()+3, &value, 4); sendDatagram(address, remoutePort, data); return true; }
void FriendListWidget::dropEvent(QDropEvent* event) { // Check, that the element is dropped from qTox QObject* o = event->source(); FriendWidget* widget = qobject_cast<FriendWidget*>(o); if (!widget) return; // Check, that the user has a friend with the same ToxId ToxId toxId(event->mimeData()->text()); Friend* f = FriendList::findFriend(toxId.getPublicKey()); if (!f) return; // Save CircleWidget before changing the Id int circleId = Settings::getInstance().getFriendCircleID(f->getPublicKey()); CircleWidget* circleWidget = CircleWidget::getFromID(circleId); moveWidget(widget, f->getStatus(), true); if (circleWidget) circleWidget->updateStatus(); }
MainWindow::MainWindow() { settings = new Settings; settings->loadSettings(); //actions manager actionsManager = new ActionsManager(this); //configure the scrollarea scrollArea = new QScrollArea; scrollArea->setBackgroundRole(QPalette::Mid); /*scrollArea->setBackgroundRole(QPalette(QColor(settings->getBackgroundColor().at(0).toInt(), settings->getBackgroundColor().at(1).toInt(), settings->getBackgroundColor().at(2).toInt())));*/ scrollArea->setAlignment(Qt::AlignCenter); scrollArea->setFrameShape(QFrame::NoFrame); setCentralWidget(scrollArea); //create the image widget and make the conections imageWidget = new ImageWidget; scrollArea->setWidget(imageWidget); connect(imageWidget, SIGNAL(couldOpen(bool)), this, SLOT(couldOpen(bool))); connect(imageWidget, SIGNAL(pixmapChanged()), this, SLOT(pixmapChangedSlot())); connect(imageWidget, SIGNAL(moveWidget(QPoint, QPoint)), this, SLOT(moveWidget(QPoint, QPoint))); //the zoom widget zoomWidget = new ZoomWidget; connect(imageWidget, SIGNAL(wheelZoom(int)), this, SLOT(wheelZoom(int))); connect(imageWidget, SIGNAL(picSizeChanged()), this, SLOT(imageTranformated())); connect(zoomWidget, SIGNAL(zoom(double)), imageWidget, SLOT(makeZoom(double))); connect(zoomWidget, SIGNAL(zoom(double)), this, SLOT(updateWindowTitle())); setNameFilters(); createActions(); createMenus(); createToolBar(); imageSetted = false; pixmapChanged = false; //file utils fileUtils = new FileUtils; fileUtils->setNameFilters(nameFilters); connect(fileUtils, SIGNAL(filePathChanged(QString)), this, SLOT(setLastPathUsed(QString))); //add actions to imageWidget, zoomin, zoomout, separator, etc imageWidget->addAction(zoomInAct); imageWidget->addAction(zoomOutAct); //a separator QAction *action1 = new QAction(this); action1->setSeparator(true); imageWidget->addAction(action1); imageWidget->addAction(normalSizeAct); imageWidget->addAction(adjustSizeAct); //another separator QAction *action2 = new QAction(this); action2->setSeparator(true); imageWidget->addAction(action2); imageWidget->addAction(filePropertiesAct); imageWidget->setContextMenuPolicy(Qt::ActionsContextMenu); this->loadSettings(); this->setWindowTitle(tr("EyeSight")); this->setWindowIcon(QIcon::fromTheme("eyesight")); this->showMenuBar(); this->addAction(this->showMenuBarAct); this->addAction(this->configureToolBarAct); this->setContextMenuPolicy(Qt::ActionsContextMenu); }
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, bool _writeableRevealZone, const QList<const ServerInfo_Card *> &cardList) : QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player) { setAcceptHoverEvents(true); setAttribute(Qt::WA_DeleteOnClose); setZValue(2000000006); setFlag(ItemIgnoresTransformations); QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal); titleLabel = new TitleLabel; connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF))); closeButton = new QPushButton("X"); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget; closeButtonProxy->setWidget(closeButton); hbox->addItem(titleLabel); hbox->addItem(closeButtonProxy); QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical); vbox->addItem(hbox); if (numberCards < 0) { QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget; sortByNameProxy->setWidget(&sortByNameCheckBox); vbox->addItem(sortByNameProxy); QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget; sortByTypeProxy->setWidget(&sortByTypeCheckBox); vbox->addItem(sortByTypeProxy); QGraphicsProxyWidget *lineProxy = new QGraphicsProxyWidget; QFrame *line = new QFrame; line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); lineProxy->setWidget(line); vbox->addItem(lineProxy); QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget; pileViewProxy->setWidget(&pileViewCheckBox); vbox->addItem(pileViewProxy); } if (_origZone->getIsShufflable() && (numberCards == -1)) { shuffleCheckBox.setChecked(settingsCache->getZoneViewShuffle()); QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget; shuffleProxy->setWidget(&shuffleCheckBox); vbox->addItem(shuffleProxy); } extraHeight = vbox->sizeHint(Qt::PreferredSize).height(); resize(150, 150); QGraphicsLinearLayout *zoneHBox = new QGraphicsLinearLayout(Qt::Horizontal); zoneContainer = new QGraphicsWidget(this); zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); zoneContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape); zoneHBox->addItem(zoneContainer); scrollBar = new QScrollBar(Qt::Vertical); scrollBar->setMinimum(0); scrollBar->setSingleStep(50); connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(handleScrollBarChange(int))); QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget; scrollBarProxy->setWidget(scrollBar); zoneHBox->addItem(scrollBarProxy); vbox->addItem(zoneHBox); zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer); connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this, SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *))); // numberCard is the num of cards we want to reveal from an area. Ex: scry the top 3 cards. // If the number is < 0 then it means that we can make the area sorted and we dont care about the order. if (numberCards < 0) { connect(&sortByNameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByName(int))); connect(&sortByTypeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByType(int))); connect(&pileViewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSetPileView(int))); sortByNameCheckBox.setChecked(settingsCache->getZoneViewSortByName()); sortByTypeCheckBox.setChecked(settingsCache->getZoneViewSortByType()); pileViewCheckBox.setChecked(settingsCache->getZoneViewPileView()); if (!settingsCache->getZoneViewSortByType()) pileViewCheckBox.setEnabled(false); }
void KCommonDecoration::updateLayout() const { QRect r = widget()->rect(); int r_x, r_y, r_x2, r_y2; r.coords(&r_x, &r_y, &r_x2, &r_y2); // layout preview widget if (m_previewWidget) { const int borderLeft = layoutMetric(LM_BorderLeft); const int borderRight = layoutMetric(LM_BorderRight); const int borderBottom = layoutMetric(LM_BorderBottom); const int titleHeight = layoutMetric(LM_TitleHeight); const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop); const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom); int left = r_x+borderLeft; int top = r_y+titleEdgeTop+titleHeight+titleEdgeBottom; int width = r_x2-borderRight-left+1; int height = r_y2-borderBottom-top+1; m_previewWidget->setGeometry(left, top, width, height); moveWidget(left,top, m_previewWidget); resizeWidget(width, height, m_previewWidget); } // resize buttons... for (int n=0; n<NumButtons; n++) { if (m_button[n]) { QSize newSize = QSize(layoutMetric(LM_ButtonWidth, true, m_button[n]), layoutMetric(LM_ButtonHeight, true, m_button[n]) ); if (newSize != m_button[n]->size() ) m_button[n]->setSize(newSize); } } // layout buttons int y = r_y + layoutMetric(LM_TitleEdgeTop) + layoutMetric(LM_ButtonMarginTop); if (m_buttonsLeft.count() > 0) { const int buttonSpacing = layoutMetric(LM_ButtonSpacing); int x = r_x + layoutMetric(LM_TitleEdgeLeft); for (ButtonContainer::const_iterator it = m_buttonsLeft.begin(); it != m_buttonsLeft.end(); ++it) { bool elementLayouted = false; if (*it) { if (!(*it)->isHidden() ) { moveWidget(x,y, *it); x += layoutMetric(LM_ButtonWidth, true, ::qt_cast<KCommonDecorationButton*>(*it) ); elementLayouted = true; } } else { x+= layoutMetric(LM_ExplicitButtonSpacer); elementLayouted = true; } if (elementLayouted && it != m_buttonsLeft.end() ) x += buttonSpacing; } } if (m_buttonsRight.count() > 0) { const int titleEdgeRightLeft = r_x2-layoutMetric(LM_TitleEdgeRight)+1; const int buttonSpacing = layoutMetric(LM_ButtonSpacing); int x = titleEdgeRightLeft - buttonContainerWidth(m_buttonsRight); for (ButtonContainer::const_iterator it = m_buttonsRight.begin(); it != m_buttonsRight.end(); ++it) { bool elementLayouted = false; if (*it) { if (!(*it)->isHidden() ) { moveWidget(x,y, *it); x += layoutMetric(LM_ButtonWidth, true, ::qt_cast<KCommonDecorationButton*>(*it) );; elementLayouted = true; } } else { x += layoutMetric(LM_ExplicitButtonSpacer); elementLayouted = true; } if (elementLayouted && it != m_buttonsRight.end() ) x += buttonSpacing; } } }
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, const QList<ServerInfo_Card *> &cardList) : QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player) { setAcceptHoverEvents(true); setAttribute(Qt::WA_DeleteOnClose); setZValue(2000000006); setFlag(ItemIgnoresTransformations); QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal); titleLabel = new TitleLabel; connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF))); closeButton = new QPushButton("X"); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget; closeButtonProxy->setWidget(closeButton); hbox->addItem(titleLabel); hbox->addItem(closeButtonProxy); QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical); vbox->addItem(hbox); if (numberCards < 0) { sortByNameCheckBox = new QCheckBox; QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget; sortByNameProxy->setWidget(sortByNameCheckBox); vbox->addItem(sortByNameProxy); sortByTypeCheckBox = new QCheckBox; QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget; sortByTypeProxy->setWidget(sortByTypeCheckBox); vbox->addItem(sortByTypeProxy); } else { sortByNameCheckBox = 0; sortByTypeCheckBox = 0; } if (_origZone->getIsShufflable() && (numberCards == -1)) { shuffleCheckBox = new QCheckBox; shuffleCheckBox->setChecked(true); QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget; shuffleProxy->setWidget(shuffleCheckBox); vbox->addItem(shuffleProxy); } else shuffleCheckBox = 0; extraHeight = vbox->sizeHint(Qt::PreferredSize).height(); resize(150, 150); zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, this); vbox->addItem(zone); if (sortByNameCheckBox) { connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int))); connect(sortByTypeCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByType(int))); sortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName()); sortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType()); } retranslateUi(); setLayout(vbox); connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents())); connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted())); zone->initializeCards(cardList); }