diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index bfa364f32b8c26f322d81f2c8e3b5a16f4a15084..621cb20200ad465b242bcd84f2c3cef58de1a60a 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 d94286866db047aed1921a737121549a0e114baa..d5df8e08d182d06b41fe4c59c1cf0c24aae2cf32 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 5bf7ea86716f77f772cb2d38b60d29165f548615..a7b1f8dec62e3838618805f0a0b2578a5c20a587 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/>