Пример #1
0
void searchTab::unfavorite()
{
	Favorite favorite("", 0, QDateTime::currentDateTime());
	for (Favorite fav : m_favorites)
	{
		if (fav.getName() == m_link)
		{
			favorite = fav;
			m_favorites.removeAll(fav);
			break;
		}
	}
	if (favorite.getName().isEmpty())
		return;

	QFile f(savePath("favorites.txt"));
	f.open(QIODevice::ReadOnly);
		QString favs = f.readAll();
	f.close();

	favs.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\r\n");
	QRegExp reg(QRegExp::escape(favorite.getName()) + "\\|(.+)\\r\\n");
	reg.setMinimal(true);
	favs.remove(reg);

	f.open(QIODevice::WriteOnly);
		f.write(favs.toUtf8());
	f.close();

	if (QFile::exists(savePath("thumbs/" + favorite.getName(true) + ".png")))
	{ QFile::remove(savePath("thumbs/" + favorite.getName(true) + ".png")); }

	_mainwindow->updateFavorites();
}
Пример #2
0
/**
 * Update the local favorites file and add thumb if necessary.
 */
void favoriteWindow::save()
{
	Favorite oldFav = favorite;
	favorite = Favorite(ui->tagLineEdit->text(), ui->noteSpinBox->value(), ui->lastViewedDateTimeEdit->dateTime());

	if (QFile::exists(ui->imageLineEdit->text()))
	{
		QPixmap img(ui->imageLineEdit->text());
		if (!img.isNull())
		{ favorite.setImage(img); }
	}
	else if (oldFav.getName() != ui->tagLineEdit->text() && QFile::exists(savePath("thumbs/" + oldFav.getName(true) + ".png")))
	{ QFile::rename(savePath("thumbs/" + oldFav.getName(true) + ".png"), savePath("thumbs/" + favorite.getName(true) + ".png")); }

	QFile f(savePath("favorites.txt"));
	f.open(QIODevice::ReadOnly);
		QString favorites = f.readAll();
	f.close();

	favorites.replace("\r\n", "\n").replace("\r", "\n").replace("\n", "\r\n");
	favorites.remove(oldFav.getName() + "|" + QString::number(oldFav.getNote()) + "|" + oldFav.getLastViewed().toString(Qt::ISODate) + "\r\n");
	favorites += favorite.getName() + "|" + QString::number(favorite.getNote()) + "|" + favorite.getLastViewed().toString(Qt::ISODate) + "\r\n";

	f.open(QIODevice::WriteOnly);
		f.write(favorites.toUtf8());
	f.close();

	emit favoritesChanged();
}
Пример #3
0
/**
 * Add a site to the list.
 */
