some part of refactoring

move plugin from private
fix translation issue (#50)
This commit is contained in:
arcan1s
2015-05-12 00:19:08 +03:00
parent daa362fc16
commit c6cadba4b6
41 changed files with 166 additions and 147 deletions

View File

@ -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})

View File

@ -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);
}

View File

@ -22,8 +22,6 @@
#include <QQmlExtensionPlugin>
class QQmlEngine;
class DPPlugin : public QQmlExtensionPlugin
{
Q_OBJECT

View File

@ -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("&nbsp;"));
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"));
}

View File

@ -43,7 +43,7 @@ class DPAdds : public QObject
} DesktopWindowsInfo;
public:
DPAdds(QObject *parent = 0);
DPAdds(QObject *parent = nullptr);
~DPAdds();
Q_INVOKABLE bool isDebugEnabled();

View File

@ -1,3 +1,3 @@
module org.kde.plasma.private.desktoppanel
module org.kde.plasma.desktoppanel
plugin dpplugin