diff --git a/applets/kicker/package/contents/ui/main.qml b/applets/kicker/package/contents/ui/main.qml index dccba7932..4f20924ea 100644 --- a/applets/kicker/package/contents/ui/main.qml +++ b/applets/kicker/package/contents/ui/main.qml @@ -1,281 +1,281 @@ /*************************************************************************** * Copyright (C) 2014-2015 by Eike Hein * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ import QtQuick 2.0 import QtQuick.Layouts 1.1 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.kicker 0.1 as Kicker Item { id: kicker anchors.fill: parent signal reset property bool isDash: (plasmoid.pluginName == "org.kde.plasma.kickerdash") Plasmoid.switchWidth: isDash || !Plasmoid.fullRepresentationItem ? 0 : Plasmoid.fullRepresentationItem.Layout.minimumWidth Plasmoid.switchHeight: isDash || !Plasmoid.fullRepresentationItem ? 0 : Plasmoid.fullRepresentationItem.Layout.minimumHeight // this is a bit of a hack to prevent Plasma from spawning a dialog on its own when we're Dash Plasmoid.preferredRepresentation: isDash ? Plasmoid.fullRepresentation : null Plasmoid.compactRepresentation: isDash ? null : compactRepresentation Plasmoid.fullRepresentation: isDash ? compactRepresentation : menuRepresentation property QtObject itemListDialogComponent: Qt.createComponent("ItemListDialog.qml"); property Item dragSource: null property QtObject globalFavorites: rootModel.favoritesModel property QtObject systemFavorites: rootModel.systemFavoritesModel Plasmoid.icon: plasmoid.configuration.useCustomButtonImage ? plasmoid.configuration.customButtonImage : plasmoid.configuration.icon onSystemFavoritesChanged: { systemFavorites.favorites = plasmoid.configuration.favoriteSystemActions; } function action_menuedit() { processRunner.runMenuEditor(); } function updateSvgMetrics() { lineSvg.horLineHeight = lineSvg.elementSize("horizontal-line").height; lineSvg.vertLineWidth = lineSvg.elementSize("vertical-line").width; } Component { id: compactRepresentation CompactRepresentation {} } Component { id: menuRepresentation MenuRepresentation {} } Kicker.RootModel { id: rootModel autoPopulate: false appNameFormat: plasmoid.configuration.appNameFormat flat: isDash ? true : plasmoid.configuration.limitDepth sorted: plasmoid.configuration.alphaSort showSeparators: !isDash appletInterface: plasmoid showAllApps: isDash showTopLevelItems: !isDash showRecentApps: plasmoid.configuration.showRecentApps showRecentDocs: plasmoid.configuration.showRecentDocs showRecentContacts: plasmoid.configuration.showRecentContacts recentOrdering: plasmoid.configuration.recentOrdering onShowRecentAppsChanged: { plasmoid.configuration.showRecentApps = showRecentApps; } onShowRecentDocsChanged: { plasmoid.configuration.showRecentDocs = showRecentDocs; } onShowRecentContactsChanged: { plasmoid.configuration.showRecentContacts = showRecentContacts; } onRecentOrderingChanged: { plasmoid.configuration.recentOrdering = recentOrdering; } Component.onCompleted: { favoritesModel.initForClient("org.kde.plasma.kicker.favorites.instance-" + plasmoid.id) if (!plasmoid.configuration.favoritesPortedToKAstats) { favoritesModel.portOldFavorites(plasmoid.configuration.favoriteApps); plasmoid.configuration.favoritesPortedToKAstats = true; } rootModel.refresh(); } } Connections { target: globalFavorites onFavoritesChanged: { plasmoid.configuration.favoriteApps = target.favorites; } } Connections { target: systemFavorites onFavoritesChanged: { plasmoid.configuration.favoriteSystemActions = target.favorites; } } Connections { target: plasmoid.configuration onFavoriteAppsChanged: { globalFavorites.favorites = plasmoid.configuration.favoriteApps; } onFavoriteSystemActionsChanged: { systemFavorites.favorites = plasmoid.configuration.favoriteSystemActions; } } Kicker.RunnerModel { id: runnerModel appletInterface: plasmoid favoritesModel: globalFavorites runners: { var runners = new Array("services"); if (isDash) { runners = runners.concat(new Array("desktopsessions", "PowerDevil")); } if (plasmoid.configuration.useExtraRunners) { runners = runners.concat(plasmoid.configuration.extraRunners); } return runners; } deleteWhenEmpty: isDash } Kicker.DragHelper { id: dragHelper dragIconSize: units.iconSizes.medium } Kicker.ProcessRunner { id: processRunner; } Kicker.WindowSystem { id: windowSystem; } PlasmaCore.FrameSvgItem { id : highlightItemSvg visible: false imagePath: "widgets/viewitem" prefix: "hover" } PlasmaCore.FrameSvgItem { id : listItemSvg visible: false imagePath: "widgets/listitem" prefix: "normal" } PlasmaCore.Svg { id: arrows imagePath: "widgets/arrows" size: "16x16" } PlasmaCore.Svg { id: lineSvg imagePath: "widgets/line" property int horLineHeight property int vertLineWidth } PlasmaComponents.Label { id: toolTipDelegate width: contentWidth - height: contentHeight + height: undefined property Item toolTip text: (toolTip != null) ? toolTip.text : "" } Timer { id: justOpenedTimer repeat: false interval: 600 } Connections { target: plasmoid onExpandedChanged: { if (expanded) { windowSystem.monitorWindowVisibility(plasmoid.fullRepresentationItem); justOpenedTimer.start(); } else { kicker.reset(); } } } function resetDragSource() { dragSource = null; } function enableHideOnWindowDeactivate() { plasmoid.hideOnWindowDeactivate = true; } Component.onCompleted: { if (plasmoid.hasOwnProperty("activationTogglesExpanded")) { plasmoid.activationTogglesExpanded = !isDash } windowSystem.focusIn.connect(enableHideOnWindowDeactivate); plasmoid.hideOnWindowDeactivate = true; if (plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) { plasmoid.setAction("menuedit", i18n("Edit Applications..."), "kmenuedit"); } updateSvgMetrics(); theme.themeChanged.connect(updateSvgMetrics); rootModel.refreshed.connect(reset); dragHelper.dropped.connect(resetDragSource); } } diff --git a/containments/desktop/package/contents/ui/AppletHandle.qml b/containments/desktop/package/contents/ui/AppletHandle.qml index a8aee3004..5493ae8bf 100644 --- a/containments/desktop/package/contents/ui/AppletHandle.qml +++ b/containments/desktop/package/contents/ui/AppletHandle.qml @@ -1,310 +1,310 @@ /* * Copyright 2011-2013 Sebastian Kügler * Copyright 2011 Marco Martin * Copyright 2014 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.components 2.0 as PlasmaComponents KQuickControlsAddons.MouseEventListener { id: appletHandle opacity: appletItem.controlsOpacity visible: opacity > 0 width: appletItem.handleWidth height: Math.max(appletItem.innerHeight - appletItem.margins.top - appletItem.margins.bottom, buttonColumn.implicitHeight) hoverEnabled: true onContainsMouseChanged: { if (!containsMouse && !pressed) { hoverTracker.restart() } } onReleased: { if (!containsMouse) { hoverTracker.restart() } } //z: dragMouseArea.z + 1 property int buttonMargin: 6 property int minimumHeight: 6 * (root.iconSize + buttonMargin) signal removeApplet signal moveFinished transform: Translate { x: (handleMerged ? 0 : controlsOpacity * appletHandle.width) * (appletHandle.LayoutMirroring.enabled ? -1 : 1) } PlasmaCore.FrameSvgItem { id: noBackgroundHandle visible: controlsOpacity > 0 z: plasmoidBackground.z - 10 anchors { top: parent.top bottom: parent.bottom left: parent.left right: parent.right // verticalCenter: parent.verticalCenter leftMargin: -margins.left topMargin: -margins.top rightMargin: -margins.right bottomMargin: -margins.bottom } smooth: true imagePath: (backgroundHints == "NoBackground" || !handleMerged) ? "widgets/background" : "" } PlasmaComponents.Label { id: toolTipDelegate width: contentWidth - height: contentHeight + height: undefined property Item toolTip text: (toolTip != null) ? toolTip.mainText : "" } ColumnLayout { id: buttonColumn width: appletItem.handleWidth anchors { top: parent.top bottom: parent.bottom right: parent.right } spacing: buttonMargin*2 ActionButton { svg: configIconsSvg elementId: "size-diagonal-tr2bl" iconSize: root.iconSize mainText: i18n("Resize") active: !resizeHandle.pressed ResizeHandle { id: resizeHandle anchors { fill: parent margins: -buttonMargin } onPressed: parent.hideToolTip(); cursorShape: parent.LayoutMirroring.enabled ? Qt.SizeFDiagCursor : Qt.SizeBDiagCursor moveX: parent.LayoutMirroring.enabled moveY: true resizeWidth: true resizeHeight: true visible: true } } ActionButton { id: rotateButton svg: configIconsSvg elementId: "rotate" mainText: i18n("Rotate") iconSize: root.iconSize action: (applet) ? applet.action("rotate") : null active: !rotateHandle.pressed Component.onCompleted: { if (action && typeof(action) != "undefined") { action.enabled = true } } MouseArea { id: rotateHandle anchors { fill: parent margins: -buttonMargin } property int startRotation property real startCenterRelativeAngle; function pointAngle(pos) { var r = Math.sqrt(pos.x * pos.x + pos.y * pos.y); var cosine = pos.x / r; if (pos.y >= 0) { return Math.acos(cosine) * (180/Math.PI); } else { return -Math.acos(cosine) * (180/Math.PI); } } function centerRelativePos(x, y) { var mousePos = appletItem.parent.mapFromItem(rotateButton, x, y); var centerPos = appletItem.parent.mapFromItem(appletItem, appletItem.width/2, appletItem.height/2); mousePos.x -= centerPos.x; mousePos.y -= centerPos.y; return mousePos; } onPressed: { parent.hideToolTip(); mouse.accepted = true animationsEnabled = false; startRotation = appletItem.rotation; startCenterRelativeAngle = pointAngle(centerRelativePos(mouse.x, mouse.y)); } onPositionChanged: { var rot = startRotation%360; var snap = 4; var newRotation = Math.round(pointAngle(centerRelativePos(mouse.x, mouse.y)) - startCenterRelativeAngle + startRotation); if (newRotation < 0) { newRotation = newRotation + 360; } else if (newRotation >= 360) { newRotation = newRotation % 360; } snapIt(0); snapIt(90); snapIt(180); snapIt(270); function snapIt(snapTo) { if (newRotation > (snapTo - snap) && newRotation < (snapTo + snap)) { newRotation = snapTo; } } //print("Start: " + startRotation + " new: " + newRotation); appletItem.rotation = newRotation; } onReleased: { // save rotation // print("saving..."); root.layoutManager.saveItem(appletItem); } } } ActionButton { svg: configIconsSvg elementId: "configure" iconSize: root.iconSize visible: (action && typeof(action) != "undefined") ? action.enabled : false action: (applet) ? applet.action("configure") : null Component.onCompleted: { if (action && typeof(action) != "undefined") { action.enabled = true } } } ActionButton { svg: configIconsSvg elementId: "maximize" iconSize: root.iconSize visible: (action && typeof(action) != "undefined") ? action.enabled : false action: (applet) ? applet.action("run associated application") : null Component.onCompleted: { if (action && typeof(action) != "undefined") { action.enabled = true } } } //spacer MouseArea { id: dragMouseArea implicitHeight: root.iconSize * 2 Layout.fillWidth: true Layout.fillHeight: true property int zoffset: 1000 drag.target: appletItem cursorShape: Qt.DragMoveCursor onPressed: { appletItem.z = appletItem.z + zoffset; animationsEnabled = false mouse.accepted = true appletItem.releasePosition(); appletItem.floating = true; placeHolder.syncWithItem(appletItem) placeHolderPaint.opacity = root.haloOpacity; } onPositionChanged: { var pos = mapToItem(root.parent, mouse.x, mouse.y); var newCont = plasmoid.containmentAt(pos.x, pos.y); if (newCont && newCont != plasmoid) { var newPos = newCont.mapFromApplet(plasmoid, pos.x, pos.y); newCont.addApplet(appletItem.applet, newPos.x, newPos.y); placeHolderPaint.opacity = 0; } else { placeHolder.syncWithItem(appletItem); } } onReleased: { appletItem.z = appletItem.z - zoffset; repositionTimer.running = false placeHolderPaint.opacity = 0 animationsEnabled = true appletItem.floating = false; appletItem.positionItem(); root.layoutManager.save() appletHandle.moveFinished() } } Item { Layout.minimumWidth: closeButton.width Layout.minimumHeight: closeButton.height ActionButton { id: closeButton svg: configIconsSvg elementId: "delete" mainText: i18n("Remove") iconSize: root.iconSize visible: { if (!applet) { return false; } var a = applet.action("remove"); return (a && typeof(a) != "undefined") ? a.enabled : false; } // we don't set action, since we want to catch the button click, // animate, and then trigger the "remove" action // Triggering the action is handled in the appletItem, we just // emit a signal here to avoid the applet-gets-removed-before-we- // can-animate it race condition. onClicked: { appletHandle.removeApplet(); } Component.onCompleted: { var a = applet.action("remove"); if (a && typeof(a) != "undefined") { a.enabled = true } } } } } } diff --git a/kcms/colors/editor/scmeditordialog.cpp b/kcms/colors/editor/scmeditordialog.cpp index f286c0ede..26babb81f 100644 --- a/kcms/colors/editor/scmeditordialog.cpp +++ b/kcms/colors/editor/scmeditordialog.cpp @@ -1,272 +1,272 @@ /* ColorEdit widget for KDE Display color scheme setup module * Copyright (C) 2016 Olivier Churlaud * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; see the file COPYING. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "scmeditordialog.h" #include "scmeditoroptions.h" #include "scmeditorcolors.h" #include "scmeditoreffects.h" #include #include #include #include #include #include #include #include #include #include SchemeEditorDialog::SchemeEditorDialog(KSharedConfigPtr config, QWidget *parent) : QDialog(parent) { m_config = config; init(); } SchemeEditorDialog::SchemeEditorDialog(const QString &path, QWidget *parent) : QDialog(parent) , m_filePath(path) { m_config = KSharedConfig::openConfig(path); m_schemeName = KConfigGroup(m_config, "General").readEntry("Name"); this->setWindowTitle(m_schemeName); init(); } bool SchemeEditorDialog::overwriteOnSave() const { return m_overwriteOnSave; } void SchemeEditorDialog::setOverwriteOnSave(bool overwrite) { m_overwriteOnSave = overwrite; buttonBox->button(QDialogButtonBox::Apply)->setVisible(overwrite); buttonBox->button(QDialogButtonBox::Save)->setVisible(!overwrite); } void SchemeEditorDialog::init() { setupUi(this); schemeKnsUploadButton->setIcon( QIcon::fromTheme(QStringLiteral("get-hot-new-stuff")) ); m_optionTab = new SchemeEditorOptions(m_config); m_colorTab = new SchemeEditorColors(m_config); m_disabledTab = new SchemeEditorEffects(m_config, QPalette::Disabled); m_inactiveTab = new SchemeEditorEffects(m_config, QPalette::Inactive); tabWidget->addTab(m_optionTab, i18n("Options")); tabWidget->addTab(m_colorTab, i18n("Colors")); tabWidget->addTab(m_disabledTab, i18n("Disabled")); tabWidget->setCurrentWidget(m_colorTab); connect(m_optionTab, &SchemeEditorOptions::changed, this, &SchemeEditorDialog::updateTabs); connect(m_colorTab, &SchemeEditorColors::changed, this, &SchemeEditorDialog::updateTabs); connect(m_disabledTab, &SchemeEditorEffects::changed, this, &SchemeEditorDialog::updateTabs); connect(m_inactiveTab, &SchemeEditorEffects::changed, this, &SchemeEditorDialog::updateTabs); // In overwrite mode we use "Apply", in regular mode "Save" button buttonBox->button(QDialogButtonBox::Apply)->setVisible(false); buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false); updateTabs(); } void SchemeEditorDialog::on_schemeKnsUploadButton_clicked() { if (m_unsavedChanges) { KMessageBox::ButtonCode reallyUpload = KMessageBox::questionYesNo( this, i18n("This colour scheme was not saved. Continue?"), i18n("Do you really want to upload?")); if (reallyUpload == KMessageBox::No) { return; } } // find path const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes/") + m_schemeName + QStringLiteral(".colors")); if (path.isEmpty() ) // if the color scheme file wasn't found { qDebug() << "path for color scheme " << m_schemeName << " couldn't be found"; return; } // upload KNS3::UploadDialog dialog(QStringLiteral("colorschemes.knsrc"), this); dialog.setUploadFile(QUrl::fromLocalFile(path) ); dialog.exec(); } void SchemeEditorDialog::on_buttonBox_clicked(QAbstractButton *button) { if (buttonBox->standardButton(button) == QDialogButtonBox::Reset) { m_config->markAsClean(); m_config->reparseConfiguration(); updateTabs(); setUnsavedChanges(false); } else if (buttonBox->standardButton(button) == QDialogButtonBox::Save || buttonBox->standardButton(button) == QDialogButtonBox::Apply) { saveScheme(); } else if (buttonBox->standardButton(button) == QDialogButtonBox::Close) { if (m_unsavedChanges) { KMessageBox::ButtonCode ans = KMessageBox::questionYesNo( this, i18n("You have unsaved changes. Do you really want to quit?"), i18n("Unsaved changes")); if (ans == KMessageBox::No) { return; } } m_config->markAsClean(); m_config->reparseConfiguration(); this->accept(); } } void SchemeEditorDialog::saveScheme() { QString name = m_schemeName; // prompt for the name to save as if (!m_overwriteOnSave) { bool ok; name = QInputDialog::getText(this, i18n("Save Color Scheme"), i18n("&Enter a name for the color scheme:"), QLineEdit::Normal, m_schemeName, &ok); if (!ok) { return; } } QString filename = name; filename.remove(QLatin1Char('\'')); // So Foo's does not become FooS QRegExp fixer(QStringLiteral("[\\W,.-]+(.?)")); int offset; while ((offset = fixer.indexIn(filename)) >= 0) filename.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper()); filename.replace(0, 1, filename.at(0).toUpper()); // check if that name is already in the list const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("color-schemes/") + filename + QStringLiteral(".colors")); QFile file(path); const int permissions = file.permissions(); const bool canWrite = (permissions & QFile::WriteUser); // or if we can overwrite it if it exists if (path.isEmpty() || !file.exists() || canWrite) { if(canWrite && !m_overwriteOnSave){ int ret = KMessageBox::questionYesNo(this, i18n("A color scheme with that name already exists.\nDo you want to overwrite it?"), i18n("Save Color Scheme"), KStandardGuiItem::overwrite(), KStandardGuiItem::cancel()); //on don't overwrite, call again the function if(ret == KMessageBox::No){ this->saveScheme(); return; } } // go ahead and save it QString newpath = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/color-schemes/"; QDir dir; dir.mkpath(newpath); newpath += filename + ".colors"; KConfig *config = m_config->copyTo(newpath); m_config->markAsClean(); m_config->reparseConfiguration(); KConfigGroup group(config, "General"); group.writeEntry("Name", name); // sync it and delete pointer config->sync(); delete config; // reopen and update window m_config = KSharedConfig::openConfig(newpath); m_schemeName = name; setWindowTitle(name); setUnsavedChanges(false); QTextStream out(stdout); out << filename << endl; } else if (!canWrite && file.exists()) { KMessageBox::error(this, i18n("You do not have permission to overwrite that scheme"), i18n("Error")); } } void SchemeEditorDialog::updateTabs(bool madeByUser) { if (madeByUser) { setUnsavedChanges(true); } KConfigGroup group(m_config, "ColorEffects:Inactive"); - bool hideInactiveTab = group.readEntry("Enable", QVariant(true)).toBool(); - if ( hideInactiveTab ) - { + bool showInactiveTab = group.readEntry("Enable", QVariant(true)).toBool(); + + const int idx = tabWidget->indexOf(m_inactiveTab); + + if (showInactiveTab && idx == -1) { tabWidget->addTab(m_inactiveTab, i18n("Inactive")); - } - else - { - tabWidget->removeTab(tabWidget->indexOf(m_inactiveTab)); + } else if (!showInactiveTab && idx > -1) { + tabWidget->removeTab(idx); } m_optionTab->updateValues(); m_colorTab->updateValues(); m_inactiveTab->updateValues(); m_disabledTab->updateValues(); } void SchemeEditorDialog::setUnsavedChanges(bool changes) { m_unsavedChanges = changes; if (changes) { buttonBox->button(QDialogButtonBox::Save)->setEnabled(true); buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true); buttonBox->button(QDialogButtonBox::Reset)->setEnabled(true); } else { buttonBox->button(QDialogButtonBox::Save)->setEnabled(false); buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); buttonBox->button(QDialogButtonBox::Reset)->setEnabled(false); } }