void sourcesWindow::addCheckboxes()
{
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	QString t = settings.value("Sources/Types", "icon").toString();

	QStringList k = m_sites->keys();
	for (int i = 0; i < k.count(); i++)
	{
		QCheckBox *check = new QCheckBox();
			check->setChecked(m_selected[i]);
			check->setText(k.at(i));
			connect(check, SIGNAL(stateChanged(int)), this, SLOT(checkUpdate()));
			m_checks << check;
			ui->gridLayout->addWidget(check, i, 0);

		int n = 1;
		if (t != "hide")
		{
			if (t == "icon" || t == "both")
			{
				QLabel *image = new QLabel();
				image->setPixmap(QPixmap(savePath("sites/"+m_sites->value(k.at(i))->type()+"/icon.png")));
				ui->gridLayout->addWidget(image, i, n);
				m_labels << image;
				n++;
			}
			if (t == "text" || t == "both")
			{
				QLabel *type = new QLabel(m_sites->value(k.at(i))->value("Name"));
				ui->gridLayout->addWidget(type, i, n);
				m_labels << type;
				n++;
			}
		}

		QBouton *del = new QBouton(k.at(i));
			del->setText(tr("Options"));
			connect(del, SIGNAL(appui(QString)), this, SLOT(settingsSite(QString)));
			m_buttons << del;
			ui->gridLayout->addWidget(del, i, n);
	}

	/*int n =  0+(t == "icon" || t == "both")+(t == "text" || t == "both");
	for (int i = 0; i < m_checks.count(); i++)
	{
		ui->gridLayout->addWidget(m_checks.at(i), i, 0);
		m_checks.at(i)->show();
		if (!m_labels.isEmpty())
		{
			for (int r = 0; r < n; r++)
			{
				ui->gridLayout->addWidget(m_labels.at(i*n+r), i*n+r, 1);
				m_labels.at(i*n+r)->show();
			}
		}
		ui->gridLayout->addWidget(m_buttons.at(i), i, n+1);
		m_buttons.at(i)->show();
	}*/
}
Пример #4
0
bool Favorite::setImage(QPixmap& img)
{
	if (!QDir(savePath("thumbs")).exists())
		QDir(savePath()).mkdir("thumbs");

	return img
			.scaled(QSize(150,150), Qt::KeepAspectRatio, Qt::SmoothTransformation)
			.save(savePath("thumbs/" + getName(true) + ".png"), "PNG");
}
Пример #5
0
void zoomWindow::setfavorite()
{
	if (!QDir(savePath("thumbs")).exists())
	{ QDir(savePath()).mkdir("thumbs"); }

	if (image != nullptr)
	{
		Favorite fav(link, 50, QDateTime::currentDateTime());
		fav.setImage(*image);
	}

	_mainwindow->updateFavorites();
	_mainwindow->updateFavoritesDock();
}
Пример #6
0
std::vector<ImageDesc> ImageDesc::fromPaths(const std::vector<std::string> paths,
                                            const std::string & image_desc_extension) {
    std::vector<ImageDesc> descs;
    for(auto & path: paths) {
        ASSERT(io::exists(path), "File " << path << " does not exists.");
        auto desc = ImageDesc(path);
        desc.setSavePathExtension(image_desc_extension);
        if(io::exists(desc.savePath())) {
            desc = *ImageDesc::load(desc.savePath());
            desc.filename = path;
        }
        descs.push_back(desc);
    }
    return descs;
}
Пример #7
0
void tagTab::updateCheckboxes()
{
	log(tr("Mise à jour des cases à cocher."));
	qDeleteAll(m_checkboxes);
	m_checkboxes.clear();
	QStringList urls = m_sites->keys();
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat, this);
	int n = settings.value("Sources/Letters", 3).toInt(), m = n;
	for (int i = 0; i < urls.size(); i++)
	{
		if (urls[i].startsWith("www."))
		{ urls[i] = urls[i].right(urls[i].length() - 4); }
		else if (urls[i].startsWith("chan."))
		{ urls[i] = urls[i].right(urls[i].length() - 5); }
		if (n < 0)
		{
			m = urls.at(i).indexOf('.');
			if (n < -1 && urls.at(i).indexOf('.', m+1) != -1)
			{ m = urls.at(i).indexOf('.', m+1); }
		}

		bool isChecked = m_selectedSources.size() > i ? m_selectedSources.at(i) : false;
		QCheckBox *c = new QCheckBox(urls.at(i).left(m), this);
			c->setChecked(isChecked);
			ui->layoutSourcesList->addWidget(c);

		m_checkboxes.append(c);
	}
	DONE();
}
Пример #8
0
void GlobalOptionsDialog::open() {
	OptionsDialog::open();

#if !( defined(__DC__) || defined(__GP32__) || defined(__PLAYSTATION2__) )
	// Set _savePath to the current save path
	Common::String savePath(ConfMan.get("savepath", _domain));
	Common::String themePath(ConfMan.get("themepath", _domain));
	Common::String extraPath(ConfMan.get("extrapath", _domain));

	if (!savePath.empty()) {
		_savePath->setLabel(savePath);
	} else {
		// Default to the current directory...
		char buf[MAXPATHLEN];
		getcwd(buf, sizeof(buf));
		_savePath->setLabel(buf);
	}

	if (themePath.empty() || !ConfMan.hasKey("themepath", _domain)) {
		_themePath->setLabel("None");
	} else {
		_themePath->setLabel(themePath);
	}

	if (extraPath.empty() || !ConfMan.hasKey("extrapath", _domain)) {
		_extraPath->setLabel("None");
	} else {
		_extraPath->setLabel(extraPath);
	}
#endif
}
Пример #9
0
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
	Common::String savePathName = getSavePath();
	checkPath(Common::FSNode(savePathName));
	if (getError().getCode() != Common::kNoError)
		return false;

	// recreate FSNode since checkPath may have changed/created the directory
	Common::FSNode savePath(savePathName);

	Common::FSNode file = savePath.getChild(filename);

	// FIXME: remove does not exist on all systems. If your port fails to
	// compile because of this, please let us know (scummvm-devel or Fingolfin).
	// There is a nicely portable workaround, too: Make this method overloadable.
	if (remove(file.getPath().c_str()) != 0) {
#ifndef _WIN32_WCE
		if (errno == EACCES)
			setError(Common::kWritePermissionDenied, "Search or write permission denied: "+file.getName());

		if (errno == ENOENT)
			setError(Common::kPathDoesNotExist, "removeSavefile: '"+file.getName()+"' does not exist or path is invalid");
#endif
		return false;
	} else {
		return true;
	}
}
Пример #10
0
// get a xliveless-compatible save game directory
static std::wstring GetOriginalSavePath()
{
	PWSTR documentsPath;

	// get the Documents folder
	if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, 0, nullptr, &documentsPath)))
	{
		// put it into a string and free it
		std::wstring savePath(documentsPath);

		CoTaskMemFree(documentsPath);
		
		// append the R* bits
		AppendPathComponent(savePath, L"\\Rockstar Games");
		AppendPathComponent(savePath, L"\\GTA IV");
		AppendPathComponent(savePath, L"\\savegames");

		// append a final separator
		savePath += L"\\";

		// and return the path
		return savePath;
	}

	// if not working, panic
	FatalError("Could not get Documents folder path for save games.");
}
Пример #11
0
// get our Citizen save game directory
static std::wstring GetCitizenSavePath()
{
	PWSTR saveBasePath;

	// get the 'Saved Games' shell directory
	if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_SavedGames, 0, nullptr, &saveBasePath)))
	{
		// create a STL string and free the used memory
		std::wstring savePath(saveBasePath);

		CoTaskMemFree(saveBasePath);

		// append our path components
		AppendPathComponent(savePath, L"\\CitizenFX");
		AppendPathComponent(savePath, L"\\GTA4");

		// append a final separator
		savePath += L"\\";

		// and return the path
		return savePath;
	}

	return GetOriginalSavePath();
}
Пример #12
0
void zoomWindow::openSaveDir(bool fav)
{
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	QString path = settings.value("Save/path"+QString(fav ? "_favorites" : "")).toString().replace("\\", "/"), fn = settings.value("Save/filename"+QString(fav ? "_favorites" : "")).toString();

	if (path.right(1) == "/")
	{ path = path.left(path.length()-1); }
	path = QDir::toNativeSeparators(path);

    QStringList files = m_image->path(fn, path);
	QString file = files.empty() ? "" : files.at(0);
	QString pth = file.section(QDir::toNativeSeparators("/"), 0, -2);
	QString url = path+QDir::toNativeSeparators("/")+pth;

	QDir dir(url);
	if (dir.exists())
	{ showInGraphicalShell(url); }
	else
	{
		int reply = QMessageBox::question(this, tr("Dossier inexistant"), tr("Le dossier de sauvegarde n'existe pas encore. Le creer ?"), QMessageBox::Yes | QMessageBox::No);
		if (reply == QMessageBox::Yes)
		{
			QDir dir(path);
			if (!dir.mkpath(pth))
			{ error(this, tr("Erreur lors de la création du dossier.\r\n%1").arg(url)); }
			showInGraphicalShell(url);
		}
	}
}
Пример #13
0
bool DumpCallback(const char* _dump_dir,const char* _minidump_id,void *context, bool success)
#endif
{
	QString dir, mid;
	Q_UNUSED(context);
	#if defined(Q_OS_WIN)
		dir = QString::fromWCharArray(_dump_dir);
		mid = QString::fromWCharArray(_minidump_id);
		Q_UNUSED(_dump_dir);
		Q_UNUSED(_minidump_id);
		Q_UNUSED(assertion);
		Q_UNUSED(exinfo);
	#elif defined(Q_OS_LINUX)
		dir = QString(md.directory().c_str());
		mid = QString::number(md.fd());
	#elif defined(Q_OS_MAC)
		dir = QString::fromWCharArray(_dump_dir);
		mid = QString::fromWCharArray(_minidump_id);
	#endif

	log(QObject::tr("Minidump sauvegardé dans le dossier \"%1\" avec l'id \"%2\" (%3)").arg(dir, mid, success ? QObject::tr("réussite") : QObject::tr("échec")));
	if (success)
	{
		QFile f(savePath("lastdump"));
		if (f.open(QFile::WriteOnly))
		{
			f.write(QDir::toNativeSeparators(dir+"/"+mid+".dmp").toLatin1());
			f.close();
		}
	}
	QProcess::startDetached("CrashReporter.exe");

	return CrashHandlerPrivate::bReportCrashesToSystem ? success : true;
}
Пример #14
0
/**
 * Constructor of the sourcesWindow, generating checkboxes and delete buttons
 * @param	selected	Bool list of currently selected websites, in the alphabetical order
 * @param	sites		QStringList of sites names
 * @param	parent		The parent window
 */
