void MainWindow::on_actionRename_triggered(bool) { if (images_.count()==0) return; QString folder = images_[0].folder(); for (int i=0; i<images_.count(); ++i) { //get EXIF date QByteArray date; if (!getExifDate(images_[i].filename(), date)) { QMessageBox::warning(this, "EXIF data not found!", "EXIF creation date not found for file:\n" + images_[i].filename() + "\nMessage: " + date + "\nAborting!"); break; } //format '2004:04:23 13:05:04' to '20040423_130504' date.replace(":", "").replace(" ","_"); //determine new file name QString file_o = images_[i].filename(false); QString ext = file_o.right(4); int number = 1; while (QFile::exists(folder + "\\" + date + "-" + QString::number(number) + ext)) { ++number; } //rename QFile::rename(images_[i].filename(), folder + "\\" + date + "-" + QString::number(number) + ext); } updateImageList(folder); updateImage(0); }
void MainWindow::on_actionOpenFolder_triggered(bool) { QString folder = QFileDialog::getExistingDirectory(this, "Select folder", Settings::path("folder")); if (folder=="") return; Settings::setPath("folder", folder); updateImageList(folder); }
void MainWindow::on_actionOpenFile_triggered(bool) { QString file = QFileDialog::getOpenFileName(this, "Select file", Settings::path("folder"), "All files (*.*);;PNG files(*.png);;JPG files (*.jpg)"); if (file=="") return; QFileInfo file_info(file); Settings::setPath("folder", file_info.canonicalPath()); updateImageList(file_info.canonicalPath(), file_info.fileName()); }
CGUITextureCacheBrowser::CGUITextureCacheBrowser(IGUIEnvironment* environment, s32 id, IGUIElement *parent) : IGUIWindow(environment, parent, id, core::rect<s32>(0,0,300,200)), Dragging(false), DragStart(0,0), CloseButton(0), Images(), SelectedTexture(-1) { #ifdef _DEBUG setDebugName("CGUIWindow"); #endif IGUISkin* skin = 0; IGUISpriteBank* sprites = 0; video::SColor color(255,255,255,255); if (environment) skin = environment->getSkin(); s32 buttonw = 15; if (skin) { buttonw = skin->getSize(EGDS_WINDOW_BUTTON_WIDTH); sprites = skin->getSpriteBank(); color = skin->getColor(EGDC_WINDOW_SYMBOL); } s32 posx = RelativeRect.getWidth() - buttonw - 4; CloseButton = Environment->addButton(core::rect<s32>(posx, 3, posx + buttonw, 3 + buttonw), this, -1, L"", skin ? skin->getDefaultText(EGDT_WINDOW_CLOSE) : L"Close" ); CloseButton->setSubElement(true); CloseButton->setAlignment(EGUIA_LOWERRIGHT, EGUIA_LOWERRIGHT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT); if (sprites) { CloseButton->setSpriteBank(sprites); CloseButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_WINDOW_CLOSE), color); CloseButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_WINDOW_CLOSE), color); } CloseButton->grab(); // window title Text = L"Texture Browser"; // panel element Panel = new CGUIPanel(environment, this); Panel->setRelativePosition( core::rect<s32>(1, buttonw + 5, 151, RelativeRect.getHeight() - 1)); Panel->setAlignment(EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_UPPERLEFT, EGUIA_LOWERRIGHT); Panel->setBorder(true); Panel->setSubElement(true); // some buttons // add images from texture cache updateImageList(); }
MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , ui_() , images_() , timer_() { ui_.setupUi(this); setWindowTitle(QApplication::applicationName()); setWindowState(Qt::WindowMaximized); //set reload action group QActionGroup* group = new QActionGroup(this); group->addAction(ui_.actionReloadAsk); group->addAction(ui_.actionReloadNo); group->addAction(ui_.actionReloadAuto); ui_.actionReloadAuto->setChecked(true); //init file watcher watcher_.setDelayInSeconds(0.001); connect(&watcher_, SIGNAL(fileChanged()), this, SLOT(reloadFile())); //start timer for image size update connect(&timer_, SIGNAL(timeout()), this, SLOT(updateImageSize())); timer_.start(250); //init images QStringList args = QApplication::arguments(); if (args.count()>1 && QFile::exists(args[1])) { QFileInfo file_info(args[1]); updateImageList(file_info.canonicalPath(), file_info.fileName()); } else { updateImageList(Settings::path("folder")); } }
void CGUITextureCacheBrowser::setSelected(s32 index) { SelectedTexture = index; updateImageList(); printf("Texture %d selected\n", index); }
void CGUITextureCacheBrowser::updateAbsolutePosition() { IGUIWindow::updateAbsolutePosition(); updateImageList(); }