diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index a7ccb809d..f8a287da7 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -1118,8 +1118,6 @@ SET(LAUNCHER_SOURCES ui/widgets/CustomCommands.h ui/widgets/EnvironmentVariables.cpp ui/widgets/EnvironmentVariables.h - ui/widgets/FocusLineEdit.cpp - ui/widgets/FocusLineEdit.h ui/widgets/IconLabel.cpp ui/widgets/IconLabel.h ui/widgets/JavaWizardWidget.cpp @@ -1128,8 +1126,6 @@ SET(LAUNCHER_SOURCES ui/widgets/LabeledToolButton.h ui/widgets/LanguageSelectionWidget.cpp ui/widgets/LanguageSelectionWidget.h - ui/widgets/LineSeparator.cpp - ui/widgets/LineSeparator.h ui/widgets/LogView.cpp ui/widgets/LogView.h ui/widgets/InfoFrame.cpp @@ -1227,7 +1223,6 @@ qt_wrap_ui(LAUNCHER_UI ui/pages/modplatform/OptionalModDialog.ui ui/pages/modplatform/modrinth/ModrinthPage.ui ui/pages/modplatform/technic/TechnicPage.ui - ui/widgets/InstanceCardWidget.ui ui/widgets/CustomCommands.ui ui/widgets/EnvironmentVariables.ui ui/widgets/InfoFrame.ui diff --git a/launcher/ui/widgets/ErrorFrame.cpp b/launcher/ui/widgets/ErrorFrame.cpp deleted file mode 100644 index 213c26b76..000000000 --- a/launcher/ui/widgets/ErrorFrame.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "ErrorFrame.h" -#include "ui_ErrorFrame.h" - -#include "ui/dialogs/CustomMessageBox.h" - -void ErrorFrame::clear() -{ - setTitle(QString()); - setDescription(QString()); -} - -ErrorFrame::ErrorFrame(QWidget* parent) : QFrame(parent), ui(new Ui::ErrorFrame) -{ - ui->setupUi(this); - ui->label_Description->setHidden(true); - ui->label_Title->setHidden(true); - updateHiddenState(); -} - -ErrorFrame::~ErrorFrame() -{ - delete ui; -} - -void ErrorFrame::updateHiddenState() -{ - if (ui->label_Description->isHidden() && ui->label_Title->isHidden()) { - setHidden(true); - } else { - setHidden(false); - } -} - -void ErrorFrame::setTitle(QString text) -{ - if (text.isEmpty()) { - ui->label_Title->setHidden(true); - } else { - ui->label_Title->setText(text); - ui->label_Title->setHidden(false); - } - updateHiddenState(); -} - -void ErrorFrame::setDescription(QString text) -{ - if (text.isEmpty()) { - ui->label_Description->setHidden(true); - updateHiddenState(); - return; - } else { - ui->label_Description->setHidden(false); - updateHiddenState(); - } - ui->label_Description->setToolTip(""); - QString intermediatetext = text.trimmed(); - bool prev(false); - QChar rem('\n'); - QString finaltext; - finaltext.reserve(intermediatetext.size()); - foreach (const QChar& c, intermediatetext) { - if (c == rem && prev) { - continue; - } - prev = c == rem; - finaltext += c; - } - QString labeltext; - labeltext.reserve(300); - 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("" + finaltext.left(287) + "..."); - QObject::connect(ui->label_Description, &QLabel::linkActivated, this, &ErrorFrame::ellipsisHandler); - } else { - ui->label_Description->setTextFormat(Qt::TextFormat::PlainText); - labeltext.append(finaltext); - } - ui->label_Description->setText(labeltext); -} - -void ErrorFrame::ellipsisHandler(const QString& link) -{ - if (!currentBox) { - currentBox = CustomMessageBox::selectable(this, QString(), desc); - connect(currentBox, &QMessageBox::finished, this, &ErrorFrame::boxClosed); - currentBox->show(); - } else { - currentBox->setText(desc); - } -} - -void ErrorFrame::boxClosed(int result) -{ - currentBox = nullptr; -} diff --git a/launcher/ui/widgets/ErrorFrame.h b/launcher/ui/widgets/ErrorFrame.h deleted file mode 100644 index 1aea6a1d8..000000000 --- a/launcher/ui/widgets/ErrorFrame.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2013-2021 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -namespace Ui { -class ErrorFrame; -} - -class ErrorFrame : public QFrame { - Q_OBJECT - - public: - explicit ErrorFrame(QWidget* parent = 0); - ~ErrorFrame(); - - void setTitle(QString text); - void setDescription(QString text); - - void clear(); - - public slots: - void ellipsisHandler(const QString& link); - void boxClosed(int result); - - private: - void updateHiddenState(); - - private: - Ui::ErrorFrame* ui; - QString desc; - class QMessageBox* currentBox = nullptr; -}; diff --git a/launcher/ui/widgets/ErrorFrame.ui b/launcher/ui/widgets/ErrorFrame.ui deleted file mode 100644 index 0bb567439..000000000 --- a/launcher/ui/widgets/ErrorFrame.ui +++ /dev/null @@ -1,92 +0,0 @@ - - - ErrorFrame - - - - 0 - 0 - 527 - 113 - - - - - 0 - 0 - - - - - 16777215 - 120 - - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - - - - - - Qt::RichText - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - true - - - Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse|Qt::TextBrowserInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - - - - - - - diff --git a/launcher/ui/widgets/FocusLineEdit.cpp b/launcher/ui/widgets/FocusLineEdit.cpp deleted file mode 100644 index 6570227bb..000000000 --- a/launcher/ui/widgets/FocusLineEdit.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "FocusLineEdit.h" -#include - -FocusLineEdit::FocusLineEdit(QWidget* parent) : QLineEdit(parent) -{ - _selectOnMousePress = false; -} - -void FocusLineEdit::focusInEvent(QFocusEvent* e) -{ - QLineEdit::focusInEvent(e); - selectAll(); - _selectOnMousePress = true; -} - -void FocusLineEdit::mousePressEvent(QMouseEvent* me) -{ - QLineEdit::mousePressEvent(me); - if (_selectOnMousePress) { - selectAll(); - _selectOnMousePress = false; - } - qDebug() << selectedText(); -} diff --git a/launcher/ui/widgets/FocusLineEdit.h b/launcher/ui/widgets/FocusLineEdit.h deleted file mode 100644 index 797969406..000000000 --- a/launcher/ui/widgets/FocusLineEdit.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include - -class FocusLineEdit : public QLineEdit { - Q_OBJECT - public: - FocusLineEdit(QWidget* parent); - virtual ~FocusLineEdit() {} - - protected: - void focusInEvent(QFocusEvent* e); - void mousePressEvent(QMouseEvent* me); - - bool _selectOnMousePress; -}; diff --git a/launcher/ui/widgets/InstanceCardWidget.ui b/launcher/ui/widgets/InstanceCardWidget.ui deleted file mode 100644 index 6eeeb0769..000000000 --- a/launcher/ui/widgets/InstanceCardWidget.ui +++ /dev/null @@ -1,58 +0,0 @@ - - - InstanceCardWidget - - - - 0 - 0 - 473 - 118 - - - - - - - - 80 - 80 - - - - - - - - &Name: - - - instNameTextBox - - - - - - - - - - &Group: - - - groupBox - - - - - - - true - - - - - - - - diff --git a/launcher/ui/widgets/LineSeparator.cpp b/launcher/ui/widgets/LineSeparator.cpp deleted file mode 100644 index 2d6239a2f..000000000 --- a/launcher/ui/widgets/LineSeparator.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "LineSeparator.h" - -#include -#include -#include -#include - -void LineSeparator::initStyleOption(QStyleOption* option) const -{ - option->initFrom(this); - // in a horizontal layout, the line is vertical (and vice versa) - if (m_orientation == Qt::Vertical) - option->state |= QStyle::State_Horizontal; -} - -LineSeparator::LineSeparator(QWidget* parent, Qt::Orientation orientation) : QWidget(parent), m_orientation(orientation) -{ - setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); -} - -QSize LineSeparator::sizeHint() const -{ - QStyleOption opt; - initStyleOption(&opt); - const int extent = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, &opt, parentWidget()); - return QSize(extent, extent); -} - -void LineSeparator::paintEvent(QPaintEvent*) -{ - QPainter p(this); - QStyleOption opt; - initStyleOption(&opt); - style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, &p, parentWidget()); -} diff --git a/launcher/ui/widgets/LineSeparator.h b/launcher/ui/widgets/LineSeparator.h deleted file mode 100644 index 719facb99..000000000 --- a/launcher/ui/widgets/LineSeparator.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include - -class QStyleOption; - -class LineSeparator : public QWidget { - Q_OBJECT - - public: - /// Create a line separator. orientation is the orientation of the line. - explicit LineSeparator(QWidget* parent, Qt::Orientation orientation = Qt::Horizontal); - QSize sizeHint() const; - void paintEvent(QPaintEvent*); - void initStyleOption(QStyleOption* option) const; - - private: - Qt::Orientation m_orientation = Qt::Horizontal; -};