aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/widgets
diff options
context:
space:
mode:
authorSefa Eyeoglu <contact@scrumplex.net>2023-08-02 18:35:35 +0200
committerSefa Eyeoglu <contact@scrumplex.net>2023-08-02 18:35:35 +0200
commit1d468ac35ad88d8c77cc83f25e3704d9bd7df01b (patch)
tree8644b1574c947a1a87c5c7b2567f746cfe17882f /launcher/ui/widgets
parentce2ca1381519a2e261d7f76dffa874d559d979c2 (diff)
downloadPrismLauncher-1d468ac35ad88d8c77cc83f25e3704d9bd7df01b.tar.gz
PrismLauncher-1d468ac35ad88d8c77cc83f25e3704d9bd7df01b.tar.bz2
PrismLauncher-1d468ac35ad88d8c77cc83f25e3704d9bd7df01b.zip
chore: reformat
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
Diffstat (limited to 'launcher/ui/widgets')
-rw-r--r--launcher/ui/widgets/CustomCommands.cpp13
-rw-r--r--launcher/ui/widgets/CustomCommands.h18
-rw-r--r--launcher/ui/widgets/DropLabel.cpp17
-rw-r--r--launcher/ui/widgets/DropLabel.h19
-rw-r--r--launcher/ui/widgets/ErrorFrame.cpp46
-rw-r--r--launcher/ui/widgets/ErrorFrame.h22
-rw-r--r--launcher/ui/widgets/FocusLineEdit.cpp9
-rw-r--r--launcher/ui/widgets/FocusLineEdit.h17
-rw-r--r--launcher/ui/widgets/IconLabel.cpp16
-rw-r--r--launcher/ui/widgets/IconLabel.h13
-rw-r--r--launcher/ui/widgets/JavaSettingsWidget.cpp145
-rw-r--r--launcher/ui/widgets/JavaSettingsWidget.h75
-rw-r--r--launcher/ui/widgets/LabeledToolButton.cpp46
-rw-r--r--launcher/ui/widgets/LabeledToolButton.h16
-rw-r--r--launcher/ui/widgets/LineSeparator.cpp14
-rw-r--r--launcher/ui/widgets/LineSeparator.h14
-rw-r--r--launcher/ui/widgets/LogView.cpp49
-rw-r--r--launcher/ui/widgets/LogView.h33
-rw-r--r--launcher/ui/widgets/ModFilterWidget.cpp110
-rw-r--r--launcher/ui/widgets/ModFilterWidget.h33
-rw-r--r--launcher/ui/widgets/ModListView.cpp46
-rw-r--r--launcher/ui/widgets/ModListView.h11
-rw-r--r--launcher/ui/widgets/PageContainer.cpp101
-rw-r--r--launcher/ui/widgets/PageContainer.h54
-rw-r--r--launcher/ui/widgets/PageContainer_p.h77
-rw-r--r--launcher/ui/widgets/ProjectItem.cpp5
-rw-r--r--launcher/ui/widgets/ProjectItem.h7
-rw-r--r--launcher/ui/widgets/SubTaskProgressBar.cpp6
-rw-r--r--launcher/ui/widgets/SubTaskProgressBar.h10
-rw-r--r--launcher/ui/widgets/ThemeCustomizationWidget.cpp18
-rw-r--r--launcher/ui/widgets/VersionListView.cpp48
-rw-r--r--launcher/ui/widgets/VersionListView.h31
-rw-r--r--launcher/ui/widgets/VersionSelectWidget.cpp52
-rw-r--r--launcher/ui/widgets/VersionSelectWidget.h49
-rw-r--r--launcher/ui/widgets/WideBar.cpp10
35 files changed, 518 insertions, 732 deletions
diff --git a/launcher/ui/widgets/CustomCommands.cpp b/launcher/ui/widgets/CustomCommands.cpp
index 5ab90395..98a1b7e8 100644
--- a/launcher/ui/widgets/CustomCommands.cpp
+++ b/launcher/ui/widgets/CustomCommands.cpp
@@ -41,9 +41,7 @@ CustomCommands::~CustomCommands()
delete ui;
}
-CustomCommands::CustomCommands(QWidget* parent):
- QWidget(parent),
- ui(new Ui::CustomCommands)
+CustomCommands::CustomCommands(QWidget* parent) : QWidget(parent), ui(new Ui::CustomCommands)
{
ui->setupUi(this);
}
@@ -51,8 +49,7 @@ CustomCommands::CustomCommands(QWidget* parent):
void CustomCommands::initialize(bool checkable, bool checked, const QString& prelaunch, const QString& wrapper, const QString& postexit)
{
ui->customCommandsGroupBox->setCheckable(checkable);
- if(checkable)
- {
+ if (checkable) {
ui->customCommandsGroupBox->setChecked(checked);
}
ui->preLaunchCmdTextBox->setText(prelaunch);
@@ -60,14 +57,14 @@ void CustomCommands::initialize(bool checkable, bool checked, const QString& pre
ui->postExitCmdTextBox->setText(postexit);
}
-
-void CustomCommands::retranslate() {
+void CustomCommands::retranslate()
+{
ui->retranslateUi(this);
}
bool CustomCommands::checked() const
{
- if(!ui->customCommandsGroupBox->isCheckable())
+ if (!ui->customCommandsGroupBox->isCheckable())
return true;
return ui->customCommandsGroupBox->isChecked();
}
diff --git a/launcher/ui/widgets/CustomCommands.h b/launcher/ui/widgets/CustomCommands.h
index ed10ba95..96a3fa62 100644
--- a/launcher/ui/widgets/CustomCommands.h
+++ b/launcher/ui/widgets/CustomCommands.h
@@ -37,19 +37,17 @@
#include <QWidget>
-namespace Ui
-{
+namespace Ui {
class CustomCommands;
}
-class CustomCommands : public QWidget
-{
+class CustomCommands : public QWidget {
Q_OBJECT
-public:
- explicit CustomCommands(QWidget *parent = 0);
+ public:
+ explicit CustomCommands(QWidget* parent = 0);
virtual ~CustomCommands();
- void initialize(bool checkable, bool checked, const QString & prelaunch, const QString & wrapper, const QString & postexit);
+ void initialize(bool checkable, bool checked, const QString& prelaunch, const QString& wrapper, const QString& postexit);
void retranslate();
bool checked() const;
@@ -57,8 +55,6 @@ public:
QString wrapperCommand() const;
QString postexitCommand() const;
-private:
- Ui::CustomCommands *ui;
+ private:
+ Ui::CustomCommands* ui;
};
-
-
diff --git a/launcher/ui/widgets/DropLabel.cpp b/launcher/ui/widgets/DropLabel.cpp
index a900e57c..b1473b35 100644
--- a/launcher/ui/widgets/DropLabel.cpp
+++ b/launcher/ui/widgets/DropLabel.cpp
@@ -1,34 +1,33 @@
#include "DropLabel.h"
-#include <QMimeData>
#include <QDropEvent>
+#include <QMimeData>
-DropLabel::DropLabel(QWidget *parent) : QLabel(parent)
+DropLabel::DropLabel(QWidget* parent) : QLabel(parent)
{
setAcceptDrops(true);
}
-void DropLabel::dragEnterEvent(QDragEnterEvent *event)
+void DropLabel::dragEnterEvent(QDragEnterEvent* event)
{
event->acceptProposedAction();
}
-void DropLabel::dragMoveEvent(QDragMoveEvent *event)
+void DropLabel::dragMoveEvent(QDragMoveEvent* event)
{
event->acceptProposedAction();
}
-void DropLabel::dragLeaveEvent(QDragLeaveEvent *event)
+void DropLabel::dragLeaveEvent(QDragLeaveEvent* event)
{
event->accept();
}
-void DropLabel::dropEvent(QDropEvent *event)
+void DropLabel::dropEvent(QDropEvent* event)
{
- const QMimeData *mimeData = event->mimeData();
+ const QMimeData* mimeData = event->mimeData();
- if (!mimeData)
- {
+ if (!mimeData) {
return;
}
diff --git a/launcher/ui/widgets/DropLabel.h b/launcher/ui/widgets/DropLabel.h
index c5ca0bcc..0027f48b 100644
--- a/launcher/ui/widgets/DropLabel.h
+++ b/launcher/ui/widgets/DropLabel.h
@@ -2,19 +2,18 @@
#include <QLabel>
-class DropLabel : public QLabel
-{
+class DropLabel : public QLabel {
Q_OBJECT
-public:
- explicit DropLabel(QWidget *parent = nullptr);
+ public:
+ explicit DropLabel(QWidget* parent = nullptr);
-signals:
+ signals:
void droppedURLs(QList<QUrl> urls);
-protected:
- void dropEvent(QDropEvent *event) override;
- void dragEnterEvent(QDragEnterEvent *event) override;
- void dragMoveEvent(QDragMoveEvent *event) override;
- void dragLeaveEvent(QDragLeaveEvent *event) override;
+ protected:
+ void dropEvent(QDropEvent* event) override;
+ void dragEnterEvent(QDragEnterEvent* event) override;
+ void dragMoveEvent(QDragMoveEvent* event) override;
+ void dragLeaveEvent(QDragLeaveEvent* event) override;
};
diff --git a/launcher/ui/widgets/ErrorFrame.cpp b/launcher/ui/widgets/ErrorFrame.cpp
index b3e41036..213c26b7 100644
--- a/launcher/ui/widgets/ErrorFrame.cpp
+++ b/launcher/ui/widgets/ErrorFrame.cpp
@@ -27,9 +27,7 @@ void ErrorFrame::clear()
setDescription(QString());
}
-ErrorFrame::ErrorFrame(QWidget *parent) :
- QFrame(parent),
- ui(new Ui::ErrorFrame)
+ErrorFrame::ErrorFrame(QWidget* parent) : QFrame(parent), ui(new Ui::ErrorFrame)
{
ui->setupUi(this);
ui->label_Description->setHidden(true);
@@ -44,24 +42,18 @@ ErrorFrame::~ErrorFrame()
void ErrorFrame::updateHiddenState()
{
- if(ui->label_Description->isHidden() && ui->label_Title->isHidden())
- {
+ if (ui->label_Description->isHidden() && ui->label_Title->isHidden()) {
setHidden(true);
- }
- else
- {
+ } else {
setHidden(false);
}
}
void ErrorFrame::setTitle(QString text)
{
- if(text.isEmpty())
- {
+ if (text.isEmpty()) {
ui->label_Title->setHidden(true);
- }
- else
- {
+ } else {
ui->label_Title->setText(text);
ui->label_Title->setHidden(false);
}
@@ -70,14 +62,11 @@ void ErrorFrame::setTitle(QString text)
void ErrorFrame::setDescription(QString text)
{
- if(text.isEmpty())
- {
+ if (text.isEmpty()) {
ui->label_Description->setHidden(true);
updateHiddenState();
return;
- }
- else
- {
+ } else {
ui->label_Description->setHidden(false);
updateHiddenState();
}
@@ -87,9 +76,8 @@ void ErrorFrame::setDescription(QString text)
QChar rem('\n');
QString finaltext;
finaltext.reserve(intermediatetext.size());
- foreach(const QChar& c, intermediatetext)
- {
- if(c == rem && prev){
+ foreach (const QChar& c, intermediatetext) {
+ if (c == rem && prev) {
continue;
}
prev = c == rem;
@@ -97,33 +85,27 @@ void ErrorFrame::setDescription(QString text)
}
QString labeltext;
labeltext.reserve(300);
- if(finaltext.length() > 290)
- {
+ if (finaltext.length() > 290) {
ui->label_Description->setOpenExternalLinks(false);
ui->label_Description->setTextFormat(Qt::TextFormat::RichText);
desc = text;
// This allows injecting HTML here.
labeltext.append("<html><body>" + finaltext.left(287) + "<a href=\"#mod_desc\">...</a></body></html>");
QObject::connect(ui->label_Description, &QLabel::linkActivated, this, &ErrorFrame::ellipsisHandler);
- }
- else
- {
+ } else {
ui->label_Description->setTextFormat(Qt::TextFormat::PlainText);
labeltext.append(finaltext);
}
ui->label_Description->setText(labeltext);
}
-void ErrorFrame::ellipsisHandler(const QString &link)
+void ErrorFrame::ellipsisHandler(const QString& link)
{
- if(!currentBox)
- {
+ if (!currentBox) {
currentBox = CustomMessageBox::selectable(this, QString(), desc);
connect(currentBox, &QMessageBox::finished, this, &ErrorFrame::boxClosed);
currentBox->show();
- }
- else
- {
+ } else {
currentBox->setText(desc);
}
}
diff --git a/launcher/ui/widgets/ErrorFrame.h b/launcher/ui/widgets/ErrorFrame.h
index d5069a14..1aea6a1d 100644
--- a/launcher/ui/widgets/ErrorFrame.h
+++ b/launcher/ui/widgets/ErrorFrame.h
@@ -17,17 +17,15 @@
#include <QFrame>
-namespace Ui
-{
+namespace Ui {
class ErrorFrame;
}
-class ErrorFrame : public QFrame
-{
+class ErrorFrame : public QFrame {
Q_OBJECT
-public:
- explicit ErrorFrame(QWidget *parent = 0);
+ public:
+ explicit ErrorFrame(QWidget* parent = 0);
~ErrorFrame();
void setTitle(QString text);
@@ -35,15 +33,15 @@ public:
void clear();
-public slots:
- void ellipsisHandler(const QString& link );
+ public slots:
+ void ellipsisHandler(const QString& link);
void boxClosed(int result);
-private:
+ private:
void updateHiddenState();
-private:
- Ui::ErrorFrame *ui;
+ private:
+ Ui::ErrorFrame* ui;
QString desc;
- class QMessageBox * currentBox = nullptr;
+ class QMessageBox* currentBox = nullptr;
};
diff --git a/launcher/ui/widgets/FocusLineEdit.cpp b/launcher/ui/widgets/FocusLineEdit.cpp
index b272100c..6570227b 100644
--- a/launcher/ui/widgets/FocusLineEdit.cpp
+++ b/launcher/ui/widgets/FocusLineEdit.cpp
@@ -1,23 +1,22 @@
#include "FocusLineEdit.h"
#include <QDebug>
-FocusLineEdit::FocusLineEdit(QWidget *parent) : QLineEdit(parent)
+FocusLineEdit::FocusLineEdit(QWidget* parent) : QLineEdit(parent)
{
_selectOnMousePress = false;
}
-void FocusLineEdit::focusInEvent(QFocusEvent *e)
+void FocusLineEdit::focusInEvent(QFocusEvent* e)
{
QLineEdit::focusInEvent(e);
selectAll();
_selectOnMousePress = true;
}
-void FocusLineEdit::mousePressEvent(QMouseEvent *me)
+void FocusLineEdit::mousePressEvent(QMouseEvent* me)
{
QLineEdit::mousePressEvent(me);
- if (_selectOnMousePress)
- {
+ if (_selectOnMousePress) {
selectAll();
_selectOnMousePress = false;
}
diff --git a/launcher/ui/widgets/FocusLineEdit.h b/launcher/ui/widgets/FocusLineEdit.h
index 71b4f140..f5ea6602 100644
--- a/launcher/ui/widgets/FocusLineEdit.h
+++ b/launcher/ui/widgets/FocusLineEdit.h
@@ -1,17 +1,14 @@
#include <QLineEdit>
-class FocusLineEdit : public QLineEdit
-{
+class FocusLineEdit : public QLineEdit {
Q_OBJECT
-public:
- FocusLineEdit(QWidget *parent);
- virtual ~FocusLineEdit()
- {
- }
+ public:
+ FocusLineEdit(QWidget* parent);
+ virtual ~FocusLineEdit() {}
-protected:
- void focusInEvent(QFocusEvent *e);
- void mousePressEvent(QMouseEvent *me);
+ protected:
+ void focusInEvent(QFocusEvent* e);
+ void mousePressEvent(QMouseEvent* me);
bool _selectOnMousePress;
};
diff --git a/launcher/ui/widgets/IconLabel.cpp b/launcher/ui/widgets/IconLabel.cpp
index bf1c2358..28776686 100644
--- a/launcher/ui/widgets/IconLabel.cpp
+++ b/launcher/ui/widgets/IconLabel.cpp
@@ -1,13 +1,12 @@
#include "IconLabel.h"
-#include <QStyle>
-#include <QStyleOption>
#include <QLayout>
#include <QPainter>
#include <QRect>
+#include <QStyle>
+#include <QStyleOption>
-IconLabel::IconLabel(QWidget *parent, QIcon icon, QSize size)
- : QWidget(parent), m_size(size), m_icon(icon)
+IconLabel::IconLabel(QWidget* parent, QIcon icon, QSize size) : QWidget(parent), m_size(size), m_icon(icon)
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
}
@@ -23,19 +22,16 @@ void IconLabel::setIcon(QIcon icon)
update();
}
-void IconLabel::paintEvent(QPaintEvent *)
+void IconLabel::paintEvent(QPaintEvent*)
{
QPainter p(this);
QRect rect = contentsRect();
int width = rect.width();
int height = rect.height();
- if(width < height)
- {
+ if (width < height) {
rect.setHeight(width);
rect.translate(0, (height - width) / 2);
- }
- else if (width > height)
- {
+ } else if (width > height) {
rect.setWidth(height);
rect.translate((width - height) / 2, 0);
}
diff --git a/launcher/ui/widgets/IconLabel.h b/launcher/ui/widgets/IconLabel.h
index 6d212c4c..41d97f69 100644
--- a/launcher/ui/widgets/IconLabel.h
+++ b/launcher/ui/widgets/IconLabel.h
@@ -1,26 +1,25 @@
#pragma once
-#include <QWidget>
#include <QIcon>
+#include <QWidget>
class QStyleOption;
/**
* This is a trivial widget that paints a QIcon of the specified size.
*/
-class IconLabel : public QWidget
-{
+class IconLabel : public QWidget {
Q_OBJECT
-public:
+ public:
/// Create a line separator. orientation is the orientation of the line.
- explicit IconLabel(QWidget *parent, QIcon icon, QSize size);
+ explicit IconLabel(QWidget* parent, QIcon icon, QSize size);
virtual QSize sizeHint() const;
- virtual void paintEvent(QPaintEvent *);
+ virtual void paintEvent(QPaintEvent*);
void setIcon(QIcon icon);
-private:
+ private:
QSize m_size;
QIcon m_icon;
};
diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp
index c94fdd8d..8c4048ff 100644
--- a/launcher/ui/widgets/JavaSettingsWidget.cpp
+++ b/launcher/ui/widgets/JavaSettingsWidget.cpp
@@ -1,20 +1,20 @@
#include "JavaSettingsWidget.h"
-#include <QVBoxLayout>
+#include <QFileDialog>
#include <QGroupBox>
-#include <QSpinBox>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
+#include <QSpinBox>
#include <QToolButton>
-#include <QFileDialog>
+#include <QVBoxLayout>
#include <sys.h>
+#include "FileSystem.h"
#include "JavaCommon.h"
#include "java/JavaInstall.h"
#include "java/JavaUtils.h"
-#include "FileSystem.h"
#include "ui/dialogs/CustomMessageBox.h"
#include "ui/widgets/VersionSelectWidget.h"
@@ -149,40 +149,30 @@ void JavaSettingsWidget::refresh()
JavaSettingsWidget::ValidationStatus JavaSettingsWidget::validate()
{
- switch(javaStatus)
- {
+ switch (javaStatus) {
default:
case JavaStatus::NotSet:
case JavaStatus::DoesNotExist:
case JavaStatus::DoesNotStart:
- case JavaStatus::ReturnedInvalidData:
- {
- int button = CustomMessageBox::selectable(
- this,
- tr("No Java version selected"),
- tr("You didn't select a Java version or selected something that doesn't work.\n"
- "%1 will not be able to start Minecraft.\n"
- "Do you wish to proceed without any Java?"
- "\n\n"
- "You can change the Java version in the settings later.\n"
- ).arg(BuildConfig.LAUNCHER_DISPLAYNAME),
- QMessageBox::Warning,
- QMessageBox::Yes | QMessageBox::No,
- QMessageBox::NoButton
- )->exec();
- if(button == QMessageBox::No)
- {
+ case JavaStatus::ReturnedInvalidData: {
+ int button = CustomMessageBox::selectable(this, tr("No Java version selected"),
+ tr("You didn't select a Java version or selected something that doesn't work.\n"
+ "%1 will not be able to start Minecraft.\n"
+ "Do you wish to proceed without any Java?"
+ "\n\n"
+ "You can change the Java version in the settings later.\n")
+ .arg(BuildConfig.LAUNCHER_DISPLAYNAME),
+ QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::NoButton)
+ ->exec();
+ if (button == QMessageBox::No) {
return ValidationStatus::Bad;
}
return ValidationStatus::JavaBad;
- }
- break;
- case JavaStatus::Pending:
- {
+ } break;
+ case JavaStatus::Pending: {
return ValidationStatus::Bad;
}
- case JavaStatus::Good:
- {
+ case JavaStatus::Good: {
return ValidationStatus::AllOK;
}
}
@@ -219,34 +209,26 @@ void JavaSettingsWidget::memoryValueChanged(int)
unsigned int min = m_minMemSpinBox->value();
unsigned int max = m_maxMemSpinBox->value();
unsigned int permgen = m_permGenSpinBox->value();
- QObject *obj = sender();
- if (obj == m_minMemSpinBox && min != observedMinMemory)
- {
+ QObject* obj = sender();
+ if (obj == m_minMemSpinBox && min != observedMinMemory) {
observedMinMemory = min;
actuallyChanged = true;
- if (min > max)
- {
+ if (min > max) {
observedMaxMemory = min;
m_maxMemSpinBox->setValue(min);
}
- }
- else if (obj == m_maxMemSpinBox && max != observedMaxMemory)
- {
+ } else if (obj == m_maxMemSpinBox && max != observedMaxMemory) {
observedMaxMemory = max;
actuallyChanged = true;
- if (min > max)
- {
+ if (min > max) {
observedMinMemory = max;
m_minMemSpinBox->setValue(max);
}
- }
- else if (obj == m_permGenSpinBox && permgen != observedPermGenMemory)
- {
+ } else if (obj == m_permGenSpinBox && permgen != observedPermGenMemory) {
observedPermGenMemory = permgen;
actuallyChanged = true;
}
- if(actuallyChanged)
- {
+ if (actuallyChanged) {
checkJavaPathOnEdit(m_javaPathTextBox->text());
updateThresholds();
}
@@ -255,8 +237,7 @@ void JavaSettingsWidget::memoryValueChanged(int)
void JavaSettingsWidget::javaVersionSelected(BaseVersion::Ptr version)
{
auto java = std::dynamic_pointer_cast<JavaInstall>(version);
- if(!java)
- {
+ if (!java) {
return;
}
auto visible = java->id.requiresPermGen();
@@ -275,8 +256,7 @@ void JavaSettingsWidget::on_javaBrowseBtn_clicked()
filter = "Java (java)";
#endif
QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"), QString(), filter);
- if(raw_path.isEmpty())
- {
+ if (raw_path.isEmpty()) {
return;
}
QString cooked_path = FS::NormalizePath(raw_path);
@@ -288,8 +268,7 @@ void JavaSettingsWidget::on_javaStatusBtn_clicked()
{
QString text;
bool failed = false;
- switch(javaStatus)
- {
+ switch (javaStatus) {
case JavaStatus::NotSet:
checkJavaPath(m_javaPathTextBox->text());
return;
@@ -297,24 +276,20 @@ void JavaSettingsWidget::on_javaStatusBtn_clicked()
text += QObject::tr("The specified file either doesn't exist or is not a proper executable.");
failed = true;
break;
- case JavaStatus::DoesNotStart:
- {
+ case JavaStatus::DoesNotStart: {
text += QObject::tr("The specified Java binary didn't start properly.<br />");
auto htmlError = m_result.errorLog;
- if(!htmlError.isEmpty())
- {
+ if (!htmlError.isEmpty()) {
htmlError.replace('\n', "<br />");
text += QString("<font color=\"red\">%1</font>").arg(htmlError);
}
failed = true;
break;
}
- case JavaStatus::ReturnedInvalidData:
- {
+ case JavaStatus::ReturnedInvalidData: {
text += QObject::tr("The specified Java binary returned unexpected results:<br />");
auto htmlOut = m_result.outLog;
- if(!htmlOut.isEmpty())
- {
+ if (!htmlOut.isEmpty()) {
htmlOut.replace('\n', "<br />");
text += QString("<font color=\"red\">%1</font>").arg(htmlOut);
}
@@ -322,26 +297,24 @@ void JavaSettingsWidget::on_javaStatusBtn_clicked()
break;
}
case JavaStatus::Good:
- text += QObject::tr("Java test succeeded!<br />Platform reported: %1<br />Java version "
- "reported: %2<br />").arg(m_result.realPlatform, m_result.javaVersion.toString());
+ text += QObject::tr(
+ "Java test succeeded!<br />Platform reported: %1<br />Java version "
+ "reported: %2<br />")
+ .arg(m_result.realPlatform, m_result.javaVersion.toString());
break;
case JavaStatus::Pending:
// TODO: abort here?
return;
}
- CustomMessageBox::selectable(
- this,
- failed ? QObject::tr("Java test failure") : QObject::tr("Java test success"),
- text,
- failed ? QMessageBox::Critical : QMessageBox::Information
- )->show();
+ CustomMessageBox::selectable(this, failed ? QObject::tr("Java test failure") : QObject::tr("Java test success"), text,
+ failed ? QMessageBox::Critical : QMessageBox::Information)
+ ->show();
}
void JavaSettingsWidget::setJavaStatus(JavaSettingsWidget::JavaStatus status)
{
javaStatus = status;
- switch(javaStatus)
- {
+ switch (javaStatus) {
case JavaStatus::Good:
m_javaStatusBtn->setIcon(goodIcon);
break;
@@ -364,29 +337,23 @@ void JavaSettingsWidget::checkJavaPathOnEdit(const QString& path)
{
auto realPath = FS::ResolveExecutable(path);
QFileInfo pathInfo(realPath);
- if (pathInfo.baseName().toLower().contains("java"))
- {
+ if (pathInfo.baseName().toLower().contains("java")) {
checkJavaPath(path);
- }
- else
- {
- if(!m_checker)
- {
+ } else {
+ if (!m_checker) {
setJavaStatus(JavaStatus::NotSet);
}
}
}
-void JavaSettingsWidget::checkJavaPath(const QString &path)
+void JavaSettingsWidget::checkJavaPath(const QString& path)
{
- if(m_checker)
- {
+ if (m_checker) {
queuedCheck = path;
return;
}
auto realPath = FS::ResolveExecutable(path);
- if(realPath.isNull())
- {
+ if (realPath.isNull()) {
setJavaStatus(JavaStatus::DoesNotExist);
return;
}
@@ -395,8 +362,7 @@ void JavaSettingsWidget::checkJavaPath(const QString &path)
m_checker->m_path = path;
m_checker->m_minMem = m_minMemSpinBox->value();
m_checker->m_maxMem = m_maxMemSpinBox->value();
- if(m_permGenSpinBox->isVisible())
- {
+ if (m_permGenSpinBox->isVisible()) {
m_checker->m_permGen = m_permGenSpinBox->value();
}
connect(m_checker.get(), &JavaChecker::checkFinished, this, &JavaSettingsWidget::checkFinished);
@@ -406,27 +372,22 @@ void JavaSettingsWidget::checkJavaPath(const QString &path)
void JavaSettingsWidget::checkFinished(JavaCheckResult result)
{
m_result = result;
- switch(result.validity)
- {
- case JavaCheckResult::Validity::Valid:
- {
+ switch (result.validity) {
+ case JavaCheckResult::Validity::Valid: {
setJavaStatus(JavaStatus::Good);
break;
}
- case JavaCheckResult::Validity::ReturnedInvalidData:
- {
+ case JavaCheckResult::Validity::ReturnedInvalidData: {
setJavaStatus(JavaStatus::ReturnedInvalidData);
break;
}
- case JavaCheckResult::Validity::Errored:
- {
+ case JavaCheckResult::Validity::Errored: {
setJavaStatus(JavaStatus::DoesNotStart);
break;
}
}
m_checker.reset();
- if(!queuedCheck.isNull())
- {
+ if (!queuedCheck.isNull()) {
checkJavaPath(queuedCheck);
queuedCheck.clear();
}
diff --git a/launcher/ui/widgets/JavaSettingsWidget.h b/launcher/ui/widgets/JavaSettingsWidget.h
index e4b7c712..6ea73da6 100644
--- a/launcher/ui/widgets/JavaSettingsWidget.h
+++ b/launcher/ui/widgets/JavaSettingsWidget.h
@@ -1,9 +1,9 @@
#pragma once
#include <QWidget>
-#include <java/JavaChecker.h>
#include <BaseVersion.h>
#include <QObjectPtr.h>
+#include <java/JavaChecker.h>
#include <QIcon>
class QLineEdit;
@@ -20,30 +20,16 @@ class QToolButton;
/**
* This is a widget for all the Java settings dialogs and pages.
*/
-class JavaSettingsWidget : public QWidget
-{
+class JavaSettingsWidget : public QWidget {
Q_OBJECT
-public:
- explicit JavaSettingsWidget(QWidget *parent);
- virtual ~JavaSettingsWidget() {};
+ public:
+ explicit JavaSettingsWidget(QWidget* parent);
+ virtual ~JavaSettingsWidget(){};
- enum class JavaStatus
- {
- NotSet,
- Pending,
- Good,
- DoesNotExist,
- DoesNotStart,
- ReturnedInvalidData
- } javaStatus = JavaStatus::NotSet;
+ enum class JavaStatus { NotSet, Pending, Good, DoesNotExist, DoesNotStart, ReturnedInvalidData } javaStatus = JavaStatus::NotSet;
- enum class ValidationStatus
- {
- Bad,
- JavaBad,
- AllOK
- };
+ enum class ValidationStatus { Bad, JavaBad, AllOK };
void refresh();
void initialize();
@@ -58,39 +44,38 @@ public:
void updateThresholds();
-
-protected slots:
+ protected slots:
void memoryValueChanged(int);
- void javaPathEdited(const QString &path);
+ void javaPathEdited(const QString& path);
void javaVersionSelected(BaseVersion::Ptr version);
void on_javaBrowseBtn_clicked();
void on_javaStatusBtn_clicked();
void checkFinished(JavaCheckResult result);
-protected: /* methods */
- void checkJavaPathOnEdit(const QString &path);
- void checkJavaPath(const QString &path);
+ protected: /* methods */
+ void checkJavaPathOnEdit(const QString& path);
+ void checkJavaPath(const QString& path);
void setJavaStatus(JavaStatus status);
void setupUi();
-private: /* data */
- VersionSelectWidget *m_versionWidget = nullptr;
- QVBoxLayout *m_verticalLayout = nullptr;
-
- QLineEdit * m_javaPathTextBox = nullptr;
- QPushButton * m_javaBrowseBtn = nullptr;
- QToolButton * m_javaStatusBtn = nullptr;
- QHBoxLayout *m_horizontalLayout = nullptr;
-
- QGroupBox *m_memoryGroupBox = nullptr;
- QGridLayout *m_gridLayout_2 = nullptr;
- QSpinBox *m_maxMemSpinBox = nullptr;
- QLabel *m_labelMinMem = nullptr;
- QLabel *m_labelMaxMem = nullptr;
- QLabel *m_labelMaxMemIcon = nullptr;
- QSpinBox *m_minMemSpinBox = nullptr;
- QLabel *m_labelPermGen = nullptr;
- QSpinBox *m_permGenSpinBox = nullptr;
+ private: /* data */
+ VersionSelectWidget* m_versionWidget = nullptr;
+ QVBoxLayout* m_verticalLayout = nullptr;
+
+ QLineEdit* m_javaPathTextBox = nullptr;
+ QPushButton* m_javaBrowseBtn = nullptr;
+ QToolButton* m_javaStatusBtn = nullptr;
+ QHBoxLayout* m_horizontalLayout = nullptr;
+
+ QGroupBox* m_memoryGroupBox = nullptr;
+ QGridLayout* m_gridLayout_2 = nullptr;
+ QSpinBox* m_maxMemSpinBox = nullptr;
+ QLabel* m_labelMinMem = nullptr;
+ QLabel* m_labelMaxMem = nullptr;
+ QLabel* m_labelMaxMemIcon = nullptr;
+ QSpinBox* m_minMemSpinBox = nullptr;
+ QLabel* m_labelPermGen = nullptr;
+ QSpinBox* m_permGenSpinBox = nullptr;
QIcon goodIcon;
QIcon yellowIcon;
QIcon badIcon;
diff --git a/launcher/ui/widgets/LabeledToolButton.cpp b/launcher/ui/widgets/LabeledToolButton.cpp
index f52e49c9..7af48b0c 100644
--- a/launcher/ui/widgets/LabeledToolButton.cpp
+++ b/launcher/ui/widgets/LabeledToolButton.cpp
@@ -33,31 +33,29 @@
* limitations under the License.
*/
-#include <QLabel>
-#include <QVBoxLayout>
-#include <QResizeEvent>
-#include <QStyleOption>
#include "LabeledToolButton.h"
#include <QApplication>
#include <QDebug>
+#include <QLabel>
+#include <QResizeEvent>
+#include <QStyleOption>
+#include <QVBoxLayout>
/*
- *
+ *
* Tool Button with a label on it, instead of the normal text rendering
- *
+ *
*/
-LabeledToolButton::LabeledToolButton(QWidget * parent)
- : QToolButton(parent)
- , m_label(new QLabel(this))
+LabeledToolButton::LabeledToolButton(QWidget* parent) : QToolButton(parent), m_label(new QLabel(this))
{
- //QToolButton::setText(" ");
+ // QToolButton::setText(" ");
m_label->setWordWrap(true);
m_label->setMouseTracking(false);
m_label->setAlignment(Qt::AlignCenter);
m_label->setTextInteractionFlags(Qt::NoTextInteraction);
// somehow, this makes word wrap work in the QLabel. yay.
- //m_label->setMinimumWidth(100);
+ // m_label->setMinimumWidth(100);
}
QString LabeledToolButton::text() const
@@ -65,7 +63,7 @@ QString LabeledToolButton::text() const
return m_label->text();
}
-void LabeledToolButton::setText(const QString & text)
+void LabeledToolButton::setText(const QString& text)
{
m_label->setText(text);
}
@@ -76,7 +74,6 @@ void LabeledToolButton::setIcon(QIcon icon)
resetIcon();
}
-
/*!
\reimp
*/
@@ -92,24 +89,21 @@ QSize LabeledToolButton::sizeHint() const
int w = 0, h = 0;
QStyleOptionToolButton opt;
initStyleOption(&opt);
- QSize sz =m_label->sizeHint();
+ QSize sz = m_label->sizeHint();
w = sz.width();
h = sz.height();
- opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
+ opt.rect.setSize(QSize(w, h)); // PM_MenuButtonIndicator depends on the height
if (popupMode() == MenuButtonPopup)
w += style()->pixelMetric(QStyle::PM_MenuButtonIndicator, &opt, this);
-
+
return style()->sizeFromContents(QStyle::CT_ToolButton, &opt, QSize(w, h), this);
}
-
-
-void LabeledToolButton::resizeEvent(QResizeEvent * event)
+void LabeledToolButton::resizeEvent(QResizeEvent* event)
{
- m_label->setGeometry(QRect(4, 4, width()-8, height()-8));
- if(!m_icon.isNull())
- {
+ m_label->setGeometry(QRect(4, 4, width() - 8, height() - 8));
+ if (!m_icon.isNull()) {
resetIcon();
}
QWidget::resizeEvent(event);
@@ -120,14 +114,14 @@ void LabeledToolButton::resetIcon()
auto iconSz = m_icon.actualSize(QSize(160, 80));
float w = iconSz.width();
float h = iconSz.height();
- float ar = w/h;
+ float ar = w / h;
// FIXME: hardcoded max size of 160x80
int newW = 80 * ar;
- if(newW > 160)
+ if (newW > 160)
newW = 160;
- QSize newSz (newW, 80);
+ QSize newSz(newW, 80);
auto pixmap = m_icon.pixmap(newSz);
m_label->setPixmap(pixmap);
m_label->setMinimumHeight(80);
- m_label->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
+ m_label->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
}
diff --git a/launcher/ui/widgets/LabeledToolButton.h b/launcher/ui/widgets/LabeledToolButton.h
index 51f99e9b..0bb5e28d 100644
--- a/launcher/ui/widgets/LabeledToolButton.h
+++ b/launcher/ui/widgets/LabeledToolButton.h
@@ -20,21 +20,21 @@
class QLabel;
-class LabeledToolButton : public QToolButton
-{
+class LabeledToolButton : public QToolButton {
Q_OBJECT
- QLabel * m_label;
+ QLabel* m_label;
QIcon m_icon;
-public:
- LabeledToolButton(QWidget * parent = 0);
+ public:
+ LabeledToolButton(QWidget* parent = 0);
QString text() const;
- void setText(const QString & text);
+ void setText(const QString& text);
void setIcon(QIcon icon);
virtual QSize sizeHint() const;
-protected:
- void resizeEvent(QResizeEvent * event);
+
+ protected:
+ void resizeEvent(QResizeEvent* event);
void resetIcon();
};
diff --git a/launcher/ui/widgets/LineSeparator.cpp b/launcher/ui/widgets/LineSeparator.cpp
index d03e6762..2d6239a2 100644
--- a/launcher/ui/widgets/LineSeparator.cpp
+++ b/launcher/ui/widgets/LineSeparator.cpp
@@ -1,11 +1,11 @@
#include "LineSeparator.h"
-#include <QStyle>
-#include <QStyleOption>
#include <QLayout>
#include <QPainter>
+#include <QStyle>
+#include <QStyleOption>
-void LineSeparator::initStyleOption(QStyleOption *option) const
+void LineSeparator::initStyleOption(QStyleOption* option) const
{
option->initFrom(this);
// in a horizontal layout, the line is vertical (and vice versa)
@@ -13,8 +13,7 @@ void LineSeparator::initStyleOption(QStyleOption *option) const
option->state |= QStyle::State_Horizontal;
}
-LineSeparator::LineSeparator(QWidget *parent, Qt::Orientation orientation)
- : QWidget(parent), m_orientation(orientation)
+LineSeparator::LineSeparator(QWidget* parent, Qt::Orientation orientation) : QWidget(parent), m_orientation(orientation)
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
}
@@ -23,12 +22,11 @@ QSize LineSeparator::sizeHint() const
{
QStyleOption opt;
initStyleOption(&opt);
- const int extent =
- style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, parentWidget());
+ const int extent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, parentWidget());
return QSize(extent, extent);
}
-void LineSeparator::paintEvent(QPaintEvent *)
+void LineSeparator::paintEvent(QPaintEvent*)
{
QPainter p(this);
QStyleOption opt;
diff --git a/launcher/ui/widgets/LineSeparator.h b/launcher/ui/widgets/LineSeparator.h
index 22927b68..719facb9 100644
--- a/launcher/ui/widgets/LineSeparator.h
+++ b/launcher/ui/widgets/LineSeparator.h
@@ -3,16 +3,16 @@
class QStyleOption;
-class LineSeparator : public QWidget
-{
+class LineSeparator : public QWidget {
Q_OBJECT
-public:
+ public:
/// Create a line separator. orientation is the orientation of the line.
- explicit LineSeparator(QWidget *parent, Qt::Orientation orientation = Qt::Horizontal);
+ explicit LineSeparator(QWidget* parent, Qt::Orientation orientation = Qt::Horizontal);
QSize sizeHint() const;
- void paintEvent(QPaintEvent *);
- void initStyleOption(QStyleOption *option) const;
-private:
+ void paintEvent(QPaintEvent*);
+ void initStyleOption(QStyleOption* option) const;
+
+ private:
Qt::Orientation m_orientation = Qt::Horizontal;
};
diff --git a/launcher/ui/widgets/LogView.cpp b/launcher/ui/widgets/LogView.cpp
index 9c46438d..8c960ebb 100644
--- a/launcher/ui/widgets/LogView.cpp
+++ b/launcher/ui/widgets/LogView.cpp
@@ -34,8 +34,8 @@
*/
#include "LogView.h"
-#include <QTextBlock>
#include <QScrollBar>
+#include <QTextBlock>
LogView::LogView(QWidget* parent) : QPlainTextEdit(parent)
{
@@ -50,13 +50,10 @@ LogView::~LogView()
void LogView::setWordWrap(bool wrapping)
{
- if(wrapping)
- {
+ if (wrapping) {
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setLineWrapMode(QPlainTextEdit::WidgetWidth);
- }
- else
- {
+ } else {
setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setLineWrapMode(QPlainTextEdit::NoWrap);
}
@@ -64,16 +61,14 @@ void LogView::setWordWrap(bool wrapping)
void LogView::setModel(QAbstractItemModel* model)
{
- if(m_model)
- {
+ if (m_model) {
disconnect(m_model, &QAbstractItemModel::modelReset, this, &LogView::repopulate);
disconnect(m_model, &QAbstractItemModel::rowsInserted, this, &LogView::rowsInserted);
disconnect(m_model, &QAbstractItemModel::rowsAboutToBeInserted, this, &LogView::rowsAboutToBeInserted);
disconnect(m_model, &QAbstractItemModel::rowsRemoved, this, &LogView::rowsRemoved);
}
m_model = model;
- if(m_model)
- {
+ if (m_model) {
connect(m_model, &QAbstractItemModel::modelReset, this, &LogView::repopulate);
connect(m_model, &QAbstractItemModel::rowsInserted, this, &LogView::rowsInserted);
connect(m_model, &QAbstractItemModel::rowsAboutToBeInserted, this, &LogView::rowsAboutToBeInserted);
@@ -83,15 +78,14 @@ void LogView::setModel(QAbstractItemModel* model)
repopulate();
}
-QAbstractItemModel * LogView::model() const
+QAbstractItemModel* LogView::model() const
{
return m_model;
}
void LogView::modelDestroyed(QObject* model)
{
- if(m_model == model)
- {
+ if (m_model == model) {
setModel(nullptr);
}
}
@@ -100,8 +94,7 @@ void LogView::repopulate()
{
auto doc = document();
doc->clear();
- if(!m_model)
- {
+ if (!m_model) {
return;
}
rowsInserted(QModelIndex(), 0, m_model->rowCount() - 1);
@@ -112,39 +105,32 @@ void LogView::rowsAboutToBeInserted(const QModelIndex& parent, int first, int la
Q_UNUSED(parent)
Q_UNUSED(first)
Q_UNUSED(last)
- QScrollBar *bar = verticalScrollBar();
+ QScrollBar* bar = verticalScrollBar();
int max_bar = bar->maximum();
int val_bar = bar->value();
- if (m_scroll)
- {
+ if (m_scroll) {
m_scroll = (max_bar - val_bar) <= 1;
- }
- else
- {
+ } else {
m_scroll = val_bar == max_bar;
}
}
void LogView::rowsInserted(const QModelIndex& parent, int first, int last)
{
- for(int i = first; i <= last; i++)
- {
+ for (int i = first; i <= last; i++) {
auto idx = m_model->index(i, 0, parent);
auto text = m_model->data(idx, Qt::DisplayRole).toString();
QTextCharFormat format(*m_defaultFormat);
auto font = m_model->data(idx, Qt::FontRole);
- if(font.isValid())
- {
+ if (font.isValid()) {
format.setFont(font.value<QFont>());
}
auto fg = m_model->data(idx, Qt::ForegroundRole);
- if(fg.isValid())
- {
+ if (fg.isValid()) {
format.setForeground(fg.value<QColor>());
}
auto bg = m_model->data(idx, Qt::BackgroundRole);
- if(bg.isValid())
- {
+ if (bg.isValid()) {
format.setBackground(bg.value<QColor>());
}
auto workCursor = textCursor();
@@ -152,10 +138,9 @@ void LogView::rowsInserted(const QModelIndex& parent, int first, int last)
workCursor.insertText(text, format);
workCursor.insertBlock();
}
- if(m_scroll && !m_scrolling)
- {
+ if (m_scroll && !m_scrolling) {
m_scrolling = true;
- QMetaObject::invokeMethod( this, "scrollToBottom", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(this, "scrollToBottom", Qt::QueuedConnection);
}
}
diff --git a/launcher/ui/widgets/LogView.h b/launcher/ui/widgets/LogView.h
index 3143360a..dde5f8f7 100644
--- a/launcher/ui/widgets/LogView.h
+++ b/launcher/ui/widgets/LogView.h
@@ -1,36 +1,35 @@
#pragma once
-#include <QPlainTextEdit>
#include <QAbstractItemView>
+#include <QPlainTextEdit>
class QAbstractItemModel;
-class LogView: public QPlainTextEdit
-{
+class LogView : public QPlainTextEdit {
Q_OBJECT
-public:
- explicit LogView(QWidget *parent = nullptr);
+ public:
+ explicit LogView(QWidget* parent = nullptr);
virtual ~LogView();
- virtual void setModel(QAbstractItemModel *model);
- QAbstractItemModel *model() const;
+ virtual void setModel(QAbstractItemModel* model);
+ QAbstractItemModel* model() const;
-public slots:
+ public slots:
void setWordWrap(bool wrapping);
- void findNext(const QString & what, bool reverse);
+ void findNext(const QString& what, bool reverse);
void scrollToBottom();
-protected slots:
+ protected slots:
void repopulate();
// note: this supports only appending
- void rowsInserted(const QModelIndex &parent, int first, int last);
- void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
+ void rowsInserted(const QModelIndex& parent, int first, int last);
+ void rowsAboutToBeInserted(const QModelIndex& parent, int first, int last);
// note: this supports only removing from front
- void rowsRemoved(const QModelIndex &parent, int first, int last);
- void modelDestroyed(QObject * model);
+ void rowsRemoved(const QModelIndex& parent, int first, int last);
+ void modelDestroyed(QObject* model);
-protected:
- QAbstractItemModel *m_model = nullptr;
- QTextCharFormat *m_defaultFormat = nullptr;
+ protected:
+ QAbstractItemModel* m_model = nullptr;
+ QTextCharFormat* m_defaultFormat = nullptr;
bool m_scroll = false;
bool m_scrolling = false;
};
diff --git a/launcher/ui/widgets/ModFilterWidget.cpp b/launcher/ui/widgets/ModFilterWidget.cpp
index ea052c41..c2c099ee 100644
--- a/launcher/ui/widgets/ModFilterWidget.cpp
+++ b/launcher/ui/widgets/ModFilterWidget.cpp
@@ -18,9 +18,8 @@ unique_qobject_ptr<ModFilterWidget> ModFilterWidget::create(Version default_vers
auto task = filter_widget->versionList()->getLoadTask();
- connect(task.get(), &Task::failed, [filter_widget]{
- filter_widget->disableVersionButton(VersionButtonID::Major, tr("failed to get version index"));
- });
+ connect(task.get(), &Task::failed,
+ [filter_widget] { filter_widget->disableVersionButton(VersionButtonID::Major, tr("failed to get version index")); });
connect(task.get(), &Task::finished, &load_version_list_loop, &QEventLoop::quit);
if (!task->isRunning())
@@ -34,16 +33,15 @@ unique_qobject_ptr<ModFilterWidget> ModFilterWidget::create(Version default_vers
return unique_qobject_ptr<ModFilterWidget>(filter_widget);
}
-ModFilterWidget::ModFilterWidget(Version def, QWidget* parent)
- : QTabWidget(parent), m_filter(new Filter()), ui(new Ui::ModFilterWidget)
+ModFilterWidget::ModFilterWidget(Version def, QWidget* parent) : QTabWidget(parent), m_filter(new Filter()), ui(new Ui::ModFilterWidget)
{
ui->setupUi(this);
- m_mcVersion_buttons.addButton(ui->strictVersionButton, VersionButtonID::Strict);
+ m_mcVersion_buttons.addButton(ui->strictVersionButton, VersionButtonID::Strict);
ui->strictVersionButton->click();
- m_mcVersion_buttons.addButton(ui->majorVersionButton, VersionButtonID::Major);
- m_mcVersion_buttons.addButton(ui->allVersionsButton, VersionButtonID::All);
- //m_mcVersion_buttons.addButton(ui->betweenVersionsButton, VersionButtonID::Between);
+ m_mcVersion_buttons.addButton(ui->majorVersionButton, VersionButtonID::Major);
+ m_mcVersion_buttons.addButton(ui->allVersionsButton, VersionButtonID::All);
+ // m_mcVersion_buttons.addButton(ui->betweenVersionsButton, VersionButtonID::Between);
connect(&m_mcVersion_buttons, SIGNAL(idClicked(int)), this, SLOT(onVersionFilterChanged(int)));
@@ -57,25 +55,19 @@ void ModFilterWidget::setInstance(MinecraftInstance* instance)
{
m_instance = instance;
- ui->strictVersionButton->setText(
- tr("Strict match (= %1)").arg(mcVersionStr()));
+ ui->strictVersionButton->setText(tr("Strict match (= %1)").arg(mcVersionStr()));
// we can't do this for snapshots sadly
- if(mcVersionStr().contains('.'))
- {
+ if (mcVersionStr().contains('.')) {
auto mcVersionSplit = mcVersionStr().split(".");
- ui->majorVersionButton->setText(
- tr("Major version match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
- }
- else
- {
+ ui->majorVersionButton->setText(tr("Major version match (= %1.%2.x)").arg(mcVersionSplit[0], mcVersionSplit[1]));
+ } else {
ui->majorVersionButton->setText(tr("Major version match (unsupported)"));
disableVersionButton(Major);
}
- ui->allVersionsButton->setText(
- tr("Any version"));
- //ui->betweenVersionsButton->setText(
- // tr("Between two versions"));
+ ui->allVersionsButton->setText(tr("Any version"));
+ // ui->betweenVersionsButton->setText(
+ // tr("Between two versions"));
}
auto ModFilterWidget::getFilter() -> std::shared_ptr<Filter>
@@ -89,19 +81,19 @@ void ModFilterWidget::disableVersionButton(VersionButtonID id, QString reason)
{
QAbstractButton* btn = nullptr;
- switch(id){
- case(VersionButtonID::Strict):
- btn = ui->strictVersionButton;
- break;
- case(VersionButtonID::Major):
- btn = ui->majorVersionButton;
- break;
- case(VersionButtonID::All):
- btn = ui->allVersionsButton;
- break;
- case(VersionButtonID::Between):
- default:
- break;
+ switch (id) {
+ case (VersionButtonID::Strict):
+ btn = ui->strictVersionButton;
+ break;
+ case (VersionButtonID::Major):
+ btn = ui->majorVersionButton;
+ break;
+ case (VersionButtonID::All):
+ btn = ui->allVersionsButton;
+ break;
+ case (VersionButtonID::Between):
+ default:
+ break;
}
if (btn) {
@@ -113,12 +105,12 @@ void ModFilterWidget::disableVersionButton(VersionButtonID id, QString reason)
void ModFilterWidget::onVersionFilterChanged(int id)
{
- //ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
- //ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between);
+ // ui->lowerVersionComboBox->setEnabled(id == VersionButtonID::Between);
+ // ui->upperVersionComboBox->setEnabled(id == VersionButtonID::Between);
int index = 1;
- auto cast_id = (VersionButtonID) id;
+ auto cast_id = (VersionButtonID)id;
if (cast_id != m_version_id) {
m_version_id = cast_id;
} else {
@@ -127,32 +119,32 @@ void ModFilterWidget::onVersionFilterChanged(int id)
m_filter->versions.clear();
- switch(cast_id){
- case(VersionButtonID::Strict):
- m_filter->versions.push_front(mcVersion());
- break;
- case(VersionButtonID::Major): {
- auto versionSplit = mcVersionStr().split(".");
+ switch (cast_id) {
+ case (VersionButtonID::Strict):
+ m_filter->versions.push_front(mcVersion());
+ break;
+ case (VersionButtonID::Major): {
+ auto versionSplit = mcVersionStr().split(".");
- auto major_version = QString("%1.%2").arg(versionSplit[0], versionSplit[1]);
- QString version_str = major_version;
+ auto major_version = QString("%1.%2").arg(versionSplit[0], versionSplit[1]);
+ QString version_str = major_version;
- while (m_version_list->hasVersion(version_str)) {
- m_filter->versions.emplace_back(version_str);
- version_str = QString("%1.%2").arg(major_version, QString::number(index++));
- }
+ while (m_version_list->hasVersion(version_str)) {
+ m_filter->versions.emplace_back(version_str);
+ version_str = QString("%1.%2").arg(major_version, QString::number(index++));
+ }
- break;
- }
- case(VersionButtonID::All):
- // Empty list to avoid enumerating all versions :P
- break;
- case(VersionButtonID::Between):
- // TODO
- break;
+ break;
+ }
+ case (VersionButtonID::All):
+ // Empty list to avoid enumerating all versions :P
+ break;
+ case (VersionButtonID::Between):
+ // TODO
+ break;
}
- if(changed())
+ if (changed())
emit filterChanged();
else
emit filterUnchanged();
diff --git a/launcher/ui/widgets/ModFilterWidget.h b/launcher/ui/widgets/ModFilterWidget.h
index 706ffd21..ed6cd0ea 100644
--- a/launcher/ui/widgets/ModFilterWidget.h
+++ b/launcher/ui/widgets/ModFilterWidget.h
@@ -1,7 +1,7 @@
#pragma once
-#include <QTabWidget>
#include <QButtonGroup>
+#include <QTabWidget>
#include "Version.h"
@@ -17,16 +17,10 @@ namespace Ui {
class ModFilterWidget;
}
-class ModFilterWidget : public QTabWidget
-{
+class ModFilterWidget : public QTabWidget {
Q_OBJECT
-public:
- enum VersionButtonID {
- Strict = 0,
- Major = 1,
- All = 2,
- Between = 3
- };
+ public:
+ enum VersionButtonID { Strict = 0, Major = 1, All = 2, Between = 3 };
struct Filter {
std::list<Version> versions;
@@ -37,7 +31,7 @@ public:
std::shared_ptr<Filter> m_filter;
-public:
+ public:
static unique_qobject_ptr<ModFilterWidget> create(Version default_version, QWidget* parent = nullptr);
~ModFilterWidget();
@@ -51,26 +45,29 @@ public:
Meta::VersionList::Ptr versionList() { return m_version_list; }
-private:
+ private:
ModFilterWidget(Version def, QWidget* parent = nullptr);
- inline auto mcVersionStr() const -> QString { return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : ""; }
+ inline auto mcVersionStr() const -> QString
+ {
+ return m_instance ? m_instance->getPackProfile()->getComponentVersion("net.minecraft") : "";
+ }
inline auto mcVersion() const -> Version { return { mcVersionStr() }; }
-private slots:
+ private slots:
void onVersionFilterChanged(int id);
-public: signals:
+ public:
+ signals:
void filterChanged();
void filterUnchanged();
-private:
+ private:
Ui::ModFilterWidget* ui;
MinecraftInstance* m_instance = nullptr;
-
-/* Version stuff */
+ /* Version stuff */
QButtonGroup m_mcVersion_buttons;
Meta::VersionList::Ptr m_version_list;
diff --git a/launcher/ui/widgets/ModListView.cpp b/launcher/ui/widgets/ModListView.cpp
index 80a918b6..c72d4c52 100644
--- a/launcher/ui/widgets/ModListView.cpp
+++ b/launcher/ui/widgets/ModListView.cpp
@@ -14,61 +14,55 @@
*/
#include "ModListView.h"
+#include <QDrag>
#include <QHeaderView>
#include <QMouseEvent>
#include <QPainter>
-#include <QDrag>
#include <QRect>
-ModListView::ModListView ( QWidget* parent )
- :QTreeView ( parent )
+ModListView::ModListView(QWidget* parent) : QTreeView(parent)
{
- setAllColumnsShowFocus ( true );
- setExpandsOnDoubleClick ( false );
- setRootIsDecorated ( false );
- setSortingEnabled ( true );
- setAlternatingRowColors ( true );
- setSelectionMode ( QAbstractItemView::ExtendedSelection );
- setHeaderHidden ( false );
+ setAllColumnsShowFocus(true);
+ setExpandsOnDoubleClick(false);
+ setRootIsDecorated(false);
+ setSortingEnabled(true);
+ setAlternatingRowColors(true);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setHeaderHidden(false);
setSelectionBehavior(QAbstractItemView::SelectRows);
- setHorizontalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setDropIndicatorShown(true);
setDragEnabled(true);
setDragDropMode(QAbstractItemView::DropOnly);
viewport()->setAcceptDrops(true);
}
-void ModListView::setModel ( QAbstractItemModel* model )
+void ModListView::setModel(QAbstractItemModel* model)
{
- QTreeView::setModel ( model );
+ QTreeView::setModel(model);
auto head = header();
head->setStretchLastSection(false);
// HACK: this is true for the checkbox column of mod lists
- auto string = model->headerData(0,head->orientation()).toString();
- if(head->count() < 1)
- {
+ auto string = model->headerData(0, head->orientation()).toString();
+ if (head->count() < 1) {
return;
}
- if(!string.size())
- {
+ if (!string.size()) {
head->setSectionResizeMode(0, QHeaderView::ResizeToContents);
head->setSectionResizeMode(1, QHeaderView::Stretch);
- for(int i = 2; i < head->count(); i++)
+ for (int i = 2; i < head->count(); i++)
head->setSectionResizeMode(i, QHeaderView::ResizeToContents);
- }
- else
- {
+ } else {
head->setSectionResizeMode(0, QHeaderView::Stretch);
- for(int i = 1; i < head->count(); i++)
+ for (int i = 1; i < head->count(); i++)
head->setSectionResizeMode(i, QHeaderView::ResizeToContents);
}
}
-void ModListView::setResizeModes(const QList<QHeaderView::ResizeMode> &modes)
+void ModListView::setResizeModes(const QList<QHeaderView::ResizeMode>& modes)
{
auto head = header();
- for(int i = 0; i < modes.count(); i++) {
+ for (int i = 0; i < modes.count(); i++) {
head->setSectionResizeMode(i, modes[i]);
}
}
-
diff --git a/launcher/ui/widgets/ModListView.h b/launcher/ui/widgets/ModListView.h
index 3f0b3b0e..86316459 100644
--- a/launcher/ui/widgets/ModListView.h
+++ b/launcher/ui/widgets/ModListView.h
@@ -17,11 +17,10 @@
#include <QHeaderView>
#include <QTreeView>
-class ModListView: public QTreeView
-{
+class ModListView : public QTreeView {
Q_OBJECT
-public:
- explicit ModListView ( QWidget* parent = 0 );
- virtual void setModel ( QAbstractItemModel* model );
- virtual void setResizeModes (const QList<QHeaderView::ResizeMode>& modes);
+ public:
+ explicit ModListView(QWidget* parent = 0);
+ virtual void setModel(QAbstractItemModel* model);
+ virtual void setResizeModes(const QList<QHeaderView::ResizeMode>& modes);
};
diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp
index b98c9796..c3b70c44 100644
--- a/launcher/ui/widgets/PageContainer.cpp
+++ b/launcher/ui/widgets/PageContainer.cpp
@@ -38,36 +38,33 @@
#include "BuildConfig.h"
#include "PageContainer_p.h"
-#include <QStackedLayout>
+#include <QDialogButtonBox>
+#include <QGridLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QListView>
#include <QPushButton>
#include <QSortFilterProxyModel>
-#include <QUrl>
+#include <QStackedLayout>
#include <QStyledItemDelegate>
-#include <QListView>
-#include <QLineEdit>
-#include <QLabel>
-#include <QDialogButtonBox>
-#include <QGridLayout>
+#include <QUrl>
#include "settings/SettingsObject.h"
#include "ui/widgets/IconLabel.h"
-#include "DesktopServices.h"
#include "Application.h"
+#include "DesktopServices.h"
-class PageEntryFilterModel : public QSortFilterProxyModel
-{
-public:
- explicit PageEntryFilterModel(QObject *parent = 0) : QSortFilterProxyModel(parent)
- {
- }
+class PageEntryFilterModel : public QSortFilterProxyModel {
+ public:
+ explicit PageEntryFilterModel(QObject* parent = 0) : QSortFilterProxyModel(parent) {}
-protected:
- bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
+ protected:
+ bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
{
const QString pattern = filterRegularExpression().pattern();
- const auto model = static_cast<PageModel *>(sourceModel());
+ const auto model = static_cast<PageModel*>(sourceModel());
const auto page = model->pages().at(sourceRow);
if (!page->shouldDisplay())
return false;
@@ -76,18 +73,15 @@ protected:
}
};
-PageContainer::PageContainer(BasePageProvider *pageProvider, QString defaultId,
- QWidget *parent)
- : QWidget(parent)
+PageContainer::PageContainer(BasePageProvider* pageProvider, QString defaultId, QWidget* parent) : QWidget(parent)
{
createUI();
m_model = new PageModel(this);
m_proxyModel = new PageEntryFilterModel(this);
int counter = 0;
auto pages = pageProvider->getPages();
- for (auto page : pages)
- {
- auto widget = dynamic_cast<QWidget *>(page);
+ for (auto page : pages) {
+ auto widget = dynamic_cast<QWidget*>(page);
widget->setParent(this);
page->stackIndex = m_pageStack->addWidget(widget);
page->listIndex = counter;
@@ -108,8 +102,7 @@ PageContainer::PageContainer(BasePageProvider *pageProvider, QString defaultId,
m_pageList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
m_pageList->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
m_pageList->setModel(m_proxyModel);
- connect(m_pageList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)),
- this, SLOT(currentChanged(QModelIndex)));
+ connect(m_pageList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex, QModelIndex)), this, SLOT(currentChanged(QModelIndex)));
m_pageStack->setStackingMode(QStackedLayout::StackOne);
m_pageList->setFocus();
selectPage(defaultId);
@@ -120,16 +113,13 @@ bool PageContainer::selectPage(QString pageId)
// now find what we want to have selected...
auto page = m_model->findPageEntryById(pageId);
QModelIndex index;
- if (page)
- {
+ if (page) {
index = m_proxyModel->mapFromSource(m_model->index(page->listIndex));
}
- if(!index.isValid())
- {
+ if (!index.isValid()) {
index = m_proxyModel->index(0, 0);
}
- if (index.isValid())
- {
+ if (index.isValid()) {
m_pageList->setCurrentIndex(index);
return true;
}
@@ -149,15 +139,11 @@ const QList<BasePage*> PageContainer::getPages() const
void PageContainer::refreshContainer()
{
m_proxyModel->invalidate();
- if(!m_currentPage->shouldDisplay())
- {
+ if (!m_currentPage->shouldDisplay()) {
auto index = m_proxyModel->index(0, 0);
- if(index.isValid())
- {
+ if (index.isValid()) {
m_pageList->setCurrentIndex(index);
- }
- else
- {
+ } else {
// FIXME: unhandled corner case: what to do when there's no page to select?
}
}
@@ -177,7 +163,7 @@ void PageContainer::createUI()
headerLabelFont.setPointSize(pointSize + 2);
m_header->setFont(headerLabelFont);
- QHBoxLayout *headerHLayout = new QHBoxLayout;
+ QHBoxLayout* headerHLayout = new QHBoxLayout;
const int leftMargin = APPLICATION->style()->pixelMetric(QStyle::PM_LayoutLeftMargin);
headerHLayout->addSpacerItem(new QSpacerItem(leftMargin, 0, QSizePolicy::Fixed, QSizePolicy::Ignored));
headerHLayout->addWidget(m_header);
@@ -195,7 +181,7 @@ void PageContainer::createUI()
m_layout->addWidget(m_pageList, 0, 0, 2, 1);
m_layout->addLayout(m_pageStack, 1, 1, 1, 1);
m_layout->setColumnStretch(1, 4);
- m_layout->setContentsMargins(0,0,0,6);
+ m_layout->setContentsMargins(0, 0, 0, 6);
setLayout(m_layout);
}
@@ -208,39 +194,32 @@ void PageContainer::retranslate()
page->retranslate();
}
-void PageContainer::addButtons(QWidget *buttons)
+void PageContainer::addButtons(QWidget* buttons)
{
m_layout->addWidget(buttons, 2, 0, 1, 2);
}
-void PageContainer::addButtons(QLayout *buttons)
+void PageContainer::addButtons(QLayout* buttons)
{
m_layout->addLayout(buttons, 2, 0, 1, 2);
}
void PageContainer::showPage(int row)
{
- if (m_currentPage)
- {
+ if (m_currentPage) {
m_currentPage->closed();
}
- if (row != -1)
- {
+ if (row != -1) {
m_currentPage = m_model->pages().at(row);
- }
- else
- {
+ } else {
m_currentPage = nullptr;
}
- if (m_currentPage)
- {
+ if (m_currentPage) {
m_pageStack->setCurrentIndex(m_currentPage->stackIndex);
m_header->setText(m_currentPage->displayName());
m_iconHeader->setIcon(m_currentPage->icon());
m_currentPage->opened();
- }
- else
- {
+ } else {
m_pageStack->setCurrentIndex(0);
m_header->setText(QString());
m_iconHeader->setIcon(APPLICATION->getThemedIcon("bug"));
@@ -249,8 +228,7 @@ void PageContainer::showPage(int row)
void PageContainer::help()
{
- if (m_currentPage)
- {
+ if (m_currentPage) {
QString pageId = m_currentPage->helpPage();
if (pageId.isEmpty())
return;
@@ -258,7 +236,7 @@ void PageContainer::help()
}
}
-void PageContainer::currentChanged(const QModelIndex &current)
+void PageContainer::currentChanged(const QModelIndex& current)
{
int selected_index = current.isValid() ? m_proxyModel->mapToSource(current).row() : -1;
@@ -272,12 +250,10 @@ void PageContainer::currentChanged(const QModelIndex &current)
bool PageContainer::prepareToClose()
{
- if(!saveAll())
- {
+ if (!saveAll()) {
return false;
}
- if (m_currentPage)
- {
+ if (m_currentPage) {
m_currentPage->closed();
}
return true;
@@ -285,8 +261,7 @@ bool PageContainer::prepareToClose()
bool PageContainer::saveAll()
{
- for (auto page : m_model->pages())
- {
+ for (auto page : m_model->pages()) {
if (!page->apply())
return false;
}
diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h
index ad74d43a..f5978dba 100644
--- a/launcher/ui/widgets/PageContainer.h
+++ b/launcher/ui/widgets/PageContainer.h
@@ -35,11 +35,11 @@
#pragma once
-#include <QWidget>
#include <QModelIndex>
+#include <QWidget>
-#include "ui/pages/BasePageProvider.h"
#include "ui/pages/BasePageContainer.h"
+#include "ui/pages/BasePageProvider.h"
class QLayout;
class IconLabel;
@@ -51,16 +51,14 @@ class QLineEdit;
class QStackedLayout;
class QGridLayout;
-class PageContainer : public QWidget, public BasePageContainer
-{
+class PageContainer : public QWidget, public BasePageContainer {
Q_OBJECT
-public:
- explicit PageContainer(BasePageProvider *pageProvider, QString defaultId = QString(),
- QWidget *parent = 0);
+ public:
+ explicit PageContainer(BasePageProvider* pageProvider, QString defaultId = QString(), QWidget* parent = 0);
virtual ~PageContainer() {}
- void addButtons(QWidget * buttons);
- void addButtons(QLayout * buttons);
+ void addButtons(QWidget* buttons);
+ void addButtons(QLayout* buttons);
/*
* Save any unsaved state and prepare to be closed.
* @return true if everything can be saved, false if there is something that requires attention
@@ -71,8 +69,7 @@ public:
/* request close - used by individual pages */
bool requestClose() override
{
- if(m_container)
- {
+ if (m_container) {
return m_container->requestClose();
}
return false;
@@ -83,36 +80,33 @@ public:
const QList<BasePage*> getPages() const;
void refreshContainer() override;
- virtual void setParentContainer(BasePageContainer * container)
- {
- m_container = container;
- };
+ virtual void setParentContainer(BasePageContainer* container) { m_container = container; };
void changeEvent(QEvent*) override;
-private:
+ private:
void createUI();
void retranslate();
-public slots:
+ public slots:
void help();
-signals:
+ signals:
/** Emitted when the currently selected page is changed */
void selectedPageChanged(BasePage* previous, BasePage* selected);
-private slots:
- void currentChanged(const QModelIndex &current);
+ private slots:
+ void currentChanged(const QModelIndex& current);
void showPage(int row);
-private:
- BasePageContainer * m_container = nullptr;
- BasePage * m_currentPage = 0;
- QSortFilterProxyModel *m_proxyModel;
- PageModel *m_model;
- QStackedLayout *m_pageStack;
- QListView *m_pageList;
- QLabel *m_header;
- IconLabel *m_iconHeader;
- QGridLayout *m_layout;
+ private:
+ BasePageContainer* m_container = nullptr;
+ BasePage* m_currentPage = 0;
+ QSortFilterProxyModel* m_proxyModel;
+ PageModel* m_model;
+ QStackedLayout* m_pageStack;
+ QListView* m_pageList;
+ QLabel* m_header;
+ IconLabel* m_iconHeader;
+ QGridLayout* m_layout;
};
diff --git a/launcher/ui/widgets/PageContainer_p.h b/launcher/ui/widgets/PageContainer_p.h
index da1a66f4..9a7651c7 100644
--- a/launcher/ui/widgets/PageContainer_p.h
+++ b/launcher/ui/widgets/PageContainer_p.h
@@ -15,21 +15,18 @@
#pragma once
-#include <QListView>
-#include <QStyledItemDelegate>
#include <QEvent>
+#include <QListView>
#include <QScrollBar>
+#include <QStyledItemDelegate>
class BasePage;
const int pageIconSize = 24;
-class PageViewDelegate : public QStyledItemDelegate
-{
-public:
- PageViewDelegate(QObject *parent) : QStyledItemDelegate(parent)
- {
- }
- QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
+class PageViewDelegate : public QStyledItemDelegate {
+ public:
+ PageViewDelegate(QObject* parent) : QStyledItemDelegate(parent) {}
+ QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
{
QSize size = QStyledItemDelegate::sizeHint(option, index);
size.setHeight(qMax(size.height(), 32));
@@ -37,10 +34,9 @@ public:
}
};
-class PageModel : public QAbstractListModel
-{
-public:
- PageModel(QObject *parent = 0) : QAbstractListModel(parent)
+class PageModel : public QAbstractListModel {
+ public:
+ PageModel(QObject* parent = 0) : QAbstractListModel(parent)
{
QPixmap empty(pageIconSize, pageIconSize);
empty.fill(Qt::transparent);
@@ -48,57 +44,47 @@ public:
}
virtual ~PageModel() {}
- int rowCount(const QModelIndex &parent = QModelIndex()) const
+ int rowCount(const QModelIndex& parent = QModelIndex()) const { return parent.isValid() ? 0 : m_pages.size(); }
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
{
- return parent.isValid() ? 0 : m_pages.size();
- }
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const
- {
- switch (role)
- {
- case Qt::DisplayRole:
- return m_pages.at(index.row())->displayName();
- case Qt::DecorationRole:
- {
- QIcon icon = m_pages.at(index.row())->icon();
- if (icon.isNull())
- icon = m_emptyIcon;
- // HACK: fixes icon stretching on windows. TODO: report Qt bug for this
- return QIcon(icon.pixmap(QSize(48,48)));
- }
+ switch (role) {
+ case Qt::DisplayRole:
+ return m_pages.at(index.row())->displayName();
+ case Qt::DecorationRole: {
+ QIcon icon = m_pages.at(index.row())->icon();
+ if (icon.isNull())
+ icon = m_emptyIcon;
+ // HACK: fixes icon stretching on windows. TODO: report Qt bug for this
+ return QIcon(icon.pixmap(QSize(48, 48)));
+ }
}
return QVariant();
}
- void setPages(const QList<BasePage *> &pages)
+ void setPages(const QList<BasePage*>& pages)
{
beginResetModel();
m_pages = pages;
endResetModel();
}
- const QList<BasePage *> &pages() const
- {
- return m_pages;
- }
+ const QList<BasePage*>& pages() const { return m_pages; }
- BasePage * findPageEntryById(QString id)
+ BasePage* findPageEntryById(QString id)
{
- for(auto page: m_pages)
- {
+ for (auto page : m_pages) {
if (page->id() == id)
return page;
}
return nullptr;
}
- QList<BasePage *> m_pages;
+ QList<BasePage*> m_pages;
QIcon m_emptyIcon;
};
-class PageView : public QListView
-{
-public:
- PageView(QWidget *parent = 0) : QListView(parent)
+class PageView : public QListView {
+ public:
+ PageView(QWidget* parent = 0) : QListView(parent)
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
setItemDelegate(new PageViewDelegate(this));
@@ -113,10 +99,9 @@ public:
return QSize(width, 100);
}
- virtual bool eventFilter(QObject *obj, QEvent *event)
+ virtual bool eventFilter(QObject* obj, QEvent* event)
{
- if (obj == verticalScrollBar() &&
- (event->type() == QEvent::Show || event->type() == QEvent::Hide))
+ if (obj == verticalScrollBar() && (event->type() == QEvent::Show || event->type() == QEvent::Hide))
updateGeometry();
return QListView::eventFilter(obj, event);
}
diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp
index 0085d6b2..1481c1b6 100644
--- a/launcher/ui/widgets/ProjectItem.cpp
+++ b/launcher/ui/widgets/ProjectItem.cpp
@@ -116,7 +116,6 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
}
int description_x = rect.x();
-
// Have the y-value be set based on the number of lines in the description, to centralize the
// description text with the space between the base and the title.
@@ -127,8 +126,8 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
description_y -= opt.fontMetrics.height();
// On the bottom, aligned to the left after the icon, and featuring at most two lines of text (with some margin space to spare)
- painter->drawText(description_x, description_y, remaining_width,
- cut_text.size() * opt.fontMetrics.height(), Qt::TextWordWrap, description);
+ painter->drawText(description_x, description_y, remaining_width, cut_text.size() * opt.fontMetrics.height(), Qt::TextWordWrap,
+ description);
}
painter->restore();
diff --git a/launcher/ui/widgets/ProjectItem.h b/launcher/ui/widgets/ProjectItem.h
index 196055ea..c3d0dce7 100644
--- a/launcher/ui/widgets/ProjectItem.h
+++ b/launcher/ui/widgets/ProjectItem.h
@@ -18,9 +18,8 @@ enum UserDataTypes {
class ProjectItemDelegate final : public QStyledItemDelegate {
Q_OBJECT
- public:
- ProjectItemDelegate(QWidget* parent);
-
- void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override;
+ public:
+ ProjectItemDelegate(QWidget* parent);
+ void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) const override;
};
diff --git a/launcher/ui/widgets/SubTaskProgressBar.cpp b/launcher/ui/widgets/SubTaskProgressBar.cpp
index 84ea5f20..39102197 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.cpp
+++ b/launcher/ui/widgets/SubTaskProgressBar.cpp
@@ -26,12 +26,11 @@ unique_qobject_ptr<SubTaskProgressBar> SubTaskProgressBar::create(QWidget* paren
return unique_qobject_ptr<SubTaskProgressBar>(progress_bar);
}
-SubTaskProgressBar::SubTaskProgressBar(QWidget* parent)
- : ui(new Ui::SubTaskProgressBar)
+SubTaskProgressBar::SubTaskProgressBar(QWidget* parent) : ui(new Ui::SubTaskProgressBar)
{
ui->setupUi(this);
}
-SubTaskProgressBar::~SubTaskProgressBar()
+SubTaskProgressBar::~SubTaskProgressBar()
{
delete ui;
}
@@ -55,4 +54,3 @@ void SubTaskProgressBar::setDetails(QString details)
{
ui->statusDetailsLabel->setText(details);
}
-
diff --git a/launcher/ui/widgets/SubTaskProgressBar.h b/launcher/ui/widgets/SubTaskProgressBar.h
index 8f8aeea2..cd08809f 100644
--- a/launcher/ui/widgets/SubTaskProgressBar.h
+++ b/launcher/ui/widgets/SubTaskProgressBar.h
@@ -25,11 +25,10 @@ namespace Ui {
class SubTaskProgressBar;
}
-class SubTaskProgressBar : public QWidget
-{
+class SubTaskProgressBar : public QWidget {
Q_OBJECT
-public:
+ public:
static unique_qobject_ptr<SubTaskProgressBar> create(QWidget* parent = nullptr);
SubTaskProgressBar(QWidget* parent = nullptr);
@@ -40,9 +39,6 @@ public:
void setStatus(QString status);
void setDetails(QString details);
-
-
-private:
+ private:
Ui::SubTaskProgressBar* ui;
-
};
diff --git a/launcher/ui/widgets/ThemeCustomizationWidget.cpp b/launcher/ui/widgets/ThemeCustomizationWidget.cpp
index 291f8ed9..d26906bd 100644
--- a/launcher/ui/widgets/ThemeCustomizationWidget.cpp
+++ b/launcher/ui/widgets/ThemeCustomizationWidget.cpp
@@ -22,13 +22,14 @@
#include "ui/themes/ITheme.h"
#include "ui/themes/ThemeManager.h"
-ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
+ThemeCustomizationWidget::ThemeCustomizationWidget(QWidget* parent) : QWidget(parent), ui(new Ui::ThemeCustomizationWidget)
{
ui->setupUi(this);
loadSettings();
connect(ui->iconsComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyIconTheme);
- connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyWidgetTheme);
+ connect(ui->widgetStyleComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
+ &ThemeCustomizationWidget::applyWidgetTheme);
connect(ui->backgroundCatComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &ThemeCustomizationWidget::applyCatTheme);
}
@@ -40,7 +41,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
/// <summary>
/// The layout was not quite right, so currently this just disables the UI elements, which should be hidden instead
/// TODO FIXME
-///
+///
/// Original Method One:
/// ui->iconsComboBox->setVisible(features& ThemeFields::ICONS);
/// ui->iconsLabel->setVisible(features& ThemeFields::ICONS);
@@ -48,7 +49,7 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
/// ui->widgetThemeLabel->setVisible(features& ThemeFields::WIDGETS);
/// ui->backgroundCatComboBox->setVisible(features& ThemeFields::CAT);
/// ui->backgroundCatLabel->setVisible(features& ThemeFields::CAT);
-///
+///
/// original Method Two:
/// if (!(features & ThemeFields::ICONS)) {
/// ui->formLayout->setRowVisible(0, false);
@@ -61,7 +62,8 @@ ThemeCustomizationWidget::~ThemeCustomizationWidget()
/// }
/// </summary>
/// <param name="features"></param>
-void ThemeCustomizationWidget::showFeatures(ThemeFields features) {
+void ThemeCustomizationWidget::showFeatures(ThemeFields features)
+{
ui->iconsComboBox->setEnabled(features & ThemeFields::ICONS);
ui->iconsLabel->setEnabled(features & ThemeFields::ICONS);
ui->widgetStyleComboBox->setEnabled(features & ThemeFields::WIDGETS);
@@ -70,7 +72,8 @@ void ThemeCustomizationWidget::showFeatures(ThemeFields features) {
ui->backgroundCatLabel->setEnabled(features & ThemeFields::CAT);
}
-void ThemeCustomizationWidget::applyIconTheme(int index) {
+void ThemeCustomizationWidget::applyIconTheme(int index)
+{
auto settings = APPLICATION->settings();
auto originalIconTheme = settings->get("IconTheme").toString();
auto& newIconTheme = m_iconThemeOptions[index].first;
@@ -83,7 +86,8 @@ void ThemeCustomizationWidget::applyIconTheme(int index) {
emit currentIconThemeChanged(index);
}
-void ThemeCustomizationWidget::applyWidgetTheme(int index) {
+void ThemeCustomizationWidget::applyWidgetTheme(int index)
+{
auto settings = APPLICATION->settings();
auto originalAppTheme = settings->get("ApplicationTheme").toString();
auto newAppTheme = ui->widgetStyleComboBox->currentData().toString();
diff --git a/launcher/ui/widgets/VersionListView.cpp b/launcher/ui/widgets/VersionListView.cpp
index 06e58d22..7701d127 100644
--- a/launcher/ui/widgets/VersionListView.cpp
+++ b/launcher/ui/widgets/VersionListView.cpp
@@ -34,35 +34,33 @@
* limitations under the License.
*/
-#include <QHeaderView>
+#include "VersionListView.h"
#include <QApplication>
-#include <QMouseEvent>
#include <QDrag>
+#include <QHeaderView>
+#include <QMouseEvent>
#include <QPainter>
-#include "VersionListView.h"
-VersionListView::VersionListView(QWidget *parent)
- :QTreeView ( parent )
+VersionListView::VersionListView(QWidget* parent) : QTreeView(parent)
{
m_emptyString = tr("No versions are currently available.");
}
-void VersionListView::rowsInserted(const QModelIndex &parent, int start, int end)
+void VersionListView::rowsInserted(const QModelIndex& parent, int start, int end)
{
- m_itemCount += end-start+1;
+ m_itemCount += end - start + 1;
updateEmptyViewPort();
QTreeView::rowsInserted(parent, start, end);
}
-
-void VersionListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+void VersionListView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end)
{
- m_itemCount -= end-start+1;
+ m_itemCount -= end - start + 1;
updateEmptyViewPort();
QTreeView::rowsInserted(parent, start, end);
}
-void VersionListView::setModel(QAbstractItemModel *model)
+void VersionListView::setModel(QAbstractItemModel* model)
{
m_itemCount = model->rowCount();
updateEmptyViewPort();
@@ -71,11 +69,9 @@ void VersionListView::setModel(QAbstractItemModel *model)
void VersionListView::reset()
{
- if(model())
- {
+ if (model()) {
m_itemCount = model()->rowCount();
- }
- else {
+ } else {
m_itemCount = 0;
}
updateEmptyViewPort();
@@ -106,28 +102,23 @@ void VersionListView::updateEmptyViewPort()
setAccessibleDescription(currentEmptyString());
#endif /* !QT_NO_ACCESSIBILITY */
- if(!m_itemCount)
- {
+ if (!m_itemCount) {
viewport()->update();
}
}
-void VersionListView::paintEvent(QPaintEvent *event)
+void VersionListView::paintEvent(QPaintEvent* event)
{
- if(m_itemCount)
- {
+ if (m_itemCount) {
QTreeView::paintEvent(event);
- }
- else
- {
+ } else {
paintInfoLabel(event);
}
}
QString VersionListView::currentEmptyString() const
{
- switch(m_emptyMode)
- {
+ switch (m_emptyMode) {
default:
case VersionListView::String:
return m_emptyString;
@@ -136,12 +127,11 @@ QString VersionListView::currentEmptyString() const
}
}
-
-void VersionListView::paintInfoLabel(QPaintEvent *event) const
+void VersionListView::paintInfoLabel(QPaintEvent* event) const
{
QString emptyString = currentEmptyString();
- //calculate the rect for the overlay
+ // calculate the rect for the overlay
QPainter painter(viewport());
painter.setRenderHint(QPainter::Antialiasing, true);
QFont font("sans", 20);
@@ -163,7 +153,7 @@ void VersionListView::paintInfoLabel(QPaintEvent *event) const
auto wrapRect = textRect;
wrapRect.adjust(-10, -10, 10, 10);
- //check if we are allowed to draw in our area
+ // check if we are allowed to draw in our area
if (!event->rect().intersects(wrapRect)) {
return;
}
diff --git a/launcher/ui/widgets/VersionListView.h b/launcher/ui/widgets/VersionListView.h
index 4153b314..07792db5 100644
--- a/launcher/ui/widgets/VersionListView.h
+++ b/launcher/ui/widgets/VersionListView.h
@@ -16,39 +16,32 @@
#pragma once
#include <QTreeView>
-class VersionListView : public QTreeView
-{
+class VersionListView : public QTreeView {
Q_OBJECT
-public:
-
- explicit VersionListView(QWidget *parent = 0);
- virtual void paintEvent(QPaintEvent *event) override;
+ public:
+ explicit VersionListView(QWidget* parent = 0);
+ virtual void paintEvent(QPaintEvent* event) override;
virtual void setModel(QAbstractItemModel* model) override;
- enum EmptyMode
- {
- Empty,
- String,
- ErrorString
- };
+ enum EmptyMode { Empty, String, ErrorString };
void setEmptyString(QString emptyString);
void setEmptyErrorString(QString emptyErrorString);
void setEmptyMode(EmptyMode mode);
-public slots:
+ public slots:
virtual void reset() override;
-protected slots:
- virtual void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end) override;
- virtual void rowsInserted(const QModelIndex &parent, int start, int end) override;
+ protected slots:
+ virtual void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override;
+ virtual void rowsInserted(const QModelIndex& parent, int start, int end) override;
-private: /* methods */
- void paintInfoLabel(QPaintEvent *event) const;
+ private: /* methods */
+ void paintInfoLabel(QPaintEvent* event) const;
void updateEmptyViewPort();
QString currentEmptyString() const;
-private: /* variables */
+ private: /* variables */
int m_itemCount = 0;
QString m_emptyString;
QString m_emptyErrorString;
diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp
index a956ddb3..9647dc79 100644
--- a/launcher/ui/widgets/VersionSelectWidget.cpp
+++ b/launcher/ui/widgets/VersionSelectWidget.cpp
@@ -13,8 +13,7 @@
VersionSelectWidget::VersionSelectWidget(QWidget* parent) : VersionSelectWidget(false, parent) {}
-VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent)
- : QWidget(parent), focusSearch(focusSearch)
+VersionSelectWidget::VersionSelectWidget(bool focusSearch, QWidget* parent) : QWidget(parent), focusSearch(focusSearch)
{
setObjectName(QStringLiteral("VersionSelectWidget"));
verticalLayout = new QVBoxLayout(this);
@@ -81,9 +80,7 @@ void VersionSelectWidget::setEmptyMode(VersionListView::EmptyMode mode)
listView->setEmptyMode(mode);
}
-VersionSelectWidget::~VersionSelectWidget()
-{
-}
+VersionSelectWidget::~VersionSelectWidget() {}
void VersionSelectWidget::setResizeOn(int column)
{
@@ -92,7 +89,8 @@ void VersionSelectWidget::setResizeOn(int column)
listView->header()->setSectionResizeMode(resizeOnColumn, QHeaderView::Stretch);
}
-bool VersionSelectWidget::eventFilter(QObject *watched, QEvent *event) {
+bool VersionSelectWidget::eventFilter(QObject* watched, QEvent* event)
+{
if (watched == search && event->type() == QEvent::KeyPress) {
const QKeyEvent* keyEvent = (QKeyEvent*)event;
const bool up = keyEvent->key() == Qt::Key_Up;
@@ -109,7 +107,7 @@ bool VersionSelectWidget::eventFilter(QObject *watched, QEvent *event) {
return QObject::eventFilter(watched, event);
}
-void VersionSelectWidget::initialize(BaseVersionList *vlist)
+void VersionSelectWidget::initialize(BaseVersionList* vlist)
{
m_vlist = vlist;
m_proxyModel->setSourceModel(vlist);
@@ -119,21 +117,17 @@ void VersionSelectWidget::initialize(BaseVersionList *vlist)
if (focusSearch)
search->setFocus();
- if (!m_vlist->isLoaded())
- {
+ if (!m_vlist->isLoaded()) {
loadList();
- }
- else
- {
- if (m_proxyModel->rowCount() == 0)
- {
+ } else {
+ if (m_proxyModel->rowCount() == 0) {
listView->setEmptyMode(VersionListView::String);
}
preselect();
}
}
-void VersionSelectWidget::closeEvent(QCloseEvent * event)
+void VersionSelectWidget::closeEvent(QCloseEvent* event)
{
QWidget::closeEvent(event);
}
@@ -141,16 +135,14 @@ void VersionSelectWidget::closeEvent(QCloseEvent * event)
void VersionSelectWidget::loadList()
{
auto newTask = m_vlist->getLoadTask();
- if (!newTask)
- {
+ if (!newTask) {
return;
}
loadTask = newTask.get();
connect(loadTask, &Task::succeeded, this, &VersionSelectWidget::onTaskSucceeded);
connect(loadTask, &Task::failed, this, &VersionSelectWidget::onTaskFailed);
connect(loadTask, &Task::progress, this, &VersionSelectWidget::changeProgress);
- if(!loadTask->isRunning())
- {
+ if (!loadTask->isRunning()) {
loadTask->start();
}
sneakyProgressBar->setHidden(false);
@@ -158,8 +150,7 @@ void VersionSelectWidget::loadList()
void VersionSelectWidget::onTaskSucceeded()
{
- if (m_proxyModel->rowCount() == 0)
- {
+ if (m_proxyModel->rowCount() == 0) {
listView->setEmptyMode(VersionListView::String);
}
sneakyProgressBar->setHidden(true);
@@ -187,25 +178,23 @@ void VersionSelectWidget::currentRowChanged(const QModelIndex& current, const QM
void VersionSelectWidget::preselect()
{
- if(preselectedAlready)
+ if (preselectedAlready)
return;
selectCurrent();
- if(preselectedAlready)
+ if (preselectedAlready)
return;
selectRecommended();
}
void VersionSelectWidget::selectCurrent()
{
- if(m_currentVersion.isEmpty())
- {
+ if (m_currentVersion.isEmpty()) {
return;
}
auto idx = m_proxyModel->getVersion(m_currentVersion);
- if(idx.isValid())
- {
+ if (idx.isValid()) {
preselectedAlready = true;
- listView->selectionModel()->setCurrentIndex(idx,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ listView->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
listView->scrollTo(idx, QAbstractItemView::PositionAtCenter);
}
}
@@ -213,10 +202,9 @@ void VersionSelectWidget::selectCurrent()
void VersionSelectWidget::selectRecommended()
{
auto idx = m_proxyModel->getRecommended();
- if(idx.isValid())
- {
+ if (idx.isValid()) {
preselectedAlready = true;
- listView->selectionModel()->setCurrentIndex(idx,QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
+ listView->selectionModel()->setCurrentIndex(idx, QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
listView->scrollTo(idx, QAbstractItemView::PositionAtCenter);
}
}
@@ -243,7 +231,7 @@ void VersionSelectWidget::setFuzzyFilter(BaseVersionList::ModelRoles role, QStri
m_proxyModel->setFilter(role, new ContainsFilter(filter));
}
-void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter *filter)
+void VersionSelectWidget::setFilter(BaseVersionList::ModelRoles role, Filter* filter)
{
m_proxyModel->setFilter(role, filter);
}
diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h
index be4ba768..b7f40101 100644
--- a/launcher/ui/widgets/VersionSelectWidget.h
+++ b/launcher/ui/widgets/VersionSelectWidget.h
@@ -35,9 +35,9 @@
#pragma once
-#include <QWidget>
-#include <QSortFilterProxyModel>
#include <QLineEdit>
+#include <QSortFilterProxyModel>
+#include <QWidget>
#include "BaseVersionList.h"
#include "VersionListView.h"
@@ -47,16 +47,15 @@ class QVBoxLayout;
class QProgressBar;
class Filter;
-class VersionSelectWidget: public QWidget
-{
+class VersionSelectWidget : public QWidget {
Q_OBJECT
-public:
- explicit VersionSelectWidget(QWidget *parent);
- explicit VersionSelectWidget(bool focusSearch = false, QWidget *parent = 0);
+ public:
+ explicit VersionSelectWidget(QWidget* parent);
+ explicit VersionSelectWidget(bool focusSearch = false, QWidget* parent = 0);
~VersionSelectWidget();
//! loads the list if needed.
- void initialize(BaseVersionList *vlist);
+ void initialize(BaseVersionList* vlist);
//! Starts a task that loads the list.
void loadList();
@@ -66,42 +65,42 @@ public:
void selectRecommended();
void selectCurrent();
- void setCurrentVersion(const QString & version);
+ void setCurrentVersion(const QString& version);
void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter);
void setExactFilter(BaseVersionList::ModelRoles role, QString filter);
- void setFilter(BaseVersionList::ModelRoles role, Filter *filter);
+ void setFilter(BaseVersionList::ModelRoles role, Filter* filter);
void setEmptyString(QString emptyString);
void setEmptyErrorString(QString emptyErrorString);
void setEmptyMode(VersionListView::EmptyMode mode);
void setResizeOn(int column);
bool eventFilter(QObject* watched, QEvent* event) override;
-signals:
+ signals:
void selectedVersionChanged(BaseVersion::Ptr version);
-protected:
- virtual void closeEvent ( QCloseEvent* );
+ protected:
+ virtual void closeEvent(QCloseEvent*);
-private slots:
+ private slots:
void onTaskSucceeded();
- void onTaskFailed(const QString &reason);
+ void onTaskFailed(const QString& reason);
void changeProgress(qint64 current, qint64 total);
- void currentRowChanged(const QModelIndex &current, const QModelIndex &);
+ void currentRowChanged(const QModelIndex& current, const QModelIndex&);
-private:
+ private:
void preselect();
-private:
+ private:
QString m_currentVersion;
- BaseVersionList *m_vlist = nullptr;
- VersionProxyModel *m_proxyModel = nullptr;
+ BaseVersionList* m_vlist = nullptr;
+ VersionProxyModel* m_proxyModel = nullptr;
int resizeOnColumn = 0;
- Task * loadTask;
+ Task* loadTask;
bool preselectedAlready = false;
bool focusSearch;
- QVBoxLayout *verticalLayout = nullptr;
- VersionListView *listView = nullptr;
- QLineEdit *search;
- QProgressBar *sneakyProgressBar = nullptr;
+ QVBoxLayout* verticalLayout = nullptr;
+ VersionListView* listView = nullptr;
+ QLineEdit* search;
+ QProgressBar* sneakyProgressBar = nullptr;
};
diff --git a/launcher/ui/widgets/WideBar.cpp b/launcher/ui/widgets/WideBar.cpp
index a77c45fe..b793d84f 100644
--- a/launcher/ui/widgets/WideBar.cpp
+++ b/launcher/ui/widgets/WideBar.cpp
@@ -7,8 +7,8 @@
class ActionButton : public QToolButton {
Q_OBJECT
public:
- ActionButton(QAction* action, QWidget* parent = nullptr, bool use_default_action = false) : QToolButton(parent),
- m_action(action), m_use_default_action(use_default_action)
+ ActionButton(QAction* action, QWidget* parent = nullptr, bool use_default_action = false)
+ : QToolButton(parent), m_action(action), m_use_default_action(use_default_action)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
@@ -227,7 +227,7 @@ void WideBar::showVisibilityMenu(QPoint const& position)
act->setCheckable(true);
act->setChecked(entry.bar_action->isVisible());
- connect(act, &QAction::toggled, entry.bar_action, [this, &entry](bool toggled){
+ connect(act, &QAction::toggled, entry.bar_action, [this, &entry](bool toggled) {
entry.bar_action->setVisible(toggled);
// NOTE: This is needed so that disabled actions get reflected on the button when it is made visible.
@@ -243,7 +243,8 @@ void WideBar::showVisibilityMenu(QPoint const& position)
m_bar_menu->popup(mapToGlobal(position));
}
-void WideBar::addContextMenuAction(QAction* action) {
+void WideBar::addContextMenuAction(QAction* action)
+{
m_context_menu_actions.append(action);
}
@@ -306,5 +307,4 @@ bool WideBar::checkHash(QByteArray const& old_hash) const
return old_hash == getHash();
}
-
#include "WideBar.moc"