_model->slotUpdateFolderState(folder);
}
- QString server = QString::fromLatin1("<a href=\"%1\">%2</a>").arg(account->url().toString(), safeUrl.toString());
+ QString server = QString::fromLatin1("<a href=\"%1\">%2</a>")
+ .arg(Utility::escape(account->url().toString()),
+ Utility::escape(safeUrl.toString()));
QString serverWithUser = server;
if (AbstractCredentials *cred = account->credentials()) {
- serverWithUser = tr("%1 as <i>%2</i>").arg(server, cred->user());
+ serverWithUser = tr("%1 as <i>%2</i>").arg(server, Utility::escape(cred->user()));
}
if (state == AccountState::Connected) {
} else if (state == AccountState::SignedOut) {
showConnectionLabel( tr("Signed out from %1.").arg(serverWithUser) );
} else {
- showConnectionLabel( tr("No connection to %1 at %2.")
- .arg(Theme::instance()->appNameGUI(),
- server), _accountState->connectionErrors() );
+ showConnectionLabel(tr("No connection to %1 at %2.")
+ .arg(Utility::escape(Theme::instance()->appNameGUI()), server),
+ _accountState->connectionErrors());
}
} else {
// ownCloud is not yet configured.
- showConnectionLabel( tr("No %1 connection configured.").arg(Theme::instance()->appNameGUI()) );
+ showConnectionLabel(tr("No %1 connection configured.")
+ .arg(Utility::escape(Theme::instance()->appNameGUI())));
}
/* Allow to expand the item if the account is connected. */
}
QModelIndex theIndx = _model->indexForPath(folder, myFolder);
if(theIndx.isValid()) {
- msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>").arg(myFolder).arg(folder->alias());
+ msg += QString::fromLatin1("<a href=\"%1?folder=%2\">%1</a>")
+ .arg(Utility::escape(myFolder), Utility::escape(folder->alias()));
} else {
msg += myFolder; // no link because we do not know the index yet.
}
<property name="text">
<string>Connected with <server> as <user></string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>Storage space: ...</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
<property name="wordWrap">
<bool>false</bool>
</property>
<property name="text">
<string>Unchecked folders will be <b>removed</b> from your local file system and will not be synchronized to this computer anymore</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="wordWrap">
<bool>true</bool>
</property>
QString timeStr;
if ( accountOnline ) {
- timeStr = tr("%1 on %2").arg(timeText).arg(accountRole);
+ timeStr = tr("%1 on %2").arg(timeText, accountRole);
} else {
- timeStr = tr("%1 on %2 (disconnected)").arg(timeText).arg(accountRole);
+ timeStr = tr("%1 on %2 (disconnected)").arg(timeText, accountRole);
QPalette p = option.palette;
painter->setPen(p.color(QPalette::Disabled, QPalette::Text));
}
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item row="1" column="0">
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
<item row="3" column="0">
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
<item row="5" column="0">
setWindowTitle(tr("Authentication Required"));
QVBoxLayout *lay = new QVBoxLayout(this);
QLabel *label = new QLabel(tr("Enter username and password for '%1' at %2.").arg(realm, domain));
+ label->setTextFormat(Qt::PlainText);
lay->addWidget(label);
QFormLayout *form = new QFormLayout;
break;
case LogStatusRename:
if( count > 1 ) {
- text = tr("%1 has been renamed to %2 and %n other file(s) have been renamed.", "", count-1).arg(file).arg(renameTarget);
+ text = tr("%1 has been renamed to %2 and %n other file(s) have been renamed.", "", count-1).arg(file, renameTarget);
} else {
- text = tr("%1 has been renamed to %2.", "%1 and %2 name files.").arg(file).arg(renameTarget);
+ text = tr("%1 has been renamed to %2.", "%1 and %2 name files.").arg(file, renameTarget);
}
break;
case LogStatusMove:
if( count > 1 ) {
- text = tr("%1 has been moved to %2 and %n other file(s) have been moved.", "", count-1).arg(file).arg(renameTarget);
+ text = tr("%1 has been moved to %2 and %n other file(s) have been moved.", "", count-1).arg(file, renameTarget);
} else {
- text = tr("%1 has been moved to %2.").arg(file).arg(renameTarget);
+ text = tr("%1 has been moved to %2.").arg(file, renameTarget);
}
break;
case LogStatusConflict:
{
const auto &x = static_cast<SubFolderInfo *>(index.internalPointer())->_subs[index.row()];
switch (role) {
- case Qt::ToolTipRole:
case Qt::DisplayRole:
//: Example text: "File.txt (23KB)"
return x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size));
+ case Qt::ToolTipRole:
+ return QString(QLatin1String("<qt>") + Utility::escape(x._size < 0 ? x._name : tr("%1 (%2)").arg(x._name, Utility::octetsToString(x._size))) + QLatin1String("</qt>"));
case Qt::CheckStateRole:
return x._checked;
case Qt::DecorationRole:
connect(_ui.localFolderChooseBtn, SIGNAL(clicked()), this, SLOT(slotChooseLocalFolder()));
_ui.localFolderChooseBtn->setToolTip(tr("Click to select a local folder to sync."));
- QString defaultPath = QString::fromLatin1( "%1/%2").arg( QDir::homePath() ).arg(Theme::instance()->appName() );
+ QString defaultPath = QDir::homePath() + QLatin1Char('/') + Theme::instance()->appName();
_ui.localFolderLineEdit->setText( QDir::toNativeSeparators( defaultPath ) );
_ui.localFolderLineEdit->setToolTip(tr("Enter the path to the local folder."));
if (QDir::cleanPath(dir) == QDir::cleanPath(curDir)) {
warnStrings.append(tr("This folder is already being synced."));
} else if (dir.startsWith(curDir + QLatin1Char('/'))) {
- warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(curDir).arg(dir));
+ warnStrings.append(tr("You are already syncing <i>%1</i>, which is a parent folder of <i>%2</i>.").arg(
+ Utility::escape(curDir), Utility::escape(dir)));
}
if (curDir == QLatin1String("/")) {
<string/>
</property>
<property name="textFormat">
- <enum>Qt::AutoText</enum>
+ <enum>Qt::RichText</enum>
</property>
<property name="margin">
<number>3</number>
<string>TextLabel</string>
</property>
<property name="textFormat">
- <enum>Qt::AutoText</enum>
+ <enum>Qt::RichText</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
<item row="5" column="1">
auto serverVersion = CheckServerJob::version(info);
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\">Successfully connected to %1: %2 version %3 (%4)</font><br/><br/>")
- .arg(url.toString())
- .arg(Theme::instance()->appNameGUI())
- .arg(CheckServerJob::versionString(info))
- .arg(serverVersion));
+ .arg(Utility::escape(url.toString()),
+ Utility::escape(Theme::instance()->appNameGUI()),
+ Utility::escape(CheckServerJob::versionString(info)),
+ Utility::escape(serverVersion)));
_ocWizard->account()->setServerVersion(serverVersion);
msg = tr("Invalid URL");
} else {
msg = tr("Failed to connect to %1 at %2:<br/>%3")
- .arg(Theme::instance()->appNameGUI(),
- reply->url().toString(),
- reply->errorString());
+ .arg(Utility::escape(Theme::instance()->appNameGUI()),
+ Utility::escape(reply->url().toString()),
+ Utility::escape(reply->errorString()));
}
bool isDowngradeAdvised = checkDowngradeAdvised(reply);
void OwncloudSetupWizard::slotNoOwnCloudFoundAuthTimeout(const QUrl&url)
{
- _ocWizard->displayError(tr("Timeout while trying to connect to %1 at %2.")
- .arg(Theme::instance()->appNameGUI(),
- url.toString()), false);
+ _ocWizard->displayError(
+ tr("Timeout while trying to connect to %1 at %2.")
+ .arg(Utility::escape(Theme::instance()->appNameGUI()), Utility::escape(url.toString())),
+ false);
}
void OwncloudSetupWizard::slotConnectToOCUrl( const QString& url )
}
errorMsg = tr("The authenticated request to the server was redirected to "
"'%1'. The URL is bad, the server is misconfigured.")
- .arg(redirectUrl.toString());
+ .arg(Utility::escape(redirectUrl.toString()));
// A 404 is actually a success: we were authorized to know that the folder does
// not exist. It will be created later...
if (!_ocWizard->account()->credentials()->stillValid(reply)) {
errorMsg = tr("Access forbidden by server. To verify that you have proper access, "
"<a href=\"%1\">click here</a> to access the service with your browser.")
- .arg(_ocWizard->account()->url().toString());
+ .arg(Utility::escape(_ocWizard->account()->url().toString()));
} else {
errorMsg = errorMessage(reply->errorString(), reply->readAll());
}
if( fi.exists() ) {
// there is an existing local folder. If its non empty, it can only be synced if the
// ownCloud is newly created.
- _ocWizard->appendToConfigurationLog( tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>").arg(localFolder));
+ _ocWizard->appendToConfigurationLog(
+ tr("Local sync folder %1 already exists, setting it up for sync.<br/><br/>")
+ .arg(Utility::escape(localFolder)));
} else {
QString res = tr("Creating local sync folder %1...").arg(localFolder);
if( fi.mkpath( localFolder ) ) {
} else {
res += tr("failed.");
qDebug() << "Failed to create " << fi.path();
- _ocWizard->displayError(tr("Could not create local folder %1").arg(localFolder), false);
+ _ocWizard->displayError(tr("Could not create local folder %1").arg(Utility::escape(localFolder)), false);
nextStep = false;
}
_ocWizard->appendToConfigurationLog( res );
}
if( !ok ) {
- _ocWizard->displayError(error, false);
+ _ocWizard->displayError(Utility::escape(error), false);
}
finalizeSetup( ok );
_remoteFolder.clear();
success = false;
} else {
- _ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error));
- _ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(_remoteFolder).arg(error), false );
+ _ocWizard->appendToConfigurationLog( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_remoteFolder)).arg(error));
+ _ocWizard->displayError( tr("Remote folder %1 creation failed with error <tt>%2</tt>.").arg(Utility::escape(_remoteFolder)).arg(error), false );
_remoteFolder.clear();
success = false;
}
const QString localFolder = _ocWizard->property("localFolder").toString();
if( success ) {
if( !(localFolder.isEmpty() || _remoteFolder.isEmpty() )) {
- _ocWizard->appendToConfigurationLog( tr("A sync connection from %1 to remote directory %2 was set up.")
- .arg(localFolder).arg(_remoteFolder));
+ _ocWizard->appendToConfigurationLog(
+ tr("A sync connection from %1 to remote directory %2 was set up.")
+ .arg(localFolder, _remoteFolder));
}
_ocWizard->appendToConfigurationLog( QLatin1String(" "));
_ocWizard->appendToConfigurationLog( QLatin1String("<p><font color=\"green\"><b>")
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
</layout>
return;
}
- QString key = QString::fromLatin1("%1:%2").arg(
- proxy.hostName(), QString::number(proxy.port()));
+ QString key = proxy.hostName() + QLatin1Char(':') + QString::number(proxy.port());
// If the proxy server has changed, forget what we know.
if (key != _proxy) {
QString altBase(palette().alternateBase().color().name());
QString dark(palette().dark().color().name());
QString background(palette().base().color().name());
- _toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).arg(background).arg(dark).arg(highlightColor).arg(altBase));
+ _toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).arg(background,dark,highlightColor,altBase));
Q_FOREACH(QAction *a, _actionGroup->actions()) {
QIcon icon = createColorAwareIcon(a->property("iconPath").toString());
<property name="text">
<string>share label</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item row="1" column="1">
<property name="text">
<string>ownCloud Path:</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
const QUrl realUrl(_shareUrl);
QString elidedUrl = fm.elidedText(_shareUrl, Qt::ElideRight, linkLengthPixel);
- u = QString("<a href=\"%1\">%2</a>").arg(realUrl.toString(QUrl::None)).arg(elidedUrl);
+ u = QString("<a href=\"%1\">%2</a>").arg(Utility::escape(realUrl.toString(QUrl::None)), Utility::escape(elidedUrl));
}
_ui->_labelShareLink->setText(u);
}
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item row="1" column="0" colspan="2">
url = QUrl(data.value("url").toString());
} else if (_account->serverVersionInt() >= (8 << 16)) {
// From ownCloud server version 8 on, a different share link scheme is used.
- url = QUrl(Utility::concatUrlPath(_account->url(), QString("index.php/s/%1").arg(data.value("token").toString())).toString());
+ url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("index.php/s/") + data.value("token").toString())).toString();
} else {
QList<QPair<QString, QString>> queryArgs;
queryArgs.append(qMakePair(QString("service"), QString("files")));
<property name="text">
<string notr="true">Placeholder for Error text</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item>
if (value.isEmpty())
return QString();
- return QString::fromLatin1("<tr><td style=\"vertical-align: top;\"><b>%1</b></td><td style=\"vertical-align: bottom;\">%2</td></tr>").arg(key).arg(value);
+ return QLatin1String("<tr><td style=\"vertical-align: top;\"><b>") + key
+ + QLatin1String("</b></td><td style=\"vertical-align: bottom;\">)") + value
+ + QLatin1String("</td></tr>");
}
// create label first
QLabel *label = new QLabel(parent);
label->setStyleSheet(QLatin1String("QLabel { padding: 8px; background-color: #fff; }"));
+ label->setTextFormat(Qt::RichText);
label->setText(details);
+
// plug label into widget action
QWidgetAction *action = new QWidgetAction(parent);
action->setDefaultWidget(label);
QLabel *lbl = new QLabel;
QString txt = tr("<p>A new version of the %1 Client is available.</p>"
"<p><b>%2</b> is available for download. The installed version is %3.</p>")
- .arg(Theme::instance()->appNameGUI()).arg(info.versionString()).arg(clientVersion());
+ .arg(Utility::escape(Theme::instance()->appNameGUI()),
+ Utility::escape(info.versionString()), Utility::escape(clientVersion()));
lbl->setText(txt);
lbl->setTextFormat(Qt::RichText);
if( _remoteFolder.isEmpty() || _remoteFolder == QLatin1String("/") ) {
t = "";
} else {
- t = tr("%1 folder '%2' is synced to local folder '%3'")
- .arg(Theme::instance()->appName()).arg(_remoteFolder)
- .arg(QDir::toNativeSeparators(locFolder));
- _ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder));
+ t = Utility::escape(tr("%1 folder '%2' is synced to local folder '%3'")
+ .arg(Theme::instance()->appName(), _remoteFolder,
+ QDir::toNativeSeparators(locFolder)));
+ _ui.rSyncEverything->setText(tr("Sync the folder '%1'").arg(_remoteFolder));
}
const bool dirNotEmpty(QDir(locFolder).entryList(QDir::AllEntries | QDir::NoDotAndDotDot).count() > 0);
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::PlainText</enum>
+ </property>
</widget>
</item>
<item>
<property name="text">
<string>Status message</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
</layout>
<property name="text">
<string notr="true">TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="text">
<string notr="true">Error Label</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="text">
<string notr="true">TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
<item row="1" column="1">
<property name="text">
<string notr="true">TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="text">
<string>Error Label</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
</widget>
</item>
</layout>
if (Utility::isWindows()) {
// check for policies first and return immediately if a value is found.
QSettings userPolicy(QString::fromLatin1("HKEY_CURRENT_USER\\Software\\Policies\\%1\\%2")
- .arg(APPLICATION_VENDOR).arg(Theme::instance()->appName()),
+ .arg(APPLICATION_VENDOR, Theme::instance()->appName()),
QSettings::NativeFormat);
if(userPolicy.contains(setting)) {
return userPolicy.value(setting);
}
QSettings machinePolicy(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\Policies\\%1\\%2")
- .arg(APPLICATION_VENDOR).arg(APPLICATION_NAME),
+ .arg(APPLICATION_VENDOR, APPLICATION_NAME),
QSettings::NativeFormat);
if(machinePolicy.contains(setting)) {
return machinePolicy.value(setting);
fi.setFile( QCoreApplication::applicationDirPath(), exclFile );
#endif
#ifdef Q_OS_UNIX
- fi.setFile( QString( SYSCONFDIR "/%1").arg(Theme::instance()->appName()), exclFile );
+ fi.setFile(QString(SYSCONFDIR "/" + Theme::instance()->appName()), exclFile);
if ( ! fi.exists() ) {
// Prefer to return the preferred path! Only use the fallback location
// if the other path does not exist and the fallback is valid.
systemSetting = systemSettings.value(param, defaultValue);
} else { // Windows
QSettings systemSettings(QString::fromLatin1("HKEY_LOCAL_MACHINE\\Software\\%1\\%2")
- .arg(APPLICATION_VENDOR).arg(Theme::instance()->appName()),
- QSettings::NativeFormat);
+ .arg(APPLICATION_VENDOR, Theme::instance()->appName()),
+ QSettings::NativeFormat);
if (!group.isEmpty()) {
systemSettings.beginGroup(group);
}
#include "version.h"
#include "config.h"
+#include "utility.h"
namespace OCC {
"ownCloud and the ownCloud Logo are registered trademarks of ownCloud GmbH "
"in the United States, other countries, or both.</p>"
)
- .arg(MIRALL_VERSION_STRING)
- .arg("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN))
- .arg(MIRALL_STRINGIFY(APPLICATION_DOMAIN));
+ .arg(Utility::escape(MIRALL_VERSION_STRING),
+ Utility::escape("https://" MIRALL_STRINGIFY(APPLICATION_DOMAIN)),
+ Utility::escape(MIRALL_STRINGIFY(APPLICATION_DOMAIN)));
devString += gitSHA1();
return devString;
QByteArray Utility::userAgentString()
{
QString re = QString::fromLatin1("Mozilla/5.0 (%1) mirall/%2")
- .arg(platform())
- .arg(QLatin1String(MIRALL_VERSION_STRING));
+ .arg(platform(), QLatin1String(MIRALL_VERSION_STRING));
QLatin1String appName(APPLICATION_SHORTNAME);