From f55033465893e71970a9a11fa0a7c048d4014ab5 Mon Sep 17 00:00:00 2001 From: william Date: Fri, 6 Mar 2015 21:42:28 +0100 Subject: automatically display the correct folder when clicking on Icon button --- desktop-editor/dialog.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'desktop-editor') diff --git a/desktop-editor/dialog.cpp b/desktop-editor/dialog.cpp index 232e645c..e3aad0d3 100644 --- a/desktop-editor/dialog.cpp +++ b/desktop-editor/dialog.cpp @@ -94,6 +94,8 @@ void Dialog::LoadDesktopFile(QString input) void Dialog::on_pbCommand_clicked() { + //TODO: detect Command directory + QString fileName = QFileDialog::getOpenFileName(this, tr("Open command"), "~", tr("All Files (*)")); ui->lCommand->setText(fileName); @@ -177,17 +179,14 @@ void Dialog::on_pbApply_clicked() tempFile.setAutoRemove(false); tempFile.open(); tempFile.close(); - qDebug() << "temp file:" << tempFile.fileName(); //TODO: capture errors QString cmd = "mv"; cmd = cmd + " " + desktopFileName + " " + tempFile.fileName(); - qDebug() << "cmd:" << cmd; int ret = LUtils::runCmd(cmd); cmd = "mv"; cmd = cmd + " " + tempFile.fileName() + " " + desktopFileName; - qDebug() << "cmd:" << cmd; ret = LUtils::runCmd(cmd); } } @@ -195,8 +194,16 @@ void Dialog::on_pbApply_clicked() void Dialog::on_pbIcon_clicked() { + QString iconFolder="~"; + if (!iconFileName.isEmpty()) { + iconFolder = iconFileName.section('/', 0, -2); + } + else if (!DF.icon.isEmpty()) { + iconFolder = DF.icon.section('/', 0, -2); + } + QString fileName = QFileDialog::getOpenFileName(this, - tr("Open command"), "~", tr("Image Files (*.png *.jpg *.bmp)")); + tr("Open command"), iconFolder, tr("Image Files (*.png *.jpg *.bmp)")); qDebug() << "icon:" << fileName; ui->pbIcon->setIcon(QPixmap(fileName)); iconFileName=fileName; -- cgit