diff options
Diffstat (limited to 'lib/about')
| -rw-r--r-- | lib/about/aboutplugin.cpp | 28 | ||||
| -rw-r--r-- | lib/about/aboutplugin.h | 2 | ||||
| -rw-r--r-- | lib/about/aboutplugin.ui | 47 | 
3 files changed, 59 insertions, 18 deletions
| diff --git a/lib/about/aboutplugin.cpp b/lib/about/aboutplugin.cpp index 7df75fa..b2fab51 100644 --- a/lib/about/aboutplugin.cpp +++ b/lib/about/aboutplugin.cpp @@ -54,19 +54,43 @@ QTreeWidgetItem *createItem(const QString &key, const QJsonValue &json, QTreeWid      return item;  } -AboutPluginDialog::AboutPluginDialog(const QPluginLoader *loader, QWidget *parent) +AboutPluginDialog::AboutPluginDialog(QPluginLoader *loader, QWidget *parent)      : QDialog(parent)      , ui(new Ui::AboutPluginDialog)  {      setAttribute(Qt::WA_DeleteOnClose, true);      ui->setupUi(this); +    // load button icon +    { +        QIcon load_icon; +        load_icon.addPixmap(style()->standardPixmap(QStyle::SP_MediaPlay), QIcon::Normal, QIcon::On); +        load_icon.addPixmap(style()->standardPixmap(QStyle::SP_MediaStop), QIcon::Normal, QIcon::Off); +        ui->load->setIcon(load_icon); +    } +      auto metaData = loader->metaData()["MetaData"].toObject();      this->setWindowTitle(metaData["name"].toString());      ui->path->setText(loader->fileName()); -    ui->loaded->setChecked(loader->isLoaded()); +    ui->load->setChecked(loader->isLoaded()); + +    connect(ui->load, &QToolButton::clicked, this, [this, loader](bool checked) { +        if(checked) { +            // load plugin +            if(!loader->load()) { +                ui->load->setChecked(false); +                ui->error->setText(loader->errorString()); +            } +        } else { +            // unload plugin +            if(!loader->unload()) { +                ui->load->setChecked(true); +                ui->error->setText(loader->errorString()); +            } +        } +    });      ui->name->setText(metaData[QLatin1Literal("name")].toString());      ui->author->setText(metaData[QLatin1Literal("author")].toString()); diff --git a/lib/about/aboutplugin.h b/lib/about/aboutplugin.h index adab215..9651060 100644 --- a/lib/about/aboutplugin.h +++ b/lib/about/aboutplugin.h @@ -21,7 +21,7 @@ class AboutPluginDialog : public QDialog      Q_OBJECT  public: -    explicit AboutPluginDialog(const QPluginLoader *loader, QWidget *parent = nullptr); +    explicit AboutPluginDialog(QPluginLoader *loader, QWidget *parent = nullptr);      ~AboutPluginDialog() override;  private: diff --git a/lib/about/aboutplugin.ui b/lib/about/aboutplugin.ui index f2d4848..31e20c6 100644 --- a/lib/about/aboutplugin.ui +++ b/lib/about/aboutplugin.ui @@ -67,21 +67,7 @@          </widget>         </item>         <item row="4" column="1"> -        <layout class="QHBoxLayout" name="controls_layout"> -         <item> -          <widget class="QPushButton" name="loaded"> -           <property name="enabled"> -            <bool>false</bool> -           </property> -           <property name="text"> -            <string>Load</string> -           </property> -           <property name="checkable"> -            <bool>true</bool> -           </property> -          </widget> -         </item> -        </layout> +        <layout class="QHBoxLayout" name="controls_layout"/>         </item>         <item row="2" column="1">          <widget class="QLabel" name="license"> @@ -127,6 +113,37 @@         </item>        </layout>       </widget> +     <widget class="QWidget" name="controls_tab"> +      <attribute name="title"> +       <string>Controls</string> +      </attribute> +      <layout class="QFormLayout" name="formLayout_2"> +       <item row="0" column="1"> +        <widget class="QToolButton" name="load"> +         <property name="text"> +          <string>Load</string> +         </property> +         <property name="checkable"> +          <bool>true</bool> +         </property> +        </widget> +       </item> +       <item row="1" column="1"> +        <widget class="QLabel" name="error"> +         <property name="text"> +          <string/> +         </property> +        </widget> +       </item> +       <item row="0" column="0"> +        <widget class="QLabel" name="error_label"> +         <property name="text"> +          <string>Status</string> +         </property> +        </widget> +       </item> +      </layout> +     </widget>      </widget>     </item>     <item> | 
