Documented GViewport a small amount, fixed a translation bug in BasicViewport.
[aesalon.git] / src / visualizer / InputCreator.cpp
blob59a70b69d9e11c71c0a2dbfb937c2dcbcc5cabc7
1 /** Aesalon, a tool to visualize program behaviour in real time.
2 Copyright (C) 2009-2011, Aesalon development team.
4 Aesalon is distributed under the terms of the GNU GPLv3. See
5 the included file LICENSE for more information.
7 @file src/visualizer/InputCreator.cpp
8 */
10 #include <QVBoxLayout>
11 #include <QFormLayout>
12 #include <QPushButton>
13 #include <QTabWidget>
14 #include <QLabel>
15 #include <QFileDialog>
16 #include <QStyle>
18 #include "visualizer/InputCreator.h"
19 #include "util/MessageSystem.h"
20 #include "visualizer/LogInput.h"
22 namespace Visualizer {
24 InputCreator::InputCreator(InputManager *inputManager) : m_inputManager(inputManager) {
25 setModal(true);
26 QVBoxLayout *layout = new QVBoxLayout();
28 QTabWidget *tabWidget = new QTabWidget();
30 tabWidget->addTab(setupLogTab(), tr("&Log file"));
32 layout->addWidget(tabWidget);
34 setLayout(layout);
37 InputCreator::~InputCreator() {
41 QWidget *InputCreator::setupLogTab() {
42 QWidget *tab = new QWidget();
44 QFormLayout *layout = new QFormLayout();
46 QHBoxLayout *selectionLayout = new QHBoxLayout();
48 m_fileLocation = new QLabel(tr("Not selected."));
49 selectionLayout->addWidget(m_fileLocation);
51 QPushButton *selectFile = new QPushButton(style()->standardIcon(QStyle::SP_DirOpenIcon), tr(""));
52 selectionLayout->addWidget(selectFile);
53 connect(selectFile, SIGNAL(clicked()), this, SLOT(fileSelected()));
55 layout->addRow(tr("File location:"), selectionLayout);
57 m_logCreateButton = new QPushButton(tr("&Open log"));
58 m_logCreateButton->setDisabled(true);
59 layout->addWidget(m_logCreateButton);
60 connect(m_logCreateButton, SIGNAL(clicked()), this, SLOT(createLogInput()));
62 tab->setLayout(layout);
64 return tab;
67 void InputCreator::fileSelected() {
68 QString filename = QFileDialog::getOpenFileName(this);
69 if(filename == "") return;
71 m_logCreateButton->setDisabled(false);
72 m_fileLocation->setText(filename);
75 void InputCreator::createLogInput() {
76 hide();
77 LogInput *li = new LogInput(m_fileLocation->text().toStdString(), m_inputManager->artisanManager());
78 emit inputCreated(li);
81 } // namespace Visualizer