Calculator::Calculator(QWidget *parent) : Popup(parent) { VIEW.calculator = this; this->setFixedSize(250, 300); QGridLayout* layout = new QGridLayout(this); QLabel* label = new QLabel(this); sum = new QLineEdit(this); QPushButton* validate = new QPushButton(this); QPushButton* cancel = new QPushButton(this); buttonsFrame = new QFrame(this); buttonsLayout = new QGridLayout(buttonsFrame); buttons = new QPushButton*[CALCULATOR_BUTTONS]; for(int i=0 ; i < CALCULATOR_BUTTONS ; i++) buttons[i] = new QPushButton(buttonsFrame); layout->addWidget(label, 0,0, 1, 2, Qt::AlignCenter); layout->addWidget(buttonsFrame, 1,0,1,2, Qt::AlignCenter); layout->addWidget(sum, 2,0, 1, 2, Qt::AlignCenter); layout->addWidget(validate, 3,0); layout->addWidget(cancel, 3,1); this->setLayout(layout); label->setText("Tapez une valeur. Ex : 9.5 ajoutera 9.5€ au compte, -14 retirera 14€"); label->setWordWrap(true); validate->setText("Valider"); cancel->setText("Annuler"); QObject::connect(validate, SIGNAL(clicked()), this, SLOT(validate())); QObject::connect(cancel, SIGNAL(clicked()), this, SLOT(cancel())); // ####### BUTTONS OF CALCULATOR ####### for( int i=0 ; i < 12 ; i++) { buttonsLayout->addWidget(buttons[i], i/3, i%3, 1, 1, Qt::AlignCenter); QObject::connect(buttons[i], SIGNAL(clicked()), this, SLOT(buttonPushed())); if(i < 10) buttons[i]->setText(QString::number((i+1)%10)); else if(i == 10) buttons[i]->setText("."); else if(i == 11) buttons[i]->setText("-"); } buttonsLayout->addWidget(buttons[12], 3, 3, 1, 1, Qt::AlignCenter);// AC QObject::connect(buttons[12], SIGNAL(clicked()), this, SLOT(buttonPushed())); buttons[12]->setText("AC"); buttonsFrame->setLayout(buttonsLayout); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { label = new QLabel("0", this); label -> setGeometry(QRect(QPoint(50,70),QSize(250,50))); label->setStyleSheet("background-color: rgb(221,160,221); font: bold 14px;"); label->setAlignment(Qt::AlignCenter); for(int i =0; i<10; i++){ QString operations[] = {"C","=","+","-","*","/","^","root","sqrt","+-"}; operationButton[i] = new QPushButton(operations[i],this); if(i == 1){ connect(operationButton[i],SIGNAL(released()),this, SLOT(equals())); } else if(i == 9){ connect(operationButton[i],SIGNAL(released()),this, SLOT(signf())); } else{ connect(operationButton[i],SIGNAL(released()),this, SLOT(operationPushed())); } } for(int i =0; i<10; i++){ QString digit = QString::number(i); buttons[i] = new QPushButton(digit,this); connect(buttons[i],SIGNAL(released()),this, SLOT(buttonPushed())); } setGeo(); }
item_template_selecter_button::item_template_selecter_button(QSqlDatabase &db, dbccache * c) : QObject(), db(db) { widget = new QPushButton(); widget->setText("Item Template..."); QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); dialog = new item_template_selecter_dialog{db,c}; }
itemextendedcost_selecter::itemextendedcost_selecter(dbcache * c) : QObject(), m_dbcache(c) { widget = new QPushButton(); widget->setText("Extended Cost..."); selected = -1; dialog = new itemextendedcost_dialog{m_dbcache}; QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); }
disenchant_loot_selecter::disenchant_loot_selecter(dbcache * c) : QObject(), m_dbcache(c) { widget = new QPushButton(); widget->setText("Disenchant Loot..."); dialog = new disenchant_loot_dialog{m_dbcache}; selected = -1; QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); }
lock_selecter::lock_selecter(dbcache * c) : QObject(), m_dbcache(c) { widget = new QPushButton(); widget->setText("Lock..."); dialog = new lock_dialog{m_dbcache}; selected = -1; QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); }
gossip_menu_selecter::gossip_menu_selecter(dbcache *c) : QObject(), m_dbcache(c) { widget = new QPushButton(); widget->setText("Gossip..."); selected = -1; dialog = new gossip_menu_dialog{m_dbcache}; QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); }
creature_loot_selecter::creature_loot_selecter(dbcache * c) : QObject(), m_dbcache(c) { widget = new QPushButton(); widget->setText("Creature Loot..."); widget->setDisabled(true); dialog = new creature_loot_dialog(m_dbcache); selected = -1; QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); QObject::connect(dialog,SIGNAL(initialized()),this,SLOT(enable())); QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { title = new QLabel("Calculator",this); title -> setGeometry(QRect(QPoint(100,25),QSize(200,50))); label = new QLabel("0",this); label -> setGeometry(QRect(QPoint(50,50),QSize(200,50))); QString inStr = "Input Path"; inputPath = new QLineEdit(inStr,this); inputPath -> setGeometry(QRect(QPoint(25,375),QSize(250,50))); inputPath -> hide(); QString outStr = "Output Path"; outputPath = new QLineEdit(outStr,this); outputPath -> setGeometry(QRect(QPoint(25,450),QSize(250,50))); outputPath -> hide(); submitButton = new QPushButton("Submit",this); connect(submitButton,SIGNAL(released()),this,SLOT(submitPath())); submitButton -> setGeometry(QRect(QPoint(100,525),QSize(100,50))); submitButton -> hide(); filePath = new QPushButton("Open",this); connect(filePath,SIGNAL(released()),this,SLOT(fileOpeAppear())); hideFilePath = new QPushButton("Close",this); connect(hideFilePath,SIGNAL(released()),this,SLOT(fileOpeDisappear())); backspace = new QPushButton("backspace",this); connect(backspace,SIGNAL(released()),this,SLOT(BackSpace())); operationButton[0] = new QPushButton("=",this); connect(operationButton[0],SIGNAL(released()),this,SLOT(equals())); operationButton[1] = new QPushButton("Esc",this); connect(operationButton[1],SIGNAL(released()),this,SLOT(clear())); for (int i = 2; i<10; i++) { QString operations[] = {"=","ESC","+","-","×","÷","(",")",".","^"}; operationButton[i] = new QPushButton(operations[i],this); connect(operationButton[i],SIGNAL(released()),this,SLOT(operationPushed())); } for (int i = 0; i<10; i++) { QString digit = QString::number(i); buttons[i] = new QPushButton(digit,this); connect(buttons[i],SIGNAL(released()),this,SLOT(buttonPushed())); } setGeo(); }
DownloadView::DownloadView(QWidget *parent) : QWidget(parent) { QBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); bar = new THBlackBar(this); QAction *action = new QAction(tr("Downloads"), this); bar->addAction(action); layout->addWidget(bar); listView = new DownloadListView(this); #ifdef APP_MAC listView->setAlternatingRowColors(true); #endif /* QPalette p = listView->palette(); p.setColor(QPalette::Base, palette().color(QPalette::Window)); listView->setPalette(p); */ PrettyItemDelegate *delegate = new PrettyItemDelegate(this, true); listView->setItemDelegate(delegate); listView->setSelectionMode(QAbstractItemView::NoSelection); // cosmetics listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); listView->setFrameShape(QFrame::NoFrame); listView->setAttribute(Qt::WA_MacShowFocusRect, false); listView->setMinimumSize(320,240); listView->setUniformItemSizes(true); listModel = DownloadManager::instance()->getModel(); listView->setModel(listModel); connect(listView, SIGNAL(downloadButtonPushed(QModelIndex)), SLOT(buttonPushed(QModelIndex))); connect(listView, SIGNAL(entered(const QModelIndex &)), SLOT(itemEntered(const QModelIndex &))); layout->addWidget(listView); updateTimer = new QTimer(this); updateTimer->setInterval(1000); connect(updateTimer, SIGNAL(timeout()), listModel, SLOT(sendReset())); downloadSettings = new DownloadSettings(this); layout->addWidget(downloadSettings); }
item_random_property_selecter::item_random_property_selecter(dbcache * c, bool suffix) : QObject(), m_dbcache(c), m_suffix(suffix) { widget = new QPushButton(); if(!suffix) { widget->setText("Random Property..."); } else { widget->setText("Random Suffix..."); } dialog = new item_random_property_dialog(m_dbcache,m_suffix); selected = -1; QObject::connect(widget,SIGNAL(clicked()),this,SLOT(buttonPushed())); QObject::connect(dialog,SIGNAL(clear()),this,SLOT(clear())); }
void PeriodicTable::connectSignals() { bool ok; QString name; unsigned int atomicNumber; QList<QPushButton*> elements(findChildren<QPushButton*>()); QList<QPushButton*>::iterator iter; for (iter = elements.begin(); iter != elements.end(); ++iter) { connect(*iter, SIGNAL(clicked()), this, SLOT(buttonPushed())); name = (*iter)->objectName(); name.remove(QRegExp("element_")); atomicNumber = name.toUInt(&ok); if (ok) { name = QString(OpenBabel::etab.GetName(atomicNumber).c_str()); (*iter)->setToolTip(QString::number(atomicNumber) + " " + name); } } }
creature_template_selecter_button::creature_template_selecter_button(QSqlDatabase &db, dbccache * c, bool clearBtn) : QObject(), db(db) { widget = new QWidget{}; widget->setLayout(new QHBoxLayout{}); widget->layout()->setContentsMargins(0,0,0,0); button = new QPushButton{}; widget->layout()->addWidget(button); if(clearBtn) { clr = new QPushButton{".."}; clr->setMaximumWidth(20); widget->layout()->addWidget(clr); QObject::connect(clr,SIGNAL(clicked()),this,SLOT(clear())); } button->setText("Creature Template..."); selected = -1; QObject::connect(button,SIGNAL(clicked()),this,SLOT(buttonPushed())); // initialize the dialog dialog = new creature_template_selecter_dialog{db, c}; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { label = new QLabel("0", this); label->setGeometry(QRect(QPoint(4 * cell_size, cell_size), QSize(4 * cell_size, cell_size))); for (size_t i = 0; i < sizeof(operations)/sizeof(QPushButton *); i++) { QString oper[] = {"C", "=", "+", "-", "*", "/"}; operations[i] = new QPushButton(oper[i], this); if (oper[i] == "="){ connect(operations[i], SIGNAL(released()), this, SLOT(equals())); }else{ connect(operations[i], SIGNAL(released()), this, SLOT(operationPushed())); } } for (size_t i = 0; i < sizeof(buttons)/sizeof(QPushButton *); i++) { QString digit = QString::number(i); buttons[i] = new QPushButton(digit, this); connect(buttons[i], SIGNAL(released()), this, SLOT(buttonPushed())); } setGeo(); }
void clientWid1::sendButtonPushed() { emit buttonPushed(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { label = new QLabel("0", this); label -> setGeometry(QRect(QPoint(75,25),QSize(50,200))); clear_button = new QPushButton("C", this); clear_button -> setGeometry(QRect(QPoint(100,300),QSize(50,50))); connect(clear_button, SIGNAL(released()), this,SLOT(clear())); equals_button = new QPushButton("=", this); equals_button -> setGeometry(QRect(QPoint(150,300),QSize(50,50))); connect(equals_button, SIGNAL(released()), this,SLOT(equals())); add_button = new QPushButton("+", this); add_button -> setGeometry(QRect(QPoint(200,150),QSize(50,50))); connect(add_button, SIGNAL(released()), this,SLOT(add())); subtract_button = new QPushButton("-", this); subtract_button -> setGeometry(QRect(QPoint(200,200),QSize(50,50))); connect(subtract_button, SIGNAL(released()), this,SLOT(subtract())); multiply_button = new QPushButton("X", this); multiply_button -> setGeometry(QRect(QPoint(200,250),QSize(50,50))); connect(multiply_button, SIGNAL(released()), this,SLOT(multiply())); divide_button = new QPushButton(":", this); divide_button -> setGeometry(QRect(QPoint(200,300),QSize(50,50))); connect(divide_button, SIGNAL(released()), this,SLOT(divide())); sin_button = new QPushButton("sin", this); sin_button -> setGeometry(QRect(QPoint(250,150),QSize(50,50))); connect(sin_button, SIGNAL(released()), this,SLOT(sin())); cos_button = new QPushButton("cos", this); cos_button -> setGeometry(QRect(QPoint(250,200),QSize(50,50))); connect(cos_button, SIGNAL(released()), this,SLOT(cos())); tan_button = new QPushButton("tan", this); tan_button -> setGeometry(QRect(QPoint(250,250),QSize(50,50))); connect(tan_button, SIGNAL(released()), this,SLOT(tan())); sqrt_button = new QPushButton("sqrt", this); sqrt_button -> setGeometry(QRect(QPoint(250,300),QSize(50,50))); connect(sqrt_button, SIGNAL(released()), this,SLOT( sqrt())); pow_button = new QPushButton("^2", this); pow_button -> setGeometry(QRect(QPoint(250,350),QSize(50,50))); connect(pow_button, SIGNAL(released()), this,SLOT(pow())); cubic_button = new QPushButton("^3", this); cubic_button -> setGeometry(QRect(QPoint(200,350),QSize(50,50))); connect(cubic_button, SIGNAL(released()), this,SLOT(cubic())); exp_button = new QPushButton("exp", this); exp_button -> setGeometry(QRect(QPoint(150,350),QSize(50,50))); connect(exp_button, SIGNAL(released()), this,SLOT(exp())); ln_button = new QPushButton("ln", this); ln_button -> setGeometry(QRect(QPoint(100,350),QSize(50,50))); connect(ln_button, SIGNAL(released()), this,SLOT(ln())); for(int i=0; i<10; i++){ QString digit = QString::number(i); buttons[i] = new QPushButton(digit, this); connect(buttons[i], SIGNAL(released()), this,SLOT(buttonPushed())); } setGeo(); }
void dma_main(void){ #else void main(void){ #endif DMA_DESC dmaChannel; char sourceString[56] = "This is a test string used to demonstrate DMA transfer."; //56 bytes char destString[56]; INT8 i; INT8 errors = 0; initDma(); //Clearing the destination memset(destString,0,sizeof(destString)); // Setting up the DMA channel. SET_WORD(dmaChannel.SRCADDRH, dmaChannel.SRCADDRL, &sourceString); // The start address of the data to be transmitted SET_WORD(dmaChannel.DESTADDRH, dmaChannel.DESTADDRL, &destString); // The start address of the destination. SET_WORD(dmaChannel.LENH, dmaChannel.LENL, sizeof(sourceString)); // Setting the number of bytes to transfer. dmaChannel.VLEN = VLEN_USE_LEN; // Using the length field to determine how many bytes to transfer. dmaChannel.PRIORITY = PRI_HIGH; // High priority. dmaChannel.M8 = M8_USE_8_BITS; // Irrelevant since length is determined by the LENH and LENL. dmaChannel.IRQMASK = FALSE; // The DMA shall not issue an IRQ upon completion. dmaChannel.DESTINC = DESTINC_1; // The destination address is to be incremented by 1 after each transfer. dmaChannel.SRCINC = SRCINC_1; // The source address inremented by 1 byte after each transfer. dmaChannel.TRIG = DMATRIG_NONE; // The DMA channel will be started manually. dmaChannel.TMODE = TMODE_BLOCK; // The number of bytes specified by LENH and LENL is transferred. dmaChannel.WORDSIZE = WORDSIZE_BYTE; // One byte is transferred each time. // Using DMA channel 0. // Setting where the DMA channel is to read the desciptor and arming the DMA channel. DMA_SET_ADDR_DESC0(&dmaChannel); DMA_ABORT_CHANNEL(0); DMA_ARM_CHANNEL(0); //Waiting for the user to start the transfer. lcdUpdate((char*)"Press S1",(char*)"to start DMA."); while(!buttonPushed()); // Clearing all DMA complete flags and starting the transfer. DMAIRQ = 0x00; DMA_START_CHANNEL(0); // Waiting for the DMA to finish. while(!(DMAIRQ & DMA_CHANNEL_0)); // Verifying that data is transferred correctly for(i=0;i<sizeof(sourceString);i++) { if(sourceString[i] != destString[i]) errors++; } //Displaying the result if(errors == 0) {lcdUpdate((char*)"Dma transfer",(char*)"correct!");} else {lcdUpdate((char*)"Error in DMA",(char*)"Transfer");} haltApplicationWithLED(); return; }