-
-
Save oppahero/2396264e4c50ce00ee7a238b6f68b08e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Dialog::on_pushButton_ChooseFile_clicked() | |
{ | |
//configurar el directorio de inicio a la ruta de inicio del usuario | |
QString homePath = QDir::homePath(); | |
//Abre el dialogo y escoge el archivo. Obtenemos el path del archivo. | |
QString filePath = QFileDialog::getOpenFileName(this,tr("Open a file"), | |
homePath,tr("All files (*.*)"),NULL,QFileDialog::DontResolveSymlinks); | |
//Se obtiene el nombre del archivo | |
QString filename = filePath.section("/",-1); | |
//Si no se selecciona nada | |
if(filename.isEmpty()) | |
return; | |
//Si se selecciono, confirmamos el envio | |
QMessageBox::StandardButton reply; | |
reply = QMessageBox::question(this,"Enviar archivo",tr("Quieres enviar \"%1\"?").arg(filename)); | |
if (reply == QMessageBox::No ) | |
return; | |
else{ | |
emit envioArchivo(); | |
sendFileToAll(filePath,filename); | |
//obtenemos la hora | |
QString currentTime = QTime::currentTime().toString("H:mm A"); | |
//añadimos al chat grupa | |
ui->textEdit_ChatDisplay->append("<font color=\"DarkRed\"><b>"+username+ | |
" ["+currentTime+"] ha enviado \""+filename+"\"</b></font>"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment