Skip to content

Commit

Permalink
Remove news toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-goode committed Jun 24, 2024
1 parent 1b98be0 commit b8f9d18
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 101 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ endif()
##################################### Set Application options #####################################

######## Set URLs ########
set(Launcher_NEWS_RSS_URL "https://prismlauncher.org/feed/feed.xml" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
set(Launcher_NEWS_RSS_URL "" CACHE STRING "URL to fetch Prism Launcher's news RSS feed from.")
set(Launcher_NEWS_OPEN_URL "https://prismlauncher.org/news" CACHE STRING "URL that gets opened when the user clicks 'More News'")
set(Launcher_HELP_URL "https://prismlauncher.org/wiki/help-pages/%1" CACHE STRING "URL (with arg %1 to be substituted with page-id) that gets opened when the user requests help")

Expand Down
63 changes: 0 additions & 63 deletions launcher/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
#include <minecraft/auth/AccountList.h>
#include <net/ApiDownload.h>
#include <net/NetJob.h>
#include <news/NewsChecker.h>
#include <tools/BaseProfiler.h>
#include <updater/ExternalUpdater.h>
#include "InstanceWindow.h"
Expand All @@ -100,7 +99,6 @@
#include "ui/dialogs/IconPickerDialog.h"
#include "ui/dialogs/ImportResourceDialog.h"
#include "ui/dialogs/NewInstanceDialog.h"
#include "ui/dialogs/NewsDialog.h"
#include "ui/dialogs/ProgressDialog.h"
#include "ui/instanceview/InstanceDelegate.h"
#include "ui/instanceview/InstanceProxyModel.h"
Expand Down Expand Up @@ -184,7 +182,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi

ui->instanceToolBar->setVisibilityState(instanceToolbarSetting->get().toByteArray());

ui->instanceToolBar->addContextMenuAction(ui->newsToolBar->toggleViewAction());
ui->instanceToolBar->addContextMenuAction(ui->instanceToolBar->toggleViewAction());
ui->instanceToolBar->addContextMenuAction(ui->actionLockToolbars);
}
Expand Down Expand Up @@ -238,7 +235,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi

// add the toolbar toggles to the view menu
ui->viewMenu->addAction(ui->instanceToolBar->toggleViewAction());
ui->viewMenu->addAction(ui->newsToolBar->toggleViewAction());

updateThemeMenu();
updateMainToolBar();
Expand Down Expand Up @@ -266,21 +262,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(secretEventFilter, &KonamiCode::triggered, this, &MainWindow::konamiTriggered);
}

// Add the news label to the news toolbar.
{
m_newsChecker.reset(new NewsChecker(APPLICATION->network(), BuildConfig.NEWS_RSS_URL));
newsLabel = new QToolButton();
newsLabel->setIcon(APPLICATION->getThemedIcon("news"));
newsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
newsLabel->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
newsLabel->setFocusPolicy(Qt::NoFocus);
ui->newsToolBar->insertWidget(ui->actionMoreNews, newsLabel);

QObject::connect(newsLabel, &QAbstractButton::clicked, this, &MainWindow::newsButtonClicked);
QObject::connect(m_newsChecker.get(), &NewsChecker::newsLoaded, this, &MainWindow::updateNewsLabel);
updateNewsLabel();
}

// Create the instance list widget
{
view = new InstanceView(ui->centralWidget);
Expand Down Expand Up @@ -371,12 +352,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
// TODO: refresh accounts here?
// auto accounts = APPLICATION->accounts();

// load the news
{
m_newsChecker->reloadNews();
updateNewsLabel();
}

if (APPLICATION->updaterEnabled()) {
bool updatesAllowed = APPLICATION->updatesAreAllowed();
updatesAllowedChanged(updatesAllowed);
Expand Down Expand Up @@ -459,7 +434,6 @@ void MainWindow::lockToolbars(bool state)
{
ui->mainToolBar->setMovable(!state);
ui->instanceToolBar->setMovable(!state);
ui->newsToolBar->setMovable(!state);
APPLICATION->settings()->set("ToolbarsLocked", state);
}

Expand All @@ -473,14 +447,12 @@ void MainWindow::konamiTriggered()
ui->mainToolBar->setStyleSheet("");
ui->instanceToolBar->setStyleSheet("");
ui->centralWidget->setStyleSheet("");
ui->newsToolBar->setStyleSheet("");
ui->statusBar->setStyleSheet("");
qDebug() << "Super Secret Mode DEACTIVATED!";
} else {
ui->mainToolBar->setStyleSheet(stylesheet);
ui->instanceToolBar->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1," + gradient);
ui->centralWidget->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1," + gradient);
ui->newsToolBar->setStyleSheet(stylesheet);
ui->statusBar->setStyleSheet(stylesheet);
qDebug() << "Super Secret Mode ACTIVATED!";
}
Expand Down Expand Up @@ -759,26 +731,6 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* ev)
return QMainWindow::eventFilter(obj, ev);
}

