OSDN Git Service

Added log file support.
[x264-launcher/x264-launcher.git] / src / win_main.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2012 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include "win_main.h"
23
24 #include "global.h"
25 #include "model_jobList.h"
26
27 #include <QDate>
28 #include <QTimer>
29
30 ///////////////////////////////////////////////////////////////////////////////
31 // Constructor & Destructor
32 ///////////////////////////////////////////////////////////////////////////////
33
34 MainWindow::MainWindow(void)
35 {
36         //Init the dialog, from the .ui file
37         setupUi(this);
38         setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint);
39
40         //Register meta types
41         qRegisterMetaType<QUuid>("QUuid");
42         qRegisterMetaType<EncodeThread::JobStatus>("EncodeThread::JobStatus");
43
44         //Freeze minimum size
45         setMinimumSize(size());
46
47         //Show version
48         setWindowTitle(QString("%1 [%2]").arg(windowTitle(), x264_version_date().toString(Qt::ISODate)));
49
50         //Create model
51         m_jobList = new JobListModel();
52         jobsView->setModel(m_jobList);
53
54         //Setup view
55         jobsView->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
56         jobsView->horizontalHeader()->setResizeMode(1, QHeaderView::Fixed);
57         jobsView->horizontalHeader()->setResizeMode(2, QHeaderView::Fixed);
58         jobsView->horizontalHeader()->resizeSection(1, 150);
59         jobsView->horizontalHeader()->resizeSection(2, 90);
60         jobsView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
61         connect(jobsView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(jobSelected(QModelIndex, QModelIndex)));
62
63         //Enable buttons
64         connect(buttonAddJob, SIGNAL(clicked()), this, SLOT(addButtonPressed()));
65 }
66
67 MainWindow::~MainWindow(void)
68 {
69 }
70
71 ///////////////////////////////////////////////////////////////////////////////
72 // Slots
73 ///////////////////////////////////////////////////////////////////////////////
74
75 void MainWindow::addButtonPressed(void)
76 {
77         EncodeThread *thrd = new EncodeThread();
78         m_jobList->insertJob(thrd);
79
80         QTimer::singleShot(2500, thrd, SLOT(start()));
81 }
82
83 void MainWindow::jobSelected(const QModelIndex & current, const QModelIndex & previous)
84 {
85         qDebug("Job selected: %d", current.row());
86         logView->setModel(m_jobList->getLogFile(current));
87         logView->scrollToBottom();
88 }