]> git.sur5r.net Git - minitube/blobdiff - src/sidebarheader.cpp
New upstream version 2.9
[minitube] / src / sidebarheader.cpp
index b6fb87a2607bfb165cf89dbb000e2267aedfa63e..399d65f244687dc05b96bac9809f2b0a527fc6c3 100644 (file)
@@ -47,7 +47,8 @@ void SidebarHeader::setup() {
     connect(forwardAction, SIGNAL(triggered()), MediaView::instance(), SLOT(goForward()));
     addAction(forwardAction);
 
-    foreach (QAction* action, actions()) {
+    const auto a = actions();
+    for (QAction* action : a) {
         window()->addAction(action);
         IconUtils::setupAction(action);
     }
@@ -64,7 +65,7 @@ QSize SidebarHeader::minimumSizeHint() const {
 void SidebarHeader::updateInfo() {
     setup();
 
-    QList<VideoSource*> history = MediaView::instance()->getHistory();
+    const QVector<VideoSource*> &history = MediaView::instance()->getHistory();
     int currentIndex = MediaView::instance()->getHistoryIndex();
 
     bool canGoForward = MediaView::instance()->canGoForward();
@@ -107,10 +108,10 @@ void SidebarHeader::setTitle(const QString &title) {
     this->title = title;
     update();
 
-    QList<VideoSource*> history = MediaView::instance()->getHistory();
+    QVector<VideoSource*> history = MediaView::instance()->getHistory();
     int currentIndex = MediaView::instance()->getHistoryIndex();
     VideoSource *currentVideoSource = history.at(currentIndex);
-    foreach (QAction* action, videoSourceActions)
+    for (QAction* action : videoSourceActions)
         removeAction(action);
     videoSourceActions = currentVideoSource->getActions();
     addActions(videoSourceActions);
@@ -121,16 +122,15 @@ void SidebarHeader::paintEvent(QPaintEvent *event) {
     if (title.isEmpty()) return;
     QPainter p(this);
     p.setPen(Qt::white);
-    p.setFont(FontUtils::small());
 
     const QRect r = rect();
 
     QString t = title;
     QRect textBox = p.boundingRect(r, Qt::AlignCenter, t);
     int i = 1;
-    const int margin = forwardAction->isVisible() ? 45 : 20;
+    const int margin = forwardAction->isVisible() ? 50 : 25;
     while (textBox.width() > r.width() - margin*2 && t.length() > 3) {
-        t = t.left(t.length() - i).trimmed() + QLatin1String("...");
+        t = t.left(t.length() - i).trimmed() + QStringLiteral("\u2026");
         textBox = p.boundingRect(r, Qt::AlignCenter, t);
         i++;
     }