mirror of
				https://github.com/arcan1s/awesome-widgets.git
				synced 2025-10-31 13:13:41 +00:00 
			
		
		
		
	implement script function
This commit is contained in:
		| @ -78,7 +78,9 @@ private slots: | ||||
|     void reinit(); | ||||
|     void replyRecieved(QNetworkReply *reply); | ||||
|     // configuration interface | ||||
|     void addCustomScript(); | ||||
|     void addNewPkgCommand(QTableWidgetItem *item); | ||||
|     void contextMenuCustomCommand(const QPoint pos); | ||||
|     void contextMenuPkgCommand(const QPoint pos); | ||||
|     void editCustomCommand(const int row, const int column); | ||||
|     void editFanItem(QListWidgetItem *item); | ||||
|  | ||||
| @ -22,6 +22,7 @@ | ||||
| #include <KStandardDirs> | ||||
| #include <QDesktopServices> | ||||
| #include <QDir> | ||||
| #include <QInputDialog> | ||||
| #include <QMenu> | ||||
| #include <QNetworkInterface> | ||||
| #include <QTextCodec> | ||||
| @ -390,7 +391,12 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent) | ||||
|             output->setCheckState(Qt::Unchecked); | ||||
|         uiDEConfig.tableWidget_customCommand->setItem(i, 2, output); | ||||
|         uiDEConfig.tableWidget_customCommand->setItem(i, 3, new QTableWidgetItem(externalScripts[i]->getPrefix())); | ||||
|         uiDEConfig.tableWidget_customCommand->setItem(i, 4, new QTableWidgetItem(QString::number(externalScripts[i]->getRedirect()))); | ||||
|         QComboBox *redirect = new QComboBox(); | ||||
|         redirect->addItem(QString("out2err")); | ||||
|         redirect->addItem(QString("nothing")); | ||||
|         redirect->addItem(QString("err2out")); | ||||
|         redirect->setCurrentIndex(externalScripts[i]->getRedirect() + 1); | ||||
|         uiDEConfig.tableWidget_customCommand->setCellWidget(i, 4, redirect); | ||||
|     } | ||||
|     externalScripts.clear(); | ||||
|     uiDEConfig.lineEdit_desktopCmd->setText(deSettings[QString("DESKTOPCMD")]); | ||||
| @ -472,6 +478,8 @@ void AwesomeWidget::createConfigurationInterface(KConfigDialog *parent) | ||||
|             this, SLOT(editTempItem(QListWidgetItem *))); | ||||
|     connect(uiDEConfig.tableWidget_customCommand, SIGNAL(cellDoubleClicked(int, int)), | ||||
|             this, SLOT(editCustomCommand(int, int))); | ||||
|     connect(uiDEConfig.tableWidget_customCommand, SIGNAL(customContextMenuRequested(QPoint)), | ||||
|             this, SLOT(contextMenuCustomCommand(QPoint))); | ||||
|     connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(itemChanged(QTableWidgetItem *)), | ||||
|             this, SLOT(addNewPkgCommand(QTableWidgetItem *))); | ||||
|     connect(uiDEConfig.tableWidget_pkgCommand, SIGNAL(customContextMenuRequested(QPoint)), | ||||
| @ -584,7 +592,8 @@ void AwesomeWidget::configAccepted() | ||||
|         else | ||||
|             script->setHasOutput(false); | ||||
|         script->setPrefix(uiDEConfig.tableWidget_customCommand->item(i, 3)->text()); | ||||
|         script->setRedirect((ExtScript::Redirect)uiDEConfig.tableWidget_customCommand->item(i, 4)->text().toInt()); | ||||
|         int redirect = ((QComboBox *)uiDEConfig.tableWidget_customCommand->cellWidget(i, 4))->currentIndex() - 1; | ||||
|         script->setRedirect((ExtScript::Redirect)redirect); | ||||
|         script->writeConfiguration(); | ||||
|         delete script; | ||||
|     } | ||||
| @ -732,6 +741,57 @@ void AwesomeWidget::configChanged() | ||||
| } | ||||
|  | ||||
|  | ||||
| void AwesomeWidget::addCustomScript() | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|  | ||||
|     QString name = QInputDialog::getText(0, i18n("Enter script name"), | ||||
|                                          i18n("Name")); | ||||
|     if (name.isEmpty()) return; | ||||
|     QString localDir = KGlobal::dirs()->locateLocal("data", "plasma_engine_extsysmon/scripts"); | ||||
|  | ||||
|     QString fileName = QDir(localDir).absoluteFilePath(name); | ||||
|     if (debug) qDebug() << PDEBUG << ":" << "Script" << fileName; | ||||
|     QFile configFile(fileName); | ||||
|     if (!configFile.open(QIODevice::WriteOnly)) return; | ||||
|     configFile.write("#!/bin/bash\n"); | ||||
|     configFile.close(); | ||||
|     configFile.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | | ||||
|                               QFile::ReadGroup | QFile::ExeGroup | | ||||
|                               QFile::ReadOther | QFile::ExeOther); | ||||
|     QDesktopServices::openUrl(QUrl(fileName)); | ||||
|  | ||||
|     fileName = QDir(localDir).absoluteFilePath(name + QString(".conf")); | ||||
|     if (debug) qDebug() << PDEBUG << ":" << "Configuration" << fileName; | ||||
|     configFile.setFileName(fileName); | ||||
|     if (!configFile.open(QIODevice::WriteOnly)) return; | ||||
|     configFile.write("ACTIVE=false\n"); | ||||
|     configFile.write("INTERVAL=1\n"); | ||||
|     configFile.write("OUTPUT=true\n"); | ||||
|     configFile.write("PREFIX=\n"); | ||||
|     configFile.write("REDIRECT=0\n"); | ||||
|     configFile.close(); | ||||
|  | ||||
|     int i = uiDEConfig.tableWidget_customCommand->rowCount(); | ||||
|     uiDEConfig.tableWidget_customCommand->insertRow(i); | ||||
|     QTableWidgetItem *nameItem = new QTableWidgetItem(name); | ||||
|     nameItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEnabled); | ||||
|     nameItem->setCheckState(Qt::Unchecked); | ||||
|     uiDEConfig.tableWidget_customCommand->setItem(i, 0, nameItem); | ||||
|     uiDEConfig.tableWidget_customCommand->setItem(i, 1, new QTableWidgetItem(QString::number(1))); | ||||
|     QTableWidgetItem *output = new QTableWidgetItem(); | ||||
|     output->setCheckState(Qt::Checked); | ||||
|     uiDEConfig.tableWidget_customCommand->setItem(i, 2, output); | ||||
|     uiDEConfig.tableWidget_customCommand->setItem(i, 3, new QTableWidgetItem(QString(""))); | ||||
|     QComboBox *redirect = new QComboBox(); | ||||
|     redirect->addItem(QString("out2err")); | ||||
|     redirect->addItem(QString("nothing")); | ||||
|     redirect->addItem(QString("err2out")); | ||||
|     redirect->setCurrentIndex(1); | ||||
|     uiDEConfig.tableWidget_customCommand->setCellWidget(i, 4, redirect); | ||||
| } | ||||
|  | ||||
|  | ||||
| void AwesomeWidget::addNewPkgCommand(QTableWidgetItem *item) | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
| @ -747,6 +807,31 @@ void AwesomeWidget::addNewPkgCommand(QTableWidgetItem *item) | ||||
| } | ||||
|  | ||||
|  | ||||
| void AwesomeWidget::contextMenuCustomCommand(const QPoint pos) | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|     if (uiDEConfig.tableWidget_customCommand->currentItem() == 0) return; | ||||
|  | ||||
|     QMenu menu(uiDEConfig.tableWidget_customCommand); | ||||
|     QAction *edit = menu.addAction(QIcon::fromTheme("document-edit"), i18n("Edit")); | ||||
|     QAction *create = menu.addAction(QIcon::fromTheme("document-new"), i18n("Create")); | ||||
|     QAction *remove = menu.addAction(QIcon::fromTheme("edit-delete"), i18n("Remove")); | ||||
|     QAction *action = menu.exec(uiDEConfig.tableWidget_customCommand->viewport()->mapToGlobal(pos)); | ||||
|     if (action == edit) { | ||||
|         editCustomCommand(uiDEConfig.tableWidget_customCommand->currentRow(), 0); | ||||
|     } else if (action == create) { | ||||
|         addCustomScript(); | ||||
|     } else if (action == remove) { | ||||
|         int row = uiDEConfig.tableWidget_customCommand->currentRow(); | ||||
|         QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_engine_extsysmon/scripts"); | ||||
|         ExtScript *script = new ExtScript(uiDEConfig.tableWidget_customCommand->item(row, 0)->text(), dirs, debug); | ||||
|         script->tryDelete(); | ||||
|         delete script; | ||||
|         uiDEConfig.tableWidget_customCommand->removeRow(row); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| void AwesomeWidget::contextMenuPkgCommand(const QPoint pos) | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
| @ -766,7 +851,7 @@ void AwesomeWidget::editCustomCommand(const int row, const int column) | ||||
|     Q_UNUSED(column); | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|  | ||||
|     QString name = uiDEConfig.tableWidget_customCommand->itemAt(row, 0)->text(); | ||||
|     QString name = uiDEConfig.tableWidget_customCommand->item(row, 0)->text(); | ||||
|     QString localDir = KStandardDirs::locateLocal("data", "plasma_engine_extsysmon/scripts"); | ||||
|     QStringList dirs = KGlobal::dirs()->findDirs("data", "plasma_engine_extsysmon/scripts"); | ||||
|     for (int i=0; i<dirs.count(); i++) { | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
|     <x>0</x> | ||||
|     <y>0</y> | ||||
|     <width>700</width> | ||||
|     <height>588</height> | ||||
|     <height>586</height> | ||||
|    </rect> | ||||
|   </property> | ||||
|   <property name="sizePolicy"> | ||||
| @ -43,10 +43,87 @@ | ||||
|         <x>0</x> | ||||
|         <y>0</y> | ||||
|         <width>684</width> | ||||
|         <height>572</height> | ||||
|         <height>570</height> | ||||
|        </rect> | ||||
|       </property> | ||||
|       <layout class="QGridLayout" name="gridLayout"> | ||||
|        <item row="5" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_hddtempCmd"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_hddtempCmd"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>hddtemp cmd</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QLineEdit" name="lineEdit_hddtempCmd"> | ||||
|            <property name="alignment"> | ||||
|             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="3" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_gpudev"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_gpudev"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>GPU device</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QComboBox" name="comboBox_gpudev"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>100</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">auto</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">disable</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">nvidia</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">ati</string> | ||||
|             </property> | ||||
|            </item> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="4" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_hdddev"> | ||||
|          <item> | ||||
| @ -80,6 +157,49 @@ | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="9" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_playerSelect"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_playerSelect"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Music player</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QComboBox" name="comboBox_playerSelect"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>100</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">mpris</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">mpd</string> | ||||
|             </property> | ||||
|            </item> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="7" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_mpdport"> | ||||
|          <item> | ||||
| @ -135,10 +255,10 @@ | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="3" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_gpudev"> | ||||
|        <item row="2" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_desktopCmd"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_gpudev"> | ||||
|           <widget class="QLabel" name="label_desktopCmd"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
| @ -146,78 +266,12 @@ | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>GPU device</string> | ||||
|             <string>Desktop check cmd</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QComboBox" name="comboBox_gpudev"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>100</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">auto</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">disable</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">nvidia</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">ati</string> | ||||
|             </property> | ||||
|            </item> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="11" column="0"> | ||||
|         <spacer name="spacer_dataengine"> | ||||
|          <property name="orientation"> | ||||
|           <enum>Qt::Vertical</enum> | ||||
|          </property> | ||||
|          <property name="sizeHint" stdset="0"> | ||||
|           <size> | ||||
|            <width>20</width> | ||||
|            <height>40</height> | ||||
|           </size> | ||||
|          </property> | ||||
|         </spacer> | ||||
|        </item> | ||||
|        <item row="5" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_hddtempCmd"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_hddtempCmd"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>hddtemp cmd</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QLineEdit" name="lineEdit_hddtempCmd"> | ||||
|           <widget class="QLineEdit" name="lineEdit_desktopCmd"> | ||||
|            <property name="alignment"> | ||||
|             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|            </property> | ||||
| @ -225,49 +279,6 @@ | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="9" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_playerSelect"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_playerSelect"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Music player</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QComboBox" name="comboBox_playerSelect"> | ||||
|            <property name="sizePolicy"> | ||||
|             <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||||
|              <horstretch>0</horstretch> | ||||
|              <verstretch>0</verstretch> | ||||
|             </sizepolicy> | ||||
|            </property> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>100</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">mpris</string> | ||||
|             </property> | ||||
|            </item> | ||||
|            <item> | ||||
|             <property name="text"> | ||||
|              <string notr="true">mpd</string> | ||||
|             </property> | ||||
|            </item> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="6" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_mpdaddress"> | ||||
|          <item> | ||||
| @ -292,10 +303,23 @@ | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="2" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_desktopCmd"> | ||||
|        <item row="11" column="0"> | ||||
|         <spacer name="spacer_dataengine"> | ||||
|          <property name="orientation"> | ||||
|           <enum>Qt::Vertical</enum> | ||||
|          </property> | ||||
|          <property name="sizeHint" stdset="0"> | ||||
|           <size> | ||||
|            <width>20</width> | ||||
|            <height>40</height> | ||||
|           </size> | ||||
|          </property> | ||||
|         </spacer> | ||||
|        </item> | ||||
|        <item row="0" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_acpi"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_desktopCmd"> | ||||
|           <widget class="QLabel" name="label_acpi"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
| @ -303,19 +327,60 @@ | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Desktop check cmd</string> | ||||
|             <string>ACPI path</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QLineEdit" name="lineEdit_desktopCmd"> | ||||
|            <property name="alignment"> | ||||
|             <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> | ||||
|           <widget class="QLineEdit" name="lineEdit_acpi"> | ||||
|            <property name="toolTip"> | ||||
|             <string>"/sys/class/power_supply/" by default</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="1" column="0"> | ||||
|         <widget class="QTableWidget" name="tableWidget_customCommand"> | ||||
|          <property name="contextMenuPolicy"> | ||||
|           <enum>Qt::CustomContextMenu</enum> | ||||
|          </property> | ||||
|          <property name="selectionMode"> | ||||
|           <enum>QAbstractItemView::SingleSelection</enum> | ||||
|          </property> | ||||
|          <attribute name="horizontalHeaderStretchLastSection"> | ||||
|           <bool>true</bool> | ||||
|          </attribute> | ||||
|          <attribute name="verticalHeaderVisible"> | ||||
|           <bool>false</bool> | ||||
|          </attribute> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Name</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Interval</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Output</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Prefix</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Redirect</string> | ||||
|           </property> | ||||
|          </column> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item row="8" column="0"> | ||||
|         <layout class="QVBoxLayout" name="layout_mpris"> | ||||
|          <item> | ||||
| @ -440,69 +505,6 @@ del - remove item</string> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item row="1" column="0"> | ||||
|         <widget class="QTableWidget" name="tableWidget_customCommand"> | ||||
|          <property name="toolTip"> | ||||
|           <string>Editable | ||||
| del - remove item</string> | ||||
|          </property> | ||||
|          <attribute name="horizontalHeaderStretchLastSection"> | ||||
|           <bool>true</bool> | ||||
|          </attribute> | ||||
|          <attribute name="verticalHeaderVisible"> | ||||
|           <bool>false</bool> | ||||
|          </attribute> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Name</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Interval</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Output</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Prefix</string> | ||||
|           </property> | ||||
|          </column> | ||||
|          <column> | ||||
|           <property name="text"> | ||||
|            <string>Redirect</string> | ||||
|           </property> | ||||
|          </column> | ||||
|         </widget> | ||||
|        </item> | ||||
|        <item row="0" column="0"> | ||||
|         <layout class="QHBoxLayout" name="layout_acpi"> | ||||
|          <item> | ||||
|           <widget class="QLabel" name="label_acpi"> | ||||
|            <property name="minimumSize"> | ||||
|             <size> | ||||
|              <width>200</width> | ||||
|              <height>0</height> | ||||
|             </size> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>ACPI path</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QLineEdit" name="lineEdit_acpi"> | ||||
|            <property name="toolTip"> | ||||
|             <string>"/sys/class/power_supply/" by default</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|       </layout> | ||||
|      </widget> | ||||
|     </widget> | ||||
|  | ||||
| @ -233,6 +233,19 @@ ExtScript::ScriptData ExtScript::run(const int time) | ||||
| } | ||||
|  | ||||
|  | ||||
| void ExtScript::tryDelete() | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|  | ||||
|     for (int i=0; i<dirs.count(); i++) { | ||||
|         QString fileName = dirs[i] + QDir::separator() + name; | ||||
|         if (debug) qDebug() << PDEBUG << ":" << "Remove file" << fileName << QFile::remove(fileName); | ||||
|         if (debug) qDebug() << PDEBUG << ":" << "Remove file" << fileName + QString(".conf") << | ||||
|                                QFile::remove(fileName + QString(".conf")); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| void ExtScript::writeConfiguration() | ||||
| { | ||||
|     if (debug) qDebug() << PDEBUG; | ||||
|  | ||||
| @ -58,6 +58,7 @@ public: | ||||
| public slots: | ||||
|     void readConfiguration(); | ||||
|     ScriptData run(const int time); | ||||
|     void tryDelete(); | ||||
|     void writeConfiguration(); | ||||
|  | ||||
| private: | ||||
|  | ||||
		Reference in New Issue
	
	Block a user