QTfrontend/ui/page/pagevideos.cpp
author Stepan777 <stepik-777@mail.ru>
Thu, 26 Jul 2012 21:58:25 +0400
changeset 7447 01111960a48d
parent 7392 bc3306c59a08
child 7507 3032a5739fe1
permissions -rw-r--r--
uploading to youtube, it works, but user interface is still incomplete
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     1
/*
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     4
 *
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     8
 *
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    12
 * GNU General Public License for more details.
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    13
 *
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    17
 */
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    18
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    19
#include <QGridLayout>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    20
#include <QPushButton>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    21
#include <QGroupBox>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    22
#include <QComboBox>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    23
#include <QCheckBox>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    24
#include <QLabel>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    25
#include <QLineEdit>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    26
#include <QSpinBox>
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    27
#include <QTableWidget>
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    28
#include <QDir>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    29
#include <QProgressBar>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    30
#include <QStringList>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    31
#include <QDesktopServices>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    32
#include <QUrl>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    33
#include <QList>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    34
#include <QMessageBox>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    35
#include <QHeaderView>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    36
#include <QKeyEvent>
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    37
#include <QVBoxLayout>
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
    38
#include <QHBoxLayout>
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    39
#include <QFileSystemWatcher>
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
    40
#include <QDateTime>
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
    41
#include <QRegExp>
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    42
#include <QNetworkAccessManager>
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    43
#include <QNetworkRequest>
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    44
#include <QNetworkReply>
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    45
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    46
#include "hwconsts.h"
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    47
#include "pagevideos.h"
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    48
#include "igbox.h"
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    49
#include "libav_iteraction.h"
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
    50
#include "gameuiconfig.h"
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    51
#include "recorder.h"
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
    52
