From 431cfbc60a255891e521c67509c84b97f08605f6 Mon Sep 17 00:00:00 2001 From: Forkk Date: Thu, 2 Jan 2014 14:37:56 -0600 Subject: Implement the news button Make the news button open the latest news post in the user's web browser. Also remove the webkit dependency. I was planning on using it to display the news in a custom window, but we'll just use the user's browser for now. --- CMakeLists.txt | 4 ++-- gui/MainWindow.cpp | 10 ++++++++++ gui/MainWindow.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ccd513d..c026de4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -527,8 +527,8 @@ ADD_EXECUTABLE(MultiMC MACOSX_BUNDLE WIN32 main.cpp ${MULTIMC_RCS}) # Link TARGET_LINK_LIBRARIES(MultiMC MultiMC_common) TARGET_LINK_LIBRARIES(MultiMC_common xz-embedded unpack200 quazip libUtil libSettings libGroupView ${MultiMC_LINK_ADDITIONAL_LIBS}) -QT5_USE_MODULES(MultiMC Core Widgets Network Xml WebKit Concurrent ${MultiMC_QT_ADDITIONAL_MODULES}) -QT5_USE_MODULES(MultiMC_common Core Widgets Network Xml WebKit Concurrent ${MultiMC_QT_ADDITIONAL_MODULES}) +QT5_USE_MODULES(MultiMC Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES}) +QT5_USE_MODULES(MultiMC_common Core Widgets Network Xml Concurrent ${MultiMC_QT_ADDITIONAL_MODULES}) ADD_DEPENDENCIES(MultiMC_common MultiMCLauncher JavaCheck) ################################ INSTALLATION AND PACKAGING ################################ diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 42823fa5..131bb6e6 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -125,6 +125,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel); + QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked); QObject::connect(MMC->newsChecker().get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel); updateNewsLabel(); } @@ -774,6 +775,15 @@ void MainWindow::on_actionMoreNews_triggered() openWebPage(QUrl("http://multimc.org/posts.html")); } +void MainWindow::newsButtonClicked() +{ + QList entries = MMC->newsChecker()->getNewsEntries(); + if (entries.count() > 0) + openWebPage(QUrl(entries[0]->link)); + else + openWebPage(QUrl("http://multimc.org/posts.html")); +} + void MainWindow::on_actionAbout_triggered() { AboutDialog dialog(this); diff --git a/gui/MainWindow.h b/gui/MainWindow.h index f5b25006..d2435ef2 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -87,6 +87,8 @@ slots: void on_actionMoreNews_triggered(); + void newsButtonClicked(); + void on_mainToolBar_visibilityChanged(bool); // void on_instanceView_customContextMenuRequested(const QPoint &pos); -- cgit v1.2.3