replaced QString uses with QStringLiteral

Minor code optimization according to Qt documentation.
This commit is contained in:
itsmattkc
2019-12-10 00:42:31 +11:00
parent f46b1245c4
commit 3bfe333878
8 changed files with 38 additions and 37 deletions
+12 -12
View File
@@ -25,7 +25,7 @@
#include "config/config.h"
QString padded(int64_t arg, int padding) {
return QString("%1").arg(arg, padding, 10, QChar('0'));
return QStringLiteral("%1").arg(arg, padding, 10, QChar('0'));
}
QString olive::timestamp_to_timecode(const int64_t &timestamp,
@@ -62,11 +62,11 @@ QString olive::timestamp_to_timecode(const int64_t &timestamp,
int64_t secs = total_seconds - mins * 60;
int64_t fraction = qRound64((timestamp_dbl - static_cast<double>(total_seconds)) * 1000);
return QString("%1%2:%3:%4.%5").arg(prefix,
padded(hours, 2),
padded(mins, 2),
padded(secs, 2),
padded(fraction, 3));
return QStringLiteral("%1%2:%3:%4.%5").arg(prefix,
padded(hours, 2),
padded(mins, 2),
padded(secs, 2),
padded(fraction, 3));
} else {
// Determine what symbol to separate frames (";" is used for drop frame, ":" is non-drop frame)
QString frame_token;
@@ -112,12 +112,12 @@ QString olive::timestamp_to_timecode(const int64_t &timestamp,
secs = f / rounded_frame_rate % 60;
frames = f % rounded_frame_rate;
return QString("%1%2:%3:%4%5%6").arg(prefix,
padded(hours, 2),
padded(mins, 2),
padded(secs, 2),
frame_token,
padded(frames, 2));
return QStringLiteral("%1%2:%3:%4%5%6").arg(prefix,
padded(hours, 2),
padded(mins, 2),
padded(secs, 2),
frame_token,
padded(frames, 2));
}
}
case kFrames:
+14 -14
View File
@@ -35,20 +35,20 @@ AboutDialog::AboutDialog(QWidget *parent) :
// Construct About text
QLabel* label =
new QLabel(QString("<html><head/><body>"
"<p><img src=\":/icons/olive-splash.png\"/></p>"
"<p><a href=\"https://www.olivevideoeditor.org/\">"
"<span style=\" text-decoration: underline; color:#007af4;\">"
"https://www.olivevideoeditor.org/"
"</span></a></p>"
"<p><b>%1</b></p>" // AppName (version identifier)
"<p>%2</p>" // First statement
"<p>%3</p>" // Second statement
"</body></html>").arg(QApplication::applicationName(),
tr("Olive is a non-linear video editor. This software is free and "
"protected by the GNU GPL."),
tr("Olive Team is obliged to inform users that Olive source code is "
"available for download from its website.")),this);
new QLabel(QStringLiteral("<html><head/><body>"
"<p><img src=\":/icons/olive-splash.png\"/></p>"
"<p><a href=\"https://www.olivevideoeditor.org/\">"
"<span style=\" text-decoration: underline; color:#007af4;\">"
"https://www.olivevideoeditor.org/"
"</span></a></p>"
"<p><b>%1</b></p>" // AppName (version identifier)
"<p>%2</p>" // First statement
"<p>%3</p>" // Second statement
"</body></html>").arg(QApplication::applicationName(),
tr("Olive is a non-linear video editor. This software is free and "
"protected by the GNU GPL."),
tr("Olive Team is obliged to inform users that Olive source code is "
"available for download from its website.")),this);
// Set text formatting
label->setAlignment(Qt::AlignCenter);
+1 -1
View File
@@ -157,7 +157,7 @@ void ActionSearch::search_update(const QString &s, const QString &p, QMenu *pare
if (comp.contains(s, Qt::CaseInsensitive)) {
// If so, we add it to the list widget.
QListWidgetItem* item = new QListWidgetItem(QString("%1\n(%2)").arg(comp, menu_text), list_widget);
QListWidgetItem* item = new QListWidgetItem(QStringLiteral("%1\n(%2)").arg(comp, menu_text), list_widget);
// Add a pointer to the original QAction in the item's data
item->setData(Qt::UserRole+1, reinterpret_cast<quintptr>(a));
+1 -1
View File
@@ -123,7 +123,7 @@ QIcon olive::icon::Create(const QString& theme, const QString &name)
QIcon icon;
for (int i=0;i<ICON_SIZE_COUNT;i++) {
icon.addFile(QString("%1/png/%2.%3.png").arg(theme, name, QString::number(ICON_SIZES[i])),
icon.addFile(QStringLiteral("%1/png/%2.%3.png").arg(theme, name, QString::number(ICON_SIZES[i])),
QSize(ICON_SIZES[i], ICON_SIZES[i]));
}
+2 -2
View File
@@ -143,7 +143,7 @@ void StyleManager::SetStyle(const QString &style_path)
olive::icon::LoadAll(style_path);
// Set palette for this
QString palette_file = QString("%1/palette.ini").arg(style_path);
QString palette_file = QStringLiteral("%1/palette.ini").arg(style_path);
if (QFileInfo::exists(palette_file)) {
qApp->setPalette(ParsePalette(palette_file));
} else {
@@ -151,7 +151,7 @@ void StyleManager::SetStyle(const QString &style_path)
}
// Set CSS style for this
QFile css_file(QString("%1/style.css").arg(style_path));
QFile css_file(QStringLiteral("%1/style.css").arg(style_path));
if (css_file.exists() && css_file.open(QFile::ReadOnly | QFile::Text)) {
// Read in entire CSS from file and set as the application stylesheet
+1 -1
View File
@@ -72,7 +72,7 @@ void AudioMonitor::paintEvent(QPaintEvent *)
if (i <= kDecibelMinimum) {
db_label = "-∞";
} else {
db_label = QString("%1").arg(i);
db_label = QStringLiteral("%1").arg(i);
}
qreal log_val = QAudio::convertVolume(i, QAudio::DecibelVolumeScale, QAudio::LogarithmicVolumeScale);
+1 -1
View File
@@ -70,7 +70,7 @@ void TaskViewItem::SetTask(Task *t)
task_ = t;
// Set name label to the name (bolded)
task_name_lbl_->setText(QString("<b>%1</b>").arg(task_->text()));
task_name_lbl_->setText(QStringLiteral("<b>%1</b>").arg(task_->text()));
// Connect to the task
connect(task_, SIGNAL(StatusChanged(Task::Status)), this, SLOT(TaskStatusChange(Task::Status)));
@@ -21,6 +21,7 @@
#include "timelineviewblockitem.h"
#include <QBrush>
#include <QCoreApplication>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
@@ -62,11 +63,11 @@ void TimelineViewBlockItem::UpdateRect()
setRect(0, y_, item_width - 1, height_ - 1);
setPos(item_left, 0.0);
// FIXME: Untranslated
setToolTip(QString("%1\n\nIn: %2\nOut: %3\nMedia In: %4").arg(block_->Name(),
QString::number(block_->in().toDouble()),
QString::number(block_->out().toDouble()),
QString::number(block_->media_in().toDouble())));
setToolTip(QCoreApplication::translate("TimelineViewBlockItem",
"%1\n\nIn: %2\nOut: %3\nMedia In: %4").arg(block_->Name(),
QString::number(block_->in().toDouble()),
QString::number(block_->out().toDouble()),
QString::number(block_->media_in().toDouble())));
}
void TimelineViewBlockItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)