diff options
Diffstat (limited to 'src-qt5/core/lumina-desktop')
10 files changed, 44 insertions, 37 deletions
diff --git a/src-qt5/core/lumina-desktop/BootSplash.cpp b/src-qt5/core/lumina-desktop/BootSplash.cpp index cdf1a3c2..f3befeaf 100644 --- a/src-qt5/core/lumina-desktop/BootSplash.cpp +++ b/src-qt5/core/lumina-desktop/BootSplash.cpp @@ -11,7 +11,7 @@ BootSplash::BootSplash() : QWidget(0, Qt::SplashScreen | Qt::X11BypassWindowMana this->setMinimumWidth( this->minimumHeight() * 1.5); this->setObjectName("LuminaBootSplash"); //for theme styling //Center the window on the primary screen - QPoint ctr = QApplication::desktop()->screenGeometry().center(); + QPoint ctr = QGuiApplication::primaryScreen()->geometry().center(); this->move( ctr.x()-(this->width()/2), ctr.y()-(this->height()/2) ); generateTipOfTheDay(); ui->label_version->setText( QString(tr("Version %1")).arg(LDesktopUtils::LuminaDesktopVersion()) ); diff --git a/src-qt5/core/lumina-desktop/Globals.h b/src-qt5/core/lumina-desktop/Globals.h index 43ea3a87..f7821466 100644 --- a/src-qt5/core/lumina-desktop/Globals.h +++ b/src-qt5/core/lumina-desktop/Globals.h @@ -41,7 +41,7 @@ public: char name[BUFSIZ]; int count = gethostname(name,sizeof(name)); if (count < 0) { - return QString::null; + return QString(); } return QString::fromLocal8Bit(name,count); } diff --git a/src-qt5/core/lumina-desktop/LDesktop.cpp b/src-qt5/core/lumina-desktop/LDesktop.cpp index e4706498..d4650433 100644 --- a/src-qt5/core/lumina-desktop/LDesktop.cpp +++ b/src-qt5/core/lumina-desktop/LDesktop.cpp @@ -208,7 +208,7 @@ void LDesktop::InitDesktop(){ checkResolution(); //Adjust the desktop config file first (if necessary) if(DEBUG){ qDebug() << "Init Desktop:" << Screen(); } //connect(desktop, SIGNAL(resized(int)), this, SLOT(UpdateGeometry(int))); - if(DEBUG){ qDebug() << "Desktop #"<<Screen()<<" -> "<< LSession::desktop()->screenGeometry(Screen()) << LSession::handle()->screenGeom(Screen()); } + if(DEBUG){ qDebug() << "Desktop #"<<Screen()<<" -> "<< QGuiApplication::screens().at(Screen())->availableGeometry() << LSession::handle()->screenGeom(Screen()); } deskMenu = new QMenu(0); connect(deskMenu, SIGNAL(triggered(QAction*)), this, SLOT(SystemApplication(QAction*)) ); winMenu = new QMenu(0); @@ -241,7 +241,7 @@ void LDesktop::InitDesktop(){ if(DEBUG){ qDebug() << "Create bgDesktop"; } bgDesktop = new LDesktopPluginSpace(); int grid = settings->value(DPREFIX+"GridSize",-1).toInt(); - if(grid<0 && LSession::desktop()->screenGeometry(Screen()).height() > 2000){ grid = 200; } + if(grid<0 && QGuiApplication::screens().at(Screen())->availableGeometry().height() > 2000){ grid = 200; } else if(grid<0){ grid = 100; } bgDesktop->SetIconSize( grid ); bgDesktop->setContextMenuPolicy(Qt::CustomContextMenu); @@ -423,7 +423,7 @@ void LDesktop::RemoveDeskPlugin(QString ID){ void LDesktop::IncreaseDesktopPluginIcons(){ int cur = settings->value(DPREFIX+"GridSize",-1).toInt(); - if(cur<0 &&LSession::desktop()->screenGeometry(Screen()).height() > 2000){ cur = 200; } + if(cur<0 && QGuiApplication::screens().at(Screen())->availableGeometry().height() > 2000){ cur = 200; } else if(cur<0){ cur = 100; } cur+=16; issyncing=true; //don't let the change cause a refresh @@ -435,7 +435,7 @@ void LDesktop::IncreaseDesktopPluginIcons(){ void LDesktop::DecreaseDesktopPluginIcons(){ int cur = settings->value(DPREFIX+"GridSize",-1).toInt(); - if(cur<0 &&LSession::desktop()->screenGeometry(Screen()).height() > 2000){ cur = 200; } + if(cur<0 && QGuiApplication::screens().at(Screen())->availableGeometry().height() > 2000){ cur = 200; } else if(cur<0){ cur = 100; } if(cur<32){ return; } //cannot get smaller than 16x16 cur-=16; @@ -483,7 +483,7 @@ void LDesktop::UpdatePanels(){ } void LDesktop::UpdateDesktopPluginArea(){ - QRegion visReg(LSession::desktop()->screenGeometry(Screen()) ); //visible region (not hidden behind a panel) + QRegion visReg(QGuiApplication::screens().at(Screen())->availableGeometry() ); //visible region (not hidden behind a panel) QRect rawRect = visReg.boundingRect(); //initial value (screen size) //qDebug() << "Update Desktop Plugin Area:" << bgWindow->geometry(); for(int i=0; i<PANELS.length(); i++){ @@ -514,11 +514,12 @@ void LDesktop::UpdateDesktopPluginArea(){ //LSession::handle()->XCB->SetScreenWorkArea((unsigned int) Screen(), rec); //Now remove the X offset to place it on the current screen (needs widget-coords, not global) globalWorkRect = rec; //save this for later - rec.moveTopLeft( QPoint( rec.x()-LSession::desktop()->screenGeometry(Screen()).x() , rec.y()-LSession::desktop()->screenGeometry(Screen()).y() ) ); + rec.moveTopLeft( QPoint( rec.x()-QGuiApplication::screens().at(Screen())->availableGeometry().x() , rec.y()-QGuiApplication::screens().at(Screen())->availableGeometry().y() ) ); //qDebug() << "DPlug Area:" << rec << bgDesktop->geometry() << LSession::handle()->desktop()->availableGeometry(bgDesktop); if(rec.size().isNull() ){ return; } //|| rec == bgDesktop->geometry()){return; } //nothing changed //bgDesktop->show(); //make sure Fluxbox is aware of it *before* we start moving it - bgDesktop->setGeometry( LSession::desktop()->screenGeometry(Screen())); + + bgDesktop->setGeometry( QGuiApplication::screens().at(Screen())->availableGeometry()); //bgDesktop->resize(LSession::desktop()->screenGeometry(Screen()).size()); //bgDesktop->move(LSession::desktop()->screenGeometry(Screen()).topLeft()); bgDesktop->setDesktopArea( rec ); diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index 7f7cc443..2495e336 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -486,19 +486,20 @@ void LSession::refreshWindowManager(){ void LSession::updateDesktops(){ qDebug() << " - Update Desktops"; - QDesktopWidget *DW = this->desktop(); - int sC = DW->screenCount(); + QList<QScreen*> screens = QGuiApplication::screens(); + int sC = screens.count(); qDebug() << " Screen Count:" << sC; qDebug() << " DESKTOPS Length:" << DESKTOPS.length(); if(sC<1){ return; } //stop here - no screens available temporarily (displayport/4K issue) screenRect = QRect(); //clear it - for(int i=0; i<sC; i++){ - screenRect = screenRect.united(DW->screenGeometry(i)); - qDebug() << " -- Screen["+QString::number(i)+"]:" << DW->screenGeometry(i); + QList<QScreen*>::const_iterator it; + int i = 0; + for(it = screens.constBegin(); it != screens.constEnd(); ++it, ++i) { + screenRect = screenRect.united((*it)->availableGeometry()); + qDebug() << " -- Screen["+QString::number(i)+"]:" << (*it)->availableGeometry(); } bool firstrun = (DESKTOPS.length()==0); - bool numchange = DESKTOPS.length()!=sC; QSettings dset("lumina-desktop", "desktopsettings"); if(firstrun && sC==1){ //Sanity check - ensure the monitor ID did not change between sessions for single-monitor setups @@ -519,7 +520,7 @@ void LSession::updateDesktops(){ } // If the screen count is changing on us - if ( sC != DW->screenCount() ) { + if ( sC != QGuiApplication::screens().count() ) { qDebug() << "Screen Count changed while running"; return; } @@ -528,7 +529,7 @@ void LSession::updateDesktops(){ QList<int> dnums; //keep track of which screens are already managed QList<QRect> geoms; for(int i=0; i<DESKTOPS.length(); i++){ - if ( DESKTOPS[i]->Screen() < 0 || DESKTOPS[i]->Screen() >= sC || geoms.contains(DW->screenGeometry(DESKTOPS[i]->Screen())) ) { + if ( DESKTOPS[i]->Screen() < 0 || DESKTOPS[i]->Screen() >= sC || geoms.contains(screens.at(i)->availableGeometry())) { //qDebug() << " - Close desktop:" << i; qDebug() << " - Close desktop on screen:" << DESKTOPS[i]->Screen(); DESKTOPS[i]->prepareToClose(); @@ -540,7 +541,7 @@ void LSession::updateDesktops(){ DESKTOPS[i]->UpdateGeometry(); DESKTOPS[i]->show(); dnums << DESKTOPS[i]->Screen(); - geoms << DW->screenGeometry(DESKTOPS[i]->Screen()); + geoms << screens.at(i)->availableGeometry(); } } @@ -549,11 +550,11 @@ void LSession::updateDesktops(){ QList<QScreen*> scrns = QApplication::screens(); for(int i=0; i<sC; i++){ allNames << scrns.at(i)->name(); - if(!dnums.contains(i) && !geoms.contains(DW->screenGeometry(i)) ){ + if(!dnums.contains(i) && !geoms.contains(screens.at(i)->availableGeometry()) ){ //Start the desktop on this screen qDebug() << " - Start desktop on screen:" << i; DESKTOPS << new LDesktop(i); - geoms << DW->screenGeometry(i); + geoms << screens.at(i)->availableGeometry(); } } dset.setValue("last_used_screens", allNames); @@ -605,8 +606,9 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ if(geom.isNull()){ return; } //Could not get geometry for some reason //Get the available geometry for the screen the window is on QRect desk; + QList<QScreen *> screens = QGuiApplication::screens(); for(int i=0; i<DESKTOPS.length(); i++){ - if( this->desktop()->screenGeometry(DESKTOPS[i]->Screen()).contains(geom.center()) ){ + if( screens.at(i)->availableGeometry().contains(geom.center()) ){ //Window is on this screen if(DEBUG){ qDebug() << " - On Screen:" << DESKTOPS[i]->Screen(); } desk = DESKTOPS[i]->availableScreenGeom(); @@ -695,8 +697,9 @@ QFileInfoList LSession::DesktopFiles(){ } QRect LSession::screenGeom(int num){ - if(num < 0 || num >= this->desktop()->screenCount() ){ return QRect(); } - QRect geom = this->desktop()->screenGeometry(num); + QList<QScreen *> screens = QGuiApplication::screens(); + if(num < 0 || num >= screens.count() ){ return QRect(); } + QRect geom = screens.at(num)->availableGeometry(); return geom; } @@ -776,10 +779,13 @@ void LSession::playAudioFile(QString filepath){ // ======================= void LSession::RootSizeChange(){ if(DESKTOPS.isEmpty() || screenRect.isNull()){ return; } //Initial setup not run yet - QDesktopWidget *DW = this->desktop(); - int sC = DW->screenCount(); + QRect tmp; - for(int i=0; i<sC; i++){ tmp = tmp.united(DW->screenGeometry(i)); } + QList<QScreen*> screens = QGuiApplication::screens(); + QList<QScreen*>::const_iterator it; + for(it = screens.constBegin(); it != screens.constEnd(); ++it) { + tmp = tmp.united( (*it)->availableGeometry() ); + } if(tmp == screenRect){ return; } //false event - session size did not change qDebug() << "Got Root Size Change"; xchange = true; diff --git a/src-qt5/core/lumina-desktop/SystemWindow.cpp b/src-qt5/core/lumina-desktop/SystemWindow.cpp index af9188bc..bfad961d 100644 --- a/src-qt5/core/lumina-desktop/SystemWindow.cpp +++ b/src-qt5/core/lumina-desktop/SystemWindow.cpp @@ -49,7 +49,7 @@ void SystemWindow::updateWindow(){ ui->tool_shutdown->setEnabled(ok); ui->frame_update->setVisible( !LOS::systemPendingUpdates().isEmpty() ); //Center this window on the current screen - QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen + QPoint center = QGuiApplication::screenAt(QCursor::pos())->availableGeometry().center(); //get the center of the current screen this->move(center.x() - this->width()/2, center.y() - this->height()/2); } 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 88f535de..f954ec4f 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -168,7 +168,7 @@ void AppLauncherPlugin::loadButton(){ //Now adjust the visible text as necessary based on font/grid sizing if(button->toolTip().isEmpty()){ button->setToolTip(txt); } //Double check that the visual icon size matches the requested size - otherwise upscale the icon - if(button->fontMetrics().width(txt) > (button->width()-OUTMARGIN) ){ + if(button->fontMetrics().horizontalAdvance(txt) > (button->width()-OUTMARGIN) ){ //Text too long, try to show it on two lines //txt = button->fontMetrics().elidedText(txt, Qt::ElideRight, 2*(button->width()-OUTMARGIN), Qt::TextWordWrap); txt =txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks @@ -177,7 +177,7 @@ void AppLauncherPlugin::loadButton(){ //need to check each line QStringList txtL = txt.split("\n"); for(int i=0; i<txtL.length(); i++){ - if(( i+1<txtL.length()) && (button->fontMetrics().width(txtL[i]) < button->width()/2) ){ + if(( i+1<txtL.length()) && (button->fontMetrics().horizontalAdvance(txtL[i]) < button->width()/2) ){ txtL[i] = txtL[i]+" "+txtL[i+1]; txtL.removeAt(i+1); } diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h index 24410e75..0febe40f 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h +++ b/src-qt5/core/lumina-desktop/desktop-plugins/applauncher/OutlineToolButton.h @@ -76,13 +76,13 @@ protected: else{outC.setHsl(textC.hue(), textC.hslSaturation(), 255, 50); } //qDebug() << "Outline Color Values:" << outC; //Now get the size of the outline border (need to scale for high-res monitors) - qreal OWidth = opt.fontMetrics.width("o")/2.0; + qreal OWidth = opt.fontMetrics.horizontalAdvance("o")/2.0; //qDebug() << "Outline Width:" << OWidth; //Now generate a QPainterPath for the text QPainterPath path; QStringList txt = this->text().split("\n"); //need each line independently, the newline actually gets painted otherwise for(int i=0; i<txt.length(); i++){ - path.addText(box.center().x() - (opt.fontMetrics.width(txt[i])/2), box.y()+((i+1)*(box.height()/txt.length()))-opt.fontMetrics.descent(), opt.font, txt[i] ); + path.addText(box.center().x() - (opt.fontMetrics.horizontalAdvance(txt[i])/2), box.y()+((i+1)*(box.height()/txt.length()))-opt.fontMetrics.descent(), opt.font, txt[i] ); } path.setFillRule(Qt::WindingFill); //Now paint the text diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index 90f3374b..6f4d62d6 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -180,8 +180,8 @@ void DesktopViewPlugin::updateContents(){ } //Now adjust the visible text as necessary based on font/grid sizing it->setToolTip(txt); - if(this->fontMetrics().width(txt) > (gridSZ.width()-4) ){ - //int dash = this->fontMetrics().width("-"); + if(this->fontMetrics().horizontalAdvance(txt) > (gridSZ.width()-4) ){ + //int dash = this->fontMetrics().horizontalAdvance("-"); //Text too long, try to show it on two lines txt = txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks if(txt.contains("\n")){ diff --git a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp index 2972ea86..d45853d1 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -79,7 +79,7 @@ void LClock::updateTime(bool adjustformat){ if( this->layout()->direction() == QBoxLayout::TopToBottom ){ //different routine for vertical text (need newlines instead of spaces) for(int i=0; i<label.count("\n")+1; i++){ - if(this->size().width() < (this->fontMetrics().width(label.section("\n",i,i))+10 )&& label.section("\n",i,i).contains(" ")){ + if(this->size().width() < (this->fontMetrics().horizontalAdvance(label.section("\n",i,i))+10 )&& label.section("\n",i,i).contains(" ")){ label.replace(label.section("\n",i,i), label.section("\n",i,i).replace(" ", "\n")); i--; } @@ -100,12 +100,12 @@ void LClock::updateTime(bool adjustformat){ int wid = 0; int lwid = 0; for(int i=0; i<lines.length(); i++){ - lwid = metrics.width(lines[i]); + lwid = metrics.horizontalAdvance(lines[i]); if(lwid>wid){ wid = lwid; } } qDebug() << "Verify Clock width:" << lines.length() << wid << lines; this->setMinimumWidth(wid); - this->setMaximumWidth(wid + (4*metrics.width("O"))); + this->setMaximumWidth(wid + (4*metrics.horizontalAdvance("O"))); }else{ //vertical layout this->setMinimumHeight(metrics.lineSpacing() * lines.length()); diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index 5acd9721..49fdeeaf 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -30,7 +30,7 @@ LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizon connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); QRect screenSize = QApplication::desktop()->availableGeometry(this); - QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize",QSize(this->fontMetrics().width("x")*30 ,screenSize.height()/1.8)).toSize(); + QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize",QSize(this->fontMetrics().horizontalAdvance("x")*30 ,screenSize.height()/1.8)).toSize(); //qDebug() << "Got Start Menu Saved Size:" << saved; if(!saved.isNull() && saved.isValid()){ startmenu->setFixedSize(saved); } //re-load the previously saved value menu->setContents(startmenu); |