diff --git a/sources/awesome-widget-kde4/awesome-widget.cpp b/sources/awesome-widget-kde4/awesome-widget.cpp index 18d58cb..78f2612 100644 --- a/sources/awesome-widget-kde4/awesome-widget.cpp +++ b/sources/awesome-widget-kde4/awesome-widget.cpp @@ -492,7 +492,7 @@ void AwesomeWidget::showUpdates(QString version) text += i18n("New version : %1", version) + QString("\n\n"); text += i18n("Click \"Ok\" to download"); int select = QMessageBox::information(0, i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel); - switch(select) { + switch (select) { case QMessageBox::Ok: QDesktopServices::openUrl(QString(RELEASES) + version); break; diff --git a/sources/awesome-widget-kde4/graphicalitem.cpp b/sources/awesome-widget-kde4/graphicalitem.cpp index 0437ced..04b0bad 100644 --- a/sources/awesome-widget-kde4/graphicalitem.cpp +++ b/sources/awesome-widget-kde4/graphicalitem.cpp @@ -75,7 +75,7 @@ QString GraphicalItem::getImage(const float value) view->resize(_width + 5.0, _height + 5.0); // paint - switch(_type) { + switch (_type) { case Vertical: pen.setWidth(_width); // inactive @@ -190,7 +190,7 @@ QString GraphicalItem::getStrType() if (debug) qDebug() << PDEBUG; QString value; - switch(_type) { + switch (_type) { case Vertical: value = QString("Vertical"); break; diff --git a/sources/awesome-widget-kf5/plugin/graphicalitem.cpp b/sources/awesome-widget-kf5/plugin/graphicalitem.cpp index 1085239..e44be2a 100644 --- a/sources/awesome-widget-kf5/plugin/graphicalitem.cpp +++ b/sources/awesome-widget-kf5/plugin/graphicalitem.cpp @@ -79,7 +79,7 @@ QString GraphicalItem::image(const float value) view->resize(m_width + 5.0, m_height + 5.0); // paint - switch(m_type) { + switch (m_type) { case Vertical: pen.setWidth(m_width); // inactive @@ -206,7 +206,7 @@ QString GraphicalItem::strType() if (debug) qDebug() << PDEBUG; QString value; - switch(m_type) { + switch (m_type) { case Vertical: value = QString("Vertical"); break; diff --git a/sources/desktop-panel-kde4/desktop-panel.cpp b/sources/desktop-panel-kde4/desktop-panel.cpp index bd2bd2c..178a866 100644 --- a/sources/desktop-panel-kde4/desktop-panel.cpp +++ b/sources/desktop-panel-kde4/desktop-panel.cpp @@ -188,7 +188,7 @@ QString DesktopPanel::panelLocationToStr(Plasma::Location loc) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Location" << loc; - switch(loc) { + switch (loc) { case Plasma::TopEdge: return i18n("Top Edge"); case Plasma::BottomEdge: diff --git a/sources/desktop-panel-kf5/package/contents/config/main.xml b/sources/desktop-panel-kf5/package/contents/config/main.xml index 3440e43..d779b52 100644 --- a/sources/desktop-panel-kf5/package/contents/config/main.xml +++ b/sources/desktop-panel-kf5/package/contents/config/main.xml @@ -14,9 +14,6 @@ - - true - windows diff --git a/sources/desktop-panel-kf5/plugin/dpadds.cpp b/sources/desktop-panel-kf5/plugin/dpadds.cpp index 73f6864..862156d 100644 --- a/sources/desktop-panel-kf5/plugin/dpadds.cpp +++ b/sources/desktop-panel-kf5/plugin/dpadds.cpp @@ -22,8 +22,14 @@ #include #include +#include #include +#include +#include +#include +#include #include +#include #include #include @@ -63,7 +69,6 @@ QStringList DPAdds::dictKeys() if (debug) qDebug() << PDEBUG; QStringList allKeys; - allKeys.append(QString("fullmark")); allKeys.append(QString("mark")); allKeys.append(QString("name")); allKeys.append(QString("number")); @@ -73,6 +78,57 @@ QStringList DPAdds::dictKeys() } +QString DPAdds::toolTipImage(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + // prepare + // clear + QGraphicsScene *toolTipScene = new QGraphicsScene(); + QGraphicsView *toolTipView = new QGraphicsView(toolTipScene); + DesktopWindowsInfo info = getInfoByDesktop(desktop); + float margin = 5.0 * info.desktop.width() / 400.0; + toolTipView->resize(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin); + toolTipScene->clear(); + toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush)); + // borders + toolTipScene->addLine(0, 0, 0, info.desktop.height() + 2.0 * margin); + toolTipScene->addLine(0, info.desktop.height() + 2.0 * margin, + info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin); + toolTipScene->addLine(info.desktop.width() + 2.0 * margin, info.desktop.height() + 2.0 * margin, + info.desktop.width() + 2.0 * margin, 0); + toolTipScene->addLine(info.desktop.width() + 2.0 * margin, 0, 0, 0); + + if (tooltipType == QString("contours")) { + QPen pen = QPen(); + pen.setWidthF(2.0 * info.desktop.width() / 400.0); + pen.setColor(QColor(tooltipColor)); + for (int i=0; iaddLine(info.windows[i].left() + margin, info.windows[i].bottom() + margin, + info.windows[i].left() + margin, info.windows[i].top() + margin, pen); + toolTipScene->addLine(info.windows[i].left() + margin, info.windows[i].top() + margin, + info.windows[i].right() + margin, info.windows[i].top() + margin, pen); + toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].top() + margin, + info.windows[i].right() + margin, info.windows[i].bottom() + margin, pen); + toolTipScene->addLine(info.windows[i].right() + margin, info.windows[i].bottom() + margin, + info.windows[i].left() + margin, info.windows[i].bottom() + margin, pen); + } + } else if (tooltipType == QString("clean")) { +// toolTip.setWindowsToPreview(info.desktopId); + } else if (tooltipType == QString("windows")) { +// toolTip.setWindowsToPreview(info.winId); + } + + QPixmap image = toolTipView->grab().scaledToWidth(tooltipWidth); + QByteArray byteArray; + QBuffer buffer(&byteArray); + image.save(&buffer, "PNG"); + + return QString("").arg(QString(byteArray.toBase64())); +} + + QString DPAdds::parsePattern(const QString pattern, const int desktop) { if (debug) qDebug() << PDEBUG; @@ -89,6 +145,42 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop) } +void DPAdds::setMark(const QString newMark) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Mark" << newMark; + + mark = newMark; +} + + +void DPAdds::setPanelsToControl(const QString newPanels) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Panels" << newPanels; + + panelsToControl.clear(); + if (newPanels == QString("-1")) { + int count = getPanels().count(); + for (int i=0; i tooltipData) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Data" << tooltipData; + + tooltipColor = tooltipData[QString("tooltipColor")].toString(); + tooltipType = tooltipData[QString("tooltipType")].toString(); + tooltipWidth = tooltipData[QString("tooltipWidth")].toInt(); +} + + QString DPAdds::valueByKey(const QString key, const int desktop) { if (debug) qDebug() << PDEBUG; @@ -99,10 +191,8 @@ QString DPAdds::valueByKey(const QString key, const int desktop) currentMark = mark; else currentMark = QString(""); - if (key == QString("fullmark")) + if (key == QString("mark")) return QString("%1").arg(currentMark, currentMark.count(), QLatin1Char(' ')); - else if (key == QString("mark")) - return currentMark; else if (key == QString("name")) return KWindowSystem::desktopName(desktop); else if (key == QString("number")) @@ -114,6 +204,56 @@ QString DPAdds::valueByKey(const QString key, const int desktop) } +QString DPAdds::editPanelsToContol(const QString current) +{ + if (debug) qDebug() << PDEBUG; + + // paint + QDialog *dialog = new QDialog(0); + QListWidget *widget = new QListWidget(dialog); + QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close, + Qt::Vertical, dialog); + QHBoxLayout *layout = new QHBoxLayout(dialog); + layout->addWidget(widget); + layout->addWidget(buttons); + dialog->setLayout(layout); + connect(buttons, SIGNAL(rejected()), dialog, SLOT(reject())); + connect(buttons, SIGNAL(accepted()), dialog, SLOT(accept())); + + // fill + QList panels = getPanels(); + for (int i=0; ilocation()), widget); + if ((current.split(QChar(',')).contains(QString::number(i))) || + (current == QString("-1"))) + item->setCheckState(Qt::Checked); + else + item->setCheckState(Qt::Unchecked); + } + + // exec + QString value; + QStringList indexes; + int ret = dialog->exec(); + switch (ret) { + case QDialog::Accepted: + for (int i=0; icount(); i++) + if (widget->item(i)->checkState() == Qt::Checked) + indexes.append(QString::number(i)); + if (indexes.count() == widget->count()) + value = QString("-1"); + else + value = indexes.join(QChar(',')); + break; + default: + value = current; + break; + } + + return value; +} + + QString DPAdds::getAboutText(const QString type) { if (debug) qDebug() << PDEBUG; @@ -172,11 +312,11 @@ QMap DPAdds::getFont(const QMap defaultFon void DPAdds::changePanelsState() { if (debug) qDebug() << PDEBUG; - if (panelsToControl == QString("-1")) return; + if (panelsToControl.isEmpty()) return; QList panels = getPanels(); // for (int i=0; iview()->isVisible(); // int winId = panels[i]->view()->winId(); // if (wasVisible) { @@ -221,6 +361,34 @@ void DPAdds::changeDesktop(const int desktop) } +DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int desktop) +{ + if (debug) qDebug() << PDEBUG; + if (debug) qDebug() << PDEBUG << ":" << "Desktop" << desktop; + + + DesktopWindowsInfo info; + info.desktop = KWindowSystem::workArea(desktop); + + QList windows = KWindowSystem::windows(); + for (int i=0; i DPAdds::getPanels() { if (debug) qDebug() << PDEBUG; @@ -242,7 +410,7 @@ QString DPAdds::panelLocationToStr(Plasma::Types::Location location) if (debug) qDebug() << PDEBUG; if (debug) qDebug() << PDEBUG << ":" << "Location" << location; - switch(location) { + switch (location) { case Plasma::Types::Location::TopEdge: return i18n("Top Edge"); case Plasma::Types::Location::BottomEdge: diff --git a/sources/desktop-panel-kf5/plugin/dpadds.h b/sources/desktop-panel-kf5/plugin/dpadds.h index 1d729b5..9fd8633 100644 --- a/sources/desktop-panel-kf5/plugin/dpadds.h +++ b/sources/desktop-panel-kf5/plugin/dpadds.h @@ -30,16 +30,28 @@ class DPAdds : public QObject { Q_OBJECT + typedef struct { + QRect desktop; + QList desktopId; + QList windows; + QList winId; + } DesktopWindowsInfo; + public: DPAdds(QObject *parent = 0); ~DPAdds(); Q_INVOKABLE bool isDebugEnabled(); Q_INVOKABLE QStringList dictKeys(); + Q_INVOKABLE QString toolTipImage(const int desktop); Q_INVOKABLE QString parsePattern(const QString pattern, const int desktop); // values + Q_INVOKABLE void setMark(const QString newMark); + Q_INVOKABLE void setPanelsToControl(const QString newPanels); + Q_INVOKABLE void setToolTipData(const QMap tooltipData); Q_INVOKABLE QString valueByKey(const QString key, const int desktop); // configuration slots + Q_INVOKABLE QString editPanelsToContol(const QString current); Q_INVOKABLE QString getAboutText(const QString type = "header"); Q_INVOKABLE QMap getFont(const QMap defaultFont); @@ -55,12 +67,14 @@ private slots: void changeDesktop(const int desktop); private: + DesktopWindowsInfo getInfoByDesktop(const int desktop); QList getPanels(); QString panelLocationToStr(Plasma::Types::Location location); // variables bool debug = false; - int oldState; - QString mark, panelsToControl; + int oldState, tooltipWidth; + QString mark, tooltipColor, tooltipType; + QList panelsToControl; };