summaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorForkk <forkk@forkk.net>2014-01-02 14:37:56 -0600
committerForkk <forkk@forkk.net>2014-01-02 14:37:56 -0600
commit431cfbc60a255891e521c67509c84b97f08605f6 (patch)
treec455888ae410bc0bd9486bc51ed9f6bba0b0d47b /gui
parent17f1864a71b69b9df14d8e06ed48a65e678d09c9 (diff)
downloadMultiMC-431cfbc60a255891e521c67509c84b97f08605f6.tar
MultiMC-431cfbc60a255891e521c67509c84b97f08605f6.tar.gz
MultiMC-431cfbc60a255891e521c67509c84b97f08605f6.tar.lz
MultiMC-431cfbc60a255891e521c67509c84b97f08605f6.tar.xz
MultiMC-431cfbc60a255891e521c67509c84b97f08605f6.zip
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.
Diffstat (limited to 'gui')
-rw-r--r--gui/MainWindow.cpp10
-rw-r--r--gui/MainWindow.h2
2 files changed, 12 insertions, 0 deletions
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<NewsEntryPtr> 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);