void MainWindow::updateNewsLabel()
{
if (m_newsChecker->isLoadingNews()) {
newsLabel->setText(tr("Loading news..."));
newsLabel->setEnabled(false);
ui->actionMoreNews->setVisible(false);
} else {
QList<NewsEntryPtr> entries = m_newsChecker->getNewsEntries();
if (entries.length() > 0) {
newsLabel->setText(entries[0]->title);
newsLabel->setEnabled(true);
ui->actionMoreNews->setVisible(true);
} else {
newsLabel->setText(tr("No news available."));
newsLabel->setEnabled(false);
ui->actionMoreNews->setVisible(false);
}
}
}

QList<int> stringToIntList(const QString& string)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
Expand Down Expand Up @@ -1315,21 +1267,6 @@ void MainWindow::on_actionOpenWiki_triggered()
DesktopServices::openUrl(QUrl(BuildConfig.HELP_URL.arg("")));
}

void MainWindow::on_actionMoreNews_triggered()
{
auto entries = m_newsChecker->getNewsEntries();
NewsDialog news_dialog(entries, this);
news_dialog.exec();
}

void MainWindow::newsButtonClicked()
{
auto entries = m_newsChecker->getNewsEntries();
NewsDialog news_dialog(entries, this);
news_dialog.toggleArticleList();
news_dialog.exec();
}

void MainWindow::onCatChanged(int)
{
setCatBackground(APPLICATION->settings()->get("TheCat").toBool());
Expand Down
10 changes: 0 additions & 10 deletions launcher/ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "net/NetJob.h"

class LaunchController;
class NewsChecker;
class QToolButton;
class InstanceProxyModel;
class LabeledToolButton;
Expand Down Expand Up @@ -140,10 +139,6 @@ class MainWindow : public QMainWindow {

void on_actionOpenWiki_triggered();

void on_actionMoreNews_triggered();

void newsButtonClicked();

void on_actionLaunchInstance_triggered();

void on_actionKillInstance_triggered();
Expand Down Expand Up @@ -199,8 +194,6 @@ class MainWindow : public QMainWindow {

void repopulateAccountsMenu();

void updateNewsLabel();

void konamiTriggered();

void globalSettingsClosed();
Expand Down Expand Up @@ -233,7 +226,6 @@ class MainWindow : public QMainWindow {
// these are managed by Qt's memory management model!
InstanceView* view = nullptr;
InstanceProxyModel* proxymodel = nullptr;
QToolButton* newsLabel = nullptr;
QLabel* m_statusLeft = nullptr;
QLabel* m_statusCenter = nullptr;
LabeledToolButton* changeIconButton = nullptr;
Expand All @@ -243,8 +235,6 @@ class MainWindow : public QMainWindow {

std::shared_ptr<Setting> instanceToolbarSetting = nullptr;

unique_qobject_ptr<NewsChecker> m_newsChecker;

InstancePtr m_selectedInstance;
QString m_currentInstIcon;

Expand Down
27 changes: 0 additions & 27 deletions launcher/ui/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,6 @@
<addaction name="actionCAT"/>
<addaction name="actionAccountsButton"/>
</widget>
<widget class="QToolBar" name="newsToolBar">
<property name="windowTitle">
<string>News Toolbar</string>
</property>
<property name="allowedAreas">
<set>Qt::BottomToolBarArea|Qt::TopToolBarArea</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>
<widget class="WideBar" name="instanceToolBar">
<property name="windowTitle">
<string>Instance Toolbar</string>
Expand Down

0 comments on commit b8f9d18

Please sign in to comment.