improve html links + small bugfixes
authorStepan777 <stepik-777@mail.ru>
Thu, 09 Aug 2012 03:00:24 +0400
changeset 7531 0adcad8714c4
parent 7528 f8cf277dca36
child 7534 ccb9c2906160
improve html links + small bugfixes
QTfrontend/ui/dialog/upload_video.cpp
QTfrontend/ui/dialog/upload_video.h
QTfrontend/ui/page/pagevideos.cpp
QTfrontend/ui/page/pagevideos.h
--- a/QTfrontend/ui/dialog/upload_video.cpp	Thu Aug 09 01:24:38 2012 +0400
+++ b/QTfrontend/ui/dialog/upload_video.cpp	Thu Aug 09 03:00:24 2012 +0400
@@ -55,10 +55,10 @@
 
     // Google requires us to display this, see https://developers.google.com/youtube/terms
     QString GoogleNotice =
-        "By clicking 'upload,' you certify that you own all rights to the content or that "
+        "<p>By clicking 'upload,' you certify that you own all rights to the content or that "
         "you are authorized by the owner to make the content publicly available on YouTube, "
         "and that it otherwise complies with the YouTube Terms of Service located at "
-        "http://www.youtube.com/t/terms.";
+        "<a href=\"http://www.youtube.com/t/terms\" style=\"color: white;\">http://www.youtube.com/t/terms</a>.</p>";
 
     // youtube doesn't understand this characters, even when they are properly escaped
     // (either with CDATA or with &lt or &gt)
@@ -67,6 +67,8 @@
     int row = 0;
 
     QGridLayout * layout = new QGridLayout(this);
+    layout->setColumnStretch(0, 1);
+    layout->setColumnStretch(1, 2);
 
     QLabel * lbLabel = new QLabel(this);
     lbLabel->setWordWrap(true);
@@ -138,6 +140,9 @@
 
     lbLabel = new QLabel(this);
     lbLabel->setWordWrap(true);
+    lbLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
+    lbLabel->setTextFormat(Qt::RichText);
+    lbLabel->setOpenExternalLinks(true);
     lbLabel->setText(GoogleNotice);
     layout->addWidget(lbLabel, row++, 0, 1, 2);
 
@@ -156,6 +161,17 @@
     connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
 }
 
+void HWUploadVideoDialog::showEvent(QShowEvent * event)
+{
+    QDialog::showEvent(event);
+
+    // set width to the same value as height (otherwise dialog has too small width)
+    QSize s = size();
+    QPoint p = pos();
+    resize(s.height(), s.height());
+    move(p.x() - (s.height() - s.width())/2, p.y());
+}
+
 void HWUploadVideoDialog::setEditable(bool editable)
 {
     leTitle->setEnabled(editable);
--- a/QTfrontend/ui/dialog/upload_video.h	Thu Aug 09 01:24:38 2012 +0400
+++ b/QTfrontend/ui/dialog/upload_video.h	Thu Aug 09 03:00:24 2012 +0400
@@ -52,6 +52,10 @@
 
         void setEditable(bool editable);
 
+    protected:
+        // virtual from QWidget
+        void showEvent(QShowEvent * event);
+
     private slots:
         void upload();
         void authFinished();
--- a/QTfrontend/ui/page/pagevideos.cpp	Thu Aug 09 01:24:38 2012 +0400
+++ b/QTfrontend/ui/page/pagevideos.cpp	Thu Aug 09 03:00:24 2012 +0400
@@ -279,6 +279,7 @@
                                            Qt::LinksAccessibleByMouse |
                                            Qt::LinksAccessibleByKeyboard);
         labelDesc->setTextFormat(Qt::RichText);
+        labelDesc->setOpenExternalLinks(true);
         pTopDescLayout->addWidget(labelDesc, 1);
 
         // buttons: play and delete
@@ -321,8 +322,7 @@
     connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles()));
     connect(btnToYouTube, SIGNAL(clicked()), this, SLOT(uploadToYouTube()));
     connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory()));
-    connect(labelDesc, SIGNAL(linkActivated(const QString&)), this, SLOT(linkActivated(const QString&)));
- }
+}
 
 PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent),
     config(0), netManager(0)
@@ -736,7 +736,7 @@
             int prefixEnd   = item->desc.indexOf("]prefix");
             if (prefixBegin != -1 && prefixEnd != -1)
             {
-                item->prefix = desc.mid(prefixBegin + 7, prefixEnd - (prefixBegin + 7));
+                item->prefix = item->desc.mid(prefixBegin + 7, prefixEnd - (prefixBegin + 7));
                 item->desc.remove(prefixBegin, prefixEnd + 7 - prefixBegin);
             }
         }
@@ -771,7 +771,7 @@
         }
     }
     if (item->uploadUrl != "no")
-        desc += QString("<a href=\"%1\">%1</a>").arg(item->uploadUrl);
+        desc += QString("<a href=\"%1\" style=\"color: white;\">%1</a>").arg(item->uploadUrl);
     desc.replace("\n", "<br/>");
 
     labelDesc->setText(desc);
@@ -807,11 +807,6 @@
         QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(item->path())));
 }
 
-void PageVideos::linkActivated(const QString & link)
-{
-    QDesktopServices::openUrl(QUrl(link));
-}
-
 void PageVideos::playSelectedFile()
 {
     int index = filesTable->currentRow();
@@ -1131,6 +1126,7 @@
     filesTable->setCellWidget(row, vcProgress, progressBar);
 
     QNetworkReply* reply = netManager->put(request, file);
+    file->setParent(reply); // automatically close file when needed
     item->pUploading = reply;
     connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
     connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished()));
--- a/QTfrontend/ui/page/pagevideos.h	Thu Aug 09 01:24:38 2012 +0400
+++ b/QTfrontend/ui/page/pagevideos.h	Thu Aug 09 03:00:24 2012 +0400
@@ -120,7 +120,6 @@
         void uploadToYouTube();
         void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
         void uploadFinished();
-        void linkActivated(const QString & link);
 };
 
 #endif // PAGE_VIDEOS_H