#include "ask_quit.h"
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    53
#include "upload_video.h"
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    54
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    55
static const QSize ThumbnailSize(350, 350*3/5);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
    56
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    57
// columns in table with list of video files
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    58
enum VideosColumns
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    59
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    60
    vcName,
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    61
    vcSize,
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    62
    vcProgress,
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    63
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    64
    vcNumColumns,
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    65
};
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    66
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    67
class VideoItem : public QTableWidgetItem
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    68
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    69
    // note: QTableWidgetItem is not Q_OBJECT
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    70
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    71
    public:
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    72
        VideoItem(const QString& name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    73
        ~VideoItem();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    74
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    75
        QString name;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    76
        QString desc; // description
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    77
        QString uploadReply;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    78
        HWRecorder * pRecorder; // non NULL if file is being encoded
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    79
        QNetworkReply * pUploading; // non NULL if file is being uploaded
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    80
        bool seen; // used when updating directory
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    81
        float lastSizeUpdate;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
    82
        float progress;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    83
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    84
        bool ready()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    85
        { return !pRecorder; }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    86
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    87
        QString path()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    88
        { return cfgdir->absoluteFilePath("Videos/" + name);  }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    89
};
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    90
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    91
VideoItem::VideoItem(const QString& name)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    92
    : QTableWidgetItem(name, UserType)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    93
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    94
    this->name = name;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    95
    pRecorder = NULL;
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
    96
    pUploading = NULL;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    97
    lastSizeUpdate = 0;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
    98
    progress = 0;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
    99
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   100
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   101
VideoItem::~VideoItem()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   102
{}
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   103
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   104
QLayout * PageVideos::bodyLayoutDefinition()
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   105
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   106
    QGridLayout * pPageLayout = new QGridLayout();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   107
    pPageLayout->setColumnStretch(0, 1);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   108
    pPageLayout->setColumnStretch(1, 2);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   109
    pPageLayout->setRowStretch(0, 1);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   110
    pPageLayout->setRowStretch(1, 1);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   111
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   112
    // options
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   113
    {
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   114
        IconedGroupBox* pOptionsGroup = new IconedGroupBox(this);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   115
        pOptionsGroup->setIcon(QIcon(":/res/Settings.png"));
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   116
        pOptionsGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   117
        pOptionsGroup->setTitle(QGroupBox::tr("Video recording options"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   118
        QGridLayout * pOptLayout = new QGridLayout(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   119
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   120
        // label for format
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   121
        QLabel *labelFormat = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   122
        labelFormat->setText(QLabel::tr("Format"));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   123
        pOptLayout->addWidget(labelFormat, 0, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   124
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   125
        // list of supported formats
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   126
        comboAVFormats = new QComboBox(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   127
        pOptLayout->addWidget(comboAVFormats, 0, 1, 1, 4);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   128
        LibavIteraction::instance().fillFormats(comboAVFormats);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   129
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   130
        // separator
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   131
        QFrame * hr = new QFrame(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   132
        hr->setFrameStyle(QFrame::HLine);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   133
        hr->setLineWidth(3);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   134
        hr->setFixedHeight(10);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   135
        pOptLayout->addWidget(hr, 1, 0, 1, 5);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   136
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   137
        // label for audio codec
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   138
        QLabel *labelACodec = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   139
        labelACodec->setText(QLabel::tr("Audio codec"));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   140
        pOptLayout->addWidget(labelACodec, 2, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   141
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   142
        // list of supported audio codecs
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   143
        comboAudioCodecs = new QComboBox(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   144
        pOptLayout->addWidget(comboAudioCodecs, 2, 1, 1, 3);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   145
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   146
        // checkbox 'record audio'
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   147
        checkRecordAudio = new QCheckBox(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   148
        checkRecordAudio->setText(QCheckBox::tr("Record audio"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   149
        pOptLayout->addWidget(checkRecordAudio, 2, 4);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   150
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   151
        // separator
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   152
        hr = new QFrame(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   153
        hr->setFrameStyle(QFrame::HLine);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   154
        hr->setLineWidth(3);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   155
        hr->setFixedHeight(10);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   156
        pOptLayout->addWidget(hr, 3, 0, 1, 5);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   157
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   158
        // label for video codec
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   159
        QLabel *labelVCodec = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   160
        labelVCodec->setText(QLabel::tr("Video codec"));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   161
        pOptLayout->addWidget(labelVCodec, 4, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   162
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   163
        // list of supported video codecs
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   164
        comboVideoCodecs = new QComboBox(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   165
        pOptLayout->addWidget(comboVideoCodecs, 4, 1, 1, 4);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   166
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   167
        // label for resolution
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   168
        QLabel *labelRes = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   169
        labelRes->setText(QLabel::tr("Resolution"));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   170
        pOptLayout->addWidget(labelRes, 5, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   171
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   172
        // width
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   173
        widthEdit = new QLineEdit(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   174
        widthEdit->setValidator(new QIntValidator(this));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   175
        pOptLayout->addWidget(widthEdit, 5, 1);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   176
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   177
        // x
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   178
        QLabel *labelX = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   179
        labelX->setText("X");
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   180
        pOptLayout->addWidget(labelX, 5, 2);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   181
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   182
        // height
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   183
        heightEdit = new QLineEdit(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   184
        heightEdit->setValidator(new QIntValidator(pOptionsGroup));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   185
        pOptLayout->addWidget(heightEdit, 5, 3);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   186
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   187
        // checkbox 'use game resolution'
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   188
        checkUseGameRes = new QCheckBox(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   189
        checkUseGameRes->setText(QCheckBox::tr("Use game resolution"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   190
        pOptLayout->addWidget(checkUseGameRes, 5, 4);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   191
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   192
        // label for framerate
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   193
        QLabel *labelFramerate = new QLabel(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   194
        labelFramerate->setText(QLabel::tr("Framerate"));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   195
        pOptLayout->addWidget(labelFramerate, 6, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   196
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   197
        // framerate
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   198
        framerateBox = new QSpinBox(pOptionsGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   199
        framerateBox->setRange(1, 200);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   200
        framerateBox->setSingleStep(1);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   201
        pOptLayout->addWidget(framerateBox, 6, 1);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   202
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   203
        // button 'set default options'
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   204
        btnDefaults = new QPushButton(pOptionsGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   205
        btnDefaults->setText(QPushButton::tr("Set default options"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   206
        pOptLayout->addWidget(btnDefaults, 7, 0, 1, 5);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   207
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   208
        pPageLayout->addWidget(pOptionsGroup, 1, 0);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   209
    }
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   210
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   211
    // list of videos
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   212
    {
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   213
        IconedGroupBox* pTableGroup = new IconedGroupBox(this);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   214
        pTableGroup->setIcon(QIcon(":/res/graphicsicon.png"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   215
        pTableGroup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   216
        pTableGroup->setTitle(QGroupBox::tr("Videos"));
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   217
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   218
        QStringList columns;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   219
        columns << tr("Name");
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   220
        columns << tr("Size");
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   221
        columns << "";
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   222
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   223
        filesTable = new QTableWidget(pTableGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   224
        filesTable->setColumnCount(vcNumColumns);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   225
        filesTable->setHorizontalHeaderLabels(columns);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   226
        filesTable->setSelectionBehavior(QAbstractItemView::SelectRows);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   227
        filesTable->setSelectionMode(QAbstractItemView::SingleSelection);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   228
        filesTable->setEditTriggers(QAbstractItemView::SelectedClicked);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   229
        filesTable->verticalHeader()->hide();
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   230
        filesTable->setMinimumWidth(400);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   231
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   232
        QHeaderView * header = filesTable->horizontalHeader();
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   233
        header->setResizeMode(vcName, QHeaderView::ResizeToContents);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   234
        header->setResizeMode(vcSize, QHeaderView::Fixed);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   235
        header->resizeSection(vcSize, 100);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   236
        header->setStretchLastSection(true);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   237
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   238
        btnOpenDir = new QPushButton(QPushButton::tr("Open videos directory"), pTableGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   239
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   240
        QVBoxLayout *box = new QVBoxLayout(pTableGroup);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   241
        box->addWidget(filesTable);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   242
        box->addWidget(btnOpenDir);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   243
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   244
        pPageLayout->addWidget(pTableGroup, 0, 1, 2, 1);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   245
    }
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   246
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   247
    // description
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   248
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   249
        IconedGroupBox* pDescGroup = new IconedGroupBox(this);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   250
        pDescGroup->setIcon(QIcon(":/res/graphicsicon.png"));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   251
        pDescGroup->setTitle(QGroupBox::tr("Description"));
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   252
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   253
        QVBoxLayout* pDescLayout = new QVBoxLayout(pDescGroup);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   254
        QHBoxLayout* pTopDescLayout = new QHBoxLayout(0);    // picture and text
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   255
        QHBoxLayout* pBottomDescLayout = new QHBoxLayout(0); // buttons
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   256
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   257
        // label with thumbnail picture
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   258
        labelThumbnail = new QLabel(pDescGroup);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   259
        labelThumbnail->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   260
        labelThumbnail->setMaximumSize(ThumbnailSize);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   261
        labelThumbnail->setStyleSheet(
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   262
                    "QFrame {"
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   263
                    "border: solid;"
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   264
                    "border-width: 3px;"
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   265
                    "border-color: #ffcc00;"
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   266
                    "border-radius: 4px;"
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   267
                    "}" );
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   268
        clearThumbnail();
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   269
        pTopDescLayout->addWidget(labelThumbnail, 2);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   270
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   271
        // label with file description
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   272
        labelDesc = new QLabel(pDescGroup);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   273
        labelDesc->setAlignment(Qt::AlignLeft | Qt::AlignTop);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   274
        pTopDescLayout->addWidget(labelDesc, 1);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   275
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   276
        // buttons: play and delete
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   277
        btnPlay = new QPushButton(QPushButton::tr("Play"), pDescGroup);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   278
        btnPlay->setEnabled(false);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   279
        pBottomDescLayout->addWidget(btnPlay);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   280
        btnDelete = new QPushButton(QPushButton::tr("Delete"), pDescGroup);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   281
        btnDelete->setEnabled(false);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   282
        pBottomDescLayout->addWidget(btnDelete);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   283
        btnToYouTube = new QPushButton(QPushButton::tr("Upload to YouTube"), pDescGroup);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   284
        btnToYouTube->setEnabled(false);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   285
        pBottomDescLayout->addWidget(btnToYouTube);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   286
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   287
        pDescLayout->addStretch(1);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   288
        pDescLayout->addLayout(pTopDescLayout, 0);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   289
        pDescLayout->addStretch(1);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   290
        pDescLayout->addLayout(pBottomDescLayout, 0);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   291
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   292
        pPageLayout->addWidget(pDescGroup, 0, 0);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   293
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   294
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   295
    return pPageLayout;
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   296
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   297
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   298
QLayout * PageVideos::footerLayoutDefinition()
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   299
{
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   300
    return NULL;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   301
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   302
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   303
void PageVideos::connectSignals()
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   304
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   305
    connect(checkUseGameRes, SIGNAL(stateChanged(int)), this, SLOT(changeUseGameRes(int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   306
    connect(checkRecordAudio, SIGNAL(stateChanged(int)), this, SLOT(changeRecordAudio(int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   307
    connect(comboAVFormats, SIGNAL(currentIndexChanged(int)), this, SLOT(changeAVFormat(int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   308
    connect(btnDefaults, SIGNAL(clicked()), this, SLOT(setDefaultOptions()));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   309
    connect(filesTable, SIGNAL(cellDoubleClicked(int, int)), this, SLOT(cellDoubleClicked(int, int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   310
    connect(filesTable, SIGNAL(cellChanged(int,int)), this, SLOT(cellChanged(int, int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   311
    connect(filesTable, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentCellChanged(int,int,int,int)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   312
    connect(btnPlay,   SIGNAL(clicked()), this, SLOT(playSelectedFile()));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   313
    connect(btnDelete, SIGNAL(clicked()), this, SLOT(deleteSelectedFiles()));
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   314
    connect(btnToYouTube, SIGNAL(clicked()), this, SLOT(uploadToYouTube()));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   315
    connect(btnOpenDir, SIGNAL(clicked()), this, SLOT(openVideosDirectory()));
7392
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   316
 }
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   317
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   318
PageVideos::PageVideos(QWidget* parent) : AbstractPage(parent),
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   319
    config(0), netManager(0)
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   320
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   321
    nameChangedFromCode = false;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   322
    numRecorders = 0;
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   323
    numUploads = 0;
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   324
    initPage();
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   325
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   326
7392
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   327
void PageVideos::init(GameUIConfig * config)
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   328
{
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   329
    this->config = config;
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   330
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   331
    QString path = cfgdir->absolutePath() + "/Videos";
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   332
    QFileSystemWatcher * pWatcher = new QFileSystemWatcher(this);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   333
    pWatcher->addPath(path);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   334
    connect(pWatcher, SIGNAL(directoryChanged(const QString &)), this, SLOT(updateFileList(const QString &)));
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   335
    updateFileList(path);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   336
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   337
    startEncoding(); // this is for videos recorded from demos which were executed directly (without frontend)
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   338
}
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   339
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   340
// user changed file format, we need to update list of codecs
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   341
void PageVideos::changeAVFormat(int index)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   342
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   343
    // remember selected codecs
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   344
    QString prevVCodec = videoCodec();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   345
    QString prevACodec = audioCodec();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   346
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   347
    // clear lists of codecs
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   348
    comboVideoCodecs->clear();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   349
    comboAudioCodecs->clear();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   350
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   351
    // get list of codecs for specified format
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   352
    LibavIteraction::instance().fillCodecs(comboAVFormats->itemData(index).toString(), comboVideoCodecs, comboAudioCodecs);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   353
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   354
    // disable audio if there is no audio codec
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   355
    if (comboAudioCodecs->count() == 0)
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   356
    {
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   357
        checkRecordAudio->setChecked(false);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   358
        checkRecordAudio->setEnabled(false);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   359
    }
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   360
    else
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   361
        checkRecordAudio->setEnabled(true);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   362
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   363
    // restore selected codecs if possible
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   364
    int iVCodec = comboVideoCodecs->findData(prevVCodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   365
    if (iVCodec != -1)
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   366
        comboVideoCodecs->setCurrentIndex(iVCodec);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   367
    int iACodec = comboAudioCodecs->findData(prevACodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   368
    if (iACodec != -1)
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   369
        comboAudioCodecs->setCurrentIndex(iACodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   370
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   371
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   372
// user switched checkbox 'use game resolution'
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   373
void PageVideos::changeUseGameRes(int state)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   374
{
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   375
    if (state && config)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   376
    {
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   377
        // set resolution to game resolution
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   378
        QRect resolution = config->vid_Resolution();
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   379
        widthEdit->setText(QString::number(resolution.width()));
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   380
        heightEdit->setText(QString::number(resolution.height()));
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   381
    }
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   382
    widthEdit->setEnabled(!state);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   383
    heightEdit->setEnabled(!state);
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   384
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   385
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   386
// user switched checkbox 'record audio'
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   387
void PageVideos::changeRecordAudio(int state)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   388
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   389
    comboAudioCodecs->setEnabled(!!state);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   390
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   391
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   392
void PageVideos::setDefaultCodecs()
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   393
{
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   394
    if (tryCodecs("mp4", "libx264", "libmp3lame"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   395
        return;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   396
    if (tryCodecs("mp4", "libx264", "libfaac"))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   397
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   398
    if (tryCodecs("mp4", "libx264", "libvo_aacenc"))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   399
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   400
    if (tryCodecs("mp4", "libx264", "aac"))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   401
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   402
    if (tryCodecs("mp4", "libx264", "mp2"))
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   403
        return;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   404
    if (tryCodecs("avi", "libxvid", "libmp3lame"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   405
        return;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   406
    if (tryCodecs("avi", "libxvid", "ac3_fixed"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   407
        return;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   408
    if (tryCodecs("avi", "libxvid", "mp2"))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   409
        return;
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   410
    if (tryCodecs("avi", "mpeg4", "libmp3lame"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   411
        return;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   412
    if (tryCodecs("avi", "mpeg4", "ac3_fixed"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   413
        return;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   414
    if (tryCodecs("avi", "mpeg4", "mp2"))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   415
        return;
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   416
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   417
    // this shouldn't happen, just in case
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   418
    if (tryCodecs("ogg", "libtheora", "libvorbis"))
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   419
        return;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   420
    tryCodecs("ogg", "libtheora", "flac");
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   421
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   422
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   423
void PageVideos::setDefaultOptions()
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   424
{
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   425
    framerateBox->setValue(25);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   426
    checkRecordAudio->setChecked(true);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   427
    checkUseGameRes->setChecked(true);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   428
    setDefaultCodecs();
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   429
}
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   430
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   431
bool PageVideos::tryCodecs(const QString & format, const QString & vcodec, const QString & acodec)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   432
{
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   433
    // first we should change format
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   434
    int iFormat = comboAVFormats->findData(format);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   435
    if (iFormat == -1)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   436
        return false;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   437
    comboAVFormats->setCurrentIndex(iFormat);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   438
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   439
    // try to find video codec
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   440
    int iVCodec = comboVideoCodecs->findData(vcodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   441
    if (iVCodec == -1)
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   442
        return false;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   443
    comboVideoCodecs->setCurrentIndex(iVCodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   444
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   445
    // try to find audio codec
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   446
    int iACodec = comboAudioCodecs->findData(acodec);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   447
    if (iACodec == -1 && checkRecordAudio->isChecked())
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   448
        return false;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   449
    if (iACodec != -1)
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   450
        comboAudioCodecs->setCurrentIndex(iACodec);
7235
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   451
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   452
    return true;
baa69bd025d9 1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff changeset
   453
}
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   454
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   455
// get file size as string
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   456
QString FileSizeStr(const QString & path)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   457
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   458
    quint64 size = QFileInfo(path).size();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   459
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   460
    quint64 KiB = 1024;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   461
    quint64 MiB = 1024*KiB;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   462
    quint64 GiB = 1024*MiB;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   463
    QString sizeStr;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   464
    if (size >= GiB)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   465
        return QString("%1 GiB").arg(QString::number(float(size)/GiB, 'f', 2));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   466
    if (size >= MiB)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   467
        return QString("%1 MiB").arg(QString::number(float(size)/MiB, 'f', 2));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   468
     if (size >= KiB)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   469
        return QString("%1 KiB").arg(QString::number(float(size)/KiB, 'f', 2));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   470
    return PageVideos::tr("%1 bytes").arg(QString::number(size));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   471
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   472
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   473
// set file size in file list in specified row
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   474
void PageVideos::updateSize(int row)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   475
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   476
    VideoItem * item = nameItem(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   477
    QString path = item->ready()? item->path() : cfgdir->absoluteFilePath("VideoTemp/" + item->pRecorder->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   478
    filesTable->item(row, vcSize)->setText(FileSizeStr(path));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   479
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   480
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   481
void PageVideos::updateFileList(const QString & path)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   482
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   483
    // mark all files as non seen
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   484
    int numRows = filesTable->rowCount();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   485
    for (int i = 0; i < numRows; i++)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   486
        nameItem(i)->seen = false;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   487
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   488
    QStringList files = QDir(path).entryList(QDir::Files);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   489
    foreach (const QString & name, files)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   490
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   491
        int row = -1;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   492
        foreach (QTableWidgetItem * item, filesTable->findItems(name, Qt::MatchExactly))
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   493
        {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   494
            if (item->type() != QTableWidgetItem::UserType || !((VideoItem*)item)->ready())
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   495
                continue;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   496
            row = item->row();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   497
            break;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   498
        }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   499
        if (row == -1)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   500
            row = appendRow(name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   501
        VideoItem * item = nameItem(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   502
        item->seen = true;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   503
        item->desc = "";
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   504
        updateSize(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   505
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   506
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   507
    // remove all non seen files
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   508
    for (int i = 0; i < filesTable->rowCount();)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   509
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   510
        VideoItem * item = nameItem(i);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   511
        if (item->ready() && !item->seen)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   512
            filesTable->removeRow(i);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   513
        else
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   514
            i++;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   515
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   516
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   517
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   518
void PageVideos::addRecorder(HWRecorder* pRecorder)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   519
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   520
    int row = appendRow(pRecorder->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   521
    VideoItem * item = nameItem(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   522
    item->pRecorder = pRecorder;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   523
    pRecorder->item = item;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   524
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   525
    // add progress bar
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   526
    QProgressBar * progressBar = new QProgressBar(filesTable);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   527
    progressBar->setMinimum(0);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   528
    progressBar->setMaximum(10000);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   529
    progressBar->setValue(0);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   530
    connect(pRecorder, SIGNAL(onProgress(float)), this, SLOT(updateProgress(float)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   531
    connect(pRecorder, SIGNAL(encodingFinished(bool)), this, SLOT(encodingFinished(bool)));
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   532
    filesTable->setCellWidget(row, vcProgress, progressBar);
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   533
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   534
    numRecorders++;
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   535
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   536
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   537
void PageVideos::setProgress(int row, VideoItem* item, float value)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   538
{
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   539
    QProgressBar * progressBar = (QProgressBar*)filesTable->cellWidget(row, vcProgress);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   540
    progressBar->setValue(value*10000);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   541
    progressBar->setFormat(QString("%1%").arg(value*100, 0, 'f', 2));
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   542
    item->progress = value;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   543
}
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   544
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   545
void PageVideos::updateProgress(float value)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   546
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   547
    HWRecorder * pRecorder = (HWRecorder*)sender();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   548
    VideoItem * item = (VideoItem*)pRecorder->item;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   549
    int row = filesTable->row(item);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   550
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   551
    // update file size every percent
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   552
    if (value - item->lastSizeUpdate > 0.01)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   553
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   554
        updateSize(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   555
        item->lastSizeUpdate = value;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   556
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   557
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   558
    setProgress(row, item, value);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   559
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   560
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   561
void PageVideos::encodingFinished(bool success)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   562
{
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   563
    numRecorders--;
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   564
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   565
    HWRecorder * pRecorder = (HWRecorder*)sender();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   566
    VideoItem * item = (VideoItem*)pRecorder->item;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   567
    int row = filesTable->row(item);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   568
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   569
    if (success)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   570
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   571
        // move file to destination
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   572
        success = cfgdir->rename("VideoTemp/" + pRecorder->name, "Videos/" + item->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   573
        if (!success)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   574
        {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   575
            // unable to rename for some reason (maybe user entered incorrect name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   576
            // try to use temp name instead.
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   577
            success = cfgdir->rename("VideoTemp/" + pRecorder->name, "Videos/" + pRecorder->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   578
            if (success)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   579
                setName(item, pRecorder->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   580
        }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   581
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   582
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   583
    if (!success)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   584
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   585
        filesTable->removeRow(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   586
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   587
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   588
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   589
    filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   590
    item->pRecorder = NULL;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   591
    updateSize(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   592
    updateDescription();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   593
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   594
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   595
void PageVideos::cellDoubleClicked(int row, int column)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   596
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   597
    play(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   598
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   599
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   600
void PageVideos::cellChanged(int row, int column)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   601
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   602
    // user can only edit name
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   603
    if (column != vcName || nameChangedFromCode)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   604
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   605
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   606
    // user has edited filename, so we should rename the file
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   607
    VideoItem * item = nameItem(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   608
    QString oldName = item->name;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   609
    QString newName = item->text();
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   610
    if (!newName.contains('.')) // user forgot an extension
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   611
    {
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   612
        int pt = oldName.lastIndexOf('.');
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   613
        if (pt != -1)
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   614
        {
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   615
            newName += oldName.right(oldName.length() - pt);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   616
            setName(item, newName);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   617
        }
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   618
    }
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   619
#ifdef Q_WS_WIN
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   620
    // there is a bug in qt, QDir::rename() doesn't fail on such names but damages files
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   621
    if (newName.contains(QRegExp("[\"*:<>?\/|]")))
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   622
    {
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   623
        setName(item, oldName);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   624
        return;
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   625
    }
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   626
#endif
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   627
    if (item->ready() && !cfgdir->rename("Videos/" + oldName, "Videos/" + newName))
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   628
    {
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   629
        // unable to rename for some reason (maybe user entered incorrect name),
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   630
        // therefore restore old name in cell
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   631
        setName(item, oldName);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   632
        return;
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   633
    }
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   634
    item->name = newName;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   635
    updateDescription();
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   636
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   637
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   638
void PageVideos::setName(VideoItem * item, const QString & newName)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   639
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   640
    nameChangedFromCode = true;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   641
    item->setText(newName);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   642
    nameChangedFromCode = false;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   643
    item->name = newName;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   644
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   645
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   646
int PageVideos::appendRow(const QString & name)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   647
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   648
    int row = filesTable->rowCount();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   649
    filesTable->setRowCount(row+1);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   650
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   651
    // add 'name' item
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   652
    QTableWidgetItem * item = new VideoItem(name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   653
    item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   654
    nameChangedFromCode = true;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   655
    filesTable->setItem(row, vcName, item);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   656
    nameChangedFromCode = false;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   657
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   658
    // add 'size' item
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   659
    item = new QTableWidgetItem();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   660
    item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   661
    item->setTextAlignment(Qt::AlignRight);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   662
    filesTable->setItem(row, vcSize, item);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   663
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   664
    // add 'progress' item
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   665
    item = new QTableWidgetItem();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   666
    item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   667
    filesTable->setItem(row, vcProgress, item);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   668
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   669
    return row;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   670
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   671
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   672
VideoItem* PageVideos::nameItem(int row)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   673
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   674
    return (VideoItem*)filesTable->item(row, vcName);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   675
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   676
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   677
void PageVideos::clearThumbnail()
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   678
{
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   679
    // add empty image for proper sizing
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   680
    QPixmap pic(ThumbnailSize);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   681
    pic.fill(QColor(0,0,0,0));
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   682
    labelThumbnail->setPixmap(pic);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   683
}
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   684
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   685
void PageVideos::updateDescription()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   686
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   687
    VideoItem * item = nameItem(filesTable->currentRow());
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   688
    if (!item)
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   689
    {
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   690
        labelDesc->clear();
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   691
        clearThumbnail();
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   692
        btnPlay->setEnabled(false);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   693
        btnDelete->setEnabled(false);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   694
        btnToYouTube->setEnabled(false);
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   695
        return;
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   696
    }
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   697
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   698
    btnPlay->setEnabled(item->ready());
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   699
    btnDelete->setEnabled(true);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   700
    btnToYouTube->setEnabled(item->ready());
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   701
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   702
    QString desc = item->name + "\n\n";
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   703
    QString thumbName = "";
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   704
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   705
    if (item->ready())
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   706
    {
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   707
        QString path = item->path();
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   708
        desc += tr("Date: ") + QFileInfo(path).created().toString(Qt::DefaultLocaleLongDate) + "\n";
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   709
        desc += tr("Size: ") + FileSizeStr(path) + "\n";
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   710
        if (item->desc == "")
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   711
            item->desc = LibavIteraction::instance().getFileInfo(path);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   712
        desc += item->desc;
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   713
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   714
        // extract thumbnail name fron description
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   715
        int prefixBegin = desc.indexOf("prefix[");
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   716
        int prefixEnd = desc.indexOf("]prefix");
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   717
        if (prefixBegin != -1 && prefixEnd != -1)
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   718
        {
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   719
            QString prefix = desc.mid(prefixBegin + 7, prefixEnd - (prefixBegin + 7));
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   720
            desc.remove(prefixBegin, prefixEnd + 7 - prefixBegin);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   721
            thumbName = prefix;
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   722
        }
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   723
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   724
        desc += item->uploadReply;
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   725
    }
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   726
    else
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   727
        desc += tr("(in progress...)");
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   728
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   729
    if (thumbName.isEmpty())
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   730
    {
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   731
        if (item->ready())
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   732
            thumbName = item->name;
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   733
        else
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   734
            thumbName = item->pRecorder->name;
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   735
        // remove extension
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   736
        int pt = thumbName.lastIndexOf('.');
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   737
        if (pt != -1)
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   738
            thumbName.truncate(pt);
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   739
    }
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   740
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   741
    if (!thumbName.isEmpty())
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   742
    {
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   743
        thumbName = cfgdir->absoluteFilePath("VideoTemp/" + thumbName);
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   744
        QPixmap pic;
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   745
        if (pic.load(thumbName + ".png") || pic.load(thumbName + ".bmp"))
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   746
        {
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   747
            if (pic.height()*ThumbnailSize.width() > pic.width()*ThumbnailSize.height())
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   748
                pic = pic.scaledToWidth(ThumbnailSize.width());
7306
3cff5c769509 Here they come - thumbnails.
Stepan777 <stepik-777@mail.ru>
parents: 7280
diff changeset
   749
            else
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   750
                pic = pic.scaledToHeight(ThumbnailSize.height());
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   751
            labelThumbnail->setPixmap(pic);
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   752
        }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   753
        else
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   754
            clearThumbnail();
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   755
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   756
    labelDesc->setText(desc);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   757
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   758
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   759
// user selected another cell, so we should change description
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   760
void PageVideos::currentCellChanged(int row, int column, int previousRow, int previousColumn)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   761
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   762
    updateDescription();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   763
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   764
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   765
// open video file in external media player
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   766
void PageVideos::play(int row)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   767
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   768
    VideoItem * item = nameItem(row);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   769
    if (item->ready())
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   770
        QDesktopServices::openUrl(QUrl("file:///" + QDir::toNativeSeparators(item->path())));
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   771
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   772
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   773
void PageVideos::playSelectedFile()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   774
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   775
    int index = filesTable->currentRow();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   776
    if (index != -1)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   777
        play(index);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   778
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   779
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   780
void PageVideos::deleteSelectedFiles()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   781
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   782
    QList<QTableWidgetItem*> items = filesTable->selectedItems();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   783
    int num = items.size() / vcNumColumns;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   784
    if (num == 0)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   785
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   786
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   787
    // ask user if (s)he is serious
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   788
    if (QMessageBox::question(this,
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   789
                              tr("Are you sure?"),
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   790
                              tr("Do you really want do remove %1 file(s)?").arg(num),
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   791
                              QMessageBox::Yes | QMessageBox::No)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   792
            != QMessageBox::Yes)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   793
        return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   794
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   795
    // remove
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   796
    foreach (QTableWidgetItem * witem, items)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   797
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   798
        if (witem->type() != QTableWidgetItem::UserType)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   799
            continue;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   800
        VideoItem * item = (VideoItem*)witem;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   801
        if (!item->ready())
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   802
            item->pRecorder->deleteLater();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   803
        else
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   804
            cfgdir->remove("Videos/" + item->name);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   805
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   806
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   807
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   808
void PageVideos::keyPressEvent(QKeyEvent * pEvent)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   809
{
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   810
    if (filesTable->hasFocus())
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   811
    {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   812
        if (pEvent->key() == Qt::Key_Delete)
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   813
        {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   814
            deleteSelectedFiles();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   815
            return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   816
        }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   817
        if (pEvent->key() == Qt::Key_Enter) // doesn't work
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   818
        {
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   819
            playSelectedFile();
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   820
            return;
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   821
        }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   822
    }
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   823
    AbstractPage::keyPressEvent(pEvent);
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   824
}
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   825
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   826
void PageVideos::openVideosDirectory()
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   827
{
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   828
    QString path = QDir::toNativeSeparators(cfgdir->absolutePath() + "/Videos");
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   829
    QDesktopServices::openUrl(QUrl("file:///" + path));
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   830
}
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   831
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   832
// clear VideoTemp directory (except for thumbnails)
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   833
void PageVideos::clearTemp()
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   834
{
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   835
    QDir temp(cfgdir->absolutePath() + "/VideoTemp");
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   836
    QStringList files = temp.entryList(QDir::Files);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   837
    foreach (const QString& file, files)
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   838
    {
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   839
        if (!file.endsWith(".bmp") && !file.endsWith(".png"))
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   840
            temp.remove(file);
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   841
    }
7280
fd707afbc3a2 pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents: 7235
diff changeset
   842
}
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   843
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   844
bool PageVideos::tryQuit(HWForm * form)
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   845
{
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   846
    bool quit = true;
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   847
    if (numRecorders != 0 || numUploads != 0)
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   848
    {
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   849
        // ask user what to do - abort or wait
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   850
        HWAskQuitDialog * askd = new HWAskQuitDialog(this, form);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   851
        askd->deleteLater();
7386
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   852
        quit = askd->exec();
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   853
    }
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   854
    if (quit)
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   855
        clearTemp();
e82a076df09b Fix bug with isInLag picture displayed at end of some videos.
Stepan777 <stepik-777@mail.ru>
parents: 7353
diff changeset
   856
    return quit;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   857
}
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   858
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   859
// returns multi-line string with list of videos in progress
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   860
/* it will look like this:
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   861
foo.avi (15.21% - encoding)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   862
bar.avi (18.21% - uploading)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   863
*/
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   864
QString PageVideos::getVideosInProgress()
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   865
{
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   866
    QString list = "";
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   867
    int count = filesTable->rowCount();
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   868
    for (int i = 0; i < count; i++)
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   869
    {
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   870
        VideoItem * item = nameItem(i);
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   871
        QString process;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   872
        if (!item->ready())
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   873
            process = tr("encoding");
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   874
        else if (item->pUploading)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   875
            process = tr("uploading");
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   876
        else
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   877
            continue;
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   878
        float progress = 100*item->progress;
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   879
        if (progress > 99.99)
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   880
            progress = 99.99; // displaying 100% may be confusing
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   881
        list += item->name + " (" + QString::number(progress, 'f', 2) + "% - " + process + ")\n";
7353
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   882
    }
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   883
    return list;
0e55228e1303 When there are videos that are being encoded and user tries to quit display dialog with warning.
Stepan777 <stepik-777@mail.ru>
parents: 7306
diff changeset
   884
}
7392
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   885
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   886
void PageVideos::startEncoding(const QByteArray & record)
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   887
{
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   888
    QDir videoTempDir(cfgdir->absolutePath() + "/VideoTemp/");
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   889
    QStringList files = videoTempDir.entryList(QStringList("*.txtout"), QDir::Files);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   890
    foreach (const QString & str, files)
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   891
    {
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   892
        QString prefix = str;
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   893
        prefix.chop(7); // remove ".txtout"
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   894
        videoTempDir.rename(prefix + ".txtout", prefix + ".txtin"); // rename this file to not open it twice
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   895
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   896
        HWRecorder* pRecorder = new HWRecorder(config, prefix);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   897
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   898
        if (!record.isEmpty())
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   899
            pRecorder->EncodeVideo(record);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   900
        else
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   901
        {
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   902
            // this is for videos recorded from demos which were executed directly (without frontend)
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   903
            QFile demofile(videoTempDir.absoluteFilePath(prefix + ".hwd"));
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   904
            if (!demofile.open(QIODevice::ReadOnly))
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   905
                continue;
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   906
            QByteArray demo = demofile.readAll();
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   907
            if (demo.isEmpty())
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   908
                continue;
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   909
            pRecorder->EncodeVideo(demo);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   910
        }
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   911
        addRecorder(pRecorder);
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   912
    }
bc3306c59a08 Correctly distinguish between game and real ticks while recording video,
Stepan777 <stepik-777@mail.ru>
parents: 7386
diff changeset
   913
}
7447
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   914
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   915
void PageVideos::uploadProgress(qint64 bytesSent, qint64 bytesTotal)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   916
{
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   917
    QNetworkReply* reply = (QNetworkReply*)sender();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   918
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   919
    VideoItem * item = NULL;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   920
    int row;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   921
    int count = filesTable->rowCount();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   922
    // find corresponding item (maybe there is a better wat to implement this?)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   923
    for (int i = 0; i < count; i++)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   924
    {
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   925
        item = nameItem(i);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   926
        if (item->pUploading == reply)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   927
        {
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   928
            row = i;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   929
            break;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   930
        }
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   931
    }
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   932
    Q_ASSERT(item);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   933
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   934
    setProgress(row, item, bytesSent*1.0/bytesTotal);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   935
}
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   936
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   937
void PageVideos::uploadFinished()
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   938
{
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   939
    QNetworkReply* reply = (QNetworkReply*)sender();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   940
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   941
    VideoItem * item = NULL;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   942
    int row;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   943
    int count = filesTable->rowCount();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   944
    for (int i = 0; i < count; i++)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   945
    {
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   946
        item = nameItem(i);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   947
        if (item->pUploading == reply)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   948
        {
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   949
            row = i;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   950
            break;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   951
        }
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   952
    }
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   953
    Q_ASSERT(item);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   954
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   955
    item->pUploading = NULL;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   956
    QByteArray answer = reply->readAll();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   957
    item->uploadReply = QString::fromUtf8(answer.data());
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   958
   // QMessageBox::information(this,"",item->uploadReply,0);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   959
    filesTable->setCellWidget(row, vcProgress, NULL); // remove progress bar
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   960
    numUploads--;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   961
}
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   962
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   963
void PageVideos::uploadToYouTube()
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   964
{
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   965
    int row = filesTable->currentRow();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   966
    VideoItem * item = nameItem(row);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   967
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   968
    if (!netManager)
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   969
        netManager = new QNetworkAccessManager(this);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   970
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   971
    HWUploadVideoDialog* dlg = new HWUploadVideoDialog(this, item->name, netManager);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   972
    dlg->deleteLater();
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   973
    if (!dlg->exec())
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   974
        return;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   975
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   976
    QNetworkRequest request(QUrl(dlg->location));
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   977
    request.setRawHeader("Content-Type", "application/octet-stream");
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   978
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   979
    QFile * file = new QFile(item->path(), this);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   980
    if (!file->open(QIODevice::ReadOnly))
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   981
        return;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   982
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   983
    // add progress bar
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   984
    QProgressBar * progressBar = new QProgressBar(filesTable);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   985
    progressBar->setMinimum(0);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   986
    progressBar->setMaximum(10000);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   987
    progressBar->setValue(0);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   988
    // make it different from encoding progress-bar
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   989
    progressBar->setStyleSheet("* {color: #00ccff; selection-background-color: #00ccff;}" );
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   990
    filesTable->setCellWidget(row, vcProgress, progressBar);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   991
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   992
    QNetworkReply* reply = netManager->put(request, file);
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   993
    item->pUploading = reply;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   994
    connect(reply, SIGNAL(uploadProgress(qint64, qint64)), this, SLOT(uploadProgress(qint64, qint64)));
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   995
    connect(reply, SIGNAL(finished()), this, SLOT(uploadFinished()));
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   996
    numUploads++;
01111960a48d uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents: 7392
diff changeset
   997
}