QTfrontend/ui/page/pagevideos.h
author sheepluva
Thu, 30 Aug 2012 20:42:29 +0200
changeset 7631 01b599d6f72d
parent 7531 0adcad8714c4
child 7633 d4251e519062
permissions -rw-r--r--
dos2unix newline fixes on 7 (video recording-)merged files
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     1
/*
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     2
 * Hedgewars, a free turn based strategy game
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     4
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     8
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    12
 * GNU General Public License for more details.
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    13
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    14
 * You should have received a copy of the GNU General Public License
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    15
 * along with this program; if not, write to the Free Software
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    17
 */
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    18
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    19
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    20
#ifndef PAGE_VIDEOS_H
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    21
#define PAGE_VIDEOS_H
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    22
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    23
#include "AbstractPage.h"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    24
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    25
class QNetworkAccessManager;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    26
class QNetworkReply;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    27
class GameUIConfig;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    28
class HWRecorder;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    29
class VideoItem;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    30
class HWForm;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    31
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    32
class PageVideos : public AbstractPage
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    33
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    34
        Q_OBJECT
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    35
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    36
    public:
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    37
        PageVideos(QWidget* parent = 0);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    38
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    39
        QSpinBox  *framerateBox;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    40
        QLineEdit *widthEdit;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    41
        QLineEdit *heightEdit;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    42
        QCheckBox *checkUseGameRes;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    43
        QCheckBox *checkRecordAudio;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    44
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    45
        QString format()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    46
        { return comboAVFormats->itemData(comboAVFormats->currentIndex()).toString(); }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    47
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    48
        QString videoCodec()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    49
        { return comboVideoCodecs->itemData(comboVideoCodecs->currentIndex()).toString(); }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    50
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    51
        QString audioCodec()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    52
        { return comboAudioCodecs->itemData(comboAudioCodecs->currentIndex()).toString(); }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    53
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    54
        void setDefaultCodecs();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    55
        bool tryCodecs(const QString & format, const QString & vcodec, const QString & acodec);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    56
        void addRecorder(HWRecorder* pRecorder);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    57
        bool tryQuit(HWForm *form);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    58
        QString getVideosInProgress(); // get multi-line string with list of videos in progress
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    59
        void startEncoding(const QByteArray & record = QByteArray());
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    60
        void init(GameUIConfig * config);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    61
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    62
    private:
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    63
        // virtuals from AbstractPage
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    64
        QLayout * bodyLayoutDefinition();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    65
        QLayout * footerLayoutDefinition();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    66
        void connectSignals();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    67
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    68
        // virtual from QWidget
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    69
        void keyPressEvent(QKeyEvent * pEvent);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    70
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    71
        void setName(VideoItem * item, const QString & newName);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    72
        void updateSize(int row);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    73
        int appendRow(const QString & name);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    74
        VideoItem* nameItem(int row);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    75
        void play(int row);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    76
        void updateDescription();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    77
        void clearTemp();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    78
        void clearThumbnail();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    79
        void setProgress(int row, VideoItem* item, float value);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    80
        VideoItem * itemFromReply(QNetworkReply* reply, int & row);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    81
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    82
        GameUIConfig * config;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    83
        QNetworkAccessManager* netManager;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    84
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    85
        // options group
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    86
        QComboBox *comboAVFormats;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    87
        QComboBox *comboVideoCodecs;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    88
        QComboBox *comboAudioCodecs;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    89
        QPushButton *btnDefaults;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    90
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    91
        // file list group
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    92
        QTableWidget *filesTable;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    93
        QPushButton *btnOpenDir;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    94
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    95
        // description group
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    96
        QPushButton *btnPlay, *btnDelete, *btnToYouTube;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    97
        QLabel *labelDesc;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    98
        QLabel *labelThumbnail;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    99
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   100
        // this flag is used to distinguish if cell was changed from code or by user
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   101
        // (in signal cellChanged)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   102
        bool nameChangedFromCode;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   103
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   104
        int numRecorders, numUploads;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   105
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   106
    private slots:
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   107
        void changeAVFormat(int index);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   108
        void changeUseGameRes(int state);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   109
        void changeRecordAudio(int state);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   110
        void setDefaultOptions();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   111
        void encodingFinished(bool success);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   112
        void updateProgress(float value);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   113
        void cellDoubleClicked(int row, int column);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   114
        void cellChanged(int row, int column);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   115
        void currentCellChanged(int row, int column, int previousRow, int previousColumn);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   116
        void playSelectedFile();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   117
        void deleteSelectedFiles();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   118
        void openVideosDirectory();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   119
        void updateFileList(const QString & path);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   120
        void uploadToYouTube();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   121
        void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   122
        void uploadFinished();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   123
};
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   124
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   125
#endif // PAGE_VIDEOS_H