Attempting QProcess execution
This commit is contained in:
parent
e5a1b2283e
commit
e1dbb7db6d
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 3.0.1, 2014-06-18T14:39:43. -->
|
||||
<!-- Written by QtCreator 3.0.1, 2014-06-18T20:10:29. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
18
picture.cpp
18
picture.cpp
@ -3,10 +3,21 @@ Picture::Picture(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::Picture){
|
||||
ui->setupUi(this);
|
||||
connect(&commandProcess,SIGNAL(readyReadStandardOutput()),this,SLOT(log()));
|
||||
connect(&commandProcess,SIGNAL(readyReadStandardError()),this,SLOT(log()));
|
||||
connect(ui->actionOpen_Files,SIGNAL(triggered()),this,SLOT(changeDirectory()));
|
||||
//changeDirectory();
|
||||
fillList();
|
||||
}
|
||||
void Picture::log(){
|
||||
QByteArray cmdoutput = commandProcess.readAllStandardOutput();
|
||||
QString txtoutput = cmdoutput;
|
||||
ui->log->append(txtoutput);
|
||||
cmdoutput = commandProcess.readAllStandardError();
|
||||
txtoutput = cmdoutput;
|
||||
ui->log->append(txtoutput);
|
||||
}
|
||||
|
||||
std::string exec(char* cmd) {
|
||||
FILE* pipe = popen(cmd, "r");
|
||||
if (!pipe) return "ERROR";
|
||||
@ -60,7 +71,8 @@ void Picture::on_erase_clicked(){
|
||||
char* a=new char[tmp2.size()+1];
|
||||
a[tmp2.size()]=0;
|
||||
memcpy(a,tmp2.c_str(),tmp2.size());
|
||||
exec(a);
|
||||
//exec(a);
|
||||
commandProcess.start(a);
|
||||
}else{
|
||||
if(!ignored){
|
||||
ignored=true;
|
||||
@ -73,10 +85,14 @@ void Picture::on_erase_clicked(){
|
||||
}
|
||||
void Picture::on_refresh_clicked(){
|
||||
fillList();
|
||||
ui->log->append("Refreshed directory");
|
||||
}
|
||||
void Picture::on_clearLog_clicked(){
|
||||
ui->log->setText("");
|
||||
ui->tabField->setCurrentIndex(0);
|
||||
}
|
||||
void Picture::on_erase_pressed(){
|
||||
ui->log->append("Erasing metadata from images...");
|
||||
ui->tabField->setCurrentIndex(1);
|
||||
on_erase_clicked();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QDebug>
|
||||
#include <QImageReader>
|
||||
#include <QDialog>
|
||||
#include <QProcess>
|
||||
|
||||
namespace Ui {
|
||||
class Picture;
|
||||
@ -34,8 +35,10 @@ private slots:
|
||||
void on_refresh_clicked();
|
||||
void on_clearLog_clicked();
|
||||
void on_erase_pressed();
|
||||
void log();
|
||||
private:
|
||||
Ui::Picture *ui;
|
||||
QDir directory;
|
||||
QProcess commandProcess;
|
||||
};
|
||||
#endif // PICTURE_H
|
||||
|
67
picture.ui
67
picture.ui
@ -14,11 +14,27 @@
|
||||
<string>Picture</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QTabWidget" name="tabField">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Commands</string>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>1</y>
|
||||
<x>20</x>
|
||||
<y>20</y>
|
||||
<width>258</width>
|
||||
<height>229</height>
|
||||
</rect>
|
||||
@ -47,26 +63,49 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="erase">
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>10</y>
|
||||
<width>124</width>
|
||||
<height>27</height>
|
||||
<x>300</x>
|
||||
<y>60</y>
|
||||
<width>107</width>
|
||||
<height>62</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="erase">
|
||||
<property name="text">
|
||||
<string>Erase Metadata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<zorder>fileList</zorder>
|
||||
<zorder>fileList</zorder>
|
||||
<zorder>layoutWidget</zorder>
|
||||
<zorder>erase</zorder>
|
||||
<zorder>pushButton</zorder>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Log</string>
|
||||
</attribute>
|
||||
<widget class="QTextEdit" name="log">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>60</y>
|
||||
<width>301</width>
|
||||
<height>191</height>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
@ -76,8 +115,8 @@
|
||||
<widget class="QPushButton" name="clearLog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>561</x>
|
||||
<y>222</y>
|
||||
<x>270</x>
|
||||
<y>220</y>
|
||||
<width>51</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
@ -87,6 +126,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
Loading…
Reference in New Issue
Block a user