sourcesWindow::sourcesWindow(QList<bool> selected, QMap<QString, Site*> *sites, QWidget *parent) : QDialog(parent), ui(new Ui::sourcesWindow), m_selected(selected), m_sites(sites)
{
	ui->setupUi(this);

	bool checkall = true;
	for (int i = 0; i < selected.count(); i++)
	{
		if (!selected.at(i))
		{
			checkall = false;
			break;
		}
	}
	if (checkall)
	{ ui->checkBox->setChecked(true); }

    QSettings settings(savePath("settings.ini"), QSettings::IniFormat);

	addCheckboxes();

	ui->gridLayout->setColumnStretch(0, 1);
	connect(ui->checkBox, SIGNAL(clicked()), this, SLOT(checkClicked()));
	checkUpdate();

	// Check for updates in the model files
	checkForUpdates();

	ui->buttonOk->setFocus();
}
Пример #15
0
void batchWindow::closeEvent(QCloseEvent *e)
{
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	settings.setValue("Batch/geometry", saveGeometry());
	settings.setValue("Batch/details", ui->buttonDetails->isChecked());
	settings.setValue("Batch/end", ui->comboEnd->currentIndex());
	settings.setValue("Batch/remove", ui->checkRemove->isChecked());
	settings.setValue("Batch/scrollToDownload", ui->checkScrollToDownload->isChecked());
	settings.sync();

	if (m_images < m_imagesCount)
	{
		cancel();
		emit rejected();
	}
	else
	{ clear(); }

	#ifdef Q_OS_WIN
		m_taskBarProgress->setVisible(false);
	#endif

	emit closed();
	e->accept();
}
Пример #16
0
bool Ps2SaveFileManager::removeSavefile(const Common::String &filename) {
	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
	Common::FSNode file;

	if (!savePath.exists() || !savePath.isDirectory())
		return false;

	if (_getDev(savePath) == MC_DEV) {
	// if (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0) {
		char path[32], temp[32];
		strcpy(temp, filename.c_str());

		// mcSplit(temp, game, ext);
		char *game = strdup(strtok(temp, "."));
		char *ext = strdup(strtok(NULL, "*"));
		sprintf(path, "mc0:ScummVM/%s", game); // per game path
		mcCheck(path);
		sprintf(path, "mc0:ScummVM/%s/%s.sav", game, ext);
		file = Common::FSNode(path);
		free(game);
		free(ext);
	} else {
		file = savePath.getChild(filename);
	}

	if (!file.exists() || file.isDirectory())
		return false;

	fio.remove(file.getPath().c_str());

	return true;
}
Пример #17
0
void zoomWindow::unignore()
{
	m_ignore.removeAll(link);
	QFile f(savePath("ignore.txt"));
	f.open(QIODevice::WriteOnly);
		f.write(m_ignore.join("\r\n").toUtf8());
	f.close();
	colore();
}
Пример #18
0
Common::StringArray Ps2SaveFileManager::listSavefiles(const Common::String &pattern) {
	Common::FSNode savePath(ConfMan.get("savepath")); // TODO: is this fast?
	Common::String _dir;
	Common::String search;
	bool _mc = (_getDev(savePath) == MC_DEV);
 		// (strncmp(savePath.getPath().c_str(), "mc0:", 4) == 0);
	char *game=0, path[32], temp[32];

	if (!savePath.exists() || !savePath.isDirectory())
		return Common::StringArray();

	printf("listSavefiles = %s\n", pattern.c_str());

	if (_mc) {
		strcpy(temp, pattern.c_str());

		// mcSplit(temp, game, ext);
		game = strdup(strtok(temp, "."));
		sprintf(path, "mc0:ScummVM/%s", game); // per game path
		mcCheck(path);

		sprintf(path, "mc0:ScummVM/%s/", game);
		_dir = Common::String(path);
		search = Common::String("*.sav");
	}
	else {
		_dir = Common::String(savePath.getPath());
		search = pattern;
	}

	Common::FSDirectory dir(_dir);
	Common::ArchiveMemberList savefiles;
	Common::StringArray results;

	printf("dir = %s --- reg = %s\n", _dir.c_str(), search.c_str());

	if (dir.listMatchingMembers(savefiles, search) > 0) {
		for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) {
			if (_mc) { // convert them back in ScummVM names
				strncpy(temp, (*file)->getName().c_str(), 3);
				temp[3] = '\0';
				sprintf(path, "%s.%s", game, temp);
				results.push_back(path);
				printf(" --> found = %s -> %s\n", (*file)->getName().c_str(), path);
			}
			else {
				results.push_back((*file)->getName());
				printf(" --> found = %s\n", (*file)->getName().c_str());
			}
		}
	}

	free(game);

	return results;
}
Пример #19
0
QPixmap Favorite::getImage() const
{
	QPixmap img(m_imagePath);
	if (img.width() > 150 || img.height() > 150)
	{
		img = img.scaled(QSize(150,150), Qt::KeepAspectRatio, Qt::SmoothTransformation);
		img.save(savePath("thumbs/" + getName(true) + ".png"), "PNG");
	}
	return img;
}
Пример #20
0
void zoomWindow::unviewitlater()
{
	m_viewItLater.removeAll(link);
	QFile f(savePath("viewitlater.txt"));
	f.open(QIODevice::WriteOnly);
		f.write(m_viewItLater.join("\r\n").toUtf8());
	f.close();

	_mainwindow->updateKeepForLater();
}
Пример #21
0
md5Fix::md5Fix(QWidget *parent) : QDialog(parent), ui(new Ui::md5Fix)
{
	ui->setupUi(this);

	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	ui->lineFolder->setText(settings.value("Save/path").toString());
	ui->lineFilename->setText(settings.value("Save/filename").toString());
	ui->progressBar->hide();

	resize(size().width(), 0);
}
Пример #22
0
void savePath(Dictionary *dict, node *tree, char *code){
    if (!tree->right && !tree->left){
        //printf("%d %d %d -> %s \n", tree->r, tree->g, tree->b, code);
        insert_dictionary(dict, tree->r, tree->g, tree->b, tree->repetitions, code);
    }
    else{
        char *result0 = malloc(strlen(code)+2);
        char *result1 = malloc(strlen(code)+2);
        strcpy(result0, code);
        strcpy(result1, code);
        strcat(result0, "0");
        strcat(result1, "1");
        savePath(dict, tree->left, result0);
        savePath(dict, tree->right, result1);
        free(result0);
        free(result1);
    }

    return;
}
Пример #23
0
void zoomWindow::favorite()
{
	m_favorites.append(link);

	QFile f(savePath("favorites.txt"));
		f.open(QIODevice::WriteOnly | QIODevice::Append);
		f.write(QString(link+"|50|"+QDateTime::currentDateTime().toString(Qt::ISODate)+"\r\n").toUtf8());
	f.close();

	setfavorite();
}
Пример #24
0
QString SavePrefix::savePath(const QString& path, const QString& extra) const
{
    QFileInfo info(path);
    KUrl savePath(info.path());

    QString file = QString(extra);
    file.append(info.fileName());

    savePath.addPath(file);
    return savePath.path();
}
Пример #25
0
void searchTab::saveSources(QList<bool> sel)
{
	log(tr("Sauvegarde des sources..."));
	m_selectedSources = sel;
	QString sav;
	for (int i = 0; i < m_selectedSources.count(); i++)
	{ sav += (m_selectedSources.at(i) ? "1" : "0"); }
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat, this);
	settings.setValue("sites", sav);
	DONE();
	updateCheckboxes();
}
Пример #26
0
void tagTab::optionsChanged()
{
	log(tr("Mise à jour des options de l'onglet \"%1\".").arg(windowTitle()));
	QSettings settings(savePath("settings.ini"), QSettings::IniFormat, this);
	ui->retranslateUi(this);
	ui->spinImagesPerPage->setValue(settings.value("limit", 20).toInt());
	ui->spinColumns->setValue(settings.value("columns", 1).toInt());
	/*QPalette p = ui->widgetResults->palette();
	p.setColor(ui->widgetResults->backgroundRole(), QColor(settings.value("serverBorderColor", "#000000").toString()));
	ui->widgetResults->setPalette(p);*/
	ui->layoutResults->setHorizontalSpacing(settings.value("Margins/main", 10).toInt());
}
Пример #27
0
BlacklistFix::BlacklistFix(QMap<QString,Site*> sites, QWidget *parent) : QDialog(parent), ui(new Ui::BlacklistFix), m_sites(sites)
{
	ui->setupUi(this);

	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	ui->lineFolder->setText(settings.value("Save/path").toString());
	ui->lineFilename->setText(settings.value("Save/filename").toString());
	ui->lineBlacklist->setText(settings.value("blacklistedtags").toString());
	ui->comboSource->addItems(m_sites.keys());
	ui->progressBar->hide();

	resize(size().width(), 0);
}
Пример #28
0
QString SaveSuffix::savePath(const QString& path, const QString& extra) const
{
    QFileInfo info(path);
    KUrl savePath(info.path());

    QString file = info.completeBaseName();
    file.append(extra);
    file.append(".");
    file.append(info.suffix());

    savePath.addPath(file);
    return savePath.path();
}
Пример #29
0
RenameExisting1::RenameExisting1(QMap<QString,Site*> sites, QWidget *parent) : QDialog(parent), ui(new Ui::RenameExisting1), m_sites(sites)
{
	ui->setupUi(this);

	QSettings settings(savePath("settings.ini"), QSettings::IniFormat);
	ui->lineFolder->setText(settings.value("Save/path").toString());
	ui->lineFilenameOrigin->setText(settings.value("Save/filename").toString());
	ui->lineFilenameDestination->setText(settings.value("Save/filename").toString());
	ui->comboSource->addItems(m_sites.keys());
	ui->progressBar->hide();

	resize(size().width(), 0);
}
Пример #30
0
void FavoriteTest::testGetImageNotExists()
{
	QFile file(savePath("thumbs/tag1.png"));
	if (file.exists())
		file.remove();

	QDateTime date = QDateTime::fromString("2016-07-02 16:35:12", "yyyy-MM-dd HH:mm:ss");
	Favorite fav("tag1", 50, date);

	QPixmap img = fav.getImage();

	QCOMPARE(img.isNull(), true);
}