mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 19:39:56 -05:00
Some more work restructuring the launcher
This commit is contained in:
@@ -27,14 +27,12 @@ set(APPLICATION_LINK_TO_OPENSPACE ON)
|
||||
|
||||
set(SOURCE_FILES
|
||||
${OPENSPACE_APPS_DIR}/Launcher/main.cpp
|
||||
${OPENSPACE_APPS_DIR}/Launcher/informationwidget.cpp
|
||||
${OPENSPACE_APPS_DIR}/Launcher/mainwindow.cpp
|
||||
${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.cpp
|
||||
${OPENSPACE_APPS_DIR}/Launcher/syncwidget.cpp
|
||||
)
|
||||
|
||||
set(HEADER_FILES
|
||||
${OPENSPACE_APPS_DIR}/Launcher/informationwidget.h
|
||||
${OPENSPACE_APPS_DIR}/Launcher/mainwindow.h
|
||||
${OPENSPACE_APPS_DIR}/Launcher/shortcutwidget.h
|
||||
${OPENSPACE_APPS_DIR}/Launcher/syncwidget.h
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "informationwidget.h"
|
||||
|
||||
InformationWidget::InformationWidget(QWidget* parent)
|
||||
: QTextEdit(parent)
|
||||
{}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2015 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __INFORMATIONWIDGET_H__
|
||||
#define __INFORMATIONWIDGET_H__
|
||||
|
||||
#include <QTextEdit>
|
||||
|
||||
class InformationWidget : public QTextEdit {
|
||||
Q_OBJECT
|
||||
public:
|
||||
InformationWidget(QWidget* parent);
|
||||
};
|
||||
|
||||
#endif // __INFORMATIONWIDGET_H__
|
||||
@@ -24,22 +24,25 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "informationwidget.h"
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QPushButton>
|
||||
#include <QThread>
|
||||
|
||||
namespace {
|
||||
const QSize WindowSize = QSize(640, 480);
|
||||
|
||||
const QString NewsURL = "http://openspace.itn.liu.se/news.txt";
|
||||
}
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: QWidget(nullptr)
|
||||
, _newsReply(nullptr)
|
||||
, _informationWidget(nullptr)
|
||||
, _networkManager(new QNetworkAccessManager)
|
||||
{
|
||||
setFixedSize(WindowSize);
|
||||
|
||||
@@ -50,7 +53,9 @@ MainWindow::MainWindow()
|
||||
image->setPixmap(p.scaledToWidth(WindowSize.width()));
|
||||
layout->addWidget(image, 0, 0, 1, 2);
|
||||
|
||||
_informationWidget = new InformationWidget(this);
|
||||
|
||||
_informationWidget = new QTextEdit(this);
|
||||
_informationWidget->setReadOnly(true);
|
||||
layout->addWidget(_informationWidget, 1, 0, 2, 1);
|
||||
|
||||
QWidget* container = new QWidget;
|
||||
@@ -92,16 +97,47 @@ MainWindow::MainWindow()
|
||||
layout->addWidget(container, 2, 1);
|
||||
|
||||
setLayout(layout);
|
||||
|
||||
initialize();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
delete _informationWidget;
|
||||
delete _networkManager;
|
||||
}
|
||||
|
||||
void MainWindow::initialize() {
|
||||
// Get the news information
|
||||
QNetworkRequest request;
|
||||
request.setUrl(QUrl(NewsURL));
|
||||
|
||||
_newsReply = _networkManager->get(request);
|
||||
connect(_newsReply, SIGNAL(finished()),
|
||||
this, SLOT(newsReadyRead())
|
||||
);
|
||||
connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)),
|
||||
this, SLOT(newsNetworkError())
|
||||
);
|
||||
}
|
||||
|
||||
void MainWindow::shortcutButtonPressed() {
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::newsNetworkError() {
|
||||
QString error = _newsReply->errorString();
|
||||
_informationWidget->setText(error);
|
||||
_newsReply->deleteLater();
|
||||
}
|
||||
|
||||
void MainWindow::newsReadyRead() {
|
||||
QByteArray data = _newsReply->readAll();
|
||||
QString news = QString::fromLatin1(data);
|
||||
_informationWidget->setText(news);
|
||||
_newsReply->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
//MainWindow::MainWindow()
|
||||
// : QWidget(nullptr)
|
||||
// , _configurationWidget(nullptr)
|
||||
|
||||
@@ -26,9 +26,11 @@
|
||||
#define __MAINWINDOW_H__
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTcpSocket>
|
||||
|
||||
class InformationWidget;
|
||||
#include <QNetworkReply>
|
||||
#include <QTextEdit>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
|
||||
class MainWindow : public QWidget {
|
||||
Q_OBJECT
|
||||
@@ -38,9 +40,18 @@ public:
|
||||
|
||||
private slots:
|
||||
void shortcutButtonPressed();
|
||||
|
||||
void newsNetworkError();
|
||||
void newsReadyRead();
|
||||
|
||||
private:
|
||||
InformationWidget* _informationWidget;
|
||||
void initialize();
|
||||
|
||||
QNetworkReply* _newsReply;
|
||||
|
||||
QTextEdit* _informationWidget;
|
||||
|
||||
QNetworkAccessManager* _networkManager;
|
||||
};
|
||||
|
||||
//class MainWindow : public QWidget {
|
||||
|
||||
Reference in New Issue
Block a user