diff options
author | Ken Moore <ken@pcbsd.org> | 2015-04-27 15:07:28 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-04-27 15:07:28 -0400 |
commit | d590979dba8ee6f23d91b1c0b1b8e092c4e68454 (patch) | |
tree | 6e6807820f2394764615e7788ee68d82baa75f91 | |
parent | Setup the lumina-desktop to use the new favorites system: (diff) | |
parent | Add two new keybard shortcuts to the default Fluxbox setting: (diff) | |
download | lumina-d590979dba8ee6f23d91b1c0b1b8e092c4e68454.tar.gz lumina-d590979dba8ee6f23d91b1c0b1b8e092c4e68454.tar.bz2 lumina-d590979dba8ee6f23d91b1c0b1b8e092c4e68454.zip |
Merge branch 'master' of github.com:pcbsd/lumina
-rw-r--r-- | lumina-desktop/fluxboxconf/fluxbox-keys | 4 | ||||
-rw-r--r-- | lumina-fileinfo/dialog.cpp | 543 | ||||
-rw-r--r-- | lumina-fileinfo/dialog.h | 44 | ||||
-rw-r--r-- | lumina-fileinfo/lumina-fileinfo.pro | 2 | ||||
-rw-r--r-- | lumina-fileinfo/main.cpp | 32 | ||||
-rw-r--r-- | lumina-fm/MainUI.cpp | 5 | ||||
-rw-r--r-- | lumina-fm/MainUI.h | 1 | ||||
-rw-r--r-- | lumina-fm/MainUI.ui | 9 | ||||
-rw-r--r-- | lumina-search/ConfigUI.cpp | 2 | ||||
-rw-r--r-- | lumina-search/ConfigUI.h | 1 | ||||
-rw-r--r-- | lumina-search/ConfigUI.ui | 37 | ||||
-rw-r--r-- | lumina-search/MainUI.cpp | 52 | ||||
-rw-r--r-- | lumina-search/MainUI.h | 9 | ||||
-rw-r--r-- | lumina-search/main.cpp | 44 |
14 files changed, 458 insertions, 327 deletions
diff --git a/lumina-desktop/fluxboxconf/fluxbox-keys b/lumina-desktop/fluxboxconf/fluxbox-keys index 4d78efcb..f0ec3519 100644 --- a/lumina-desktop/fluxboxconf/fluxbox-keys +++ b/lumina-desktop/fluxboxconf/fluxbox-keys @@ -58,6 +58,10 @@ Mod1 Shift Tab :PrevWindow {groups} (workspace=[current]) (workspace=[current]) Mod4 Tab :NextTab Mod4 Shift Tab :PrevTab +# Arrange/Tile Current windows +Mod4 Left :ArrangeWindowsStackRight (Layer=Normal) +Mod4 Right :ArrangeWindowsStackLeft (Layer=Normal) + # go to a specific tab in the current window Mod4 1 :Tab 1 Mod4 2 :Tab 2 diff --git a/lumina-fileinfo/dialog.cpp b/lumina-fileinfo/dialog.cpp index 0444a390..19e935ad 100644 --- a/lumina-fileinfo/dialog.cpp +++ b/lumina-fileinfo/dialog.cpp @@ -13,354 +13,347 @@ //we just change the required lines and we don't touch to the rest of the file and copy it back. void Dialog::textReplace(QString &origin, QString from, QString to, QString topic) { - if (origin.contains(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive))) { - origin.replace(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive),"\n" + topic + "=" + to + "\n"); - } else { - origin.append(topic + "=" + to + "\n"); - } + if (origin.contains(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive))) { + origin.replace(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive),"\n" + topic + "=" + to + "\n"); + } else { + origin.append(topic + "=" + to + "\n"); + } } //get the template from the user home directory or from the qrc files void Dialog::copyTemplate(QString templateType) { - if ((templateType == "-link") or (templateType == "-app")) { - if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template")) { - //We take the template from homedir - QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template", desktopFileName); - } else { - //last possibility is to use the qrc template. - //But based on the initialisation, this should never occurs - QFile::copy(":defaults/fileinfo" + templateType + ".template", desktopFileName); - } - } else { - //error message for developpers - qDebug() << "copyTemplate only accept '-link' or '-app' as parameter"; - } + if ((templateType == "-link") or (templateType == "-app")) { + if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template")) { + //We take the template from homedir + QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template", desktopFileName); + } else { + //last possibility is to use the qrc template. + //But based on the initialisation, this should never occurs + QFile::copy(":defaults/fileinfo" + templateType + ".template", desktopFileName); + } + } else { + //error message for developpers + qDebug() << "copyTemplate only accept '-link' or '-app' as parameter"; + } } Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) + QDialog(parent), + ui(new Ui::Dialog) { - ui->setupUi(this); - desktopType="Application"; //default value - - //Setup all the icons using libLumina - setupIcons(); - - //we copy qrc templates in the home dir of the user. - //this allow the user to adapt those template to is own whishes - QString templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template"; - if (!QFile::exists(templateFile)) { - QFile::copy(":defaults/fileinfo-link.template", templateFile); - QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); - } - templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template"; - if (!QFile::exists(templateFile)) { - QFile::copy(":defaults/fileinfo-app.template", templateFile); - QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); - } + ui->setupUi(this); + desktopType="Application"; //default value + + //Setup all the icons using libLumina + setupIcons(); + + //we copy qrc templates in the home dir of the user. + //this allow the user to adapt those template to is own whishes + QString templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-link.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } + templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-app.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } } Dialog::~Dialog() { - delete ui; + delete ui; } void Dialog::setupIcons(){ - this->setWindowIcon( LXDG::findIcon("unknown","") ); - ui->pbWorkingDir->setIcon( LXDG::findIcon("folder","") ); - ui->pbCommand->setIcon( LXDG::findIcon("system-search","") ); + this->setWindowIcon( LXDG::findIcon("unknown","") ); + ui->pbWorkingDir->setIcon( LXDG::findIcon("folder","") ); + ui->pbCommand->setIcon( LXDG::findIcon("system-search","") ); } //Inform the user that required input parameters are missing void Dialog::MissingInputs() { - qDebug() << "We cannot continue without a desktop file !!!"; - QMessageBox::critical(this, tr("Error"), tr("Lumina-fileinfo requires inputs:")+"\n"+QString(tr("Example: \"%1\"")).arg("lumina-fileinfo <-application>|<-link> desktopfile") ); - exit(1); + qDebug() << "We cannot continue without a desktop file !!!"; + QMessageBox::critical(this, tr("Error"), tr("Lumina-fileinfo requires inputs:")+"\n"+QString(tr("Example: \"%1\"")).arg("lumina-fileinfo <-application>|<-link> desktopfile") ); + exit(1); } //Initialise the layout of the screen. void Dialog::Initialise(QString param) { - - //in case of "link", several objects are no required - if (param.startsWith("-link")) { - ui->cbRunInTerminal->setVisible(false); - ui->cbStartupNotification->setVisible(false); - ui->lCommand->setVisible(false); - ui->pbCommand->setVisible(false); - ui->lblCommand->setVisible(false); - ui->lblOptions->setVisible(false); - ui->lblWorkingDir->setText(tr("URL")); //we use the WorkingDir boxes for URL - desktopType="link"; - } - if (param.startsWith("-app")) { - ui->cbRunInTerminal->setVisible(true); - ui->cbStartupNotification->setVisible(true); - ui->lCommand->setVisible(true); - ui->pbCommand->setVisible(true); - ui->lblCommand->setVisible(true); - ui->lblOptions->setVisible(true); - ui->lblWorkingDir->setText(tr("Working dir")); - desktopType="app"; - } + //in case of "link", several objects are no required + if (param.startsWith("-link")) { + ui->cbRunInTerminal->setVisible(false); + ui->cbStartupNotification->setVisible(false); + ui->lCommand->setVisible(false); + ui->pbCommand->setVisible(false); + ui->lblCommand->setVisible(false); + ui->lblOptions->setVisible(false); + ui->lblWorkingDir->setText(tr("URL")); //we use the WorkingDir boxes for URL + desktopType="link"; + } + if (param.startsWith("-app")) { + ui->cbRunInTerminal->setVisible(true); + ui->cbStartupNotification->setVisible(true); + ui->lCommand->setVisible(true); + ui->pbCommand->setVisible(true); + ui->lblCommand->setVisible(true); + ui->lblOptions->setVisible(true); + ui->lblWorkingDir->setText(tr("Working dir")); + desktopType="app"; + } } - - - //load the desktop file or the required template void Dialog::LoadDesktopFile(QString input) { - //if we have "-" as 1st char, it means that this is not a desktop file, but a parameter - desktopFileName = input; - if (input.startsWith("-")) { - QMessageBox::critical(this,tr("Error"),tr("The filename cannot start with a \"-\".")); - exit(1); - } - - //if proposed file does not exist, than we will create one based on the templates - if (!QFile::exists(input)) { - if (desktopType=="link") { - copyTemplate("-link"); - } else { - copyTemplate("-app"); - } + //if we have "-" as 1st char, it means that this is not a desktop file, but a parameter + desktopFileName = input; + if (input.startsWith("-")) { + QMessageBox::critical(this,tr("Error"),tr("The filename cannot start with a \"-\".")); + exit(1); + } + //if proposed file does not exist, than we will create one based on the templates + if (!QFile::exists(input)) { + if (desktopType=="link") { + copyTemplate("-link"); + } else { + copyTemplate("-app"); } - - //use the standard LXDG object and load the desktop file - bool ok = false; - if(desktopFileName.endsWith(".desktop")){ - DF = LXDG::loadDesktopFile(desktopFileName, ok); + } + + //use the standard LXDG object and load the desktop file + bool ok = false; + if(desktopFileName.endsWith(".desktop")){ + DF = LXDG::loadDesktopFile(desktopFileName, ok); + } + if( ok ) { + if ((DF.type == XDGDesktop::LINK) && (desktopType!="link" )) { + //we open a desktop type "link" but it was not mentionned by parameters + Dialog::Initialise("-link"); } - if( ok ) { - if ((DF.type == XDGDesktop::LINK) && (desktopType!="link" )) { - //we open a desktop type "link" but it was not mentionned by parameters - Dialog::Initialise("-link"); - } - ui->lName->setText(DF.name); - ui->lComment->setText(DF.comment); - ui->lCommand->setText(DF.exec); - //in case of "link" desktop, we populate the correct content in lWorkingDir - if (desktopType=="link") { - ui->lWorkingDir->setText(DF.url); - } else { - ui->lWorkingDir->setText(DF.path); - } - if (DF.startupNotify) ui->cbStartupNotification->setChecked(true); else ui->cbStartupNotification->setChecked(false); - if (DF.useTerminal) ui->cbRunInTerminal->setChecked(true); else ui->cbRunInTerminal->setChecked(false); - iconFileName=""; - ui->pbIcon->setIcon(LXDG::findIcon(DF.icon,"")); - this->setWindowTitle(DF.filePath.section("/",-1)); + ui->lName->setText(DF.name); + ui->lComment->setText(DF.comment); + ui->lCommand->setText(DF.exec); + //in case of "link" desktop, we populate the correct content in lWorkingDir + if (desktopType=="link") { + ui->lWorkingDir->setText(DF.url); } else { - QMessageBox::critical(this, tr("Error"), tr("Invalid File Supplied:") +"\n"+desktopFileName ); - exit(1); + ui->lWorkingDir->setText(DF.path); } - - //we load the file in memory and will adapt it before saving it to disk - QFile file(desktopFileName); - inMemoryFile=""; - if (file.open(QFile::ReadOnly)) { - QTextStream fileData(&file); - inMemoryFile = fileData.readAll(); - file.close(); - //perform some validation checks - //TODO: put those Regex in a config file. - //this will allow checks improvements without compilation of the file - if ((inMemoryFile.contains(QRegExp(".*\\[Desktop Entry\\].*\n"))) && - (inMemoryFile.contains(QRegExp("\n\\s*Type\\s*=.*\n"))) && - (inMemoryFile.contains(QRegExp("\n\\s*Name\\s*=.*\n")))) { - //qDebug() << "sounds a good file"; - } else { - //qDebug() << "wrong file!!!!"; - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Question); - msgBox.setText(tr("There are some issues with this file !!!!")); - msgBox.setInformativeText(tr("Either you correct this file your self with an editor, or you start from scratch using the link or app template.\nPlease note that this process will update the file called:") + desktopFileName); - QPushButton *linkButton = msgBox.addButton("Link",QMessageBox::AcceptRole); - QPushButton *appButton = msgBox.addButton("App",QMessageBox::ResetRole); - QPushButton *cancelButton = msgBox.addButton("Cancel",QMessageBox::NoRole); - msgBox.exec(); - if (msgBox.clickedButton() == linkButton) { - QFile::remove(desktopFileName); - copyTemplate("-link"); - Initialise("-link"); - LoadDesktopFile(desktopFileName); - } - if (msgBox.clickedButton() == appButton) { - QFile::remove(desktopFileName); - copyTemplate("-app"); - Initialise("-app"); - LoadDesktopFile(desktopFileName); - } - if (msgBox.clickedButton() == cancelButton) { - //we stop here - exit(0); - } - } + if (DF.startupNotify) ui->cbStartupNotification->setChecked(true); else ui->cbStartupNotification->setChecked(false); + if (DF.useTerminal) ui->cbRunInTerminal->setChecked(true); else ui->cbRunInTerminal->setChecked(false); + iconFileName=""; + ui->pbIcon->setIcon(LXDG::findIcon(DF.icon,"")); + this->setWindowTitle(DF.filePath.section("/",-1)); + } else { + QMessageBox::critical(this, tr("Error"), tr("Invalid File Supplied:") +"\n"+desktopFileName ); + exit(1); + } + + //we load the file in memory and will adapt it before saving it to disk + QFile file(desktopFileName); + inMemoryFile=""; + if (file.open(QFile::ReadOnly)) { + QTextStream fileData(&file); + inMemoryFile = fileData.readAll(); + file.close(); + //perform some validation checks + //this will allow checks improvements without compilation of the file + if ((inMemoryFile.contains(QRegExp(".*\\[Desktop Entry\\].*\n"))) && + (inMemoryFile.contains(QRegExp("\n\\s*Type\\s*=.*\n"))) && + (inMemoryFile.contains(QRegExp("\n\\s*Name\\s*=.*\n")))) { + //qDebug() << "sounds a good file"; + } else { + //qDebug() << "wrong file!!!!"; + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("There are some issues with this file !!!!")); + msgBox.setInformativeText(tr("Either you correct this file your self with an editor, or you start from scratch using the link or app template.\nPlease note that this process will update the file called:") + desktopFileName); + QPushButton *linkButton = msgBox.addButton("Link",QMessageBox::AcceptRole); + QPushButton *appButton = msgBox.addButton("App",QMessageBox::ResetRole); + QPushButton *cancelButton = msgBox.addButton("Cancel",QMessageBox::NoRole); + msgBox.exec(); + if (msgBox.clickedButton() == linkButton) { + QFile::remove(desktopFileName); + copyTemplate("-link"); + Initialise("-link"); + LoadDesktopFile(desktopFileName); + } + if (msgBox.clickedButton() == appButton) { + QFile::remove(desktopFileName); + copyTemplate("-app"); + Initialise("-app"); + LoadDesktopFile(desktopFileName); + } + if (msgBox.clickedButton() == cancelButton) { + //we stop here + exit(0); + } } + } } void Dialog::on_pbCommand_clicked() { - //the default directory is the user's home directory - QString commandFolder = QDir::homePath(); - if (!ui->lCommand->text().isEmpty()) commandFolder = ui->lCommand->text().section('/', 0, -2); - if (commandFolder.isEmpty()) commandFolder = QDir::homePath(); - - QString fileName = QFileDialog::getOpenFileName(this, + //the default directory is the user's home directory + QString commandFolder = QDir::homePath(); + if (!ui->lCommand->text().isEmpty()) commandFolder = ui->lCommand->text().section('/', 0, -2); + if (commandFolder.isEmpty()) commandFolder = QDir::homePath(); + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open command"), commandFolder, tr("All Files (*)")); - if (!fileName.isEmpty()) { - ui->lCommand->setText(fileName); - ui->lCommand->setModified(true); - } + if (!fileName.isEmpty()) { + ui->lCommand->setText(fileName); + ui->lCommand->setModified(true); + } } void Dialog::on_pbWorkingDir_clicked() { - //the default directory is / - QString workingDir = "/"; - if (ui->lWorkingDir->text().isEmpty()) workingDir = "/"; - else workingDir = ui->lWorkingDir->text(); - QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; - QString directory = QFileDialog::getExistingDirectory(this, + //the default directory is / + QString workingDir = "/"; + if (ui->lWorkingDir->text().isEmpty()) workingDir = "/"; + else workingDir = ui->lWorkingDir->text(); + QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; + QString directory = QFileDialog::getExistingDirectory(this, tr("Working Directory"), workingDir, options); - if (!directory.isEmpty()) { - ui->lWorkingDir->setText(directory); - ui->lWorkingDir->setModified(true); - } + if (!directory.isEmpty()) { + ui->lWorkingDir->setText(directory); + ui->lWorkingDir->setModified(true); + } } //we save the changes to the destination file void Dialog::on_pbApply_clicked() { - QString from,to; - QString desktopTypeVal="Application"; - if (DF.type == XDGDesktop::APP) { desktopTypeVal="Application"; } - else if (DF.type == XDGDesktop::LINK) { desktopTypeVal="Link"; } - else if (DF.type == XDGDesktop::DIR) { desktopTypeVal="Dir"; } - textReplace(inMemoryFile, desktopTypeVal, desktopType, "Type"); - - if (ui->lName->isModified()) { textReplace(inMemoryFile, DF.name, ui->lName->text(), "Name");} - if (ui->lComment->isModified()) { textReplace(inMemoryFile, DF.comment, ui->lComment->text(), "Comment");} - if (ui->lCommand->isModified()) { textReplace(inMemoryFile, DF.exec, ui->lCommand->text(),"Exec");} - if (desktopType=="link") { - //incase of "link" layout WorkingDir is corresponding to the URL - if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.url, ui->lWorkingDir->text(),"URL");} - } else { - if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.path, ui->lWorkingDir->text(),"Path");} - } - if (ui->cbStartupNotification->isChecked() != DF.startupNotify) { - if (DF.startupNotify) {from="true"; to="false";} else {from="false"; to="true";} - textReplace(inMemoryFile, from, to,"StartupNotify"); - } - if (ui->cbRunInTerminal->isChecked() != DF.useTerminal) { - if (DF.useTerminal) {from="true"; to="false";} else {from="false"; to="true";} - textReplace(inMemoryFile, from, to,"Terminal"); - } - if (!iconFileName.isEmpty()) { - from=DF.icon; - to=iconFileName; - textReplace(inMemoryFile, from, to,"Icon"); - } - - QFile file(desktopFileName); - if (file.open(QFile::ReadWrite)) { - file.seek(0); - file.write(inMemoryFile.toUtf8()); - - file.resize(file.pos());//remove possible trailing lines - - file.close(); - } else { - //problem to write to the disk - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to write the adapted desktop file to the disk. Can you re-try the modification after solving the issue with the disk ?")); - } - - //hack required to update the icon on the desktop - QTemporaryFile tempFile ; - tempFile.setAutoRemove(false); - tempFile.setFileTemplate("/tmp/lumina-XXXXXX"); - tempFile.open(); - tempFile.close(); - - QString cmd = "mv"; - cmd = cmd + " " + desktopFileName + " " + tempFile.fileName(); - int ret = LUtils::runCmd(cmd); - if (ret !=0 ) { - qDebug() << "Problem to execute:" << cmd; - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); - - } - - cmd = "mv"; - cmd = cmd + " " + tempFile.fileName() + " " + desktopFileName; - ret = LUtils::runCmd(cmd); - if (ret !=0 ) { - qDebug() << "Problem to execute:" << cmd; - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); - } + QString from,to; + QString desktopTypeVal="Application"; + if (DF.type == XDGDesktop::APP) { desktopTypeVal="Application"; } + else if (DF.type == XDGDesktop::LINK) { desktopTypeVal="Link"; } + else if (DF.type == XDGDesktop::DIR) { desktopTypeVal="Dir"; } + textReplace(inMemoryFile, desktopTypeVal, desktopType, "Type"); + + if (ui->lName->isModified()) { textReplace(inMemoryFile, DF.name, ui->lName->text(), "Name");} + if (ui->lComment->isModified()) { textReplace(inMemoryFile, DF.comment, ui->lComment->text(), "Comment");} + if (ui->lCommand->isModified()) { textReplace(inMemoryFile, DF.exec, ui->lCommand->text(),"Exec");} + if (desktopType=="link") { + //incase of "link" layout WorkingDir is corresponding to the URL + if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.url, ui->lWorkingDir->text(),"URL");} + } else { + if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.path, ui->lWorkingDir->text(),"Path");} + } + if (ui->cbStartupNotification->isChecked() != DF.startupNotify) { + if (DF.startupNotify) {from="true"; to="false";} else {from="false"; to="true";} + textReplace(inMemoryFile, from, to,"StartupNotify"); + } + if (ui->cbRunInTerminal->isChecked() != DF.useTerminal) { + if (DF.useTerminal) {from="true"; to="false";} else {from="false"; to="true";} + textReplace(inMemoryFile, from, to,"Terminal"); + } + if (!iconFileName.isEmpty()) { + from=DF.icon; + to=iconFileName; + textReplace(inMemoryFile, from, to,"Icon"); + } + + QFile file(desktopFileName); + if (file.open(QFile::ReadWrite)) { + file.seek(0); + file.write(inMemoryFile.toUtf8()); + + file.resize(file.pos());//remove possible trailing lines + + file.close(); + } else { + //problem to write to the disk + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to write the adapted desktop file to the disk. Can you re-try the modification after solving the issue with the disk ?")); + } + + //hack required to update the icon on the desktop + QTemporaryFile tempFile ; + tempFile.setAutoRemove(false); + tempFile.setFileTemplate("/tmp/lumina-XXXXXX"); + tempFile.open(); + tempFile.close(); + + QString cmd = "mv"; + cmd = cmd + " " + desktopFileName + " " + tempFile.fileName(); + int ret = LUtils::runCmd(cmd); + if (ret !=0 ) { + qDebug() << "Problem to execute:" << cmd; + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); + } + + cmd = "mv"; + cmd = cmd + " " + tempFile.fileName() + " " + desktopFileName; + ret = LUtils::runCmd(cmd); + if (ret !=0 ) { + qDebug() << "Problem to execute:" << cmd; + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); + } } void Dialog::on_pbIcon_clicked() { - //the default directory is local/share/icons - QString iconFolder = LOS::AppPrefix()+"/share/icons"; - if (!iconFileName.isEmpty()) iconFolder = iconFileName.section('/', 0, -2); - else if (!DF.icon.isEmpty()) iconFolder = DF.icon.section('/', 0, -2); - if (iconFolder.isEmpty()) iconFolder = LOS::AppPrefix()+"/share/icons"; - - QString fileName = QFileDialog::getOpenFileName(this, + //the default directory is local/share/icons + QString iconFolder = LOS::AppPrefix()+"/share/icons"; + if (!iconFileName.isEmpty()) iconFolder = iconFileName.section('/', 0, -2); + else if (!DF.icon.isEmpty()) iconFolder = DF.icon.section('/', 0, -2); + if (iconFolder.isEmpty()) iconFolder = LOS::AppPrefix()+"/share/icons"; + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open command"), iconFolder, tr("Image Files (*.png *.jpg *.bmp)")); - if (!fileName.isEmpty()) { - ui->pbIcon->setIcon(QPixmap(fileName)); - iconFileName=fileName; - } + if (!fileName.isEmpty()) { + ui->pbIcon->setIcon(QPixmap(fileName)); + iconFileName=fileName; + } } void Dialog::on_lName_textChanged(QString text) { - if (text != DF.name && inMemoryFile.contains(QRegExp("\nName\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { - QMessageBox msgBox; - msgBox.setText(tr("By modifying this value, you will loose all translated versions")); - msgBox.setInformativeText(tr("The field: Name is translated in several other languages. If you want to continue, you will loose all translated versions")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - int answer = msgBox.exec(); - if (answer==QMessageBox::Ok) { - //remove all translated versions. The lang cannot be null, but the value can be. - inMemoryFile.replace(QRegExp("\nName\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); - } else { - ui->lName->setText(DF.name); - } - } + if (text != DF.name && inMemoryFile.contains(QRegExp("\nName\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { + QMessageBox msgBox; + msgBox.setText(tr("By modifying this value, you will loose all translated versions")); + msgBox.setInformativeText(tr("The field: Name is translated in several other languages. If you want to continue, you will loose all translated versions")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + int answer = msgBox.exec(); + if (answer==QMessageBox::Ok) { + //remove all translated versions. The lang cannot be null, but the value can be. + inMemoryFile.replace(QRegExp("\nName\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); + } else { + ui->lName->setText(DF.name); + } + } } void Dialog::on_lComment_textChanged(QString text) { - if (text != DF.name && inMemoryFile.contains(QRegExp("\nComment\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { - QMessageBox msgBox; - msgBox.setText(tr("By modifying this value, you will loose all translated versions")); - msgBox.setInformativeText(tr("The field: Comment is translated in several other languages. If you want to continue, you will loose all translated versions")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - int answer = msgBox.exec(); - if (answer==QMessageBox::Ok) { - //remove all translated versions. The lang cannot be null, but the value can be. - inMemoryFile.replace(QRegExp("\nComment\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); - } else { - ui->lName->setText(DF.comment); - } - } + if (text != DF.name && inMemoryFile.contains(QRegExp("\nComment\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { + QMessageBox msgBox; + msgBox.setText(tr("By modifying this value, you will loose all translated versions")); + msgBox.setInformativeText(tr("The field: Comment is translated in several other languages. If you want to continue, you will loose all translated versions")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + int answer = msgBox.exec(); + if (answer==QMessageBox::Ok) { + //remove all translated versions. The lang cannot be null, but the value can be. + inMemoryFile.replace(QRegExp("\nComment\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); + } else { + ui->lName->setText(DF.comment); + } + } } diff --git a/lumina-fileinfo/dialog.h b/lumina-fileinfo/dialog.h index 6f0a4dbf..785cb52e 100644 --- a/lumina-fileinfo/dialog.h +++ b/lumina-fileinfo/dialog.h @@ -10,42 +10,42 @@ class Dialog; class Dialog : public QDialog { - Q_OBJECT - + Q_OBJECT + public: - explicit Dialog(QWidget *parent = 0); + explicit Dialog(QWidget *parent = 0); - XDGDesktop DF ; - QString inMemoryFile; + XDGDesktop DF ; + QString inMemoryFile; - QString desktopFileName ; - QString iconFileName; - QString desktopType; + QString desktopFileName ; + QString iconFileName; + QString desktopType; - void Initialise(QString); - void MissingInputs(); - void LoadDesktopFile(QString); + void Initialise(QString); + void MissingInputs(); + void LoadDesktopFile(QString); - ~Dialog(); + ~Dialog(); public slots: - void setupIcons(); + void setupIcons(); private slots: - void on_pbCommand_clicked(); - void on_pbWorkingDir_clicked(); - void on_pbApply_clicked(); - void on_pbIcon_clicked(); + void on_pbCommand_clicked(); + void on_pbWorkingDir_clicked(); + void on_pbApply_clicked(); + void on_pbIcon_clicked(); - void textReplace(QString &origin, QString from, QString to, QString topic); - void copyTemplate(QString templateType); + void textReplace(QString &origin, QString from, QString to, QString topic); + void copyTemplate(QString templateType); - void on_lName_textChanged(QString text); - void on_lComment_textChanged(QString text); + void on_lName_textChanged(QString text); + void on_lComment_textChanged(QString text); private: - Ui::Dialog *ui; + Ui::Dialog *ui; }; #endif // DIALOG_H diff --git a/lumina-fileinfo/lumina-fileinfo.pro b/lumina-fileinfo/lumina-fileinfo.pro index b565818d..c90dd5a4 100644 --- a/lumina-fileinfo/lumina-fileinfo.pro +++ b/lumina-fileinfo/lumina-fileinfo.pro @@ -100,7 +100,7 @@ TRANSLATIONS = i18n/lumina-fileinfo_af.ts \ i18n/lumina-fileinfo_zh_CN.ts \ i18n/lumina-fileinfo_zh_HK.ts \ i18n/lumina-fileinfo_zh_TW.ts \ - i18n/lumina-fileinfo_zu.ts + i18n/lumina-fileinfo_zu.ts dotrans.path=$$PREFIX/share/Lumina-DE/i18n/ dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$$PREFIX/share/Lumina-DE/i18n/ diff --git a/lumina-fileinfo/main.cpp b/lumina-fileinfo/main.cpp index 59e86623..5f6a0d57 100644 --- a/lumina-fileinfo/main.cpp +++ b/lumina-fileinfo/main.cpp @@ -9,22 +9,22 @@ int main(int argc, char ** argv) { - QApplication a(argc, argv); - LUtils::LoadTranslation(&a, "lumina-fileinfo"); - LuminaThemeEngine theme(&a); + QApplication a(argc, argv); + LUtils::LoadTranslation(&a, "lumina-fileinfo"); + LuminaThemeEngine theme(&a); - Dialog w; - QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); - if (argc==2) { - w.LoadDesktopFile(QString(argv[1]).simplified()); - } else if (argc==3) { - w.Initialise(QString(argv[1]).simplified()); - w.LoadDesktopFile(QString(argv[2]).simplified()); - } else { - w.MissingInputs(); - } - w.show(); + Dialog w; + QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); + if (argc==2) { + w.LoadDesktopFile(QString(argv[1]).simplified()); + } else if (argc==3) { + w.Initialise(QString(argv[1]).simplified()); + w.LoadDesktopFile(QString(argv[2]).simplified()); + } else { + w.MissingInputs(); + } + w.show(); - int retCode = a.exec(); - return retCode; + int retCode = a.exec(); + return retCode; }
\ No newline at end of file diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 7f1e5fcc..95c4af4e 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -162,6 +162,7 @@ void MainUI::setupIcons(){ ui->actionBackToBrowser->setIcon( LXDG::findIcon("go-previous","") ); ui->actionManage_Bookmarks->setIcon( LXDG::findIcon("bookmarks-organize","") ); ui->actionScan->setIcon( LXDG::findIcon("system-search","") ); + ui->actionSearch->setIcon( LXDG::findIcon("edit-find","") ); //Browser page ui->tool_addNewFile->setIcon( LXDG::findIcon("document-new","")); @@ -679,6 +680,10 @@ void MainUI::on_actionNew_Tab_triggered(){ tabBar->setCurrentIndex(tabBar->count()-1); } +void MainUI::on_actionSearch_triggered(){ + QProcess::startDetached("lumina-search -dir \""+getCurrentDir()+"\""); +} + void MainUI::on_actionClose_triggered(){ if(tabBar->count() > 1){ if(QMessageBox::Yes != QMessageBox::question(this, tr("Verify Quit"), tr("You have multiple tabs open. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) ){ diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index b18d25a5..345e2dd4 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -140,6 +140,7 @@ private slots: //Menu Actions void on_actionNew_Tab_triggered(); + void on_actionSearch_triggered(); void on_actionClose_triggered(); void on_actionView_Hidden_Files_triggered(); void on_actionShow_Action_Buttons_triggered(); diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui index 4b2156c2..9ef367d7 100644 --- a/lumina-fm/MainUI.ui +++ b/lumina-fm/MainUI.ui @@ -1113,6 +1113,7 @@ <string>File</string> </property> <addaction name="actionNew_Tab"/> + <addaction name="actionSearch"/> <addaction name="separator"/> <addaction name="actionClose"/> </widget> @@ -1297,6 +1298,14 @@ <string>Load Thumbnails</string> </property> </action> + <action name="actionSearch"> + <property name="text"> + <string>Search Directory</string> + </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/lumina-search/ConfigUI.cpp b/lumina-search/ConfigUI.cpp index ada82946..18480984 100644 --- a/lumina-search/ConfigUI.cpp +++ b/lumina-search/ConfigUI.cpp @@ -24,6 +24,7 @@ ConfigUI::ConfigUI(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigUI){ ui->tool_getStartDir->setIcon( LXDG::findIcon("folder","") ); ui->tool_adddirs->setIcon( LXDG::findIcon("list-add","") ); ui->tool_rmdir->setIcon( LXDG::findIcon("list-remove","") ); + newDefaults = false; } ConfigUI::~ConfigUI(){ @@ -74,6 +75,7 @@ void ConfigUI::on_buttonBox_accepted(){ } dirs.removeDuplicates(); newSkipDirs = dirs; + newDefaults = ui->check_setDefaults->isChecked(); this->close(); } diff --git a/lumina-search/ConfigUI.h b/lumina-search/ConfigUI.h index 0ee385c5..173fd6c7 100644 --- a/lumina-search/ConfigUI.h +++ b/lumina-search/ConfigUI.h @@ -21,6 +21,7 @@ public: QString newStartDir; QStringList newSkipDirs; + bool newDefaults; private: Ui::ConfigUI *ui; diff --git a/lumina-search/ConfigUI.ui b/lumina-search/ConfigUI.ui index 95d3a4ad..6a3060e0 100644 --- a/lumina-search/ConfigUI.ui +++ b/lumina-search/ConfigUI.ui @@ -112,11 +112,38 @@ </widget> </item> <item row="3" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="check_setDefaults"> + <property name="text"> + <string>Save as Defaults</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> diff --git a/lumina-search/MainUI.cpp b/lumina-search/MainUI.cpp index 6597f589..8f90d536 100644 --- a/lumina-search/MainUI.cpp +++ b/lumina-search/MainUI.cpp @@ -47,7 +47,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ settings = new QSettings("LuminaDE", "lumina-search",this); searcher->startDir = settings->value("StartSearchDir", QDir::homePath()).toString(); searcher->skipDirs = settings->value("SkipSearchDirs", QStringList()).toStringList(); - + updateDefaultStatusTip(); this->show(); workthread->start(); QTimer::singleShot(0,this, SLOT(setupIcons()) ); @@ -67,6 +67,38 @@ void MainUI::setupIcons(){ ui->tool_configure->setIcon( LXDG::findIcon("configure","") ); } +// =============== +// PUBLIC FUNCTIONS (for input handling primarily) +// =============== +void MainUI::disableExcludes(){ + searcher->skipDirs.clear(); + updateDefaultStatusTip(); +} + +void MainUI::setSearchDirectory(QString path){ + ui->radio_files->setChecked(true); + searcher->startDir = path; + updateDefaultStatusTip(); +} + +void MainUI::setSearchTerm(QString text){ + ui->line_search->setText(text); +} + +//============== +// PRIVATE +//============== +void MainUI::updateDefaultStatusTip(){ + if(ui->radio_files->isChecked()){ + QString txt = tr("Search: %1 -- Smart: %2"); + QString dir = searcher->startDir; + dir.replace(QDir::homePath(), "~"); + QString smart = searcher->skipDirs.isEmpty() ? tr("Off"): tr("On"); + txt = txt.arg(dir,smart); + ui->statusbar->showMessage(txt); + } +} + //============== // PRIVATE SLOTS //============== @@ -90,19 +122,23 @@ void MainUI::searchTypeChanged(){ void MainUI::configureSearch(){ ConfigUI dlg(this); - dlg.loadInitialValues( searcher->startDir, searcher->skipDirs); + dlg.loadInitialValues( settings->value("StartSearchDir",QDir::homePath()).toString(), settings->value("SkipSearchDirs",QStringList()).toStringList()); dlg.exec(); if(dlg.newStartDir.isEmpty()){ return; }//cancelled QString startdir = dlg.newStartDir; QStringList skipdirs = dlg.newSkipDirs; - //Save these values for later - settings->setValue("StartSearchDir", startdir); - settings->setValue("SkipSearchDirs", skipdirs); - + //Save these values for later (if selected) + if(dlg.newDefaults){ + //save these values as the new defaults + settings->setValue("StartSearchDir", startdir); + settings->setValue("SkipSearchDirs", skipdirs); + } + //Set these values in the searcher searcher->startDir = startdir; searcher->skipDirs = skipdirs; + updateDefaultStatusTip(); } void MainUI::searchChanged(){ @@ -114,7 +150,7 @@ void MainUI::searchChanged(){ void MainUI::startSearch(){ ui->listWidget->clear(); stopSearch(); //just in case a search is still running - if(ui->line_search->text().isEmpty()){ return; } //nothing to search for + if(ui->line_search->text().isEmpty()){ updateDefaultStatusTip(); return; } //nothing to search for //emit the proper signal for the worker if(!workthread->isRunning()){ workthread->start(); } //make sure the thread is running @@ -153,6 +189,7 @@ void MainUI::stopSearch(){ searcher->StopSearch(); ui->tool_stop->setVisible(false); ui->tool_configure->setVisible(ui->radio_files->isChecked()); + updateDefaultStatusTip(); } void MainUI::searchMessage(QString msg){ @@ -162,4 +199,5 @@ void MainUI::searchMessage(QString msg){ void MainUI::searchFinished(){ ui->tool_stop->setVisible(false); ui->tool_configure->setVisible(ui->radio_files->isChecked()); + updateDefaultStatusTip(); } diff --git a/lumina-search/MainUI.h b/lumina-search/MainUI.h index cd4a1db7..0a9f4acb 100644 --- a/lumina-search/MainUI.h +++ b/lumina-search/MainUI.h @@ -29,8 +29,13 @@ public: MainUI(); ~MainUI(); + void disableExcludes(); + void setSearchDirectory(QString path); + void setSearchTerm(QString text); + public slots: void setupIcons(); + void startSearch(); //emit the proper signal for the worker private: Ui::MainUI *ui; @@ -39,6 +44,8 @@ private: Worker *searcher; QSettings *settings; + void updateDefaultStatusTip(); + private slots: //Button Slots void closeApplication(){ @@ -52,7 +59,7 @@ private slots: void searchChanged(); //for active searching while typing //Worker Interaction - void startSearch(); //emit the proper signal for the worker + //void startSearch(); //Moved to a public slot void foundSearchItem(QString path); //To get the worker's results void stopSearch(); void searchMessage(QString); diff --git a/lumina-search/main.cpp b/lumina-search/main.cpp index 305c388b..f03bf04a 100644 --- a/lumina-search/main.cpp +++ b/lumina-search/main.cpp @@ -8,6 +8,12 @@ #include <LuminaThemes.h> #include <LuminaUtils.h> +//==== INPUT FORMAT ==== +// lumina-search [-no-excludes] [-dir [directory]] [-search <term>] +// -no-excludes: Don't exclude anything from this search +// -dir [directory]: Setup a file/dir search within the current working dir (or specified dir) +// -search <term>: Start a search with the given term +//=================== int main(int argc, char ** argv) { //qDebug() << "Init App..."; @@ -21,6 +27,44 @@ int main(int argc, char ** argv) MainUI w; QObject::connect(&theme,SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.show(); + if(argc>1){ + bool startsearch = false; + for(int i=1; i<argc; i++){ + QString val = QString(argv[i]).toLower(); + if( val == "-no-excludes"){ w.disableExcludes(); } + else if(val=="-dir"){ + //Check the next input value for a directory path + QString dir; + if( argc>(i+1) ){ dir = QString(argv[i+1]); } + //Check the input for validity + if(dir.startsWith("-")){dir.clear(); } //not a directory, just another input + else if(!dir.startsWith("/")){ //not an absolute path + dir = QDir::currentPath()+"/"+dir; + QFileInfo info(dir); + if( !info.exists() || !info.isDir() ){ dir.clear(); } //invalid relative dir + } + + if(dir.isEmpty()){ dir= QDir::currentPath(); } //use the current directory + else{ i++; } //using the next input value - skip it for the next iteration + w.setSearchDirectory( dir ); + + }else if(val=="-search"){ + //Check the next input value for a text string + QString text; + if( argc>(i+1) ){ text = QString(argv[i+1]); } + //Check the input for validity + if( !text.isEmpty() ){ + i++; //using the next input value - skip it for the next iteration + w.setSearchTerm( text ); + startsearch = true; + } + } + }//end loop over inputs + if(startsearch){ + //A CLI search was requested, go ahead and start it now + QTimer::singleShot(10, &w, SLOT(startSearch())); + } + } //end check for input arguments return a.exec(); } |