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>
|
||||
|
28
picture.cpp
28
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";
|
||||
@ -37,13 +48,13 @@ void Picture::fillList() {
|
||||
ui->fileList->clear();
|
||||
//ui->fileList->addItems(directory.entryList());
|
||||
foreach(const QString &str,directory.entryList()){
|
||||
QImageReader reader(directory.absolutePath()+"/"+str);
|
||||
if(!reader.format().isEmpty()){
|
||||
ui->fileList->addItem(str);
|
||||
}
|
||||
QImageReader reader(directory.absolutePath()+"/"+str);
|
||||
if(!reader.format().isEmpty()){
|
||||
ui->fileList->addItem(str);
|
||||
}
|
||||
}
|
||||
if(ui->fileList->count()==0){
|
||||
ui->fileList->addItem("<NO PICTURES>");
|
||||
ui->fileList->addItem("<NO PICTURES>");
|
||||
}
|
||||
}
|
||||
void Picture::on_cd_clicked(){
|
||||
@ -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
|
||||
|
153
picture.ui
153
picture.ui
@ -14,77 +14,118 @@
|
||||
<string>Picture</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<widget class="QTabWidget" name="tabField">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>1</y>
|
||||
<width>258</width>
|
||||
<height>229</height>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>301</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QListWidget" name="fileList"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<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>20</x>
|
||||
<y>20</y>
|
||||
<width>258</width>
|
||||
<height>229</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="cd">
|
||||
<widget class="QListWidget" name="fileList"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="cd">
|
||||
<property name="text">
|
||||
<string>Change Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refresh">
|
||||
<property name="text">
|
||||
<string>Refresh Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<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>Change Directory</string>
|
||||
<string>Erase Metadata</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="refresh">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Refresh Directory</string>
|
||||
<string>Label</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="erase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>10</y>
|
||||
<width>124</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Erase Metadata</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="log">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>60</y>
|
||||
<width>301</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="clearLog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>561</x>
|
||||
<y>222</y>
|
||||
<width>51</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</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>10</x>
|
||||
<y>10</y>
|
||||
<width>381</width>
|
||||
<height>192</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="clearLog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>220</y>
|
||||
<width>51</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
|
Loading…
Reference in New Issue
Block a user