mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-24 15:09:33 -05:00
Added three new methods on misc: getOpenFileName, getOpenFileNames and getSaveFileName. Please use this rather than QFileDialog.
Added save and restore of the last used directories for the following types - Extra files - Certificates - History - Images - Messages - Blogs (not tested) It is easy to change. Added attach of multiple files at once in CreateForumMsg. The RetroShare links of the added files in CreateForumMsg are added with new style and as anchor with size information. Added translation to some file dialogs. Removed (commented out) not needed methods in NetworkDialog. Fixed handling of filenames with umlauts when adding extra files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3894 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c1e3947957
commit
f7252fd693
@ -463,6 +463,7 @@ SOURCES += main.cpp \
|
||||
util/rsversion.cpp \
|
||||
util/printpreview.cpp \
|
||||
util/log.cpp \
|
||||
util/misc.cpp \
|
||||
gui/bwgraph/bwgraph.cpp \
|
||||
gui/profile/ProfileView.cpp \
|
||||
gui/profile/ProfileEdit.cpp \
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <QFileInfo>
|
||||
#include <QWidgetAction>
|
||||
#include <QTimer>
|
||||
#include <QFileDialog>
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include <gpgme.h>
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QTime>
|
||||
@ -294,51 +293,48 @@ void NetworkDialog::peerdetails()
|
||||
}
|
||||
|
||||
/** Open a QFileDialog to browse for a pem/pqi file. */
|
||||
void NetworkDialog::loadcert()
|
||||
{
|
||||
/* Create a new input dialog, which allows users to create files, too */
|
||||
QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
//dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setReadOnly(false);
|
||||
|
||||
/* Prompt the user to select a file or create a new one */
|
||||
if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
|
||||
/* Check if the file exists */
|
||||
QFile torrcFile(filename);
|
||||
if (!QFileInfo(filename).exists()) {
|
||||
/* The given file does not exist. Should we create it? */
|
||||
int response = VMessageBox::question(this,
|
||||
tr("File Not Found"),
|
||||
tr("%1 does not exist. Would you like to create it?")
|
||||
.arg(filename),
|
||||
VMessageBox::Yes, VMessageBox::No);
|
||||
|
||||
if (response == VMessageBox::No) {
|
||||
/* Don't create it. Just bail. */
|
||||
return;
|
||||
}
|
||||
/* Attempt to create the specified file */
|
||||
if (!torrcFile.open(QIODevice::WriteOnly)) {
|
||||
VMessageBox::warning(this,
|
||||
tr("Failed to Create File"),
|
||||
tr("Unable to create %1 [%2]").arg(filename)
|
||||
.arg(torrcFile.errorString()),
|
||||
VMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//ui.lineTorConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <sstream>
|
||||
//void NetworkDialog::loadcert()
|
||||
//{
|
||||
// use misc::getOpenFileName
|
||||
// /* Create a new input dialog, which allows users to create files, too */
|
||||
// QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
// //dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
// //dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
// dialog.setFileMode(QFileDialog::AnyFile);
|
||||
// dialog.setReadOnly(false);
|
||||
//
|
||||
// /* Prompt the user to select a file or create a new one */
|
||||
// if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
//
|
||||
// /* Check if the file exists */
|
||||
// QFile torrcFile(filename);
|
||||
// if (!QFileInfo(filename).exists()) {
|
||||
// /* The given file does not exist. Should we create it? */
|
||||
// int response = VMessageBox::question(this,
|
||||
// tr("File Not Found"),
|
||||
// tr("%1 does not exist. Would you like to create it?")
|
||||
// .arg(filename),
|
||||
// VMessageBox::Yes, VMessageBox::No);
|
||||
//
|
||||
// if (response == VMessageBox::No) {
|
||||
// /* Don't create it. Just bail. */
|
||||
// return;
|
||||
// }
|
||||
// /* Attempt to create the specified file */
|
||||
// if (!torrcFile.open(QIODevice::WriteOnly)) {
|
||||
// VMessageBox::warning(this,
|
||||
// tr("Failed to Create File"),
|
||||
// tr("Unable to create %1 [%2]").arg(filename)
|
||||
// .arg(torrcFile.errorString()),
|
||||
// VMessageBox::Ok);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// //ui.lineTorConfig->setText(filename);
|
||||
//}
|
||||
|
||||
void NetworkDialog::updateDisplay()
|
||||
{
|
||||
@ -580,128 +576,131 @@ RsCertId getNeighRsCertId(QTreeWidgetItem *i)
|
||||
* All of these rely on the finding of the current Id.
|
||||
*/
|
||||
|
||||
std::string NetworkDialog::loadneighbour()
|
||||
{
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::loadneighbour()" << std::endl;
|
||||
#endif
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Select Certificate"), "",
|
||||
tr("Certificates (*.pqi *.pem)"));
|
||||
//std::string NetworkDialog::loadneighbour()
|
||||
//{
|
||||
//#ifdef NET_DEBUG
|
||||
// std::cerr << "NetworkDialog::loadneighbour()" << std::endl;
|
||||
//#endif
|
||||
// use misc::getOpenFileName
|
||||
// QString fileName = QFileDialog::getOpenFileName(this, tr("Select Certificate"), "",
|
||||
// tr("Certificates (*.pqi *.pem)"));
|
||||
//
|
||||
// std::string file = fileName.toStdString();
|
||||
// std::string id;
|
||||
// std::string gpg_id;
|
||||
// if (file != "")
|
||||
// {
|
||||
// rsPeers->loadCertificateFromFile(file, id, gpg_id);
|
||||
// }
|
||||
// return id;
|
||||
//}
|
||||
|
||||
std::string file = fileName.toStdString();
|
||||
std::string id;
|
||||
std::string gpg_id;
|
||||
if (file != "")
|
||||
{
|
||||
rsPeers->loadCertificateFromFile(file, id, gpg_id);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
//void NetworkDialog::addneighbour()
|
||||
//{
|
||||
//// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
//#ifdef NET_DEBUG
|
||||
// std::cerr << "NetworkDialog::addneighbour()" << std::endl;
|
||||
//#endif
|
||||
// /*
|
||||
// rsServer->NeighAddFriend(getNeighRsCertId(c));
|
||||
// */
|
||||
//}
|
||||
|
||||
void NetworkDialog::addneighbour()
|
||||
{
|
||||
// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::addneighbour()" << std::endl;
|
||||
#endif
|
||||
/*
|
||||
rsServer->NeighAddFriend(getNeighRsCertId(c));
|
||||
*/
|
||||
}
|
||||
|
||||
void NetworkDialog::authneighbour()
|
||||
{
|
||||
// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::authneighbour()" << std::endl;
|
||||
#endif
|
||||
/*
|
||||
RsAuthId code;
|
||||
rsServer->NeighAuthFriend(getNeighRsCertId(c), code);
|
||||
*/
|
||||
}
|
||||
//void NetworkDialog::authneighbour()
|
||||
//{
|
||||
//// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
//#ifdef NET_DEBUG
|
||||
// std::cerr << "NetworkDialog::authneighbour()" << std::endl;
|
||||
//#endif
|
||||
// /*
|
||||
// RsAuthId code;
|
||||
// rsServer->NeighAuthFriend(getNeighRsCertId(c), code);
|
||||
// */
|
||||
//}
|
||||
|
||||
/** Open a QFileDialog to browse for a pem/pqi file. */
|
||||
void NetworkDialog::on_actionAddFriend_activated()
|
||||
{
|
||||
/* Create a new input dialog, which allows users to create files, too */
|
||||
QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
//dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setReadOnly(false);
|
||||
|
||||
/* Prompt the user to select a file or create a new one */
|
||||
if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
|
||||
/* Check if the file exists */
|
||||
QFile torrcFile(filename);
|
||||
if (!QFileInfo(filename).exists()) {
|
||||
/* The given file does not exist. Should we create it? */
|
||||
int response = VMessageBox::question(this,
|
||||
tr("File Not Found"),
|
||||
tr("%1 does not exist. Would you like to create it?")
|
||||
.arg(filename),
|
||||
VMessageBox::Yes, VMessageBox::No);
|
||||
|
||||
if (response == VMessageBox::No) {
|
||||
/* Don't create it. Just bail. */
|
||||
return;
|
||||
}
|
||||
/* Attempt to create the specified file */
|
||||
if (!torrcFile.open(QIODevice::WriteOnly)) {
|
||||
VMessageBox::warning(this,
|
||||
tr("Failed to Create File"),
|
||||
tr("Unable to create %1 [%2]").arg(filename)
|
||||
.arg(torrcFile.errorString()),
|
||||
VMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//ui.lineTorConfig->setText(filename);
|
||||
// /* Create a new input dialog, which allows users to create files, too */
|
||||
// use misc::getOpenFileName
|
||||
// QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
// //dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
// //dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
// dialog.setFileMode(QFileDialog::AnyFile);
|
||||
// dialog.setReadOnly(false);
|
||||
//
|
||||
// /* Prompt the user to select a file or create a new one */
|
||||
// if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
// return;
|
||||
// }
|
||||
// QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
//
|
||||
// /* Check if the file exists */
|
||||
// QFile torrcFile(filename);
|
||||
// if (!QFileInfo(filename).exists()) {
|
||||
// /* The given file does not exist. Should we create it? */
|
||||
// int response = VMessageBox::question(this,
|
||||
// tr("File Not Found"),
|
||||
// tr("%1 does not exist. Would you like to create it?")
|
||||
// .arg(filename),
|
||||
// VMessageBox::Yes, VMessageBox::No);
|
||||
//
|
||||
// if (response == VMessageBox::No) {
|
||||
// /* Don't create it. Just bail. */
|
||||
// return;
|
||||
// }
|
||||
// /* Attempt to create the specified file */
|
||||
// if (!torrcFile.open(QIODevice::WriteOnly)) {
|
||||
// VMessageBox::warning(this,
|
||||
// tr("Failed to Create File"),
|
||||
// tr("Unable to create %1 [%2]").arg(filename)
|
||||
// .arg(torrcFile.errorString()),
|
||||
// VMessageBox::Ok);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// //ui.lineTorConfig->setText(filename);
|
||||
}
|
||||
|
||||
|
||||
void NetworkDialog::on_actionExportKey_activated()
|
||||
{
|
||||
qDebug() << " exportcert";
|
||||
|
||||
std::string cert = rsPeers->GetRetroshareInvite();
|
||||
if (cert.empty()) {
|
||||
QMessageBox::information(this, tr("RetroShare"),
|
||||
tr("Sorry, create certificate failed"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
QString qdir = QFileDialog::getSaveFileName(this,
|
||||
tr("Please choose a filename"),
|
||||
QDir::homePath(),
|
||||
tr("RetroShare Certificate (*.rsc );;All Files (*)"));
|
||||
//Todo: move save to file to p3Peers::SaveCertificateToFile
|
||||
|
||||
if (qdir.isEmpty() == false) {
|
||||
QFile CertFile (qdir);
|
||||
if (CertFile.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) {
|
||||
if (CertFile.write(QByteArray(cert.c_str())) > 0) {
|
||||
QMessageBox::information(this, tr("RetroShare"),
|
||||
tr("Certificate file successfully created"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
} else {
|
||||
QMessageBox::information(this, tr("RetroShare"),
|
||||
tr("Sorry, certificate file creation failed"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
}
|
||||
CertFile.close();
|
||||
} else {
|
||||
QMessageBox::information(this, tr("RetroShare"),
|
||||
tr("Sorry, certificate file creation failed"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
// qDebug() << " exportcert";
|
||||
//
|
||||
// std::string cert = rsPeers->GetRetroshareInvite();
|
||||
// if (cert.empty()) {
|
||||
// QMessageBox::information(this, tr("RetroShare"),
|
||||
// tr("Sorry, create certificate failed"),
|
||||
// QMessageBox::Ok, QMessageBox::Ok);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// use misc::getSaveFileName
|
||||
// QString qdir = QFileDialog::getSaveFileName(this,
|
||||
// tr("Please choose a filename"),
|
||||
// QDir::homePath(),
|
||||
// tr("RetroShare Certificate (*.rsc );;All Files (*)"));
|
||||
// //Todo: move save to file to p3Peers::SaveCertificateToFile
|
||||
//
|
||||
// if (qdir.isEmpty() == false) {
|
||||
// QFile CertFile (qdir);
|
||||
// if (CertFile.open(QIODevice::WriteOnly/* | QIODevice::Text*/)) {
|
||||
// if (CertFile.write(QByteArray(cert.c_str())) > 0) {
|
||||
// QMessageBox::information(this, tr("RetroShare"),
|
||||
// tr("Certificate file successfully created"),
|
||||
// QMessageBox::Ok, QMessageBox::Ok);
|
||||
// } else {
|
||||
// QMessageBox::information(this, tr("RetroShare"),
|
||||
// tr("Sorry, certificate file creation failed"),
|
||||
// QMessageBox::Ok, QMessageBox::Ok);
|
||||
// }
|
||||
// CertFile.close();
|
||||
// } else {
|
||||
// QMessageBox::information(this, tr("RetroShare"),
|
||||
// tr("Sorry, certificate file creation failed"),
|
||||
// QMessageBox::Ok, QMessageBox::Ok);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void NetworkDialog::on_actionCreate_New_Profile_activated()
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void insertConnect();
|
||||
std::string loadneighbour();
|
||||
// std::string loadneighbour();
|
||||
/* void loadneighbour(); */
|
||||
void updateNewDiscoveryInfo() ;
|
||||
|
||||
@ -55,10 +55,10 @@ private slots:
|
||||
//void unvalidGPGkeyWidgetCostumPopupMenu( QPoint point );
|
||||
|
||||
/** Called when user clicks "Load Cert" to choose location of a Cert file */
|
||||
void loadcert();
|
||||
// void loadcert();
|
||||
|
||||
void authneighbour();
|
||||
void addneighbour();
|
||||
// void authneighbour();
|
||||
// void addneighbour();
|
||||
|
||||
void on_actionAddFriend_activated();
|
||||
//void on_actionCopyKey_activated();
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QColorDialog>
|
||||
#include <QFontDialog>
|
||||
#include <QDropEvent>
|
||||
#include <QFileDialog>
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
#include "common/GroupDefs.h"
|
||||
@ -64,6 +63,7 @@
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include "NewsFeed.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <time.h>
|
||||
@ -1103,18 +1103,15 @@ void PeersDialog::exportfriend()
|
||||
}
|
||||
|
||||
std::string id = getPeerRsCertId(c);
|
||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save Certificate"), "",
|
||||
tr("Certificates (*.pqi)"));
|
||||
|
||||
std::string file = fileName.toStdString();
|
||||
if (file != "")
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_CERT, tr("Save Certificate"), tr("Certificates (*.pqi)"), fileName))
|
||||
{
|
||||
#ifdef PEERS_DEBUG
|
||||
std::cerr << "PeersDialog::exportfriend() Saving to: " << file << std::endl;
|
||||
#endif
|
||||
if (rsPeers)
|
||||
{
|
||||
rsPeers->saveCertificateToFile(id, file);
|
||||
rsPeers->saveCertificateToFile(id, fileName.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1727,8 +1724,8 @@ void PeersDialog::updateAvatar()
|
||||
|
||||
void PeersDialog::getAvatar()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg *.tiff *.gif)");
|
||||
if(!fileName.isEmpty())
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg *.tiff *.gif)"), fileName))
|
||||
{
|
||||
QPixmap picture;
|
||||
picture = QPixmap(fileName).scaled(96,96, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
@ -1794,14 +1791,10 @@ void PeersDialog::statusmessage()
|
||||
|
||||
void PeersDialog::addExtraFile()
|
||||
{
|
||||
// select a file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath = qfile.toStdString();
|
||||
if (filePath != "")
|
||||
{
|
||||
PeersDialog::addAttachment(filePath);
|
||||
}
|
||||
QString file;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", file)) {
|
||||
addAttachment(file.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
|
||||
void PeersDialog::addAttachment(std::string filePath) {
|
||||
@ -1950,12 +1943,13 @@ bool PeersDialog::fileSave()
|
||||
|
||||
bool PeersDialog::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("Text File (*.txt );;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_HISTORY, tr("Save as..."), tr("Text File (*.txt );;All Files (*)"), fn)) {
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PeersDialog::setCurrentFileName(const QString &fileName)
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
|
@ -38,6 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QPainter.h>
|
||||
#include <util/misc.h>
|
||||
|
||||
class RSHumanReadableDelegate: public QAbstractItemDelegate
|
||||
|
@ -20,6 +20,7 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDir>
|
||||
|
||||
#include "SearchDialog.h"
|
||||
#include "RetroShareLink.h"
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QBuffer>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -244,8 +243,8 @@ void CreateChannel::cancelChannel()
|
||||
|
||||
void CreateChannel::addChannelLogo()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), QDir::homePath(), tr("Pictures (*.png *.xpm *.jpg)"));
|
||||
if(!fileName.isEmpty())
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg)"), fileName))
|
||||
{
|
||||
picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <QDragEnterEvent>
|
||||
#include <QUrl>
|
||||
#include <QFileDialog>
|
||||
#include <QTimer>
|
||||
#include <QMessageBox>
|
||||
#include <QBuffer>
|
||||
@ -289,14 +288,15 @@ void CreateChannelMsg::addAttachment(const std::string &hash, const std::string
|
||||
|
||||
void CreateChannelMsg::addExtraFile()
|
||||
{
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "CreateChannelMsg::addExtraFile() opening file dialog";
|
||||
std::cerr << std::endl;
|
||||
/* add a SubFileItem to the attachment section */
|
||||
std::cerr << "CreateChannelMsg::addExtraFile() opening file dialog";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// select a file
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Add Extra File"), "", "", 0, QFileDialog::DontResolveSymlinks);
|
||||
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
|
||||
addAttachment((*fileIt).toUtf8().constData());
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
|
||||
addAttachment((*fileIt).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -563,8 +563,8 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::
|
||||
|
||||
void CreateChannelMsg::addThumbnail()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Load File"), QDir::homePath(), tr("Pictures (*.png *.xpm *.jpg)"));
|
||||
if(!fileName.isEmpty())
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg)"), fileName))
|
||||
{
|
||||
picture = QPixmap(fileName).scaled(156,107, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <QDateTime>
|
||||
#include <QFontDialog>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QBuffer>
|
||||
#include <QTextCodec>
|
||||
#include <QSound>
|
||||
@ -37,6 +36,7 @@
|
||||
#include "PopupChatDialog.h"
|
||||
#include "PopupChatWindow.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "util/misc.h"
|
||||
#include "rshare.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -889,26 +889,19 @@ void PopupChatDialog::updateAvatar()
|
||||
|
||||
void PopupChatDialog::addExtraFile()
|
||||
{
|
||||
// select a file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath = qfile.toStdString();
|
||||
if (filePath != "")
|
||||
{
|
||||
addAttachment(filePath,0);
|
||||
}
|
||||
QString file;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", file)) {
|
||||
addAttachment(file.toUtf8().constData(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::addExtraPicture()
|
||||
{
|
||||
// select a picture file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, "Load Picture File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)",0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath=qfile.toStdString();
|
||||
if(filePath!="")
|
||||
{
|
||||
PopupChatDialog::addAttachment(filePath,1); //picture
|
||||
}
|
||||
// select a picture file
|
||||
QString file;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) {
|
||||
addAttachment(file.toUtf8().constData(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void PopupChatDialog::addAttachment(std::string filePath,int flag)
|
||||
@ -1115,12 +1108,13 @@ bool PopupChatDialog::fileSave()
|
||||
|
||||
bool PopupChatDialog::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("Text File (*.txt );;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_HISTORY, tr("Save as..."), tr("Text File (*.txt );;All Files (*)"), fn)) {
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void PopupChatDialog::setCurrentFileName(const QString &fileName)
|
||||
|
@ -21,13 +21,13 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "PopupChatWindow.h"
|
||||
#include "PopupChatDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/settings/RsharePeerSettings.h"
|
||||
#include "gui/common/StatusDefs.h"
|
||||
#include"util/misc.h"
|
||||
|
||||
#include <retroshare/rsmsgs.h>
|
||||
#include <retroshare/rsnotify.h>
|
||||
@ -262,9 +262,9 @@ void PopupChatWindow::calculateTitle(PopupChatDialog *dialog)
|
||||
|
||||
void PopupChatWindow::getAvatar()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
|
||||
|
||||
if(!fileName.isEmpty()) {
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg *.tiff *.gif)"), fileName))
|
||||
{
|
||||
QPixmap picture = QPixmap(fileName).scaled(96,96, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
std::cerr << "Sending avatar image down the pipe" << std::endl;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDropEvent>
|
||||
|
||||
@ -195,14 +194,12 @@ void CreateForumMsg::addSmileys()
|
||||
|
||||
void CreateForumMsg::addFile()
|
||||
{
|
||||
// select a file
|
||||
QString qfile = QFileDialog::getOpenFileName(this, tr("Add Extra File"), "", "", 0,
|
||||
QFileDialog::DontResolveSymlinks);
|
||||
std::string filePath = qfile.toStdString();
|
||||
if (filePath != "")
|
||||
{
|
||||
CreateForumMsg::addAttachment(filePath);
|
||||
}
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
|
||||
addAttachment((*fileIt).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::addAttachment(std::string filePath) {
|
||||
@ -236,21 +233,18 @@ void CreateForumMsg::fileHashingFinished(AttachFileItem* file) {
|
||||
return;
|
||||
}
|
||||
|
||||
//convert fileSize from uint_64 to string for html link
|
||||
char fileSizeChar [100];
|
||||
sprintf(fileSizeChar, "%llu", (unsigned long long int)file->FileSize());
|
||||
std::string fileSize = *(&fileSizeChar);
|
||||
RetroShareLink link(QString::fromUtf8(file->FileName().c_str()), file->FileSize(), QString::fromStdString(file->FileHash()));
|
||||
if (link.valid()) {
|
||||
QString mesgString = link.toHtmlSize() + "<br>";
|
||||
|
||||
std::string mesgString = "<a href='retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "'>"
|
||||
+ "retroshare://file|" + (file->FileName()) + "|" + fileSize + "|" + (file->FileHash()) + "</a>" + "<br>";
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString << std::endl;
|
||||
std::cerr << "CreateForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
ui.forumMessage->textCursor().insertHtml(QString::fromStdString(mesgString));
|
||||
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
ui.forumMessage->textCursor().insertHtml(mesgString);
|
||||
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
}
|
||||
}
|
||||
|
||||
void CreateForumMsg::dropEvent(QDropEvent *event)
|
||||
|
@ -25,12 +25,12 @@
|
||||
#include <QTextCodec>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QFileDialog>
|
||||
#include <QTextList>
|
||||
#include <QColorDialog>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QTimer>
|
||||
#include <QCompleter>
|
||||
#include <QItemDelegate>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -1894,10 +1894,10 @@ void MessageComposer::fileNew()
|
||||
|
||||
void MessageComposer::fileOpen()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Open File..."),
|
||||
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (!fn.isEmpty())
|
||||
QString fn;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_MESSAGES, tr("Open File..."), tr("HTML-Files (*.htm *.html);;All Files (*)"), fn)) {
|
||||
load(fn);
|
||||
}
|
||||
}
|
||||
|
||||
bool MessageComposer::fileSave()
|
||||
@ -1917,12 +1917,13 @@ bool MessageComposer::fileSave()
|
||||
|
||||
bool MessageComposer::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_MESSAGES, tr("Save as..."), tr("HTML-Files (*.htm *.html);;All Files (*)"), fn)) {
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void MessageComposer::saveasDraft()
|
||||
@ -1949,9 +1950,8 @@ void MessageComposer::filePrint()
|
||||
void MessageComposer::filePrintPdf()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",
|
||||
QString(), "*.pdf");
|
||||
if (!fileName.isEmpty()) {
|
||||
QString fileName;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_MESSAGES, tr("Export PDF"), "*.pdf", fileName)) {
|
||||
if (QFileInfo(fileName).suffix().isEmpty())
|
||||
fileName.append(".pdf");
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
@ -2024,19 +2024,15 @@ void MessageComposer::on_contactsdockWidget_visibilityChanged(bool visible)
|
||||
|
||||
void MessageComposer::addImage()
|
||||
{
|
||||
QString fileimg = QFileDialog::getOpenFileName( this, tr( "Choose Image" ),
|
||||
QString(Settings->valueFromGroup("MessageComposer", "LastDir").toString()) ,tr("Image Files supported (*.png *.jpeg *.jpg *.gif)"));
|
||||
QString fileimg;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Choose Image"), tr("Image Files supported (*.png *.jpeg *.jpg *.gif)"), fileimg)) {
|
||||
QImage base(fileimg);
|
||||
|
||||
if ( fileimg.isEmpty() ) {
|
||||
return;
|
||||
QString pathimage = fileimg.left(fileimg.lastIndexOf("/"))+"/";
|
||||
Settings->setValueToGroup("MessageComposer", "LastDir", pathimage);
|
||||
|
||||
Create_New_Image_Tag(fileimg);
|
||||
}
|
||||
|
||||
QImage base(fileimg);
|
||||
|
||||
QString pathimage = fileimg.left(fileimg.lastIndexOf("/"))+"/";
|
||||
Settings->setValueToGroup("MessageComposer", "LastDir", pathimage);
|
||||
|
||||
Create_New_Image_Tag(fileimg);
|
||||
}
|
||||
|
||||
void MessageComposer::Create_New_Image_Tag( const QString urlremoteorlocal )
|
||||
@ -2139,9 +2135,11 @@ void MessageComposer::addPostSplitter()
|
||||
void MessageComposer::attachFile()
|
||||
{
|
||||
// select a file
|
||||
QStringList files = QFileDialog::getOpenFileNames(this, tr("Add Extra File"), "", "", 0, QFileDialog::DontResolveSymlinks);
|
||||
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
|
||||
MessageComposer::addAttachment((*fileIt).toUtf8().constData());
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
for (QStringList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) {
|
||||
addAttachment((*fileIt).toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,11 +21,12 @@
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QTextCodec>
|
||||
|
||||
#include "CryptoPage.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rspeers.h> //for rsPeers variable
|
||||
|
||||
@ -115,12 +116,12 @@ bool CryptoPage::fileSave()
|
||||
|
||||
bool CryptoPage::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("RetroShare Certificate (*.rsc );;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_CERT, tr("Save as..."), tr("RetroShare Certificate (*.rsc );;All Files (*)"), fn)) {
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CryptoPage::setCurrentFileName(const QString &fileName)
|
||||
|
@ -173,6 +173,45 @@ void RshareSettings::setSheetName(QString sheet)
|
||||
setValue(SETTING_SHEETNAME, sheet);
|
||||
}
|
||||
|
||||
static QString getKeyForLastDir(RshareSettings::enumLastDir type)
|
||||
{
|
||||
switch (type) {
|
||||
case RshareSettings::LASTDIR_EXTRAFILE:
|
||||
return "ExtraFile";
|
||||
case RshareSettings::LASTDIR_CERT:
|
||||
return "Certificate";
|
||||
case RshareSettings::LASTDIR_HISTORY:
|
||||
return "History";
|
||||
case RshareSettings::LASTDIR_IMAGES:
|
||||
return "Images";
|
||||
case RshareSettings::LASTDIR_MESSAGES:
|
||||
return "Messages";
|
||||
case RshareSettings::LASTDIR_BLOGS:
|
||||
return "Messages";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
QString RshareSettings::getLastDir(enumLastDir type)
|
||||
{
|
||||
QString key = getKeyForLastDir(type);
|
||||
if (key.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return valueFromGroup("LastDir", key).toString();
|
||||
}
|
||||
|
||||
void RshareSettings::setLastDir(enumLastDir type, const QString &lastDir)
|
||||
{
|
||||
QString key = getKeyForLastDir(type);
|
||||
if (key.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setValueToGroup("LastDir", key, lastDir);
|
||||
}
|
||||
|
||||
/** Returns the bandwidth line filter. */
|
||||
uint RshareSettings::getBWGraphFilter()
|
||||
{
|
||||
|
@ -55,7 +55,17 @@ class QMainWindow;
|
||||
*/
|
||||
class RshareSettings : public RSettings
|
||||
{
|
||||
|
||||
public:
|
||||
enum enumLastDir
|
||||
{
|
||||
LASTDIR_EXTRAFILE,
|
||||
LASTDIR_CERT,
|
||||
LASTDIR_HISTORY,
|
||||
LASTDIR_IMAGES,
|
||||
LASTDIR_MESSAGES,
|
||||
LASTDIR_BLOGS
|
||||
};
|
||||
|
||||
public:
|
||||
/* create settings object */
|
||||
static void Create ();
|
||||
@ -92,6 +102,9 @@ public:
|
||||
/** Set the destination log file. */
|
||||
void setLogFile(QString file);
|
||||
|
||||
QString getLastDir(enumLastDir type);
|
||||
void setLastDir(enumLastDir type, const QString &lastDir);
|
||||
|
||||
/* Get the bandwidth graph line filter. */
|
||||
uint getBWGraphFilter();
|
||||
/** Set the bandwidth graph line filter. */
|
||||
|
@ -20,10 +20,10 @@
|
||||
****************************************************************/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "CreateBlog.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsblogs.h>
|
||||
|
||||
@ -143,8 +143,8 @@ void CreateBlog::createBlog()
|
||||
|
||||
void CreateBlog::addBlogLogo(){
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
|
||||
if(!fileName.isEmpty())
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg)"), fileName))
|
||||
{
|
||||
picture = QPixmap(fileName).scaled(64,64, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QColorDialog>
|
||||
#include <QFontComboBox>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QPrintDialog>
|
||||
#include <QPrinter>
|
||||
#include <QTextCodec>
|
||||
@ -35,6 +35,7 @@
|
||||
|
||||
#include "CreateBlogMsg.h"
|
||||
#include "gui/msgs/textformat.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsblogs.h>
|
||||
|
||||
@ -803,9 +804,8 @@ void CreateBlogMsg::fileNew()
|
||||
|
||||
void CreateBlogMsg::fileOpen()
|
||||
{
|
||||
QString fn = QFileDialog::getOpenFileName(this, tr("Open File..."),
|
||||
QString(), tr("HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (!fn.isEmpty())
|
||||
QString fn;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_BLOGS, tr("Open File..."), tr("HTML-Files (*.htm *.html);;All Files (*)"), fn))
|
||||
load(fn);
|
||||
}
|
||||
|
||||
@ -823,14 +823,15 @@ bool CreateBlogMsg::fileSave()
|
||||
|
||||
bool CreateBlogMsg::fileSaveAs()
|
||||
{
|
||||
QString fn = QFileDialog::getSaveFileName(this, tr("Save as..."),
|
||||
QString(), tr("ODF files (*.odt);;HTML-Files (*.htm *.html);;All Files (*)"));
|
||||
if (fn.isEmpty())
|
||||
return false;
|
||||
if (! (fn.endsWith(".odt", Qt::CaseInsensitive) || fn.endsWith(".htm", Qt::CaseInsensitive) || fn.endsWith(".html", Qt::CaseInsensitive)) )
|
||||
fn += ".odt"; // default
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
QString fn;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_BLOGS, tr("Save as..."), tr("ODF files (*.odt);;HTML-Files (*.htm *.html);;All Files (*)"), fn)) {
|
||||
if (! (fn.endsWith(".odt", Qt::CaseInsensitive) || fn.endsWith(".htm", Qt::CaseInsensitive) || fn.endsWith(".html", Qt::CaseInsensitive)) )
|
||||
fn += ".odt"; // default
|
||||
setCurrentFileName(fn);
|
||||
return fileSave();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CreateBlogMsg::filePrint()
|
||||
@ -872,9 +873,8 @@ void CreateBlogMsg::filePrintPdf()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
//! [0]
|
||||
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",
|
||||
QString(), "*.pdf");
|
||||
if (!fileName.isEmpty()) {
|
||||
QString fileName;
|
||||
if (misc::getSaveFileName(this, RshareSettings::LASTDIR_MESSAGES, tr("Export PDF"), "*.pdf", fileName)) {
|
||||
if (QFileInfo(fileName).suffix().isEmpty())
|
||||
fileName.append(".pdf");
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
@ -901,22 +901,14 @@ void CreateBlogMsg::setCurrentFileName(const QString &fileName)
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
void CreateBlogMsg::addImage()
|
||||
void CreateBlogMsg::addImage()
|
||||
{
|
||||
|
||||
QString fileimg = QFileDialog::getOpenFileName( this, tr( "Choose Image" ),
|
||||
QString(setter.value("LastDir").toString()) ,tr("Image Files supported (*.png *.jpeg *.jpg *.gif)"));
|
||||
QString fileimg;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_MESSAGES, tr("Choose Image"), tr("Image Files supported (*.png *.jpeg *.jpg *.gif)"), fileimg)) {
|
||||
QImage base(fileimg);
|
||||
|
||||
if ( fileimg.isEmpty() ) {
|
||||
return;
|
||||
Create_New_Image_Tag(fileimg);
|
||||
}
|
||||
|
||||
QImage base(fileimg);
|
||||
|
||||
QString pathimage = fileimg.left(fileimg.lastIndexOf("/"))+"/";
|
||||
setter.setValue("LastDir",pathimage);
|
||||
|
||||
Create_New_Image_Tag(fileimg);
|
||||
}
|
||||
|
||||
void CreateBlogMsg::Create_New_Image_Tag( const QString urlremoteorlocal )
|
||||
|
Binary file not shown.
@ -1742,6 +1742,16 @@ p, li { white-space: pre-wrap; }
|
||||
<source>Please add a Name</source>
|
||||
<translation>Bitte Name hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+53"/>
|
||||
<source>Load File</source>
|
||||
<translation type="unfinished">Lade Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>Pictures (*.png *.xpm *.jpg)</source>
|
||||
<translation type="unfinished">Bilder (*.png *.xpm *.jpg)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/unfinished/blogs/CreateBlog.ui" line="-137"/>
|
||||
<source>Authemticated Messages</source>
|
||||
@ -1876,7 +1886,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Rückgängig</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/unfinished/blogs/CreateBlogMsg.cpp" line="+197"/>
|
||||
<location filename="../gui/unfinished/blogs/CreateBlogMsg.cpp" line="+198"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -2036,12 +2046,12 @@ Do you want to save your changes?</source>
|
||||
Möchten Sie die Änderungen speichern?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+21"/>
|
||||
<location line="+22"/>
|
||||
<source>Open File...</source>
|
||||
<translation>Datei öffnen...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>HTML-Files (*.htm *.html);;All Files (*)</source>
|
||||
<translation>HTML-Dateien (*.htm *.html);;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
@ -2051,22 +2061,27 @@ Möchten Sie die Änderungen speichern?</translation>
|
||||
<translation>Speichern unter...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>ODF files (*.odt);;HTML-Files (*.htm *.html);;All Files (*)</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+16"/>
|
||||
<location line="+17"/>
|
||||
<source>Print Document</source>
|
||||
<translation>Dokument drucken</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+64"/>
|
||||
<location line="+33"/>
|
||||
<source>Export PDF</source>
|
||||
<translation type="unfinished">PDF exportieren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+30"/>
|
||||
<source>Choose Image</source>
|
||||
<translation>Bild wählen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>Image Files supported (*.png *.jpeg *.jpg *.gif)</source>
|
||||
<translation>Unterstützte Bilddateien (*.png *.jpeg *.jpg *.gif)</translation>
|
||||
</message>
|
||||
@ -2174,7 +2189,7 @@ Möchten Sie die Änderungen speichern?</translation>
|
||||
<translation>Erstellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/channels/CreateChannel.cpp" line="+164"/>
|
||||
<location filename="../gui/channels/CreateChannel.cpp" line="+163"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -2184,7 +2199,7 @@ Möchten Sie die Änderungen speichern?</translation>
|
||||
<translation>Bitte einen Name hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+83"/>
|
||||
<location line="+84"/>
|
||||
<source>Load File</source>
|
||||
<translation>Lade Datei</translation>
|
||||
</message>
|
||||
@ -2285,12 +2300,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Drag'n'Drop Dateien aus den Suchergebnissen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/channels/CreateChannelMsg.cpp" line="+297"/>
|
||||
<location filename="../gui/channels/CreateChannelMsg.cpp" line="+296"/>
|
||||
<source>Add Extra File</source>
|
||||
<translation>Zusätzlich eine Datei hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+26"/>
|
||||
<location line="+27"/>
|
||||
<location line="+202"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
@ -2306,7 +2321,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Bitte Subjekt nicht vergessen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+40"/>
|
||||
<location line="+41"/>
|
||||
<source>Load File</source>
|
||||
<translation>Lade Datei</translation>
|
||||
</message>
|
||||
@ -2436,7 +2451,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location line="+173"/>
|
||||
<location filename="../gui/forums/CreateForumMsg.cpp" line="+72"/>
|
||||
<location filename="../gui/forums/CreateForumMsg.cpp" line="+71"/>
|
||||
<source>Paste RetroShare Link</source>
|
||||
<translation>RetroShare Link einfügen</translation>
|
||||
</message>
|
||||
@ -2481,7 +2496,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Du kannst Dateien mit Drag'n'Drop anhängen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/forums/CreateForumMsg.cpp" line="+93"/>
|
||||
<location filename="../gui/forums/CreateForumMsg.cpp" line="+88"/>
|
||||
<location line="+4"/>
|
||||
<source>Drop file error.</source>
|
||||
<translation>Dateifehler bei Drag'n'Drop.</translation>
|
||||
@ -2542,7 +2557,7 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>CryptoPage</name>
|
||||
<message>
|
||||
<location filename="../gui/settings/CryptoPage.cpp" line="+93"/>
|
||||
<location filename="../gui/settings/CryptoPage.cpp" line="+94"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -2552,12 +2567,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Dein öffentlicher Schlüssel ist in die Zwischenablage kopiert worden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+24"/>
|
||||
<location line="+25"/>
|
||||
<source>Save as...</source>
|
||||
<translation>Speichern unter...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>RetroShare Certificate (*.rsc );;All Files (*)</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
@ -5827,18 +5842,18 @@ Möchtest Du die Nachricht in den Entwürfen speichern?</translation>
|
||||
<translation>&Format</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+257"/>
|
||||
<location line="+258"/>
|
||||
<source>Open File...</source>
|
||||
<translation>Datei öffnen...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<location line="+23"/>
|
||||
<source>HTML-Files (*.htm *.html);;All Files (*)</source>
|
||||
<translation>HTML-Dateien (*.htm *.html);;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-1"/>
|
||||
<location line="+0"/>
|
||||
<source>Save as...</source>
|
||||
<translation>Speichern unter...</translation>
|
||||
</message>
|
||||
@ -5848,29 +5863,34 @@ Möchtest Du die Nachricht in den Entwürfen speichern?</translation>
|
||||
<translation>Dokument drucken</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+62"/>
|
||||
<location line="+12"/>
|
||||
<source>Export PDF</source>
|
||||
<translation>PDF exportieren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+49"/>
|
||||
<source>Message has not been Sent.
|
||||
Do you want to save message ?</source>
|
||||
<translation>Nachricht noch nicht versandt.
|
||||
Willst Du die Nachricht speichern ?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+24"/>
|
||||
<location line="+25"/>
|
||||
<source>Choose Image</source>
|
||||
<translation>Bild wählen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>Image Files supported (*.png *.jpeg *.jpg *.gif)</source>
|
||||
<translation>Unterstützte Bilddateien (*.png *.jpeg *.jpg *.gif)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+114"/>
|
||||
<location line="+111"/>
|
||||
<source>Add Extra File</source>
|
||||
<translation>Zusätzliche Datei hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+273"/>
|
||||
<location line="+274"/>
|
||||
<location line="+6"/>
|
||||
<source>Drop file error.</source>
|
||||
<translation>Dateifehler bei Drag'n'Drop.</translation>
|
||||
@ -5886,7 +5906,7 @@ Willst Du die Nachricht speichern ?</translation>
|
||||
<translation>Datei nicht gefunden oder Dateiname nicht akzeptiert.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-2014"/>
|
||||
<location line="-2012"/>
|
||||
<source>Friend Recommendation(s)</source>
|
||||
<translation>Freundempfehlung(en)</translation>
|
||||
</message>
|
||||
@ -6372,7 +6392,7 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>MessengerWindow</name>
|
||||
<message>
|
||||
<location filename="../gui/MessengerWindow.cpp" line="+293"/>
|
||||
<location filename="../gui/MessengerWindow.cpp" line="+292"/>
|
||||
<source>Expand all</source>
|
||||
<translation>Alle erweitern</translation>
|
||||
</message>
|
||||
@ -6587,37 +6607,27 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>NetworkDialog</name>
|
||||
<message>
|
||||
<location filename="../gui/NetworkDialog.cpp" line="+300"/>
|
||||
<location line="+328"/>
|
||||
<source>Select a pem/pqi File</source>
|
||||
<translation>Wählen einer PEM- oder PQI-Datei</translation>
|
||||
<translation type="obsolete">Wählen einer PEM- oder PQI-Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-311"/>
|
||||
<location line="+328"/>
|
||||
<source>File Not Found</source>
|
||||
<translation>Datei nicht gefunden</translation>
|
||||
<translation type="obsolete">Datei nicht gefunden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-327"/>
|
||||
<location line="+328"/>
|
||||
<source>%1 does not exist. Would you like to create it?</source>
|
||||
<translation>%1 ist nicht vorhanden. Möchten Sie es jetzt erstellen?</translation>
|
||||
<translation type="obsolete">%1 ist nicht vorhanden. Möchten Sie es jetzt erstellen?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-317"/>
|
||||
<location line="+328"/>
|
||||
<source>Failed to Create File</source>
|
||||
<translation>Es ist nicht gelungen, die Datei zu erstellen</translation>
|
||||
<translation type="obsolete">Es ist nicht gelungen, die Datei zu erstellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-327"/>
|
||||
<location line="+328"/>
|
||||
<source>Unable to create %1 [%2]</source>
|
||||
<translation>Kann %1 [%2] nicht erstellen</translation>
|
||||
<translation type="obsolete">Kann %1 [%2] nicht erstellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-218"/>
|
||||
<location filename="../gui/NetworkDialog.cpp" line="+436"/>
|
||||
<source>Personal signature</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -6654,14 +6664,12 @@ Right-click and select 'make friend' to be able to connect.</source>
|
||||
Rechtsklick und als Freund hinzufügen um zu verbinden.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+97"/>
|
||||
<source>Select Certificate</source>
|
||||
<translation>Zertifikat auswählen</translation>
|
||||
<translation type="obsolete">Zertifikat auswählen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<source>Certificates (*.pqi *.pem)</source>
|
||||
<translation>Zertifikate (*.pqi *.pem)</translation>
|
||||
<translation type="obsolete">Zertifikate (*.pqi *.pem)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/NetworkDialog.ui" line="+111"/>
|
||||
@ -6772,7 +6780,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Leeren</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/NetworkDialog.cpp" line="-364"/>
|
||||
<location filename="../gui/NetworkDialog.cpp" line="-263"/>
|
||||
<source>Deny friend</source>
|
||||
<translation>Blockiere Freund</translation>
|
||||
</message>
|
||||
@ -6797,12 +6805,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Nachbar-Details...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+201"/>
|
||||
<location line="+198"/>
|
||||
<source>Unknown</source>
|
||||
<translation>Unbekannt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-301"/>
|
||||
<location line="-298"/>
|
||||
<source>Authentication matrix</source>
|
||||
<translation>Authentifizierungsmatrix</translation>
|
||||
</message>
|
||||
@ -6812,28 +6820,17 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Netzwerk Ansicht</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+377"/>
|
||||
<location line="+374"/>
|
||||
<source>yourself</source>
|
||||
<translation>selbst</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+142"/>
|
||||
<location line="+16"/>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-9"/>
|
||||
<source>Certificate file successfully created</source>
|
||||
<translation>Zertifikat-Datei erfolgreich erstellt</translation>
|
||||
<translation type="obsolete">Zertifikat-Datei erfolgreich erstellt</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<location line="+6"/>
|
||||
<source>Sorry, certificate file creation failed</source>
|
||||
<translation>Zertifikat-Datei konnte nicht erstellt werden</translation>
|
||||
<translation type="obsolete">Zertifikat-Datei konnte nicht erstellt werden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/NetworkDialog.ui" line="-179"/>
|
||||
@ -6889,19 +6886,16 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Peer ID</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/NetworkDialog.cpp" line="-26"/>
|
||||
<source>Sorry, create certificate failed</source>
|
||||
<translation>Zertifikat-Datei konnte nicht erstellt werden</translation>
|
||||
<translation type="obsolete">Zertifikat-Datei konnte nicht erstellt werden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+6"/>
|
||||
<source>Please choose a filename</source>
|
||||
<translation>Bitte wählen sie einen Dateinamen</translation>
|
||||
<translation type="obsolete">Bitte wählen sie einen Dateinamen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>RetroShare Certificate (*.rsc );;All Files (*)</source>
|
||||
<translation>RetroShare Zertifikat (*.rsc );;Alle Dateien (*)</translation>
|
||||
<translation type="obsolete">RetroShare Zertifikat (*.rsc );;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -7315,12 +7309,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Chat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+674"/>
|
||||
<location line="+675"/>
|
||||
<source>Save Certificate</source>
|
||||
<translation>Zertifikat speichern</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>Certificates (*.pqi)</source>
|
||||
<translation>Zertifikate (*.pqi)</translation>
|
||||
</message>
|
||||
@ -7435,18 +7429,28 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Verfügbar</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+422"/>
|
||||
<location line="+419"/>
|
||||
<location line="+2"/>
|
||||
<source>New group chat</source>
|
||||
<translation>Neuer Gruppenchat</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+352"/>
|
||||
<location line="+285"/>
|
||||
<source>Load File</source>
|
||||
<translation>Lade Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>Pictures (*.png *.xpm *.jpg *.tiff *.gif)</source>
|
||||
<translation>Bilder (*.png *.xpm *.jpg *.tiff *.gif)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+67"/>
|
||||
<source>Add Extra File</source>
|
||||
<translation>Zusätzliche Datei hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+99"/>
|
||||
<location line="+95"/>
|
||||
<location line="+6"/>
|
||||
<source>Drop file error.</source>
|
||||
<translation>Dateifehler bei Drag'n'Drop.</translation>
|
||||
@ -7554,7 +7558,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location line="-107"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1479"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1472"/>
|
||||
<source>Add Friend</source>
|
||||
<translation>Freund hinzufügen</translation>
|
||||
</message>
|
||||
@ -7609,12 +7613,12 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-40"/>
|
||||
<location line="+846"/>
|
||||
<location line="+843"/>
|
||||
<source>RetroShare</source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-807"/>
|
||||
<location line="-804"/>
|
||||
<source>Message Group</source>
|
||||
<translation>Gruppe anschreiben</translation>
|
||||
</message>
|
||||
@ -7629,17 +7633,17 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Gruppe entfernen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+799"/>
|
||||
<location line="+796"/>
|
||||
<source>Do you want to remove this Friend?</source>
|
||||
<translation>Willst du diesen Freund entfernen?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+729"/>
|
||||
<location line="+726"/>
|
||||
<source>Save as...</source>
|
||||
<translation>Speichern unter...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>Text File (*.txt );;All Files (*)</source>
|
||||
<translation>Text Datei (*.txt );;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
@ -7667,12 +7671,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Status Spalte ausblenden</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1805"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-1798"/>
|
||||
<source>Friends Storm</source>
|
||||
<translation>Aktivitäten</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1160"/>
|
||||
<location line="+1157"/>
|
||||
<source>is typing...</source>
|
||||
<translation>tippt...</translation>
|
||||
</message>
|
||||
@ -7692,7 +7696,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Freunde</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-862"/>
|
||||
<location filename="../gui/PeersDialog.cpp" line="-859"/>
|
||||
<location line="+80"/>
|
||||
<source>Paste Friend Link</source>
|
||||
<translation>RetroShare Link einfügen</translation>
|
||||
@ -7969,7 +7973,7 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>PluginFrame</name>
|
||||
<message>
|
||||
<location filename="../gui/PluginManagerWidget.cpp" line="+62"/>
|
||||
<location filename="../gui/PluginManagerWidget.cpp" line="+61"/>
|
||||
<source>Remove</source>
|
||||
<translation>Entfernen</translation>
|
||||
</message>
|
||||
@ -8005,12 +8009,17 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Avatar zeigen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+315"/>
|
||||
<location line="+153"/>
|
||||
<source>Load Picture File</source>
|
||||
<translation>Lade Bilddatei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+155"/>
|
||||
<source>File not found or file name not accepted.</source>
|
||||
<translation>Datei nicht gefunden oder Dateiname nicht akzeptiert.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+90"/>
|
||||
<location line="+91"/>
|
||||
<source>Messages you send will be delivered after Friend is again Online</source>
|
||||
<translation>Nachrichten, die Du versendest gehen bei diesem Freund erst wieder ein wenn er Online ist</translation>
|
||||
</message>
|
||||
@ -8078,12 +8087,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Durchgestrichen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="-261"/>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="-255"/>
|
||||
<source>Add Extra File</source>
|
||||
<translation>Zusätzlich eine Datei hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+165"/>
|
||||
<location line="+158"/>
|
||||
<location line="+6"/>
|
||||
<source>Drop file error.</source>
|
||||
<translation>Dateifehler bei Drag'n'Drop.</translation>
|
||||
@ -8105,17 +8114,17 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Chat Verlauf speichern</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="+60"/>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="+61"/>
|
||||
<source>Save as...</source>
|
||||
<translation>Speichern unter...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+1"/>
|
||||
<location line="+0"/>
|
||||
<source>Text File (*.txt );;All Files (*)</source>
|
||||
<translation>Text Datei (*.txt );;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-719"/>
|
||||
<location line="-712"/>
|
||||
<source>Your Friend is offline
|
||||
Do you want to send them a Message instead</source>
|
||||
<translation>Dein Freund ist Offline willst du ihm stattdessen eine Nachricht senden</translation>
|
||||
@ -8126,7 +8135,7 @@ Do you want to send them a Message instead</source>
|
||||
<translation>Bild anhängen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="+761"/>
|
||||
<location filename="../gui/chat/PopupChatDialog.cpp" line="+755"/>
|
||||
<source>is Idle and may not reply</source>
|
||||
<translation>antwortet möglicherweise nicht, da der Status auf "Untätig" gesetzt wurde</translation>
|
||||
</message>
|
||||
@ -8146,7 +8155,7 @@ Do you want to send them a Message instead</source>
|
||||
<translation>ist Offline.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-719"/>
|
||||
<location line="-713"/>
|
||||
<source>Paste RetroShare Link</source>
|
||||
<translation>RetroShare Link einfügen</translation>
|
||||
</message>
|
||||
@ -8195,6 +8204,16 @@ Do you want to send them a Message instead</source>
|
||||
<source>RetroShare</source>
|
||||
<translation>RetroShare</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+7"/>
|
||||
<source>Load File</source>
|
||||
<translation>Lade Datei</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+0"/>
|
||||
<source>Pictures (*.png *.xpm *.jpg *.tiff *.gif)</source>
|
||||
<translation>Bilder (*.png *.xpm *.jpg *.tiff *.gif)</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>PrintPreview</name>
|
||||
@ -8336,7 +8355,7 @@ Do you want to send them a Message instead</source>
|
||||
<context>
|
||||
<name>ProfileView</name>
|
||||
<message>
|
||||
<location filename="../gui/profile/ProfileView.cpp" line="+72"/>
|
||||
<location filename="../gui/profile/ProfileView.cpp" line="+70"/>
|
||||
<source>Clear Photo</source>
|
||||
<translation>Photo entfernen</translation>
|
||||
</message>
|
||||
@ -8743,17 +8762,17 @@ p, li { white-space: pre-wrap; }
|
||||
<message>
|
||||
<location filename="../gui/elastic/node.cpp" line="+320"/>
|
||||
<source>Deny friend</source>
|
||||
<translation type="unfinished">Blockiere Freund</translation>
|
||||
<translation>Blockiere Freund</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>Make friend</source>
|
||||
<translation type="unfinished">Freund hinzufügen</translation>
|
||||
<translation>Freund hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+2"/>
|
||||
<source>Peer details</source>
|
||||
<translation type="unfinished">Nachbar Details</translation>
|
||||
<translation>Nachbar Details</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -9281,7 +9300,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location line="+196"/>
|
||||
<location filename="../gui/SearchDialog.cpp" line="+218"/>
|
||||
<location filename="../gui/SearchDialog.cpp" line="+219"/>
|
||||
<source>Download</source>
|
||||
<translation>Herunterladen</translation>
|
||||
</message>
|
||||
@ -10694,7 +10713,7 @@ p, li { white-space: pre-wrap; }
|
||||
</message>
|
||||
<message>
|
||||
<location line="+26"/>
|
||||
<location filename="../gui/feeds/SubFileItem.cpp" line="+578"/>
|
||||
<location filename="../gui/feeds/SubFileItem.cpp" line="+576"/>
|
||||
<location line="+6"/>
|
||||
<source>Play File</source>
|
||||
<translation>Datei abspielen</translation>
|
||||
@ -11473,7 +11492,7 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>misc</name>
|
||||
<message>
|
||||
<location filename="../util/misc.h" line="+118"/>
|
||||
<location filename="../util/misc.cpp" line="+36"/>
|
||||
<source>Unknown</source>
|
||||
<comment>Unknown (size)</comment>
|
||||
<translation>Unbekannt</translation>
|
||||
@ -11509,7 +11528,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+179"/>
|
||||
<location line="+124"/>
|
||||
<source>Unknown</source>
|
||||
<translation>Unbekannt</translation>
|
||||
</message>
|
||||
|
286
retroshare-gui/src/util/misc.cpp
Normal file
286
retroshare-gui/src/util/misc.cpp
Normal file
@ -0,0 +1,286 @@
|
||||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2008, defnax
|
||||
* Copyright (C) 2006 Christophe Dumez
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*************************************************************************/
|
||||
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "misc.h"
|
||||
|
||||
// return best userfriendly storage unit (B, KiB, MiB, GiB, TiB)
|
||||
// use Binary prefix standards from IEC 60027-2
|
||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||
// value must be given in bytes
|
||||
QString misc::friendlyUnit(float val)
|
||||
{
|
||||
if(val < 0) {
|
||||
return tr("Unknown", "Unknown (size)");
|
||||
}
|
||||
const QString units[4] = {tr(" B", "bytes"), tr(" KiB", "kibibytes (1024 bytes)"), tr(" MiB", "mebibytes (1024 kibibytes)"), tr(" GiB", "gibibytes (1024 mibibytes)")};
|
||||
for(unsigned int i=0; i<5; ++i) {
|
||||
if (val < 1024.) {
|
||||
return QString(QByteArray::number(val, 'f', 1)) + units[i];
|
||||
}
|
||||
val /= 1024.;
|
||||
}
|
||||
return QString(QByteArray::number(val, 'f', 1)) + tr(" TiB", "tebibytes (1024 gibibytes)");
|
||||
}
|
||||
|
||||
bool misc::isPreviewable(QString extension)
|
||||
{
|
||||
extension = extension.toUpper();
|
||||
if(extension == "AVI") return true;
|
||||
if(extension == "MP3") return true;
|
||||
if(extension == "OGG") return true;
|
||||
if(extension == "OGM") return true;
|
||||
if(extension == "WMV") return true;
|
||||
if(extension == "WMA") return true;
|
||||
if(extension == "MPEG") return true;
|
||||
if(extension == "MPG") return true;
|
||||
if(extension == "ASF") return true;
|
||||
if(extension == "QT") return true;
|
||||
if(extension == "RM") return true;
|
||||
if(extension == "RMVB") return true;
|
||||
if(extension == "RMV") return true;
|
||||
if(extension == "SWF") return true;
|
||||
if(extension == "FLV") return true;
|
||||
if(extension == "WAV") return true;
|
||||
if(extension == "MOV") return true;
|
||||
if(extension == "VOB") return true;
|
||||
if(extension == "MID") return true;
|
||||
if(extension == "AC3") return true;
|
||||
if(extension == "MP4") return true;
|
||||
if(extension == "MP2") return true;
|
||||
if(extension == "AVI") return true;
|
||||
if(extension == "FLAC") return true;
|
||||
if(extension == "AU") return true;
|
||||
if(extension == "MPE") return true;
|
||||
if(extension == "MOV") return true;
|
||||
if(extension == "MKV") return true;
|
||||
if(extension == "AIF") return true;
|
||||
if(extension == "AIFF") return true;
|
||||
if(extension == "AIFC") return true;
|
||||
if(extension == "RA") return true;
|
||||
if(extension == "RAM") return true;
|
||||
if(extension == "M4P") return true;
|
||||
if(extension == "M4A") return true;
|
||||
if(extension == "3GP") return true;
|
||||
if(extension == "AAC") return true;
|
||||
if(extension == "SWA") return true;
|
||||
if(extension == "MPC") return true;
|
||||
if(extension == "MPP") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// return qBittorrent config path
|
||||
QString misc::qBittorrentPath()
|
||||
{
|
||||
QString qBtPath = QDir::homePath()+QDir::separator()+QString::fromUtf8(".qbittorrent") + QDir::separator();
|
||||
// Create dir if it does not exist
|
||||
if(!QFile::exists(qBtPath)){
|
||||
QDir dir(qBtPath);
|
||||
dir.mkpath(qBtPath);
|
||||
}
|
||||
return qBtPath;
|
||||
}
|
||||
|
||||
QString misc::findFileInDir(QString dir_path, QString fileName)
|
||||
{
|
||||
QDir dir(dir_path);
|
||||
if(dir.exists(fileName)) {
|
||||
return dir.filePath(fileName);
|
||||
}
|
||||
QStringList subDirs = dir.entryList(QDir::Dirs);
|
||||
QString subdir_name;
|
||||
foreach(subdir_name, subDirs) {
|
||||
QString result = findFileInDir(dir.path()+QDir::separator()+subdir_name, fileName);
|
||||
if(!result.isNull()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
// Can't use template class for QString because >,< use unicode code for sorting
|
||||
// which is not what a human would expect when sorting strings.
|
||||
void misc::insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder)
|
||||
{
|
||||
int i = 0;
|
||||
if(sortOrder == Qt::AscendingOrder) {
|
||||
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) > 0) {
|
||||
++i;
|
||||
}
|
||||
}else{
|
||||
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) < 0) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
list.insert(i, value);
|
||||
}
|
||||
|
||||
float misc::getPluginVersion(QString filePath)
|
||||
{
|
||||
QFile plugin(filePath);
|
||||
if(!plugin.exists()){
|
||||
qDebug("%s plugin does not exist, returning 0.0", filePath.toUtf8().data());
|
||||
return 0.0;
|
||||
}
|
||||
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
return 0.0;
|
||||
}
|
||||
float version = 0.0;
|
||||
while (!plugin.atEnd()){
|
||||
QByteArray line = plugin.readLine();
|
||||
if(line.startsWith("#VERSION: ")){
|
||||
line = line.split(' ').last();
|
||||
line.replace("\n", "");
|
||||
version = line.toFloat();
|
||||
qDebug("plugin %s version: %.2f", filePath.toUtf8().data(), version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
// Take a number of seconds and return an user-friendly
|
||||
// time duration like "1d 2h 10m".
|
||||
QString misc::userFriendlyDuration(qlonglong seconds)
|
||||
{
|
||||
if(seconds < 0) {
|
||||
return tr("Unknown");
|
||||
}
|
||||
if(seconds < 60) {
|
||||
return tr("< 1m", "< 1 minute");
|
||||
}
|
||||
int minutes = seconds / 60;
|
||||
if(minutes < 60) {
|
||||
return tr("%1 minutes","e.g: 10minutes").arg(QString::QString::fromUtf8(misc::toString(minutes).c_str()));
|
||||
}
|
||||
int hours = minutes / 60;
|
||||
minutes = minutes - hours*60;
|
||||
if(hours < 24) {
|
||||
return tr("%1h %2m", "e.g: 3hours 5minutes").arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str()));
|
||||
}
|
||||
int days = hours / 24;
|
||||
hours = hours - days * 24;
|
||||
if(days < 365) {
|
||||
return tr("%1d %2h", "e.g: 2days 10hours").arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str()));
|
||||
}
|
||||
int years = days / 365;
|
||||
days = days - years * 365;
|
||||
return tr("%1y %2d", "e.g: 2 years 2days ").arg(QString::fromUtf8(misc::toString(years).c_str())).arg(QString::fromUtf8(misc::toString(days).c_str()));
|
||||
}
|
||||
|
||||
QString misc::userFriendlyUnit(double count, unsigned int decimal, double factor)
|
||||
{
|
||||
if (count <= 0.0) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
QString output;
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (count < factor) {
|
||||
break;
|
||||
}
|
||||
|
||||
count /= factor;
|
||||
}
|
||||
|
||||
QString unit;
|
||||
switch (i) {
|
||||
case 0:
|
||||
decimal = 0; // no decimal
|
||||
break;
|
||||
case 1:
|
||||
unit = tr("k", "e.g: 3.1 k");
|
||||
break;
|
||||
case 2:
|
||||
unit = tr("M", "e.g: 3.1 M");
|
||||
break;
|
||||
case 3:
|
||||
unit = tr("G", "e.g: 3.1 G");
|
||||
break;
|
||||
default: // >= 4
|
||||
unit = tr("T", "e.g: 3.1 T");
|
||||
}
|
||||
|
||||
return QString("%1 %2").arg(count, 0, 'f', decimal).arg(unit);
|
||||
}
|
||||
|
||||
QString misc::removeNewLine(const QString &text)
|
||||
{
|
||||
return QString(text).replace("\n", " ");
|
||||
}
|
||||
|
||||
QString misc::removeNewLine(const std::string &text)
|
||||
{
|
||||
return QString::fromUtf8(text.c_str()).replace("\n", " ");
|
||||
}
|
||||
|
||||
QString misc::removeNewLine(const std::wstring &text)
|
||||
{
|
||||
return QString::fromStdWString(text).replace("\n", " ");
|
||||
}
|
||||
|
||||
bool misc::getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
file = QFileDialog::getOpenFileName(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (file.isEmpty() == false) {
|
||||
lastDir = QFileInfo(file).absoluteDir().absolutePath();
|
||||
Settings->setLastDir(type, lastDir);
|
||||
}
|
||||
|
||||
return !file.isEmpty();
|
||||
}
|
||||
|
||||
bool misc::getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QStringList &files)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
files = QFileDialog::getOpenFileNames(parent, caption, lastDir, filter, NULL, QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (files.isEmpty() == false) {
|
||||
lastDir = QFileInfo(*files.begin()).absoluteDir().absolutePath();
|
||||
Settings->setLastDir(type, lastDir);
|
||||
}
|
||||
|
||||
return !files.isEmpty();
|
||||
}
|
||||
|
||||
bool misc::getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file)
|
||||
{
|
||||
QString lastDir = Settings->getLastDir(type);
|
||||
|
||||
file = QFileDialog::getSaveFileName(parent, caption, lastDir, filter);
|
||||
|
||||
if (file.isEmpty() == false) {
|
||||
lastDir = QFileInfo(file).absoluteDir().absolutePath();
|
||||
Settings->setLastDir(type, lastDir);
|
||||
}
|
||||
|
||||
return !file.isEmpty();
|
||||
}
|
@ -26,29 +26,17 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QList>
|
||||
#include <QPair>
|
||||
#include <QThread>
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QStyleOptionProgressBarV2>
|
||||
#include <QStyleOptionViewItemV2>
|
||||
#include <QModelIndex>
|
||||
#include <QPainter>
|
||||
#include <QProgressBar>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
|
||||
/* Miscellaneaous functions that can be useful */
|
||||
class misc : public QObject{
|
||||
Q_OBJECT
|
||||
class misc : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
// Convert any type of variable to C++ String
|
||||
// convert=true will convert -1 to 0
|
||||
template <class T> static std::string toString(const T& x, bool convert=false) {
|
||||
@ -113,272 +101,65 @@ class misc : public QObject{
|
||||
// use Binary prefix standards from IEC 60027-2
|
||||
// see http://en.wikipedia.org/wiki/Kilobyte
|
||||
// value must be given in bytes
|
||||
static QString friendlyUnit(float val) {
|
||||
if(val < 0) {
|
||||
return tr("Unknown", "Unknown (size)");
|
||||
}
|
||||
const QString units[4] = {tr(" B", "bytes"), tr(" KiB", "kibibytes (1024 bytes)"), tr(" MiB", "mebibytes (1024 kibibytes)"), tr(" GiB", "gibibytes (1024 mibibytes)")};
|
||||
for(unsigned int i=0; i<5; ++i) {
|
||||
if (val < 1024.) {
|
||||
return QString(QByteArray::number(val, 'f', 1)) + units[i];
|
||||
}
|
||||
val /= 1024.;
|
||||
}
|
||||
return QString(QByteArray::number(val, 'f', 1)) + tr(" TiB", "tebibytes (1024 gibibytes)");
|
||||
}
|
||||
static QString friendlyUnit(float val);
|
||||
|
||||
static bool isPreviewable(QString extension){
|
||||
extension = extension.toUpper();
|
||||
if(extension == "AVI") return true;
|
||||
if(extension == "MP3") return true;
|
||||
if(extension == "OGG") return true;
|
||||
if(extension == "OGM") return true;
|
||||
if(extension == "WMV") return true;
|
||||
if(extension == "WMA") return true;
|
||||
if(extension == "MPEG") return true;
|
||||
if(extension == "MPG") return true;
|
||||
if(extension == "ASF") return true;
|
||||
if(extension == "QT") return true;
|
||||
if(extension == "RM") return true;
|
||||
if(extension == "RMVB") return true;
|
||||
if(extension == "RMV") return true;
|
||||
if(extension == "SWF") return true;
|
||||
if(extension == "FLV") return true;
|
||||
if(extension == "WAV") return true;
|
||||
if(extension == "MOV") return true;
|
||||
if(extension == "VOB") return true;
|
||||
if(extension == "MID") return true;
|
||||
if(extension == "AC3") return true;
|
||||
if(extension == "MP4") return true;
|
||||
if(extension == "MP2") return true;
|
||||
if(extension == "AVI") return true;
|
||||
if(extension == "FLAC") return true;
|
||||
if(extension == "AU") return true;
|
||||
if(extension == "MPE") return true;
|
||||
if(extension == "MOV") return true;
|
||||
if(extension == "MKV") return true;
|
||||
if(extension == "AIF") return true;
|
||||
if(extension == "AIFF") return true;
|
||||
if(extension == "AIFC") return true;
|
||||
if(extension == "RA") return true;
|
||||
if(extension == "RAM") return true;
|
||||
if(extension == "M4P") return true;
|
||||
if(extension == "M4A") return true;
|
||||
if(extension == "3GP") return true;
|
||||
if(extension == "AAC") return true;
|
||||
if(extension == "SWA") return true;
|
||||
if(extension == "MPC") return true;
|
||||
if(extension == "MPP") return true;
|
||||
return false;
|
||||
}
|
||||
static bool isPreviewable(QString extension);
|
||||
|
||||
// return qBittorrent config path
|
||||
static QString qBittorrentPath() {
|
||||
QString qBtPath = QDir::homePath()+QDir::separator()+QString::fromUtf8(".qbittorrent") + QDir::separator();
|
||||
// Create dir if it does not exist
|
||||
if(!QFile::exists(qBtPath)){
|
||||
QDir dir(qBtPath);
|
||||
dir.mkpath(qBtPath);
|
||||
}
|
||||
return qBtPath;
|
||||
}
|
||||
|
||||
// Not used anymore because it is not safe
|
||||
// static bool removePath(QString path) {
|
||||
// qDebug((QString::fromUtf8("file to delete:") + path).toUtf8());
|
||||
// if(!QFile::remove(path)) {
|
||||
// // Probably a folder
|
||||
// QDir current_dir(path);
|
||||
// if(current_dir.exists()) {
|
||||
// //Remove sub items
|
||||
// QStringList subItems = current_dir.entryList();
|
||||
// QString item;
|
||||
// foreach(item, subItems) {
|
||||
// if(item != QString::fromUtf8(".") && item != QString::fromUtf8("..")) {
|
||||
// qDebug("-> Removing "+(path+QDir::separator()+item).toUtf8());
|
||||
// removePath(path+QDir::separator()+item);
|
||||
// }
|
||||
// }
|
||||
// // Remove empty folder
|
||||
// if(current_dir.rmdir(path)) {
|
||||
// return true;
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// }else{
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
static QString findFileInDir(QString dir_path, QString fileName) {
|
||||
QDir dir(dir_path);
|
||||
if(dir.exists(fileName)) {
|
||||
return dir.filePath(fileName);
|
||||
}
|
||||
QStringList subDirs = dir.entryList(QDir::Dirs);
|
||||
QString subdir_name;
|
||||
foreach(subdir_name, subDirs) {
|
||||
QString result = findFileInDir(dir.path()+QDir::separator()+subdir_name, fileName);
|
||||
if(!result.isNull()) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
static QString qBittorrentPath();
|
||||
|
||||
static QString findFileInDir(QString dir_path, QString fileName);
|
||||
|
||||
// Insertion sort, used instead of bubble sort because it is
|
||||
// approx. 5 times faster.
|
||||
template <class T> static void insertSort(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder) {
|
||||
int i = 0;
|
||||
if(sortOrder == Qt::AscendingOrder) {
|
||||
while(i < list.size() and value.second > list.at(i).second) {
|
||||
++i;
|
||||
}
|
||||
}else{
|
||||
while(i < list.size() and value.second < list.at(i).second) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
list.insert(i, value);
|
||||
}
|
||||
// template <class T> static void insertSort(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder) {
|
||||
// int i = 0;
|
||||
// if(sortOrder == Qt::AscendingOrder) {
|
||||
// while(i < list.size() and value.second > list.at(i).second) {
|
||||
// ++i;
|
||||
// }
|
||||
// }else{
|
||||
// while(i < list.size() and value.second < list.at(i).second) {
|
||||
// ++i;
|
||||
// }
|
||||
// }
|
||||
// list.insert(i, value);
|
||||
// }
|
||||
|
||||
template <class T> static void insertSort2(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder) {
|
||||
int i = 0;
|
||||
if(sortOrder == Qt::AscendingOrder) {
|
||||
while(i < list.size() and value.first > list.at(i).first) {
|
||||
++i;
|
||||
}
|
||||
}else{
|
||||
while(i < list.size() and value.first < list.at(i).first) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
list.insert(i, value);
|
||||
}
|
||||
// template <class T> static void insertSort2(QList<QPair<int, T> > &list, const QPair<int, T>& value, Qt::SortOrder sortOrder) {
|
||||
// int i = 0;
|
||||
// if(sortOrder == Qt::AscendingOrder) {
|
||||
// while(i < list.size() and value.first > list.at(i).first) {
|
||||
// ++i;
|
||||
// }
|
||||
// }else{
|
||||
// while(i < list.size() and value.first < list.at(i).first) {
|
||||
// ++i;
|
||||
// }
|
||||
// }
|
||||
// list.insert(i, value);
|
||||
// }
|
||||
|
||||
// Can't use template class for QString because >,< use unicode code for sorting
|
||||
// which is not what a human would expect when sorting strings.
|
||||
static void insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder) {
|
||||
int i = 0;
|
||||
if(sortOrder == Qt::AscendingOrder) {
|
||||
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) > 0) {
|
||||
++i;
|
||||
}
|
||||
}else{
|
||||
while(i < list.size() and QString::localeAwareCompare(value.second, list.at(i).second) < 0) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
list.insert(i, value);
|
||||
}
|
||||
static void insertSortString(QList<QPair<int, QString> > &list, QPair<int, QString> value, Qt::SortOrder sortOrder);
|
||||
|
||||
static float getPluginVersion(QString filePath) {
|
||||
QFile plugin(filePath);
|
||||
if(!plugin.exists()){
|
||||
qDebug("%s plugin does not exist, returning 0.0", filePath.toUtf8().data());
|
||||
return 0.0;
|
||||
}
|
||||
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
return 0.0;
|
||||
}
|
||||
float version = 0.0;
|
||||
while (!plugin.atEnd()){
|
||||
QByteArray line = plugin.readLine();
|
||||
if(line.startsWith("#VERSION: ")){
|
||||
line = line.split(' ').last();
|
||||
line.replace("\n", "");
|
||||
version = line.toFloat();
|
||||
qDebug("plugin %s version: %.2f", filePath.toUtf8().data(), version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return version;
|
||||
}
|
||||
static float getPluginVersion(QString filePath);
|
||||
|
||||
// Take a number of seconds and return an user-friendly
|
||||
// time duration like "1d 2h 10m".
|
||||
static QString userFriendlyDuration(qlonglong seconds)
|
||||
{
|
||||
if(seconds < 0) {
|
||||
return tr("Unknown");
|
||||
}
|
||||
if(seconds < 60) {
|
||||
return tr("< 1m", "< 1 minute");
|
||||
}
|
||||
int minutes = seconds / 60;
|
||||
if(minutes < 60) {
|
||||
return tr("%1 minutes","e.g: 10minutes").arg(QString::QString::fromUtf8(misc::toString(minutes).c_str()));
|
||||
}
|
||||
int hours = minutes / 60;
|
||||
minutes = minutes - hours*60;
|
||||
if(hours < 24) {
|
||||
return tr("%1h %2m", "e.g: 3hours 5minutes").arg(QString::fromUtf8(misc::toString(hours).c_str())).arg(QString::fromUtf8(misc::toString(minutes).c_str()));
|
||||
}
|
||||
int days = hours / 24;
|
||||
hours = hours - days * 24;
|
||||
if(days < 365) {
|
||||
return tr("%1d %2h", "e.g: 2days 10hours").arg(QString::fromUtf8(misc::toString(days).c_str())).arg(QString::fromUtf8(misc::toString(hours).c_str()));
|
||||
}
|
||||
int years = days / 365;
|
||||
days = days - years * 365;
|
||||
return tr("%1y %2d", "e.g: 2 years 2days ").arg(QString::fromUtf8(misc::toString(years).c_str())).arg(QString::fromUtf8(misc::toString(days).c_str()));
|
||||
}
|
||||
static QString userFriendlyDuration(qlonglong seconds);
|
||||
|
||||
static QString userFriendlyUnit(double count, unsigned int decimal, double factor = 1000)
|
||||
{
|
||||
if (count <= 0.0) {
|
||||
return "0";
|
||||
}
|
||||
static QString userFriendlyUnit(double count, unsigned int decimal, double factor = 1000);
|
||||
|
||||
QString output;
|
||||
static QString removeNewLine(const QString &text);
|
||||
static QString removeNewLine(const std::string &text);
|
||||
static QString removeNewLine(const std::wstring &text);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < 5; i++) {
|
||||
if (count < factor) {
|
||||
break;
|
||||
}
|
||||
static bool getOpenFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file);
|
||||
static bool getOpenFileNames(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QStringList &files);
|
||||
|
||||
count /= factor;
|
||||
}
|
||||
|
||||
QString unit;
|
||||
switch (i) {
|
||||
case 0:
|
||||
decimal = 0; // no decimal
|
||||
break;
|
||||
case 1:
|
||||
unit = tr("k", "e.g: 3.1 k");
|
||||
break;
|
||||
case 2:
|
||||
unit = tr("M", "e.g: 3.1 M");
|
||||
break;
|
||||
case 3:
|
||||
unit = tr("G", "e.g: 3.1 G");
|
||||
break;
|
||||
default: // >= 4
|
||||
unit = tr("T", "e.g: 3.1 T");
|
||||
}
|
||||
|
||||
return QString("%1 %2").arg(count, 0, 'f', decimal).arg(unit);
|
||||
}
|
||||
|
||||
static QString removeNewLine(const QString &text)
|
||||
{
|
||||
return QString(text).replace("\n", " ");
|
||||
}
|
||||
|
||||
static QString removeNewLine(const std::string &text)
|
||||
{
|
||||
return QString::fromUtf8(text.c_str()).replace("\n", " ");
|
||||
}
|
||||
|
||||
static QString removeNewLine(const std::wstring &text)
|
||||
{
|
||||
return QString::fromStdWString(text).replace("\n", " ");
|
||||
}
|
||||
static bool getSaveFileName(QWidget *parent, RshareSettings::enumLastDir type, const QString &caption, const QString &filter, QString &file);
|
||||
};
|
||||
|
||||
// Trick to get a portable sleep() function
|
||||
|
Loading…
Reference in New Issue
Block a user