diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop')
6 files changed, 83 insertions, 13 deletions
diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index 3088696f..bdc4f4d3 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -168,6 +168,7 @@ void LSession::setupSession(){ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange(QString)) ); connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) ); if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;} + setenv("QT_AUTO_SCREEN_SCALE_FACTOR","1",true); //Enable the automatic Qt5 DPI scaling for apps for(int i=0; i<4; i++){ LSession::processEvents(); } //Again, just a few event loops here so thing can settle before we close the splash screen //launchStartupApps(); QTimer::singleShot(500, this, SLOT(launchStartupApps()) ); diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 8d8106f7..1730dbaa 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -1,11 +1,13 @@ #include "AppLauncherPlugin.h" #include "../../LSession.h" #include "OutlineToolButton.h" +#include <QClipboard> #define OUTMARGIN 10 //special margin for fonts due to the outlining effect from the OutlineToolbutton AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){ QVBoxLayout *lay = new QVBoxLayout(); + inputDLG = 0; this->setLayout(lay); lay->setContentsMargins(0,0,0,0); button = new OutlineToolButton(this); @@ -35,6 +37,7 @@ void AppLauncherPlugin::Cleanup(){ void AppLauncherPlugin::loadButton(){ QString def = this->ID().section("::",1,50).section("---",0,0).simplified(); QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary + QFileInfo info(path); this->contextMenu()->clear(); //qDebug() << "Default Application Launcher:" << def << path; bool ok = QFile::exists(path); @@ -71,7 +74,6 @@ void AppLauncherPlugin::loadButton(){ watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes } }else if(ok){ - QFileInfo info(path); button->setWhatsThis(info.absoluteFilePath()); if(info.isDir()){ if(path.startsWith("/media/")){ @@ -101,13 +103,18 @@ void AppLauncherPlugin::loadButton(){ this->contextMenu()->addAction(LXDG::findIcon("document-open",""), tr("Open"), this, SLOT(buttonClicked()) ); this->contextMenu()->addAction(LXDG::findIcon("document-preview",""), tr("Open With"), this, SLOT(openWith()) ); } - this->contextMenu()->addAction(LXDG::findIcon("document-properties",""), tr("Properties"), this, SLOT(fileProperties()) ); - if(QFileInfo(path).isWritable()){ - this->contextMenu()->addSeparator(); - this->contextMenu()->addAction(LXDG::findIcon("document-close",""), tr("Delete File"), this, SLOT(fileDelete()) ); + this->contextMenu()->addAction(LXDG::findIcon("document-properties",""), tr("View Properties"), this, SLOT(fileProperties()) ); + this->contextMenu()->addSection(tr("File Operations")); + if(!path.endsWith(".desktop")){ + this->contextMenu()->addAction(LXDG::findIcon("edit-rename","edit-new"), tr("Rename"), this, SLOT(fileRename()) ); + } + this->contextMenu()->addAction(LXDG::findIcon("edit-copy",""), tr("Copy"), this, SLOT(fileCopy()) ); + if(info.isWritable() || (info.isSymLink() && QFileInfo(info.absolutePath()).isWritable() ) ){ + this->contextMenu()->addAction(LXDG::findIcon("edit-cut",""), tr("Cut"), this, SLOT(fileCut()) ); + this->contextMenu()->addAction(LXDG::findIcon("document-close",""), tr("Delete"), this, SLOT(fileDelete()) ); } //If the file is a symlink, put the overlay on the icon - if(QFileInfo(path).isSymLink()){ + if(info.isSymLink()){ QImage img = button->icon().pixmap(QSize(icosize,icosize)).toImage(); int oSize = icosize/3; //overlay size QPixmap overlay = LXDG::findIcon("emblem-symbolic-link").pixmap(oSize,oSize).scaled(oSize,oSize, Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -198,3 +205,57 @@ void AppLauncherPlugin::fileDelete(){ if(path.isEmpty() || !QFile::exists(path)){ return; } //invalid file QFile::remove(path); } + +void AppLauncherPlugin::fileCut(){ + QString path = button->whatsThis(); + QList<QUrl> urilist; //Also assemble a URI list for cros-app compat (no copy/cut distinguishing) + urilist << QUrl::fromLocalFile(path); + path.prepend("cut::::"); + //Now save that data to the global clipboard + QMimeData *dat = new QMimeData; + dat->clear(); + dat->setData("x-special/lumina-copied-files", path.toLocal8Bit()); + dat->setUrls(urilist); //the text/uri-list mimetype - built in Qt conversion/use + QApplication::clipboard()->clear(); + QApplication::clipboard()->setMimeData(dat); +} + +void AppLauncherPlugin::fileCopy(){ + QString path = button->whatsThis(); + QList<QUrl> urilist; //Also assemble a URI list for cros-app compat (no copy/cut distinguishing) + urilist << QUrl::fromLocalFile(path); + path.prepend("copy::::"); + //Now save that data to the global clipboard + QMimeData *dat = new QMimeData; + dat->clear(); + dat->setData("x-special/lumina-copied-files", path.toLocal8Bit()); + dat->setUrls(urilist); //the text/uri-list mimetype - built in Qt conversion/use + QApplication::clipboard()->clear(); + QApplication::clipboard()->setMimeData(dat); +} + +void AppLauncherPlugin::fileRename(){ + if(inputDLG == 0){ + inputDLG = new QInputDialog(0, Qt::Dialog | Qt::WindowStaysOnTopHint); + inputDLG->setInputMode(QInputDialog::TextInput); + inputDLG->setTextValue(button->whatsThis().section("/",-1)); + inputDLG->setTextEchoMode(QLineEdit::Normal); + inputDLG->setLabelText( tr("New Filename") ); + connect(inputDLG, SIGNAL(finished(int)), this, SLOT(renameFinished(int)) ); + } + inputDLG->showNormal(); +} + +void AppLauncherPlugin::renameFinished(int result){ + QString newname = inputDLG->textValue(); + inputDLG->deleteLater(); + inputDLG = 0; + qDebug() << "Got Rename Result:" << result << QDialog::Accepted << newname; + if(result != QDialog::Accepted){ return; } + QString newpath = button->whatsThis().section("/",0,-2)+"/"+newname; + qDebug() << "Move File:" << button->whatsThis() << newpath; + if( QFile::rename(button->whatsThis(), newpath) ){ + //No special actions here yet - TODO + qDebug() << " - SUCCESS"; + } +} diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h index 95fc9284..b1e3fc85 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h @@ -35,6 +35,7 @@ private: QToolButton *button; QFileSystemWatcher *watcher; //QMenu *menu; + QInputDialog *inputDLG; private slots: void loadButton(); @@ -49,6 +50,10 @@ private slots: void openWith(); void fileProperties(); void fileDelete(); + void fileCut(); + void fileCopy(); + void fileRename(); + void renameFinished(int result); public slots: void LocaleChange(){ diff --git a/src-qt5/core/lumina-desktop/main.cpp b/src-qt5/core/lumina-desktop/main.cpp index b42a3816..5eb58aa9 100644 --- a/src-qt5/core/lumina-desktop/main.cpp +++ b/src-qt5/core/lumina-desktop/main.cpp @@ -73,6 +73,7 @@ int main(int argc, char ** argv) setenv("DESKTOP_SESSION","Lumina",1); setenv("XDG_CURRENT_DESKTOP","Lumina",1); unsetenv("QT_QPA_PLATFORMTHEME"); //causes issues with Lumina themes - not many people have this by default... + unsetenv("QT_AUTO_SCREEN_SCALE_FACTOR"); //causes pixel-specific scaling issues with the desktop - turn this on after-the-fact for other apps //Startup the session LSession a(argc, argv); if(!a.isPrimaryProcess()){ return 0; } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp index a71fd57e..edd0a4eb 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp @@ -80,6 +80,7 @@ void LSysTray::checkAll(){ if(!isRunning || stopping || checking){ pending = true; return; } //Don't check if not running at the moment checking = true; pending = false; + bool listChanged = false; //Make sure this tray should handle the windows (was not disabled in the backend) bool TrayRunning = LSession::handle()->registerVisualTray(this->winId()); //qDebug() << "System Tray: Check tray apps"; @@ -94,6 +95,7 @@ void LSysTray::checkAll(){ LI->removeWidget(cont); cont->deleteLater(); i--; //List size changed + listChanged = true; //Re-adjust the maximum widget size to account for what is left if(this->layout()->direction()==QBoxLayout::LeftToRight){ this->setMaximumSize( trayIcons.length()*this->height(), 10000); @@ -103,7 +105,7 @@ void LSysTray::checkAll(){ }else{ //Tray Icon already exists //qDebug() << " - SysTray: Update Icon"; - trayIcons[i]->update(); + //trayIcons[i]->repaint(); wins.removeAt(index); //Already found - remove from the list } } @@ -139,13 +141,14 @@ void LSysTray::checkAll(){ continue; } LI->update(); //make sure there is no blank space in the layout + listChanged = true; } - /*if(listChanged){ + if(listChanged){ //Icons got moved around: be sure to re-draw all of them to fix visuals for(int i=0; i<trayIcons.length(); i++){ - trayIcons[i]->update(); + trayIcons[i]->repaint(); } - }*/ + } //qDebug() << " - System Tray: check done"; checking = false; if(pending){ QTimer::singleShot(0,this, SLOT(checkAll()) ); } @@ -164,4 +167,3 @@ void LSysTray::UpdateTrayWindow(WId win){ //qDebug() << "System Tray: Missing Window - check all"; QTimer::singleShot(0,this, SLOT(checkAll()) ); } - diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index 9fdbce50..6736359c 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -79,7 +79,7 @@ void TrayIcon::updateIcon(){ if(AID==0){ return; } //Make sure the icon is square QSize icosize = this->size(); - LSession::handle()->XCB->ResizeWindow(AID, icosize.width(), icosize.height()); + LSession::handle()->XCB->ResizeWindow(AID, icosize.width()*2, icosize.height()*2); QTimer::singleShot(500, this, SLOT(update()) ); //make sure to re-draw the window in a moment } @@ -103,7 +103,7 @@ void TrayIcon::paintEvent(QPaintEvent *event){ //qDebug() << " - Pix size:" << pix.size().width() << pix.size().height(); //qDebug() << " - Geom:" << this->geometry().x() << this->geometry().y() << this->geometry().width() << this->geometry().height(); if(!pix.isNull()){ - if(this->size() != pix.size()){ QTimer::singleShot(10, this, SLOT(updateIcon())); } + if((this->size()*2) != pix.size()){ QTimer::singleShot(10, this, SLOT(updateIcon())); } painter.drawPixmap(0,0,this->width(), this->height(), pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation) ); badpaints = 0; //good paint }else{ |