diff options
| author | swirl <swurl@swurl.xyz> | 2022-01-26 17:40:49 -0500 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-26 17:40:49 -0500 | 
| commit | 02889b7a11842f8d1a34ec5ce6dff1f0b4a486fb (patch) | |
| tree | d8eed237b3c830c47edeeeb0fb59236d740d5ab5 /launcher/ui | |
| parent | 068094583912797855cc7ef8045198d51eedcfac (diff) | |
| parent | 0eff21a4f1ee97e4b0a484c608eac9617897446d (diff) | |
| download | PrismLauncher-02889b7a11842f8d1a34ec5ce6dff1f0b4a486fb.tar.gz PrismLauncher-02889b7a11842f8d1a34ec5ce6dff1f0b4a486fb.tar.bz2 PrismLauncher-02889b7a11842f8d1a34ec5ce6dff1f0b4a486fb.zip | |
Merge pull request #67 from PolyMC/feature/no_paste_ee
Full replacement of paste.ee
Diffstat (limited to 'launcher/ui')
| -rw-r--r-- | launcher/ui/GuiUtil.cpp | 17 | ||||
| -rw-r--r-- | launcher/ui/pages/global/PastePage.cpp (renamed from launcher/ui/pages/global/PasteEEPage.cpp) | 50 | ||||
| -rw-r--r-- | launcher/ui/pages/global/PastePage.h (renamed from launcher/ui/pages/global/PasteEEPage.h) | 14 | ||||
| -rw-r--r-- | launcher/ui/pages/global/PastePage.ui (renamed from launcher/ui/pages/global/PasteEEPage.ui) | 67 | ||||
| -rw-r--r-- | launcher/ui/pages/instance/LogPage.ui | 2 | ||||
| -rw-r--r-- | launcher/ui/pages/instance/OtherLogsPage.ui | 2 | 
6 files changed, 59 insertions, 93 deletions
| diff --git a/launcher/ui/GuiUtil.cpp b/launcher/ui/GuiUtil.cpp index efb1a4df..9eb658e2 100644 --- a/launcher/ui/GuiUtil.cpp +++ b/launcher/ui/GuiUtil.cpp @@ -16,21 +16,8 @@  QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)  {      ProgressDialog dialog(parentWidget); -    auto APIKeySetting = APPLICATION->settings()->get("PasteEEAPIKey").toString(); -    if(APIKeySetting == "multimc") -    { -        APIKeySetting = BuildConfig.PASTE_EE_KEY; -    } -    std::unique_ptr<PasteUpload> paste(new PasteUpload(parentWidget, text, APIKeySetting)); - -    if (!paste->validateText()) -    { -        CustomMessageBox::selectable( -            parentWidget, QObject::tr("Upload failed"), -            QObject::tr("The log file is too big. You'll have to upload it manually."), -            QMessageBox::Warning)->exec(); -        return QString(); -    } +    auto pasteUrlSetting = APPLICATION->settings()->get("PastebinURL").toString(); +    std::unique_ptr<PasteUpload> paste(new PasteUpload(parentWidget, text, pasteUrlSetting));      dialog.execWithTask(paste.get());      if (!paste->wasSuccessful()) diff --git a/launcher/ui/pages/global/PasteEEPage.cpp b/launcher/ui/pages/global/PastePage.cpp index 4b375d9a..7c69e1a4 100644 --- a/launcher/ui/pages/global/PasteEEPage.cpp +++ b/launcher/ui/pages/global/PastePage.cpp @@ -1,4 +1,4 @@ -/* Copyright 2013-2021 MultiMC Contributors +/* Copyright 2013-2021 MultiMC & PolyMC Contributors   *   * Licensed under the Apache License, Version 2.0 (the "License");   * you may not use this file except in compliance with the License. @@ -13,69 +13,51 @@   * limitations under the License.   */ -#include "PasteEEPage.h" -#include "ui_PasteEEPage.h" +#include "PastePage.h" +#include "ui_PastePage.h"  #include <QMessageBox>  #include <QFileDialog>  #include <QStandardPaths>  #include <QTabBar> +#include <QVariant>  #include "settings/SettingsObject.h"  #include "tools/BaseProfiler.h"  #include "Application.h" -PasteEEPage::PasteEEPage(QWidget *parent) : +PastePage::PastePage(QWidget *parent) :      QWidget(parent), -    ui(new Ui::PasteEEPage) +    ui(new Ui::PastePage)  { +    static QRegularExpression validUrlRegExp("https?://.+");      ui->setupUi(this); +    ui->urlChoices->setValidator(new QRegularExpressionValidator(validUrlRegExp, ui->urlChoices));      ui->tabWidget->tabBar()->hide();\ -    connect(ui->customAPIkeyEdit, &QLineEdit::textEdited, this, &PasteEEPage::textEdited);      loadSettings();  } -PasteEEPage::~PasteEEPage() +PastePage::~PastePage()  {      delete ui;  } -void PasteEEPage::loadSettings() +void PastePage::loadSettings()  {      auto s = APPLICATION->settings(); -    QString keyToUse = s->get("PasteEEAPIKey").toString(); -    if(keyToUse == "multimc") -    { -        ui->multimcButton->setChecked(true); -    } -    else -    { -        ui->customButton->setChecked(true); -        ui->customAPIkeyEdit->setText(keyToUse); -    } +    QString pastebinURL = s->get("PastebinURL").toString(); +    ui->urlChoices->setCurrentText(pastebinURL);  } -void PasteEEPage::applySettings() +void PastePage::applySettings()  {      auto s = APPLICATION->settings(); - -    QString pasteKeyToUse; -    if (ui->customButton->isChecked()) -        pasteKeyToUse = ui->customAPIkeyEdit->text(); -    else -    { -        pasteKeyToUse =  "multimc"; -    } -    s->set("PasteEEAPIKey", pasteKeyToUse); +    QString pastebinURL = ui->urlChoices->currentText(); +    s->set("PastebinURL", pastebinURL);  } -bool PasteEEPage::apply() +bool PastePage::apply()  {      applySettings();      return true;  } - -void PasteEEPage::textEdited(const QString& text) -{ -    ui->customButton->setChecked(true); -} diff --git a/launcher/ui/pages/global/PasteEEPage.h b/launcher/ui/pages/global/PastePage.h index a1c7d434..d475dfd9 100644 --- a/launcher/ui/pages/global/PasteEEPage.h +++ b/launcher/ui/pages/global/PastePage.h @@ -21,16 +21,16 @@  #include <Application.h>  namespace Ui { -class PasteEEPage; +class PastePage;  } -class PasteEEPage : public QWidget, public BasePage +class PastePage : public QWidget, public BasePage  {      Q_OBJECT  public: -    explicit PasteEEPage(QWidget *parent = 0); -    ~PasteEEPage(); +    explicit PastePage(QWidget *parent = 0); +    ~PastePage();      QString displayName() const override      { @@ -54,9 +54,7 @@ private:      void loadSettings();      void applySettings(); -private slots: -    void textEdited(const QString &text); -  private: -    Ui::PasteEEPage *ui; +    Ui::PastePage *ui;  }; + diff --git a/launcher/ui/pages/global/PasteEEPage.ui b/launcher/ui/pages/global/PastePage.ui index 10883781..2d13a765 100644 --- a/launcher/ui/pages/global/PasteEEPage.ui +++ b/launcher/ui/pages/global/PastePage.ui @@ -1,7 +1,7 @@  <?xml version="1.0" encoding="UTF-8"?>  <ui version="4.0"> - <class>PasteEEPage</class> - <widget class="QWidget" name="PasteEEPage"> + <class>PastePage</class> + <widget class="QWidget" name="PastePage">    <property name="geometry">     <rect>      <x>0</x> @@ -36,50 +36,55 @@         <item>          <widget class="QGroupBox" name="groupBox_2">           <property name="title"> -          <string>paste.ee API key</string> +          <string>Pastebin URL</string>           </property> -         <layout class="QVBoxLayout" name="verticalLayout_10"> +         <layout class="QVBoxLayout" name="verticalLayout_3">            <item> -           <widget class="QRadioButton" name="multimcButton"> -            <property name="text"> -             <string>MultiMC key - 12MB &upload limit</string> +           <widget class="Line" name="line"> +            <property name="orientation"> +             <enum>Qt::Horizontal</enum>              </property> -            <attribute name="buttonGroup"> -             <string notr="true">pasteButtonGroup</string> -            </attribute>             </widget>            </item>            <item> -           <widget class="QRadioButton" name="customButton"> -            <property name="text"> -             <string>&Your own key - 12MB upload limit:</string> +           <widget class="QLabel" name="label_2"> +            <property name="font"> +             <font> +              <pointsize>10</pointsize> +             </font>              </property> -            <attribute name="buttonGroup"> -             <string notr="true">pasteButtonGroup</string> -            </attribute> -           </widget> -          </item> -          <item> -           <widget class="QLineEdit" name="customAPIkeyEdit"> -            <property name="echoMode"> -             <enum>QLineEdit::Password</enum> +            <property name="text"> +             <string><html><head/><body><p>Note: only input that starts with <span style=" font-weight:600;">http://</span> or <span style=" font-weight:600;">https://</span> will be accepted.</p></body></html></string>              </property> -            <property name="placeholderText"> -             <string>Paste your API key here!</string> +            <property name="scaledContents"> +             <bool>false</bool>              </property>             </widget>            </item>            <item> -           <widget class="Line" name="line"> -            <property name="orientation"> -             <enum>Qt::Horizontal</enum> +           <widget class="QComboBox" name="urlChoices"> +            <property name="editable"> +             <bool>true</bool> +            </property> +            <property name="insertPolicy"> +             <enum>QComboBox::NoInsert</enum>              </property> +            <item> +             <property name="text"> +              <string>https://0x0.st</string> +             </property> +            </item> +            <item> +             <property name="text"> +              <string>https://paste.polymc.org</string> +             </property> +            </item>             </widget>            </item>            <item>             <widget class="QLabel" name="label">              <property name="text"> -             <string><html><head/><body><p><a href="https://paste.ee">paste.ee</a> is used by MultiMC for log uploads. If you have a <a href="https://paste.ee">paste.ee</a> account, you can add your API key here and have your uploaded logs paired with your account.</p></body></html></string> +             <string><html><head/><body><p>Here you can choose from a predefined list of paste services, or input the URL of a different paste service of your choice, provided it supports the same protocol as 0x0.st, that is POST a file parameter to the URL and return a link in the response body.</p></body></html></string>              </property>              <property name="textFormat">               <enum>Qt::RichText</enum> @@ -116,13 +121,7 @@   </widget>   <tabstops>    <tabstop>tabWidget</tabstop> -  <tabstop>multimcButton</tabstop> -  <tabstop>customButton</tabstop> -  <tabstop>customAPIkeyEdit</tabstop>   </tabstops>   <resources/>   <connections/> - <buttongroups> -  <buttongroup name="pasteButtonGroup"/> - </buttongroups>  </ui> diff --git a/launcher/ui/pages/instance/LogPage.ui b/launcher/ui/pages/instance/LogPage.ui index ccfc1551..31bb368c 100644 --- a/launcher/ui/pages/instance/LogPage.ui +++ b/launcher/ui/pages/instance/LogPage.ui @@ -100,7 +100,7 @@           <item>            <widget class="QPushButton" name="btnPaste">             <property name="toolTip"> -            <string>Upload the log to paste.ee - it will stay online for a month</string> +            <string>Upload the log to the paste service configured in preferences</string>             </property>             <property name="text">              <string>Upload</string> diff --git a/launcher/ui/pages/instance/OtherLogsPage.ui b/launcher/ui/pages/instance/OtherLogsPage.ui index 56ff3b62..77f3e647 100644 --- a/launcher/ui/pages/instance/OtherLogsPage.ui +++ b/launcher/ui/pages/instance/OtherLogsPage.ui @@ -84,7 +84,7 @@           <item row="3" column="2">            <widget class="QPushButton" name="btnPaste">             <property name="toolTip"> -            <string>Upload the log to paste.ee - it will stay online for a month</string> +            <string>Upload the log to the paste service configured in preferences.</string>             </property>             <property name="text">              <string>Upload</string> | 
