Add news checking system and news toolbar
This commit is contained in:
parent
9d8006b597
commit
4495e20cd7
@ -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"));
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ slots:
|
||||
|
||||
void on_actionReportBug_triggered();
|
||||
|
||||
void on_actionNews_triggered();
|
||||
void on_actionMoreNews_triggered();
|
||||
|
||||
void on_mainToolBar_visibilityChanged(bool);
|
||||
|
||||
@ -163,6 +163,8 @@ slots:
|
||||
|
||||
void repopulateAccountsMenu();
|
||||
|
||||
void updateNewsLabel();
|
||||
|
||||
/*!
|
||||
* Runs the DownloadUpdateTask and installs updates.
|
||||
*/
|
||||
@ -181,6 +183,7 @@ private:
|
||||
ConsoleWindow *console;
|
||||
LabeledToolButton *renameButton;
|
||||
QToolButton *changeIconButton;
|
||||
QToolButton* newsLabel;
|
||||
|
||||
BaseInstance *m_selectedInstance;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>688</width>
|
||||
<height>650</height>
|
||||
<height>460</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -72,7 +72,6 @@
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionReportBug"/>
|
||||
<addaction name="actionNews"/>
|
||||
<addaction name="actionAbout"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCAT"/>
|
||||
@ -121,6 +120,36 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionDeleteInstance"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="newsToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>News Toolbar</string>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::BottomToolBarArea</set>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextBesideIcon</enum>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>BottomToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionMoreNews"/>
|
||||
</widget>
|
||||
<action name="actionAddInstance">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphics.qrc">
|
||||
@ -229,19 +258,22 @@
|
||||
<string>Open the bug tracker to report a bug with MultiMC.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNews">
|
||||
<action name="actionMoreNews">
|
||||
<property name="icon">
|
||||
<iconset resource="../graphics.qrc">
|
||||
<normaloff>:/icons/toolbar/news</normaloff>:/icons/toolbar/news</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>News</string>
|
||||
<string>More News</string>
|
||||
</property>
|
||||
<property name="iconText">
|
||||
<string>More...</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Open the MultiMC dev blog to read news about MultiMC.</string>
|
||||
<string>Open the MultiMC development blog to read more news about MultiMC.</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Open the MultiMC dev blog to read news about MultiMC.</string>
|
||||
<string>Open the MultiMC development blog to read more news about MultiMC.</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAbout">
|
||||
|
@ -102,6 +102,11 @@ void NewsChecker::rssDownloadFailed()
|
||||
}
|
||||
|
||||
|
||||
QList<NewsEntryPtr> NewsChecker::getNewsEntries() const
|
||||
{
|
||||
return m_newsEntries;
|
||||
}
|
||||
|
||||
bool NewsChecker::isLoadingNews() const
|
||||
{
|
||||
return m_newsNetJob.get() != nullptr;
|
||||
|
@ -43,6 +43,9 @@ public:
|
||||
*/
|
||||
bool isNewsLoaded() const;
|
||||
|
||||
//! True if the news is currently loading. If true, reloadNews() will do nothing.
|
||||
bool isLoadingNews() const;
|
||||
|
||||
/*!
|
||||
* Returns a list of news entries.
|
||||
*/
|
||||
@ -79,9 +82,6 @@ protected:
|
||||
//! The network job to use to load the news.
|
||||
NetJobPtr m_newsNetJob;
|
||||
|
||||
//! True if the news is currently loading. If true, reloadNews() will do nothing.
|
||||
bool isLoadingNews() const;
|
||||
|
||||
//! True if news has been loaded.
|
||||
bool m_loadedNews;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user