summaryrefslogtreecommitdiffstats
path: root/gui/MainWindow.cpp
diff options
context:
space:
mode:
authorForkk <forkk@forkk.net>2014-01-02 13:25:38 -0600
committerForkk <forkk@forkk.net>2014-01-02 13:25:38 -0600
commit4495e20cd7f7f2ab062f3b60f19ac4b79f32c350 (patch)
treef5bbc9d40ea49fcfd52e3d310c7c1e0ce4c8c6a2 /gui/MainWindow.cpp
parent9d8006b597aead06f1d51dacbdb346ebab3d5e8f (diff)
downloadMultiMC-4495e20cd7f7f2ab062f3b60f19ac4b79f32c350.tar
MultiMC-4495e20cd7f7f2ab062f3b60f19ac4b79f32c350.tar.gz
MultiMC-4495e20cd7f7f2ab062f3b60f19ac4b79f32c350.tar.lz
MultiMC-4495e20cd7f7f2ab062f3b60f19ac4b79f32c350.tar.xz
MultiMC-4495e20cd7f7f2ab062f3b60f19ac4b79f32c350.zip
Add news checking system and news toolbar
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r--gui/MainWindow.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp
index 3f086b36..85ad319b 100644
--- a/gui/MainWindow.cpp
+++ b/gui/MainWindow.cpp
@@ -116,6 +116,17 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
renameButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
+ // Add the news label to the news toolbar.
+ {
+ newsLabel = new QToolButton();
+ newsLabel->setIcon(QIcon(":/icons/toolbar/news"));
+ newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
+ newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel);
+ QObject::connect(MMC->newsChecker().get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel);
+ updateNewsLabel();
+ }
+
// Create the instance list widget
{
view = new KCategorizedView(ui->centralWidget);
@@ -249,6 +260,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
}
MMC->newsChecker()->reloadNews();
+ updateNewsLabel();
// set up the updater object.
auto updater = MMC->updateChecker();
@@ -433,6 +445,30 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
return QMainWindow::eventFilter(obj, ev);
}
+void MainWindow::updateNewsLabel()
+{
+ auto newsChecker = MMC->newsChecker();
+ if (newsChecker->isLoadingNews())
+ {
+ newsLabel->setText(tr("Loading news..."));
+ newsLabel->setEnabled(false);
+ }
+ else
+ {
+ QList<NewsEntryPtr> entries = newsChecker->getNewsEntries();
+ if (entries.length() > 0)
+ {
+ newsLabel->setText(entries[0]->title);
+ newsLabel->setEnabled(true);
+ }
+ else
+ {
+ newsLabel->setText(tr("No news available."));
+ newsLabel->setEnabled(false);
+ }
+ }
+}
+
void MainWindow::updateAvailable(QString repo, QString versionName, int versionId)
{
UpdateDialog dlg;
@@ -708,7 +744,7 @@ void MainWindow::on_actionReportBug_triggered()
openWebPage(QUrl("http://multimc.myjetbrains.com/youtrack/dashboard#newissue=yes"));
}
-void MainWindow::on_actionNews_triggered()
+void MainWindow::on_actionMoreNews_triggered()
{
openWebPage(QUrl("http://multimc.org/posts.html"));
}