aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp144
1 files changed, 78 insertions, 66 deletions
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
index 56b72a3c..3e0150e2 100644
--- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
+++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp
@@ -11,10 +11,10 @@
#include <QFileDialog>
#include <QMessageBox>
-#include <LuminaUtils.h>
+#include <LUtils.h>
#include <LuminaOS.h>
-LFileInfo INFO = LFileInfo("");
+//LFileInfo INFO = LFileInfo("");
MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){
ui->setupUi(this); //load the designer form
@@ -22,10 +22,12 @@ MainUI::MainUI() : QDialog(), ui(new Ui::MainUI){
terminate_thread = false;
UpdateIcons(); //Set all the icons in the dialog
SetupConnections();
+ INFO = 0;
}
MainUI::~MainUI(){
terminate_thread = true;
+ if(INFO!=0){ delete INFO; }
}
//=============
@@ -35,74 +37,82 @@ void MainUI::LoadFile(QString path, QString type){
//Do the first file information tab
qDebug() << "Load File:" << path << type;
- INFO = LFileInfo(path);
- if(INFO.exists()){ canwrite = INFO.isWritable(); }
- else if(!INFO.filePath().isEmpty()){
+ INFO = new LFileInfo(path);
+ if(INFO->exists()){ canwrite = INFO->isWritable(); }
+ else if(!INFO->filePath().isEmpty()){
//See if the containing directory can be written
- QFileInfo chk(INFO.absolutePath());
- canwrite = (chk.isDir() && chk.isWritable());
+ //QFileInfo chk(INFO->absolutePath());
+ canwrite = (INFO->isDir() && INFO->isWritable());
}else{
canwrite = true; //no associated file yet
}
- if(!INFO.exists() && !type.isEmpty()){
+ if(!INFO->exists() && !type.isEmpty()){
//Set the proper type flag on the shortcut
- if(type=="APP"){ INFO.XDG()->type = XDGDesktop::APP; }
- else if(type=="LINK"){ INFO.XDG()->type = XDGDesktop::LINK; }
+ if(type=="APP"){ INFO->XDG()->type = XDGDesktop::APP; }
+ else if(type=="LINK"){ INFO->XDG()->type = XDGDesktop::LINK; }
}
//First load the general file information
- if(!INFO.filePath().isEmpty()){
- ui->label_file_name->setText( INFO.fileName() );
- ui->label_file_mimetype->setText( INFO.mimetype() );
- if(!INFO.isDir()){ ui->label_file_size->setText( LUtils::BytesToDisplaySize( INFO.size() ) ); }
+ if(!INFO->filePath().isEmpty()){
+ ui->label_file_name->setText( INFO->fileName() );
+ ui->label_file_mimetype->setText( INFO->mimetype() );
+ if(!INFO->isDir()){ ui->label_file_size->setText( LUtils::BytesToDisplaySize( INFO->size() ) ); }
else {
ui->label_file_size->setText(tr("---Calculating---"));
- QtConcurrent::run(this, &MainUI::GetDirSize, INFO.absoluteFilePath());
+ QtConcurrent::run(this, &MainUI::GetDirSize, INFO->absoluteFilePath());
}
- ui->label_file_owner->setText(INFO.owner());
- ui->label_file_group->setText(INFO.group());
- ui->label_file_created->setText( INFO.created().toString(Qt::SystemLocaleLongDate) );
- ui->label_file_modified->setText( INFO.lastModified().toString(Qt::SystemLocaleLongDate) );
+ ui->label_file_owner->setText(INFO->owner());
+ ui->label_file_group->setText(INFO->group());
+ ui->label_file_created->setText( INFO->created().toString(Qt::SystemLocaleLongDate) );
+ ui->label_file_modified->setText( INFO->lastModified().toString(Qt::SystemLocaleLongDate) );
//Get the file permissions
QString perms;
- if(INFO.isReadable() && INFO.isWritable()){ perms = tr("Read/Write"); }
- else if(INFO.isReadable()){ perms = tr("Read Only"); }
- else if(INFO.isWritable()){ perms = tr("Write Only"); }
+ if(INFO->isReadable() && INFO->isWritable()){ perms = tr("Read/Write"); }
+ else if(INFO->isReadable()){ perms = tr("Read Only"); }
+ else if(INFO->isWritable()){ perms = tr("Write Only"); }
else{ perms = tr("No Access"); }
ui->label_file_perms->setText(perms);
//Now the special "type" for the file
QString ftype;
- if(INFO.suffix().toLower()=="desktop"){ ftype = tr("XDG Shortcut"); }
- else if(INFO.isDir()){ ftype = tr("Directory"); }
- else if(INFO.isExecutable()){ ftype = tr("Binary"); }
- else{ ftype = INFO.suffix().toUpper(); }
- if(INFO.isHidden()){ ftype = QString(tr("Hidden %1")).arg(type); }
+ if(INFO->suffix().toLower()=="desktop"){ ftype = tr("XDG Shortcut"); }
+ else if(INFO->isDir()){ ftype = tr("Directory"); }
+ else if(INFO->isExecutable()){ ftype = tr("Binary"); }
+ else{ ftype = INFO->suffix().toUpper(); }
+ if(INFO->isHidden()){ ftype = QString(tr("Hidden %1")).arg(type); }
ui->label_file_type->setText(ftype);
//Now load the icon for the file
- if(INFO.isImage()){
- ui->label_file_icon->setPixmap( QPixmap(INFO.absoluteFilePath()).scaledToHeight(64) );
+ if(INFO->isImage()){
+ //qDebug() << "Set Image:";
+ QPixmap pix(INFO->absoluteFilePath());
+ ui->label_file_icon->setPixmap( pix.scaledToHeight(64) );
+ ui->label_file_size->setText( ui->label_file_size->text()+" ("+QString::number(pix.width())+" x "+QString::number(pix.height())+" px)" );
+ //qDebug() << " - done with image";
}else{
- ui->label_file_icon->setPixmap( LXDG::findIcon( INFO.iconfile(), "unknown").pixmap(QSize(64,64)) );
+ ui->label_file_icon->setPixmap( LXDG::findIcon( INFO->iconfile(), "unknown").pixmap(QSize(64,64)) );
}
//Now verify the tab is available in the widget
+ //qDebug() << "Check tab widget";
if(ui->tabWidget->indexOf(ui->tab_file)<0){
+ //qDebug() << "Add File Info Tab";
ui->tabWidget->addTab(ui->tab_file, tr("File Information"));
}
+ //qDebug() << "Done with Tab Check";
}else{
if(ui->tabWidget->indexOf(ui->tab_file)>=0){
ui->tabWidget->removeTab( ui->tabWidget->indexOf(ui->tab_file) );
}
}
//Now load the special XDG desktop info
- qDebug() << INFO.isDesktopFile() << type;
- if(INFO.isDesktopFile() || !type.isEmpty()){
+ qDebug() << "Check XDG Info:" << type;
+ //qDebug() << INFO->isDesktopFile() << type;
+ if(INFO->isDesktopFile() || !type.isEmpty()){
- if(INFO.XDG()->type == XDGDesktop::APP){
- ui->line_xdg_command->setText(INFO.XDG()->exec);
- ui->line_xdg_wdir->setText(INFO.XDG()->path);
- ui->check_xdg_useTerminal->setChecked( INFO.XDG()->useTerminal );
- ui->check_xdg_startupNotify->setChecked( INFO.XDG()->startupNotify );
- }else if(INFO.XDG()->type==XDGDesktop::LINK){
+ if(INFO->XDG()->type == XDGDesktop::APP){
+ ui->line_xdg_command->setText(INFO->XDG()->exec);
+ ui->line_xdg_wdir->setText(INFO->XDG()->path);
+ ui->check_xdg_useTerminal->setChecked( INFO->XDG()->useTerminal );
+ ui->check_xdg_startupNotify->setChecked( INFO->XDG()->startupNotify );
+ }else if(INFO->XDG()->type==XDGDesktop::LINK){
//Hide the options that are unavailable for links
//Command line (exec)
ui->line_xdg_command->setVisible(false);
@@ -114,13 +124,13 @@ void MainUI::LoadFile(QString path, QString type){
ui->check_xdg_startupNotify->setVisible(false);
//Now load the variables for this type of shortcut
ui->lblWorkingDir->setText(tr("URL:"));
- ui->line_xdg_wdir->setText( INFO.XDG()->url );
+ ui->line_xdg_wdir->setText( INFO->XDG()->url );
ui->tool_xdg_getDir->setVisible(false); //the dir selection button
}
- ui->line_xdg_name->setText(INFO.XDG()->name);
- ui->line_xdg_comment->setText(INFO.XDG()->comment);
- ui->push_xdg_getIcon->setWhatsThis( INFO.XDG()->icon );
+ ui->line_xdg_name->setText(INFO->XDG()->name);
+ ui->line_xdg_comment->setText(INFO->XDG()->comment);
+ ui->push_xdg_getIcon->setWhatsThis( INFO->XDG()->icon );
ReloadAppIcon();
ui->push_save->setVisible(true);
ui->push_save->setEnabled(false);
@@ -140,6 +150,7 @@ void MainUI::LoadFile(QString path, QString type){
//Setup the tab
if(type.isEmpty()){ ui->tabWidget->setCurrentIndex(0); }
else if(ui->tabWidget->count()>1){ ui->tabWidget->setCurrentIndex(1); }
+ qDebug() << "Done Loading File";
}
void MainUI::UpdateIcons(){
@@ -209,6 +220,7 @@ void MainUI::GetDirSize(const QString dirname) const {
void MainUI::SetupConnections(){
connect(ui->line_xdg_command, SIGNAL(editingFinished()), this, SLOT(xdgvaluechanged()) );
connect(ui->line_xdg_comment, SIGNAL(editingFinished()), this, SLOT(xdgvaluechanged()) );
+ connect(ui->tool_xdg_getCommand, SIGNAL(clicked()), this, SLOT(getXdgCommand()) );
connect(ui->line_xdg_name, SIGNAL(editingFinished()), this, SLOT(xdgvaluechanged()) );
connect(ui->line_xdg_wdir, SIGNAL(editingFinished()), this, SLOT(xdgvaluechanged()) );
connect(ui->check_xdg_useTerminal, SIGNAL(clicked()), this, SLOT(xdgvaluechanged()) );
@@ -229,8 +241,8 @@ void MainUI::on_push_close_clicked(){
void MainUI::on_push_save_clicked(){
//Save all the xdg values into the structure
- if( (!INFO.isDesktopFile() && !INFO.filePath().isEmpty()) || !canwrite){ return; }
- if(INFO.filePath().isEmpty()){
+ if( (!INFO->isDesktopFile() && !INFO->filePath().isEmpty()) || !canwrite){ return; }
+ if(INFO->filePath().isEmpty()){
//Need to prompt for where to save the file and what to call it
QString appdir = QString(getenv("XDG_DATA_HOME"))+"/applications/";
if(!QFile::exists(appdir)){ QDir dir; dir.mkpath(appdir); }
@@ -238,39 +250,39 @@ void MainUI::on_push_save_clicked(){
if(filePath.isEmpty()){ return; }
if(!filePath.endsWith(".desktop")){ filePath.append(".desktop"); }
//Update the file paths in the data structure
- INFO.setFile(filePath);
- INFO.XDG()->filePath = filePath;
+ INFO->setFile(filePath);
+ INFO->XDG()->filePath = filePath;
}
- XDGDesktop XDG = *INFO.XDG();
+ XDGDesktop *XDG = INFO->XDG();
//Now change the structure
- XDG.name = ui->line_xdg_name->text();
- XDG.genericName = ui->line_xdg_name->text().toLower();
- XDG.comment = ui->line_xdg_comment->text();
- XDG.icon = ui->push_xdg_getIcon->whatsThis();
+ XDG->name = ui->line_xdg_name->text();
+ XDG->genericName = ui->line_xdg_name->text().toLower();
+ XDG->comment = ui->line_xdg_comment->text();
+ XDG->icon = ui->push_xdg_getIcon->whatsThis();
//Now do the type-specific fields
- if(XDG.type==XDGDesktop::APP){
- XDG.exec = ui->line_xdg_command->text();
- XDG.tryexec = ui->line_xdg_command->text().section(" ",0,0); //use the first word/binary for the existance check
- XDG.path = ui->line_xdg_wdir->text(); //working dir/path
- XDG.useTerminal = ui->check_xdg_useTerminal->isChecked();
- XDG.startupNotify = ui->check_xdg_startupNotify->isChecked();
- }else if(XDG.type==XDGDesktop::LINK){
- XDG.url = ui->line_xdg_wdir->text(); //we re-used this field
+ if(XDG->type == XDGDesktop::APP){
+ XDG->exec = ui->line_xdg_command->text();
+ XDG->tryexec = ui->line_xdg_command->text().section(" ",0,0); //use the first word/binary for the existance check
+ XDG->path = ui->line_xdg_wdir->text(); //working dir/path
+ XDG->useTerminal = ui->check_xdg_useTerminal->isChecked();
+ XDG->startupNotify = ui->check_xdg_startupNotify->isChecked();
+ }else if(XDG->type==XDGDesktop::LINK){
+ XDG->url = ui->line_xdg_wdir->text(); //we re-used this field
}
//Clear any info which this utility does not support at the moment
- XDG.actionList.clear();
- XDG.actions.clear();
+ XDG->actionList.clear();
+ XDG->actions.clear();
//Now save the structure to file
- bool saved = LXDG::saveDesktopFile( XDG, true); //Try to merge the file/structure as necessary
+ bool saved = XDG->saveDesktopFile(true); //Try to merge the file/structure as necessary
qDebug() << "File Saved:" << saved;
ui->push_save->setEnabled( !saved );
if(saved){
//Re-load the file info
- LoadFile(INFO.absoluteFilePath());
+ LoadFile(INFO->absoluteFilePath());
}
}
-void MainUI::on_tool_xdg_getCommand_clicked(QString prev){
+void MainUI::getXdgCommand(QString prev){
//Find a binary to run
QString dir = prev; //start with the previous attempt (if there was one)
if(dir.isEmpty()){ ui->line_xdg_command->text(); }//then try current selection
@@ -279,7 +291,7 @@ void MainUI::on_tool_xdg_getCommand_clicked(QString prev){
if(file.isEmpty()){ return; } //cancelled
if(!LUtils::isValidBinary(file)){
QMessageBox::warning(this, tr("Error"), tr("Invalid selection: Not a valid executable"));
- on_tool_xdg_getCommand_clicked(file);
+ getXdgCommand(file);
return;
}
ui->line_xdg_command->setText(file);
@@ -312,7 +324,7 @@ void MainUI::on_push_xdg_getIcon_clicked(){
//XDG Value Changed
void MainUI::xdgvaluechanged(){
- if(INFO.isDesktopFile() || INFO.filePath().isEmpty()){
+ if(INFO!=0 && (INFO->isDesktopFile() || INFO->filePath().isEmpty() ) ){
ui->push_save->setVisible(true);
//Compare the current UI values to the file values
ui->push_save->setEnabled(canwrite); //assume changed at this point
bgstack15