From 91d1d55b5b3419148eda6c3e5a2ccd48773ae73c Mon Sep 17 00:00:00 2001 From: Romain DERRE <romain.derre@pc227-25.pedago.ensiie.fr> Date: Mon, 25 Mar 2019 16:46:23 +0100 Subject: [PATCH] =?UTF-8?q?layout=20infos=20g=C3=A9n=C3=A9rales?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/mainwindow.cpp | 20 ++++++- app/mainwindow.h | 4 ++ app/mainwindow.ui | 142 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 155 insertions(+), 11 deletions(-) diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index bfa364f..621cb20 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -28,9 +28,14 @@ void MainWindow::update_status(GeneralStatus &genStatus) int m = time/60; int s = time - m*60; - //ui->statusBar->clearMessage(); - QString message = "uptime: " + QString::number(j)+ ":" + QString::number(h) + ":" + QString::number(m) + ":" + QString::number(s) + "\ntasks running: " + QString::number(genStatus.getNbTask()) + "\nCPU: " + QString::number(genStatus.getCPU()) + "%\nmemory: " + QString::number(genStatus.getMem()) + "%"; - ui->label_2->setText(message); + QString uptime = QString::number(j)+ ":" + QString::number(h) + ":" + QString::number(m) + ":" + QString::number(s); + ui->label_uptime->setText(uptime); + + ui->label_CPU->setText(QString::number(genStatus.getCPU()) + "%"); + + ui->label_mem->setText(QString::number(genStatus.getMem()) + "%"); + + ui->label_nbTask->setText(QString::number(genStatus.getNbTask())); } @@ -54,3 +59,12 @@ void MainWindow::on_comboBox_currentTextChanged(const QString &arg1) } } +void MainWindow::on_commandLinkButton_7_clicked() +{ + bool ok; + QString text = QInputDialog::getText(this, tr("Create task"), + tr("Task command:"), QLineEdit::Normal, + QDir::home().dirName(), &ok); + if (ok && !text.isEmpty()) + system(text.toStdString().c_str()); +} diff --git a/app/mainwindow.h b/app/mainwindow.h index d942868..d5df8e0 100644 --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -3,6 +3,8 @@ #include <QMainWindow> #include <QMessageBox> +#include <QInputDialog> +#include <QDir> #include "generalstatus.h" namespace Ui { @@ -21,6 +23,8 @@ public: private slots: void on_comboBox_currentTextChanged(const QString &arg1); + void on_commandLinkButton_7_clicked(); + private: Ui::MainWindow *ui; }; diff --git a/app/mainwindow.ui b/app/mainwindow.ui index 5bf7ea8..a7b1f8d 100644 --- a/app/mainwindow.ui +++ b/app/mainwindow.ui @@ -54,14 +54,96 @@ </layout> </item> <item> - <widget class="QLabel" name="label_2"> - <property name="maximumSize"> - <size> - <width>200</width> - <height>16777215</height> - </size> - </property> - </widget> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label_2"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Uptime:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label_uptime"/> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_nbTask"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Tasks running:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_CPU"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_6"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>2</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>CPU:</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_8"> + <property name="minimumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>100</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Memory:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_mem"/> + </item> + </layout> </item> </layout> </item> @@ -88,6 +170,29 @@ <property name="sizeConstraint"> <enum>QLayout::SetMaximumSize</enum> </property> + <item> + <widget class="QCommandLinkButton" name="commandLinkButton_7"> + <property name="text"> + <string>Create Task</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>10</height> + </size> + </property> + </spacer> + </item> <item> <widget class="QCommandLinkButton" name="commandLinkButton_6"> <property name="minimumSize"> @@ -101,6 +206,22 @@ </property> </widget> </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>10</width> + <height>20</height> + </size> + </property> + </spacer> + </item> <item> <widget class="QComboBox" name="comboBox"> <property name="minimumSize"> @@ -272,6 +393,11 @@ <string>Night Model</string> </property> </action> + <action name="actionCreate_task"> + <property name="text"> + <string>Create task</string> + </property> + </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> -- GitLab