void PatternView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "piano" ), tr( "Open in piano-roll" ), _cm ); _cm->insertAction( _cm->actions()[0], a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInPianoRoll() ) ); _cm->insertSeparator( _cm->actions()[1] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), tr( "Clear all notes" ), m_pat, SLOT( clear() ) ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), this, SLOT( resetName() ) ); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), this, SLOT( changeName() ) ); if ( m_pat->type() == Pattern::BeatPattern ) { _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "step_btn_add" ), tr( "Add steps" ), m_pat, SLOT( addSteps() ) ); _cm->addAction( embed::getIconPixmap( "step_btn_remove" ), tr( "Remove steps" ), m_pat, SLOT( removeSteps() ) ); } }
int conectar(Peer** peer) { char ip[16]; int porta; char nome[16]; printf("Digite o ip: "); rewind(stdin); scanf("%s", ip); printf("Digite a porta: "); rewind(stdin); scanf("%d", &porta); printf("Digite seu nickname: "); rewind(stdin); fgets(nome, 16, stdin); nome[strlen(nome)-1] = 0; printf("\nConectando...\n"); *peer = startup(ip, porta); if(*peer) { printf("k.\n"); changeName(*peer, nome, strlen(nome)); } return (*peer) != NULL; }
YaoJiang::YaoJiang(QWidget *parent) : QDialog(parent), ui(new Ui::YaoJiang) { /* 随机种子 */ qsrand(QTime::currentTime().msec()); ind=-1; ui->setupUi(this); names[0]="lili"; names[1]="beibei"; names[2]="xiaoxue"; names[3]="qiqi"; names[4]="feifei"; timer=new QTimer(this); timer->setInterval(200); timer->start(); paintFlag=false; /* 使用定时器控制 重画 */ connect(timer,SIGNAL(timeout()), this,SLOT(repaint())); connect(timer,SIGNAL(timeout()), this,SLOT(changeName())); /* 绑定两个按钮到槽函数 */ connect(ui->bstart,SIGNAL(clicked()), this,SLOT(changePaintFlag())); connect(ui->bstop,SIGNAL(clicked()), this,SLOT(changePaintFlag())); }
void btEditorNodeType::disconnectChangeProperty() { disconnect(m_sender, SIGNAL(propertyChanged(QString, QVariant)), this, SLOT(changeProperty(QString, QVariant))); disconnect(m_sender, SIGNAL(propertyDescriptionChanged(QString, QString, QString)), this, SLOT(changePropertyDescription(QString,QString, QString))); disconnect(m_sender, SIGNAL(nameChanged(QString)), this, SLOT(changeName(QString))); disconnect(m_sender, SIGNAL(descriptionChanged(QString)), this, SLOT(changeDescription(QString))); disconnect(m_sender, SIGNAL(classNameChanged(QString)), this, SLOT(changeClassName(QString))); }
ComputerPlayer::ComputerPlayer() : Player("CPU") { m_ePlayerDifficulty = PlayerDifficultyEasy; //Just for the fun of it - create a random name switch (rand()%10) { case 0: changeName("Walter White"); break; case 1: changeName("Jesse Pinkman"); break; case 2: changeName("Gustavo Fring"); break; case 3: changeName("Hector Salamanca"); break; case 4: changeName("Daryl Dixon"); break; case 5: changeName("Rick Grimes"); break; case 6: changeName("Darth Vader"); break; case 7: changeName("Francis Underwood"); break; case 8: changeName("Hank Schrader"); break; case 9: changeName("Saul Goodman"); break; } }
void ContextMenu::rename() { QInputDialog* inputDialog = new QInputDialog(); inputDialog->setOptions(QInputDialog::NoButtons); QString oldName = getNearestPointName(_lastPosImage); QString newName = inputDialog->getText(NULL, tr("Rename"), tr("Point name:"), QLineEdit::Normal, oldName); if (!newName.isEmpty() && (newName != oldName)) emit changeName(oldName, newName); }
void Sphere::apply() { changeName(m_Dlg.ui.name_edit->text()); vec3_t x = getVector(m_Dlg.ui.x); double slider_value = double(m_Dlg.ui.slider->value()); double slider_max = double(m_Dlg.ui.slider->maxValue()); float r1 = m_Dlg.ui.rmin->text().toFloat(); float r2 = m_Dlg.ui.rmax->text().toFloat(); float r = r1 + (slider_value/slider_max)*(r2-r1); vtk->SetCenter(x[0],x[1],x[2]); vtk->SetRadius(r); m_Ws->render(); }
void VNSocket::createContextMenu() { contextMenu = new QMenu; QAction *changeNameAction = contextMenu->addAction("Rename Socket"); QAction *changeTypeAction = contextMenu->addAction("change Type"); // QAction *changeArrayAction = contextMenu->addAction("Array"); // changeArrayAction->setCheckable(true); // changeArrayAction->setChecked(data->isArray()); connect(changeNameAction, SIGNAL(triggered()), this, SLOT(changeName())); connect(changeTypeAction, SIGNAL(triggered()), this, SLOT(changeType())); // connect(changeArrayAction, SIGNAL(triggered()), this, SLOT(setArray())); }
void AutomationPatternView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "automation" ), tr( "Open in Automation editor" ), _cm ); _cm->insertAction( _cm->actions()[0], a ); connect(a, SIGNAL(triggered()), this, SLOT(openInAutomationEditor())); _cm->insertSeparator( _cm->actions()[1] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), tr( "Clear" ), m_pat, SLOT( clear() ) ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), this, SLOT( resetName() ) ); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), this, SLOT( changeName() ) ); _cm->addAction( embed::getIconPixmap( "record" ), tr( "Set/clear record" ), this, SLOT( toggleRecording() ) ); _cm->addAction( embed::getIconPixmap( "flip_y" ), tr( "Flip Vertically (Visible)" ), this, SLOT( flipY() ) ); _cm->addAction( embed::getIconPixmap( "flip_x" ), tr( "Flip Horizontally (Visible)" ), this, SLOT( flipX() ) ); if( !m_pat->m_objects.isEmpty() ) { _cm->addSeparator(); QMenu * m = new QMenu( tr( "%1 Connections" ). arg( m_pat->m_objects.count() ), _cm ); for( AutomationPattern::objectVector::iterator it = m_pat->m_objects.begin(); it != m_pat->m_objects.end(); ++it ) { if( *it ) { a = new QAction( tr( "Disconnect \"%1\"" ). arg( ( *it )->fullDisplayName() ), m ); a->setData( ( *it )->id() ); m->addAction( a ); } } connect( m, SIGNAL( triggered( QAction * ) ), this, SLOT( disconnectObject( QAction * ) ) ); _cm->addMenu( m ); }
void UnstructuredGridReader::apply() { changeName(m_Dlg.ui.name_edit->text()); QString file_name = m_Dlg.ui.file_label->text(); if (file_name.size() >= 4) { if (file_name.right(4) == ".vtu") { m_UseXml = true; m_Xml->SetFileName(qPrintable(file_name)); } else { m_UseXml = false; m_Vtk->SetFileName(qPrintable(file_name)); } } m_Ws->render(); }
void patternView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "piano" ), tr( "Open in piano-roll" ), _cm ); _cm->insertAction( _cm->actions()[0], a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInPianoRoll() ) ); _cm->insertSeparator( _cm->actions()[1] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "edit_erase" ), tr( "Clear all notes" ), m_pat, SLOT( clear() ) ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), this, SLOT( resetName() ) ); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), this, SLOT( changeName() ) ); _cm->addSeparator(); bool freeze_separator = false; if( !( m_pat->m_instrumentTrack->isMuted() || m_pat->isMuted() ) ) { _cm->addAction( embed::getIconPixmap( "freeze" ), m_pat->m_frozenPattern ? tr( "Refreeze" ) : tr( "Freeze" ), m_pat, SLOT( freeze() ) ); freeze_separator = true; } if( m_pat->m_frozenPattern ) { _cm->addAction( embed::getIconPixmap( "unfreeze" ), tr( "Unfreeze" ), m_pat, SLOT( unfreeze() ) ); freeze_separator = true; } if( freeze_separator ) { _cm->addSeparator(); } _cm->addAction( embed::getIconPixmap( "step_btn_add" ), tr( "Add steps" ), m_pat, SLOT( addSteps() ) ); _cm->addAction( embed::getIconPixmap( "step_btn_remove" ), tr( "Remove steps" ), m_pat, SLOT( removeSteps() ) ); }
void bbTCOView::constructContextMenu( QMenu * _cm ) { QAction * a = new QAction( embed::getIconPixmap( "bb_track" ), tr( "Open in Beat+Bassline-Editor" ), _cm ); _cm->insertAction( _cm->actions()[0], a ); connect( a, SIGNAL( triggered( bool ) ), this, SLOT( openInBBEditor() ) ); _cm->insertSeparator( _cm->actions()[1] ); _cm->addSeparator(); _cm->addAction( embed::getIconPixmap( "reload" ), tr( "Reset name" ), this, SLOT( resetName() ) ); _cm->addAction( embed::getIconPixmap( "edit_rename" ), tr( "Change name" ), this, SLOT( changeName() ) ); _cm->addAction( embed::getIconPixmap( "colorize" ), tr( "Change color" ), this, SLOT( changeColor() ) ); }
Client::Client(const string& newName, const string& ipaddress, int port) { if(ConnectToHost(port,ipaddress.length()<=1?"127.0.0.1":ipaddress.c_str())){ success=true; string welcomeMsg; if(receiveText(welcomeMsg)){ stringstream ss(""); ss<<"Client connected to: "<<welcomeMsg<<" ,IP: "<<ipaddress<<" [port: "<<port<<"]"; wiBackLog::post(ss.str().c_str()); changeName(newName); serverName=welcomeMsg; } } else{ success=false; stringstream ss(""); ss<<"Connecting to server on address: "<<ipaddress<< " [port "<<port<<"] FAILED with: "<<WSAGetLastError(); wiBackLog::post(ss.str().c_str()); } }
// Overloading () operator. The function takes in an EXPRESSION // as parameter and then calls the function associated with the // COMMAND specified by the EXPRESSION. The function returns // the output of calling those functions, which usually is an informative // message about the status of performing the specific action. // Expressions are strings, and need to be parsed in order to retrieve // the COMMAND to be excuted. Essentially a functor std::string IRCCommandHandler::operator()(std::string exp) { expression = exp; parse(); // Parsing function that gets the command from the EXPRESSION FILE_LOG(logDEBUG) << "Command = " << command; FILE_LOG(logDEBUG) << "Attempting to run COMMAND..."; std::string result; // Calling functions associated with an EXPRESSION's COMMAND if (command == "MSG") result = message(); else if (command == "CONNECT") result = connect(); else if (command == "CONNECT") result = disconnect(); else if (command == "CREATECHANNEL") result = createChannel(); else if (command == "GETCHANNELS") result = getChannels(); else if (command == "JOINCHANNEL") result = joinChannel(); else if (command == "PING") result = ping(); else if (command == "CHANGENAME") result = changeName(); else result = "Invalid IRC Command '" + command + "'"; return result; }
int main(int argc, char const *argv[]) { if (argc == 1) { printf("ERROR: the program takes one argument\n"); return 0; } argv[1]; FILE *input = fopen(argv[1], "r"); Book *book = createBook(); readBookFromFile(input, book); fclose(input); sh_fileName = argv[1]; sh_book = book; signal(SIGINT, signal_handler); char command[10]; char *name = NULL; //(char *) malloc(sizeof(char)*80); char *number = NULL; // (char *) malloc(sizeof(char)*80); char *str = NULL; //(char *) malloc(80); bool corName; bool corNumber; while (true) { corName = true; corNumber = true; scanf("%s", command); if(!strcmp(command, "debprint")) { fullPrint(book); } else if(!strcmp(command, "print")) { printBook(stdout, book); } else if(!strcmp(command, "find")) { str = read(stdin); printFound(stdout, book, str); free(str); } else if(!strcmp(command, "create")) { name = read(stdin); number = read(stdin); corName = correctName(name); corNumber = correctNumber(number); if (correctName && correctNumber) { appendBook(book, name, number); } free(name); free(number); } else if(!strcmp(command, "delete")) { int id; scanf("%d", &id); removeContact(book, id); } else if(!strcmp(command, "change")) { int id; scanf("%d%s", &id, command); str = read(stdin); if(!strcmp(command, "number")) { corName = correctName(str); if (corName) changeNumber(book, id, str); } else if (!strcmp(command, "name")) { corNumber = correctNumber(str); if (corNumber) changeName(book, id, str); } else { printf("ERROR: Expected \"name\" or \"number\" after id in the command change\n"); } free(str); } else if(!strcmp(command, "exit")) { FILE* output = fopen(argv[1], "w"); printBook(output, book); fclose(output); deleteBook(book); break; } else { printf("ERROR: Unknown command %s\n", command); } if (!corName) { printf("ERROR: Invalid name\n"); } if (!corNumber) { printf("ERROR: Invalid number\n"); } } return 0; }
void TrayMenu::addTorrent(RTorrent * torrent) { no_torrent->setVisible(false); InfoAction * action = 0; QWidgetAction * waction = 0; QMenu * tmenu = new QMenu(menu); tmenu->setTitle(tr("Loading...")); //Add caption QLabel * lbl = new QLabel(tr("<b>Torrent's info</b>")); lbl->setAlignment(Qt::AlignHCenter); waction = new QWidgetAction(tmenu); waction->setDefaultWidget(lbl); tmenu->addAction(waction); connect(torrent,SIGNAL(changeName(QString)), this,SLOT(changeName(QString))); //Add rate status action = new InfoAction(tmenu); action->setText(tr("%1, %2")); action->setText1(tr("UP: %1 kb/s")); action->setText2(tr("DOWN: %1 kb/s")); action->setParam1(tr("N/A")); action->setParam2(tr("N/A")); action->setIcon(QIcon(":/img/updown.png")); connect(torrent,SIGNAL(changeDownRate(double)), action,SLOT(setParam2(double))); connect(torrent,SIGNAL(changeUpRate(double)), action,SLOT(setParam1(double))); tmenu->addAction(action); //Add rateio status action = new InfoAction(tmenu); action->setText(tr("%1")); action->setText1(tr("Rateio: %1")); action->setParam1(tr("N/A")); connect(torrent,SIGNAL(changeRatio(double)), action,SLOT(setParam1(double))); tmenu->addAction(action); //Add progress QProgressBar * bar = new QProgressBar(tmenu); bar->setAlignment(Qt::AlignHCenter); waction = new QWidgetAction(tmenu); waction->setDefaultWidget(bar); tmenu->addAction(waction); connect(torrent,SIGNAL(changeCompletedChunks(int)), bar,SLOT(setValue(int))); connect(torrent,SIGNAL(changeSizeChunks(int)), bar,SLOT(setMaximum(int))); connect(torrent,SIGNAL(changeCompletedChunks(int)), this,SLOT(changeCompletedChunks(int))); //Add priority QComboBox * combo = new QComboBox(tmenu); combo->addItem(QIcon(),tr("Idle")); combo->addItem(QIcon(),tr("Low")); combo->addItem(QIcon(),tr("Normal")); combo->addItem(QIcon(),tr("High")); combo->setEditable(false); waction = new QWidgetAction(tmenu); waction->setDefaultWidget(combo); tmenu->addAction(waction); connect(torrent,SIGNAL(changePriority(int)), combo,SLOT(setCurrentIndex (int))); connect(combo,SIGNAL(activated(int)), torrent,SLOT(setPriority(int))); //Other connect(torrent,SIGNAL(changeChunkSize(long)), this,SLOT(changeChunkSize(long))); connect(torrent,SIGNAL(changeState(int)), this,SLOT(changeState(int))); tmenu->addSeparator(); QAction * command = 0; //control action command = tmenu->addAction(QIcon(":/img/close.png"),tr("Close")); connect(command,SIGNAL(triggered (bool)), torrent,SLOT(close(bool))); command = tmenu->addAction(QIcon(":/img/open.png"),tr("Start")); connect(command,SIGNAL(triggered (bool)), torrent,SLOT(start(bool))); command = tmenu->addAction(QIcon(":/img/stop.png"),tr("Stop")); connect(command,SIGNAL(triggered (bool)), torrent,SLOT(stop(bool))); command = tmenu->addAction(QIcon(":/img/rehash0.png"),tr("Rehash")); connect(command,SIGNAL(triggered (bool)), torrent,SLOT(check_hash(bool))); command = tmenu->addAction(QIcon(":/img/erase.png"),tr("Erase")); connect(command,SIGNAL(triggered (bool)), torrent,SLOT(erase(bool))); //connect AutoUpdate when menu visible connect(tmenu,SIGNAL(aboutToShow()), torrent, SLOT(fullUpdate())); connect(tmenu,SIGNAL(aboutToShow()), torrent,SLOT(enableAutoUpdate())); connect(tmenu,SIGNAL(aboutToHide()), torrent,SLOT(disableAutoUpdate())); torrents[torrent->getId()] = tmenu; menu->insertMenu(sep,tmenu); }
SubTracks::ParseResult SubTracks::parse(QString text) { qDebug("SubTracks::parse: '%s'", text.toUtf8().data()); ParseResult result = SubtitleUnchanged; QRegExp rx_subtitle("^ID_(SUBTITLE|FILE_SUB|VOBSUB)_ID=(\\d+)"); QRegExp rx_sid("^ID_(SID|VSID)_(\\d+)_(LANG|NAME)=(.*)"); QRegExp rx_subtitle_file("^ID_FILE_SUB_FILENAME=(.*)"); if (rx_subtitle.indexIn(text) > -1) { int ID = rx_subtitle.cap(2).toInt(); QString type = rx_subtitle.cap(1); SubData::Type t; if (type == "FILE_SUB") t = SubData::File; else if (type == "VOBSUB") t = SubData::Vob; else t = SubData::Sub; if (find(t, ID) > -1) { qWarning("SubTracks::parse: subtitle type: %d, ID: %d already exists!", t, ID); } else { add(t,ID); result = SubtitleAdded; } } else if (rx_sid.indexIn(text) > -1) { int ID = rx_sid.cap(2).toInt(); QString value = rx_sid.cap(4); QString attr = rx_sid.cap(3); QString type = rx_sid.cap(1); SubData::Type t = SubData::Sub; if (type == "VSID") t = SubData::Vob; if (find(t, ID) == -1) { qWarning("SubTracks::parse: subtitle type: %d, ID: %d doesn't exist!", t, ID); } else { if (attr=="NAME") changeName(t,ID, value); else changeLang(t,ID, value); result = SubtitleChanged; } } else if (rx_subtitle_file.indexIn(text) > -1) { QString file = rx_subtitle_file.cap(1); if ( subs.count() > 0 ) { int last = subs.count() -1; if (subs[last].type() == SubData::File) { subs[last].setFilename( file ); result = SubtitleChanged; } } } return result; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Creazione finestra ui->setupUi(this); mDialogSendIp = NULL; mDialogText = NULL; mDialogAbout = NULL; mNetworkSession = NULL; // Creazione menu' mSendFileAction = new QAction("Send a file", this); menuBar()->addAction(mSendFileAction); connect(mSendFileAction, SIGNAL(triggered()), this, SLOT(selectFileToSend())); mSendTextAction = new QAction("Send text message", this); menuBar()->addAction(mSendTextAction); connect(mSendTextAction, SIGNAL(triggered()), this, SLOT(showSendTextDialog())); mSendToIPAction = new QAction("Send by IP", this); menuBar()->addAction(mSendToIPAction); connect(mSendToIPAction, SIGNAL(triggered()), this, SLOT(sendToIp())); mCurrentIPAction = new QAction("Current IP address", this); menuBar()->addAction(mCurrentIPAction); connect(mCurrentIPAction, SIGNAL(triggered()), this, SLOT(showCurrentIP())); mChangeFolderAction = new QAction("Change folder", this); menuBar()->addAction(mChangeFolderAction); connect(mChangeFolderAction, SIGNAL(triggered()), this, SLOT(changeFolder())); mChangeNameAction = new QAction("Change user name", this); menuBar()->addAction(mChangeNameAction); connect(mChangeNameAction, SIGNAL(triggered()), this, SLOT(changeName())); mAboutAction = new QAction("About Dukto", this); menuBar()->addAction(mAboutAction); connect(mAboutAction, SIGNAL(triggered()), this, SLOT(showAbout())); // Progress dialog per operazioni mProgressDialog = new QProgressDialog("", "", 0, 100); mProgressDialog->setWindowModality(Qt::WindowModal); // Connecting dialog mConnectingDialog = new QProgressDialog("\nConnecting...", "", 0, 0); mConnectingDialog->setCancelButton(NULL); mConnectingDialog->setAutoClose(false); mConnectingDialog->setMinimumDuration(0); mConnectingDialog->setWindowModality(Qt::WindowModal); // Percorso salvato QSettings settings("msec.it", "Dukto"); QString path = settings.value("dukto/currentpath", "C:/Dukto").toString(); QDir d; if (d.mkpath(path)) { QDir::setCurrent(path); ui->labelDest->setText("Folder: " + path.replace('/', "\\")); } // Percorso di default else { path = "C:/Dukto"; d.mkpath(path); QDir::setCurrent(path); ui->labelDest->setText("Folder: " + path.replace('/', "\\")); settings.setValue("dukto/currentpath", path); } // Inizialmente nascondo la lista ui->listWidget->setVisible(false); }
void Cutter::apply() { changeName(m_Dlg.ui.name_edit->text()); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Creazione finestra ui->setupUi(this); mDialogSendIp = NULL; mDialogText = NULL; mNetworkSession = NULL; // Creazione menu' mSendFileAction = new QAction("Send a file", this); menuBar()->addAction(mSendFileAction); connect(mSendFileAction, SIGNAL(triggered()), this, SLOT(selectFileToSend())); mSendTextAction = new QAction("Send text message", this); menuBar()->addAction(mSendTextAction); connect(mSendTextAction, SIGNAL(triggered()), this, SLOT(showSendTextDialog())); mSendToIPAction = new QAction("Send by IP", this); menuBar()->addAction(mSendToIPAction); connect(mSendToIPAction, SIGNAL(triggered()), this, SLOT(sendToIp())); mCurrentIPAction = new QAction("Current IP address", this); menuBar()->addAction(mCurrentIPAction); connect(mCurrentIPAction, SIGNAL(triggered()), this, SLOT(showCurrentIP())); mChangeFolderAction = new QAction("Change folder", this); menuBar()->addAction(mChangeFolderAction); connect(mChangeFolderAction, SIGNAL(triggered()), this, SLOT(changeFolder())); mChangeNameAction = new QAction("Change user name", this); menuBar()->addAction(mChangeNameAction); connect(mChangeNameAction, SIGNAL(triggered()), this, SLOT(changeName())); // Progress dialog per operazioni mProgressDialog = new QProgressDialog("", "", 0, 100); mProgressDialog->setWindowModality(Qt::WindowModal); // Connecting dialog mConnectingDialog = new QProgressDialog("\nConnecting...", "", 0, 0); mConnectingDialog->setCancelButton(NULL); mConnectingDialog->setAutoClose(false); mConnectingDialog->setMinimumDuration(0); mConnectingDialog->setWindowModality(Qt::WindowModal); // Percorso di default QDir d; if (d.mkpath("E:\\Dukto\\")) { QDir::setCurrent("E:\\Dukto\\"); ui->labelDest->setText("Folder: E:\\Dukto"); } else { d.mkpath("C:\\Dukto\\"); QDir::setCurrent("C:\\Dukto\\"); ui->labelDest->setText("Folder: C:\\Dukto"); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); // Initialize Bet ui->GuessNumBet->setNum(Config::GuessNumBet); ui->BlackJackBet->setNum(Config::BlackjackBet); // Initialize server configs this->socket = -1; this->serverIP = ui->serverIPDisplay->text(); this->serverPort = ui->serverPortDisplay->text().toInt(); // Initialize games this->guess_num_client = new GuessNumClient(this); this->blackjack_client = new BlackJackClient(this); this->guess_num_client->setModal(true); this->blackjack_client->setModal(true); // Initialize keep alive timer this->keepAlive = new QTimer(); this->keepAlive->setInterval(Config::KeepAliveFrequency); // Initialize dialog this->initializeWaitDialog(); this->initializeGuessNumDialogs(); this->initializeBlackjackDialogs(); *(user.mutable_name()) = "Anomynous"; ui->name->setText(QString("Anomynous")); ui->BlackJackButton->setEnabled(false); ui->GuessNumButton->setEnabled(false); // Register custom type so QObject::connect can work qRegisterMetaType<System::Type>("System::Type"); QObject::connect(ui->ConfigureServerButton, SIGNAL(clicked()), this, SLOT(showServerConfigDialog())); QObject::connect(ui->TryConnectionButton, SIGNAL(clicked()), this, SLOT(tryConnect())); QObject::connect(this, SIGNAL(connectionInvalid()), this, SLOT(warnConnection())); QObject::connect(this->keepAlive, SIGNAL(timeout()), this, SLOT(keepAlivePokeServer())); QObject::connect(this->guess_num_client, SIGNAL(waitForRival()), this->guessnum_congrat, SLOT(exec())); QObject::connect(this->guess_num_client, SIGNAL(loseGame()), this->guessnum_loser, SLOT(exec())); QObject::connect(this->guess_num_client, SIGNAL(winGame()), this->guessnum_winner, SLOT(exec())); QObject::connect(this->guess_num_client, SIGNAL(modify_player_money(int)), this, SLOT(increaseMoney(int))); QObject::connect(this->guess_num_client, SIGNAL(finished(int)), this->guess_num_client, SLOT(cleanUp())); QObject::connect(this->blackjack_client, SIGNAL(modify_player_money(int)), this, SLOT(increaseMoney(int))); QObject::connect(this->blackjack_client, SIGNAL(waitForRival()), this->blackjack_wait, SLOT(exec())); QObject::connect(this->blackjack_client, SIGNAL(showBlackjackResult(int,int)), this->blackjack_result_dialog, SLOT(showResult(int,int))); QObject::connect(this->blackjack_client, SIGNAL(finished(int)), this->blackjack_client, SLOT(cleanUp())); QObject::connect(this->blackjack_result_dialog, SIGNAL(finished(int)), this->blackjack_client, SLOT(accept())); QObject::connect(ui->GuessNumButton, &QPushButton::clicked, [this](){ joinGame(System::GUESSNUM); }); QObject::connect(ui->BlackJackButton, &QPushButton::clicked, [this](){ joinGame(System::JACK); }); QObject::connect(this->guess_num_client, SIGNAL(rival_die()), this, SLOT(handleGuessNumPlayerDie())); QObject::connect(this->blackjack_client, SIGNAL(rival_die()), this, SLOT(handleBlackJackPlayerDie())); // Prompt for change name at startup. changeName(); }
//Constructors: ProjectFilenamesDialog::ProjectFilenamesDialog(ftk::ProjectFiles * files, QWidget * parent) : QDialog(parent) { pFiles = files; QString buttonText = tr("Change..."); int labelWidths = 120; QVBoxLayout *masterLayout = new QVBoxLayout; /* QHBoxLayout *pLayout = new QHBoxLayout; projectLabel = new QLabel(tr("Project File: ")); projectLabel->setFixedWidth(labelWidths); projectFile = new QLabel(projfile); projectFile->setFrameShadow(QFrame::Sunken); projectFile->setFrameShape(QFrame::StyledPanel); pLayout->addWidget(projectLabel); pLayout->addWidget(projectFile); //pLayout->addStretch(5); masterLayout->addLayout(pLayout); */ QHBoxLayout *pathLayout = new QHBoxLayout; pathLabel = new QLabel(tr("Project Path: ")); pathLabel->setFixedWidth(labelWidths); inputPath = new QLabel(QString::fromStdString(files->path)); inputPath->setFrameShadow(QFrame::Sunken); inputPath->setFrameShape(QFrame::StyledPanel); pathButton = new QPushButton(buttonText); pathButton->setVisible(false); connect(pathButton, SIGNAL(clicked()), this, SLOT(changePath())); pathLayout->addWidget(pathLabel); pathLayout->addWidget(inputPath); pathLayout->addWidget(pathButton); masterLayout->addLayout(pathLayout); QHBoxLayout *nLayout = new QHBoxLayout; nameLabel = new QLabel(tr("Project Name: ")); nameLabel->setFixedWidth(labelWidths); nameText = new QLabel(QString::fromStdString(files->name)); nameText->setFrameShadow(QFrame::Sunken); nameText->setFrameShape(QFrame::StyledPanel); nameButton = new QPushButton(buttonText); connect(nameButton, SIGNAL(clicked()), this, SLOT(changeName())); nLayout->addWidget(nameLabel); nLayout->addWidget(nameText); nLayout->addWidget(nameButton); masterLayout->addLayout(nLayout); //masterLayout->addStretch(5); masterLayout->addSpacerItem(new QSpacerItem(labelWidths,5)); QHBoxLayout *iLayout = new QHBoxLayout; inputLabel = new QLabel(tr("Input: ")); inputLabel->setFixedWidth(labelWidths); inputFile = new QLabel(QString::fromStdString(files->input)); inputFile->setFrameShadow(QFrame::Sunken); inputFile->setFrameShape(QFrame::StyledPanel); inputButton = new QPushButton(buttonText); inputButton->setVisible(false); connect(inputButton, SIGNAL(clicked()), this, SLOT(changeInput())); iLayout->addWidget(inputLabel); iLayout->addWidget(inputFile); iLayout->addWidget(inputButton); masterLayout->addLayout(iLayout); QHBoxLayout *oLayout = new QHBoxLayout; outputLabel = new QLabel(tr("Output: ")); outputLabel->setFixedWidth(labelWidths); outputFile = new QLabel(QString::fromStdString(files->output)); outputFile->setFrameShadow(QFrame::Sunken); outputFile->setFrameShape(QFrame::StyledPanel); outputButton = new QPushButton(buttonText); outputButton->setVisible(false); connect(outputButton, SIGNAL(clicked()), this, SLOT(changeOutput())); oLayout->addWidget(outputLabel); oLayout->addWidget(outputFile); oLayout->addWidget(outputButton); masterLayout->addLayout(oLayout); QHBoxLayout *lLayout = new QHBoxLayout; logLabel = new QLabel(tr("Edit Log: ")); logLabel->setFixedWidth(labelWidths); logFile = new QLabel(QString::fromStdString(files->log)); logFile->setFrameShadow(QFrame::Sunken); logFile->setFrameShape(QFrame::StyledPanel); logButton = new QPushButton(buttonText); logButton->setEnabled(false); //Cannot change the log file here!! logButton->setVisible(false); connect(logButton, SIGNAL(clicked()), this, SLOT(changeLog())); lLayout->addWidget(logLabel); lLayout->addWidget(logFile); lLayout->addWidget(logButton); masterLayout->addLayout(lLayout); QHBoxLayout *dLayout = new QHBoxLayout; definitionLabel = new QLabel(tr("Project Definition: ")); definitionLabel->setFixedWidth(labelWidths); definitionFile = new QLabel(QString::fromStdString(files->definition)); definitionFile->setFrameShadow(QFrame::Sunken); definitionFile->setFrameShape(QFrame::StyledPanel); definitionButton = new QPushButton(buttonText); definitionButton->setVisible(false); connect(definitionButton, SIGNAL(clicked()), this, SLOT(changeDefinition())); dLayout->addWidget(definitionLabel); dLayout->addWidget(definitionFile); dLayout->addWidget(definitionButton); masterLayout->addLayout(dLayout); QHBoxLayout *tLayout = new QHBoxLayout; tableLabel = new QLabel(tr("Table: ")); tableLabel->setFixedWidth(labelWidths); tableFile = new QLabel(QString::fromStdString(files->table)); tableFile->setFrameShadow(QFrame::Sunken); tableFile->setFrameShape(QFrame::StyledPanel); tableButton = new QPushButton(buttonText); tableButton->setVisible(false); connect(tableButton, SIGNAL(clicked()), this, SLOT(changeTable())); tLayout->addWidget(tableLabel); tLayout->addWidget(tableFile); tLayout->addWidget(tableButton); masterLayout->addLayout(tLayout); QHBoxLayout *a_tLayout = new QHBoxLayout; adjTablesLabel = new QLabel(tr("Adj_Tables: ")); adjTablesLabel->setFixedWidth(labelWidths); adjTablesFile = new QLabel(QString::fromStdString(files->adjTables)); adjTablesFile->setFrameShadow(QFrame::Sunken); adjTablesFile->setFrameShape(QFrame::StyledPanel); adjTablesButton = new QPushButton(buttonText); adjTablesButton->setVisible(false); connect(adjTablesButton, SIGNAL(clicked()), this, SLOT(changeAdjTables())); a_tLayout->addWidget(adjTablesLabel); a_tLayout->addWidget(adjTablesFile); a_tLayout->addWidget(adjTablesButton); masterLayout->addLayout(a_tLayout); masterLayout->addStretch(5); QHBoxLayout *okLayout = new QHBoxLayout; quitButton = new QPushButton(tr("Cancel")); connect(quitButton, SIGNAL(clicked()), this, SLOT(reject())); okButton = new QPushButton(tr("Done")); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); okLayout->addStretch(20); okLayout->addWidget(quitButton); okLayout->addWidget(okButton); masterLayout->addLayout(okLayout); this->setLayout(masterLayout); //this->setupDefaults(); }