void pre_lzw_mp::do_work(){ thread_num = ui.lineEdit_3->text().toInt(); src = ui.lineEdit->text(); dst = ui.lineEdit_2->text(); int level_num = 0; QString level_num_str = ""; QDir src_dir(src); QRegExp reg_05d("(\\d){5}"); QFileInfoList src_list = src_dir.entryInfoList(); // qDebug()<<src_list.length(); QList<QFileInfo>::iterator src_beg = src_list.begin(); for(QList<QFileInfo>::iterator src_iter = src_beg; src_iter < src_list.end(); ++src_iter){ if((*src_iter).isDir() && (reg_05d.exactMatch((*src_iter).fileName()))){ pool<<(*src_iter).fileName(); } } int l = pool.length(); int i; #pragma omp parallel for num_threads(6) for(i = 0; i < l; ++i){ qDebug()<<pool.at(i)<<omp_get_thread_num(); //do_lzw(pool.at(i)); } }
void pre_lzw::do_work(){ QString src = ui.lineEdit->text(); QDir src_dir(src); QDir handled_dir = ""; QString label_str = ""; QFileInfoList src_list = src_dir.entryInfoList(); QList<QFileInfo>::iterator src_b = src_list.begin(); QRegExp reg_05d("(\\d){5}"); for(; src_b < src_list.end(); ++src_b){ if(reg_05d.exactMatch((*src_b).fileName())){ label_str += (*src_b).path() + "/" + (*src_b).fileName() + QString("\n"); handled_dir = QDir((*src_b).path() + "/" + (*src_b).fileName()); do_lzw(handled_dir); } } }
void SettingsDialog::accept() { QSettings s; s.setValue("bt/seed_enabled", ui->seedCheckBox->isChecked()); QDir src_dir(s.value("bt/datapath", getDefaultGameDataDirectory()).toString()); QDir dst_dir(QDir::fromNativeSeparators(ui->dataPathEdit->text())); if (src_dir != dst_dir) { s.setValue("bt/datapath", ui->dataPathEdit->text()); emit moveGameDataRequested(src_dir.absolutePath(), dst_dir.absolutePath()); } s.setValue("bt/download_limit_enabled", ui->downloadCheckBox->isChecked()); s.setValue("bt/upload_limit_enabled", ui->uploadCheckBox->isChecked()); s.setValue("bt/download_limit_value", ui->downloadSpin->value()); s.setValue("bt/upload_limit_value", ui->uploadSpin->value()); s.setValue("bt/connections_limit_value", ui->connectionsSpin->value()); s.setValue("bt/utp_enabled", ui->utpCheckBox->isChecked()); QDialog::accept(); }
void Application::copyFilesRecursively(const QString &src_path, const QString &dst_path) { QFileInfo src_file(src_path); if(!src_file.exists()) throw Exception(Exception::getErrorMessage(ERR_FILE_DIR_NOT_ACCESSED).arg(src_path), __PRETTY_FUNCTION__,__FILE__,__LINE__); if(src_file.isDir()) { QString new_src_path, new_dst_path; QStringList filenames; QDir dst_dir(dst_path), src_dir(src_path); if(!dst_dir.exists() && !dst_dir.mkpath(dst_path)) throw Exception(Exception::getErrorMessage(ERR_FILE_DIR_NOT_WRITTEN).arg(dst_path), __PRETTY_FUNCTION__,__FILE__,__LINE__); filenames = src_dir.entryList({QString("*%1").arg(GlobalAttributes::CONFIGURATION_EXT)}, QDir::Files | QDir::NoDotAndDotDot); for(QString filename : filenames) { //Avoiding the copy of ui-style.conf file if(!filename.contains(GlobalAttributes::UI_STYLE_CONF)) { new_src_path = src_path + src_dir.separator() + filename; new_dst_path = dst_path + dst_dir.separator() + filename; copyFilesRecursively(new_src_path, new_dst_path); } } } else if(!QFile::exists(dst_path) && !QFile::copy(src_path, dst_path)) { throw Exception(Exception::getErrorMessage(ERR_FILE_DIR_NOT_WRITTEN).arg(dst_path), __PRETTY_FUNCTION__,__FILE__,__LINE__); } }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QDir src_dir("../gfx/"); QDir dst_dir("c:/temp/"); dst_dir.mkdir("gfx_2x/"); dst_dir.cd("gfx_2x/"); QRgb filter_rgb = qRgba(240, 0, 0, 255); QRgb mask_rgb = qRgba(255, 0, 255, 255); QRgb shadow_rgb = qRgba(127, 0, 127, 255); QStringList list = src_dir.entryList(); foreach(const QString file, list) { qDebug("found file: %s", file.toStdString().c_str()); QImage image(src_dir.filePath(file)); if( !image.isNull() ) { if( image.width() % 2 != 0 ) { throw "image width not multiple of 2"; } if( image.height() % 2 != 0 ) { throw "image height not multiple of 2"; } int new_width = image.width() / 2; int new_height = image.height() / 2; QImage new_image(new_width, new_height, image.format()); new_image.fill(0); for(int y=0;y<new_height;y++) { for(int x=0;x<new_width;x++) { QRgb rgb00 = image.pixel(2*x, 2*y); QRgb rgb10 = image.pixel(2*x+1, 2*y); QRgb rgb01 = image.pixel(2*x, 2*y); QRgb rgb11 = image.pixel(2*x+1, 2*y+1); if( rgb00 == filter_rgb || rgb10 == filter_rgb || rgb01 == filter_rgb || rgb11 == filter_rgb ) { rgb00 = filter_rgb; rgb10 = filter_rgb; rgb01 = filter_rgb; rgb11 = filter_rgb; } else if( rgb00 == mask_rgb || rgb10 == mask_rgb || rgb01 == mask_rgb || rgb11 == mask_rgb ) { rgb00 = mask_rgb; rgb10 = mask_rgb; rgb01 = mask_rgb; rgb11 = mask_rgb; } else if( rgb00 == shadow_rgb || rgb10 == shadow_rgb || rgb01 == shadow_rgb || rgb11 == shadow_rgb ) { rgb00 = shadow_rgb; rgb10 = shadow_rgb; rgb01 = shadow_rgb; rgb11 = shadow_rgb; } /*if( rgb00 == mask_rgb ) { rgb00 = qRgba(0, 0, 0, 0); } if( rgb10 == mask_rgb ) { rgb10 = qRgba(0, 0, 0, 0); } if( rgb01 == mask_rgb ) { rgb01 = qRgba(0, 0, 0, 0); } if( rgb11 == mask_rgb ) { rgb11 = qRgba(0, 0, 0, 0); } if( rgb00 == shadow_rgb ) { rgb00 = qRgba(0, 0, 0, 0); } if( rgb10 == shadow_rgb ) { rgb10 = qRgba(0, 0, 0, 0); } if( rgb01 == shadow_rgb ) { rgb01 = qRgba(0, 0, 0, 0); } if( rgb11 == shadow_rgb ) { rgb11 = qRgba(0, 0, 0, 0); }*/ int irgb00[] = {qRed(rgb00), qGreen(rgb00), qBlue(rgb00), qAlpha(rgb00)}; int irgb10[] = {qRed(rgb10), qGreen(rgb10), qBlue(rgb10), qAlpha(rgb10)}; int irgb01[] = {qRed(rgb01), qGreen(rgb01), qBlue(rgb01), qAlpha(rgb01)}; int irgb11[] = {qRed(rgb11), qGreen(rgb11), qBlue(rgb11), qAlpha(rgb11)}; int irgb[] = {0, 0, 0, 0}; for(int i=0;i<4;i++) { int result = (int)((irgb00[i] + irgb10[i] + irgb01[i] + irgb11[i]) / 4.0); irgb[i] = result; } QRgb rgb = qRgba(irgb[0], irgb[1], irgb[2], irgb[3]); new_image.setPixel(x, y, rgb); } } QString save_filename = dst_dir.filePath(file); qDebug(" save as %s", save_filename.toStdString().c_str()); if( !new_image.save(save_filename) ) { throw "failed to save"; } } else { qDebug(" failed to load"); } }