mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-07-15 22:59:57 +00:00
some part of refactoring
move plugin from private fix translation issue (#50)
This commit is contained in:
@ -19,7 +19,7 @@ import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Layouts 1.0 as QtLayouts
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
|
||||
|
||||
Item {
|
||||
|
@ -20,7 +20,7 @@ import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
|
||||
|
||||
Item {
|
||||
|
@ -20,7 +20,7 @@ import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
|
||||
|
||||
Item {
|
||||
|
@ -20,7 +20,7 @@ import QtQuick.Controls 1.3 as QtControls
|
||||
import QtQuick.Controls.Styles 1.3 as QtStyles
|
||||
import QtQuick.Dialogs 1.1 as QtDialogs
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
|
||||
|
||||
Item {
|
||||
|
@ -22,7 +22,7 @@ import org.kde.plasma.plasmoid 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
import "."
|
||||
|
||||
|
||||
@ -35,9 +35,11 @@ Item {
|
||||
"tooltipType": plasmoid.configuration.tooltipType,
|
||||
"tooltipWidth": plasmoid.configuration.tooltipWidth
|
||||
}
|
||||
property bool initializated: false
|
||||
|
||||
signal needUpdate
|
||||
signal needTooltipUpdate
|
||||
signal sizeUpdate
|
||||
|
||||
|
||||
// init
|
||||
@ -49,16 +51,17 @@ Item {
|
||||
|
||||
|
||||
// ui
|
||||
Grid {
|
||||
GridLayout {
|
||||
anchors.fill: parent
|
||||
horizontalItemAlignment: Grid.AlignHCenter
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
columns: plasmoid.configuration.verticalLayout ? 1 : DPAdds.numberOfDesktops()
|
||||
rows: plasmoid.configuration.verticalLayout ? DPAdds.numberOfDesktops() : 1
|
||||
|
||||
Repeater {
|
||||
id: repeater
|
||||
Layout.columnSpan: 0
|
||||
Layout.rowSpan: 0
|
||||
model: DPAdds.numberOfDesktops()
|
||||
|
||||
Text {
|
||||
id: text
|
||||
height: contentHeight
|
||||
@ -101,8 +104,6 @@ Item {
|
||||
onNeedUpdate: {
|
||||
if (debug) console.log("[main::onNeedUpdate]")
|
||||
|
||||
var newHeight = 0
|
||||
var newWidth = 0
|
||||
for (var i=0; i<repeater.count; i++) {
|
||||
if (!repeater.itemAt(i)) {
|
||||
if (debug) console.log("[main::onNeedUpdate] : Nothing to do here " + i)
|
||||
@ -124,12 +125,9 @@ Item {
|
||||
repeater.itemAt(i).font.weight = general.fontWeight[plasmoid.configuration.fontWeight]
|
||||
}
|
||||
repeater.itemAt(i).update()
|
||||
newHeight += plasmoid.configuration.height == 0 ? repeater.itemAt(i).contentHeight : plasmoid.configuration.height / repeater.count
|
||||
newWidth += plasmoid.configuration.width == 0 ? repeater.itemAt(i).contentWidth : plasmoid.configuration.width / repeater.count
|
||||
}
|
||||
Layout.minimumHeight = newHeight
|
||||
Layout.minimumWidth = newWidth
|
||||
|
||||
if (!initializated) sizeUpdate()
|
||||
needTooltipUpdate()
|
||||
}
|
||||
|
||||
@ -141,6 +139,19 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
onSizeUpdate: {
|
||||
if (debug) console.log("[main::onSizeUpdate]")
|
||||
|
||||
var newHeight = 0
|
||||
var newWidth = 0
|
||||
for (var i=0; i<repeater.count; i++) {
|
||||
newHeight += plasmoid.configuration.height == 0 ? repeater.itemAt(i).contentHeight : plasmoid.configuration.height / repeater.count
|
||||
newWidth += plasmoid.configuration.width == 0 ? repeater.itemAt(i).contentWidth : plasmoid.configuration.width / repeater.count
|
||||
}
|
||||
Layout.minimumHeight = newHeight
|
||||
Layout.minimumWidth = newWidth
|
||||
}
|
||||
|
||||
Plasmoid.onActivated: {
|
||||
if (debug) console.log("[main::onActivated]")
|
||||
|
||||
@ -150,10 +161,13 @@ Item {
|
||||
Plasmoid.onUserConfiguringChanged: {
|
||||
if (debug) console.log("[main::onUserConfiguringChanged]")
|
||||
|
||||
initializated = false
|
||||
DPAdds.setMark(plasmoid.configuration.mark)
|
||||
DPAdds.setPanelsToControl(plasmoid.configuration.panels)
|
||||
DPAdds.setToolTipData(tooltipSettings)
|
||||
|
||||
needUpdate()
|
||||
initializated = true
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -18,7 +18,7 @@
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 1.3 as QtControls
|
||||
|
||||
import org.kde.plasma.private.desktoppanel 1.0
|
||||
import org.kde.plasma.desktoppanel 1.0
|
||||
|
||||
|
||||
Item {
|
||||
|
@ -1,4 +1,5 @@
|
||||
set (PLUGIN_NAME dpplugin)
|
||||
add_definitions(-DTRANSLATION_DOMAIN=\"plasma_applet_org.kde.plasma.desktoppanel\")
|
||||
|
||||
add_definitions (${Qt5Core_DEFINITIONS})
|
||||
set (Qt_INCLUDE ${Qt5Core_INCLUDE_DIRS}
|
||||
@ -21,13 +22,12 @@ include_directories (${CMAKE_SOURCE_DIR}
|
||||
${Qt_INCLUDE}
|
||||
${Kf5_INCLUDE})
|
||||
|
||||
file (GLOB SUBPROJECT_SOURCE *.cpp)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
file (GLOB_RECURSE SUBPROJECT_SOURCE *.cpp ${PROJECT_TRDPARTY_DIR}/fontdialog/*.cpp)
|
||||
file (GLOB SUBPROJECT_NOTIFY *.notifyrc)
|
||||
|
||||
add_library (${PLUGIN_NAME} SHARED ${SUBPROJECT_SOURCE})
|
||||
target_link_libraries (${PLUGIN_NAME} ${Qt_LIBRARIES} ${Kf5_LIBRARIES})
|
||||
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/desktoppanel)
|
||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/private/desktoppanel)
|
||||
install (TARGETS ${PLUGIN_NAME} DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/desktoppanel)
|
||||
install (FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/plasma/desktoppanel)
|
||||
install (FILES ${SUBPROJECT_NOTIFY} DESTINATION ${KNOTIFYRC_INSTALL_DIR})
|
||||
|
@ -33,7 +33,7 @@ static QObject *dpadds_singletontype_provider(QQmlEngine *engine, QJSEngine *scr
|
||||
|
||||
void DPPlugin::registerTypes(const char *uri)
|
||||
{
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.desktoppanel"));
|
||||
Q_ASSERT(uri == QLatin1String("org.kde.plasma.desktoppanel"));
|
||||
|
||||
qmlRegisterSingletonType<DPAdds>(uri, 1, 0, "DPAdds", dpadds_singletontype_provider);
|
||||
}
|
||||
|
@ -22,8 +22,6 @@
|
||||
#include <QQmlExtensionPlugin>
|
||||
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
class DPPlugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -109,7 +109,7 @@ QString DPAdds::toolTipImage(const int desktop)
|
||||
QStringList windowList;
|
||||
for (int i=0; i<info.windowsData.count(); i++)
|
||||
windowList.append(info.windowsData[i].name);
|
||||
return QString("<ul><li>") + windowList.join(QString("</li><li>")) + QString("</li></ul>");
|
||||
return QString("<ul><li>%1</li></ul>").arg(windowList.join(QString("</li><li>")));
|
||||
}
|
||||
// init
|
||||
QGraphicsScene *toolTipScene = new QGraphicsScene();
|
||||
@ -188,7 +188,7 @@ QString DPAdds::parsePattern(const QString pattern, const int desktop)
|
||||
QStringList keys = dictKeys();
|
||||
parsed.replace(QString("$$"), QString("$\\$\\"));
|
||||
for (int i=0; i<keys.count(); i++)
|
||||
parsed.replace(QString("$") + keys[i], valueByKey(keys[i], desktop));
|
||||
parsed.replace(QString("$%1").arg(keys[i]), valueByKey(keys[i], desktop));
|
||||
parsed.replace(QString(" "), QString(" "));
|
||||
parsed.replace(QString("$\\$\\"), QString("$$"));
|
||||
|
||||
@ -238,11 +238,7 @@ QString DPAdds::valueByKey(const QString key, int desktop)
|
||||
if (debug) qDebug() << PDEBUG << ":" << "Requested key" << key;
|
||||
if (desktop == -1) desktop = currentDesktop();
|
||||
|
||||
QString currentMark;
|
||||
if (currentDesktop() == desktop)
|
||||
currentMark = mark;
|
||||
else
|
||||
currentMark = QString("");
|
||||
QString currentMark = currentDesktop() == desktop ? mark : QString("");
|
||||
if (key == QString("mark"))
|
||||
return QString("%1").arg(currentMark, mark.count(), QLatin1Char(' '));
|
||||
else if (key == QString("name"))
|
||||
@ -261,7 +257,7 @@ QString DPAdds::editPanelsToContol(const QString current)
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
|
||||
// paint
|
||||
QDialog *dialog = new QDialog(0);
|
||||
QDialog *dialog = new QDialog(nullptr);
|
||||
QListWidget *widget = new QListWidget(dialog);
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Open | QDialogButtonBox::Close,
|
||||
Qt::Vertical, dialog);
|
||||
@ -366,7 +362,7 @@ void DPAdds::changePanelsState()
|
||||
if (debug) qDebug() << PDEBUG;
|
||||
if (panelsToControl.isEmpty()) return;
|
||||
|
||||
QList<Plasma::Containment *> panels = getPanels();
|
||||
// QList<Plasma::Containment *> panels = getPanels();
|
||||
// for (int i=0; i<panels.count(); i++) {
|
||||
// if (!panelsToControl.contains(i)) continue;
|
||||
// bool wasVisible = panels[i]->view()->isVisible();
|
||||
@ -384,13 +380,13 @@ void DPAdds::changePanelsState()
|
||||
// KWindowSystem::setOnAllDesktops(winId, true);
|
||||
// }
|
||||
// }
|
||||
panels.clear();
|
||||
// panels.clear();
|
||||
}
|
||||
|
||||
|
||||
void DPAdds::sendNotification(const QString eventId, const QString message)
|
||||
{
|
||||
KNotification *notification = KNotification::event(eventId, QString("Desktop Panel ::: ") + eventId, message);
|
||||
KNotification *notification = KNotification::event(eventId, QString("Desktop Panel ::: %1").arg(eventId), message);
|
||||
notification->setComponentName(QString("plasma-applet-org.kde.plasma.desktop-panel"));
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ class DPAdds : public QObject
|
||||
} DesktopWindowsInfo;
|
||||
|
||||
public:
|
||||
DPAdds(QObject *parent = 0);
|
||||
DPAdds(QObject *parent = nullptr);
|
||||
~DPAdds();
|
||||
|
||||
Q_INVOKABLE bool isDebugEnabled();
|
||||
|
@ -1,3 +1,3 @@
|
||||
module org.kde.plasma.private.desktoppanel
|
||||
module org.kde.plasma.desktoppanel
|
||||
|
||||
plugin dpplugin
|
||||
|
Reference in New Issue
Block a user