diff options
author | Ken Moore <moorekou@gmail.com> | 2016-07-01 14:20:17 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2016-07-01 14:20:17 -0400 |
commit | 2c50dffda96b2fc20062397e1b9d536a0d5bf239 (patch) | |
tree | 558bcbe2b2e06266d095718e41c86d69481482d3 | |
parent | Add the new JSON menu generation scripts to the "core" files installed (since... (diff) | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-2c50dffda96b2fc20062397e1b9d536a0d5bf239.tar.gz lumina-2c50dffda96b2fc20062397e1b9d536a0d5bf239.tar.bz2 lumina-2c50dffda96b2fc20062397e1b9d536a0d5bf239.zip |
Merge branch 'master' of github.com:trueos/lumina
5 files changed, 99 insertions, 57 deletions
diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp index a2c30ebd..1fc136de 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp +++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.cpp @@ -32,12 +32,17 @@ MainUI::~MainUI(){ // PUBLIC //============= 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{ + else if(!INFO.filePath().isEmpty()){ //See if the containing directory can be written QFileInfo chk(INFO.absolutePath()); canwrite = (chk.isDir() && chk.isWritable()); + }else{ + canwrite = true; //no associated file yet } if(!INFO.exists() && !type.isEmpty()){ //Set the proper type flag on the shortcut @@ -46,40 +51,51 @@ void MainUI::LoadFile(QString path, QString type){ } //First load the general file information - 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()); - } - 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"); } - 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); } - 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.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()); + } + 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"); } + 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); } + 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) ); + }else{ + ui->label_file_icon->setPixmap( LXDG::findIcon( INFO.iconfile(), "unknown").pixmap(QSize(64,64)) ); + } + //Now verify the tab is available in the widget + if(ui->tabWidget->indexOf(ui->tab_file)<0){ + ui->tabWidget->addTab(ui->tab_file, tr("File Information")); + } }else{ - ui->label_file_icon->setPixmap( LXDG::findIcon( INFO.iconfile(), "unknown").pixmap(QSize(64,64)) ); + if(ui->tabWidget->indexOf(ui->tab_file)>=0){ + ui->tabWidget->removeTab( ui->tabWidget->indexOf(ui->tab_file) ); + } } //Now load the special XDG desktop info - if(INFO.isDesktopFile()){ + qDebug() << INFO.isDesktopFile() << type; + if(INFO.isDesktopFile() || !type.isEmpty()){ if(INFO.XDG()->type == XDGDesktop::APP){ ui->line_xdg_command->setText(INFO.XDG()->exec); @@ -108,16 +124,22 @@ void MainUI::LoadFile(QString path, QString type){ ReloadAppIcon(); ui->push_save->setVisible(true); ui->push_save->setEnabled(false); + //Now ensure the xdg tab exists in the widget + if(ui->tabWidget->indexOf(ui->tab_deskedit)<0){ + qDebug() << "Adding the deskedit tab"; + ui->tabWidget->addTab(ui->tab_deskedit, tr("Edit Shortcut")); + } }else{ xdgvaluechanged(); //just do the disables here //Also remove the xdg tab - if(ui->tabWidget->count()>1){ ui->tabWidget->removeTab(1); } + if(ui->tabWidget->indexOf(ui->tab_deskedit) >= 0){ + qDebug() << "Removing the deskedit tab"; + ui->tabWidget->removeTab( ui->tabWidget->indexOf(ui->tab_deskedit) ); + } } //Setup the tab if(type.isEmpty()){ ui->tabWidget->setCurrentIndex(0); } else if(ui->tabWidget->count()>1){ ui->tabWidget->setCurrentIndex(1); } - //Hide the tab bar (the autoHideTabBar setting was not added until Qt 5.4) - if(ui->tabWidget->count() < 2){ ui->tabWidget->tabBar()->hide(); } } void MainUI::UpdateIcons(){ @@ -207,8 +229,18 @@ void MainUI::on_push_close_clicked(){ void MainUI::on_push_save_clicked(){ //Save all the xdg values into the structure - if(!INFO.isDesktopFile() || !canwrite){ return; } - XDGDesktop XDG = *INFO.XDG();; + 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/"; + QString filePath = QFileDialog::getSaveFileName(this, tr("Save Application File"), appdir, tr("Application Registrations (*.desktop)") ); + 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; + } + XDGDesktop XDG = *INFO.XDG(); //Now change the structure XDG.name = ui->line_xdg_name->text(); XDG.genericName = ui->line_xdg_name->text().toLower(); @@ -279,7 +311,7 @@ void MainUI::on_push_xdg_getIcon_clicked(){ //XDG Value Changed void MainUI::xdgvaluechanged(){ - if(INFO.isDesktopFile()){ + if(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 diff --git a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.ui b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.ui index d8cc554d..51657ba1 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/MainUI.ui +++ b/src-qt5/desktop-utils/lumina-fileinfo/MainUI.ui @@ -17,7 +17,7 @@ <item> <widget class="QTabWidget" name="tabWidget"> <property name="currentIndex"> - <number>0</number> + <number>1</number> </property> <widget class="QWidget" name="tab_file"> <attribute name="title"> @@ -387,17 +387,29 @@ </spacer> </item> <item> - <widget class="QPushButton" name="push_save"> + <widget class="QToolButton" name="push_save"> <property name="text"> <string>Save</string> </property> + <property name="popupMode"> + <enum>QToolButton::InstantPopup</enum> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> </widget> </item> <item> - <widget class="QPushButton" name="push_close"> + <widget class="QToolButton" name="push_close"> <property name="text"> <string>Close</string> </property> + <property name="popupMode"> + <enum>QToolButton::DelayedPopup</enum> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> </widget> </item> </layout> diff --git a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.desktop b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.desktop index 91dace87..9fec3b03 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.desktop +++ b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Exec=lumina-fileinfo %f +Exec=lumina-fileinfo -application %f TryExec=lumina-fileinfo Icon=unknown Terminal=false @@ -7,5 +7,4 @@ Type=Application StartupNotify=true Categories=System; Name=Lumina File Information -Comment=View or edit file information - +Comment=View or edit file information including application links diff --git a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro index 2c4ffdbe..1c1bfc70 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro +++ b/src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo.pro @@ -89,7 +89,10 @@ TRANSLATIONS = i18n/lumina-fileinfo_af.ts \ dotrans.path=$${L_SHAREDIR}/lumina-desktop/i18n/ dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$${L_SHAREDIR}/lumina-desktop/i18n/ -INSTALLS += target +desktop.files=lumina-fileinfo.desktop +desktop.path=$${L_SHAREDIR}/applications/ + +INSTALLS += target desktop WITH_I18N{ INSTALLS += dotrans diff --git a/src-qt5/desktop-utils/lumina-fileinfo/main.cpp b/src-qt5/desktop-utils/lumina-fileinfo/main.cpp index f8ba3620..394ac579 100644 --- a/src-qt5/desktop-utils/lumina-fileinfo/main.cpp +++ b/src-qt5/desktop-utils/lumina-fileinfo/main.cpp @@ -18,11 +18,9 @@ int main(int argc, char ** argv) //Read the input variables QString path = ""; QString flag = ""; - if (argc==2) { - path = QString::fromLocal8Bit(argv[1]); - }else if (argc==3) { - flag = QString::fromLocal8Bit(argv[1]); - path = QString::fromLocal8Bit(argv[2]); + for(int i=1; i<argc; i++){ + if( QString(argv[i]).startsWith("-") ){ flag = QString(argv[i]); } + else{ path = QString(argv[i]); break; } } //Check the input variables // - path @@ -35,11 +33,11 @@ int main(int argc, char ** argv) flag = "LINK"; //for internal use }else{ //Invalid flag - clear the path as well + flag.clear(); path.clear(); } } - if(!path.isEmpty()){ - //if(!QFile::exists(path)){ LUtils::writeFile(path,QStringList()); } //create an empty file + if(!path.isEmpty() || !flag.isEmpty()){ MainUI w; QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(UpdateIcons()) ); w.LoadFile(path, flag); @@ -48,12 +46,10 @@ int main(int argc, char ** argv) return retCode; }else{ //Show an error text and exit - QStringList msg; - msg << "ERROR: Invalid input arguments"; - msg << "Usage: \"lumina-fileinfo [-application | -link] <file>"; - qDebug() << msg.join("\n"); + qDebug() << "ERROR: Invalid input arguments"; + qDebug() << "Usage: \"lumina-fileinfo [-application | -link] [file]"; return 1; } -}
\ No newline at end of file +} |