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);
|
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
|
// Create the instance list widget
|
||||||
{
|
{
|
||||||
view = new KCategorizedView(ui->centralWidget);
|
view = new KCategorizedView(ui->centralWidget);
|
||||||
@ -249,6 +260,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
}
|
}
|
||||||
|
|
||||||
MMC->newsChecker()->reloadNews();
|
MMC->newsChecker()->reloadNews();
|
||||||
|
updateNewsLabel();
|
||||||
|
|
||||||
// set up the updater object.
|
// set up the updater object.
|
||||||
auto updater = MMC->updateChecker();
|
auto updater = MMC->updateChecker();
|
||||||
@ -433,6 +445,30 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
return QMainWindow::eventFilter(obj, 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)
|
void MainWindow::updateAvailable(QString repo, QString versionName, int versionId)
|
||||||
{
|
{
|
||||||
UpdateDialog dlg;
|
UpdateDialog dlg;
|
||||||
@ -708,7 +744,7 @@ void MainWindow::on_actionReportBug_triggered()
|
|||||||
openWebPage(QUrl("http://multimc.myjetbrains.com/youtrack/dashboard#newissue=yes"));
|
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"));
|
openWebPage(QUrl("http://multimc.org/posts.html"));
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ slots:
|
|||||||
|
|
||||||
void on_actionReportBug_triggered();
|
void on_actionReportBug_triggered();
|
||||||
|
|
||||||
void on_actionNews_triggered();
|
void on_actionMoreNews_triggered();
|
||||||
|
|
||||||
void on_mainToolBar_visibilityChanged(bool);
|
void on_mainToolBar_visibilityChanged(bool);
|
||||||
|
|
||||||
@ -163,6 +163,8 @@ slots:
|
|||||||
|
|
||||||
void repopulateAccountsMenu();
|
void repopulateAccountsMenu();
|
||||||
|
|
||||||
|
void updateNewsLabel();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Runs the DownloadUpdateTask and installs updates.
|
* Runs the DownloadUpdateTask and installs updates.
|
||||||
*/
|
*/
|
||||||
@ -181,6 +183,7 @@ private:
|
|||||||
ConsoleWindow *console;
|
ConsoleWindow *console;
|
||||||
LabeledToolButton *renameButton;
|
LabeledToolButton *renameButton;
|
||||||
QToolButton *changeIconButton;
|
QToolButton *changeIconButton;
|
||||||
|
QToolButton* newsLabel;
|
||||||
|
|
||||||
BaseInstance *m_selectedInstance;
|
BaseInstance *m_selectedInstance;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>688</width>
|
<width>688</width>
|
||||||
<height>650</height>
|
<height>460</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -72,7 +72,6 @@
|
|||||||
<addaction name="actionSettings"/>
|
<addaction name="actionSettings"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionReportBug"/>
|
<addaction name="actionReportBug"/>
|
||||||
<addaction name="actionNews"/>
|
|
||||||
<addaction name="actionAbout"/>
|
<addaction name="actionAbout"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionCAT"/>
|
<addaction name="actionCAT"/>
|
||||||
@ -121,6 +120,36 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDeleteInstance"/>
|
<addaction name="actionDeleteInstance"/>
|
||||||
</widget>
|
</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">
|
<action name="actionAddInstance">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../graphics.qrc">
|
<iconset resource="../graphics.qrc">
|
||||||
@ -229,19 +258,22 @@
|
|||||||
<string>Open the bug tracker to report a bug with MultiMC.</string>
|
<string>Open the bug tracker to report a bug with MultiMC.</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionNews">
|
<action name="actionMoreNews">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="../graphics.qrc">
|
<iconset resource="../graphics.qrc">
|
||||||
<normaloff>:/icons/toolbar/news</normaloff>:/icons/toolbar/news</iconset>
|
<normaloff>:/icons/toolbar/news</normaloff>:/icons/toolbar/news</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>News</string>
|
<string>More News</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>More...</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<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>
|
||||||
<property name="statusTip">
|
<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>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionAbout">
|
<action name="actionAbout">
|
||||||
|
@ -102,6 +102,11 @@ void NewsChecker::rssDownloadFailed()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<NewsEntryPtr> NewsChecker::getNewsEntries() const
|
||||||
|
{
|
||||||
|
return m_newsEntries;
|
||||||
|
}
|
||||||
|
|
||||||
bool NewsChecker::isLoadingNews() const
|
bool NewsChecker::isLoadingNews() const
|
||||||
{
|
{
|
||||||
return m_newsNetJob.get() != nullptr;
|
return m_newsNetJob.get() != nullptr;
|
||||||
|
@ -43,6 +43,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isNewsLoaded() const;
|
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.
|
* Returns a list of news entries.
|
||||||
*/
|
*/
|
||||||
@ -79,9 +82,6 @@ protected:
|
|||||||
//! The network job to use to load the news.
|
//! The network job to use to load the news.
|
||||||
NetJobPtr m_newsNetJob;
|
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.
|
//! True if news has been loaded.
|
||||||
bool m_loadedNews;
|
bool m_loadedNews;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user