mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 16:58:16 +03:00
add duplicate view in context menu
This commit is contained in:
parent
c159753c4f
commit
965644ce2c
@ -15,6 +15,9 @@
|
||||
<method name="switchToLayout">
|
||||
<arg name="layout" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="duplicateView">
|
||||
<arg name="containmentId" type="u" direction="in"/>
|
||||
</method>
|
||||
<method name="removeView">
|
||||
<arg name="containmentId" type="u" direction="in"/>
|
||||
</method>
|
||||
|
@ -1166,6 +1166,14 @@ QStringList Corona::contextMenuData()
|
||||
return data;
|
||||
}
|
||||
|
||||
void Corona::duplicateView(const uint &containmentId)
|
||||
{
|
||||
auto view = m_layoutsManager->synchronizer()->viewForContainment((int)containmentId);
|
||||
if (view) {
|
||||
view->duplicateView();
|
||||
}
|
||||
}
|
||||
|
||||
void Corona::removeView(const uint &containmentId)
|
||||
{
|
||||
auto view = m_layoutsManager->synchronizer()->viewForContainment((int)containmentId);
|
||||
|
@ -165,6 +165,7 @@ public slots:
|
||||
void aboutApplication();
|
||||
void activateLauncherMenu();
|
||||
void loadDefaultLayout() override;
|
||||
void duplicateView(const uint &containmentId);
|
||||
void removeView(const uint &containmentId);
|
||||
void setBackgroundFromBroadcast(QString activity, QString screenName, QString filename);
|
||||
void setBroadcastedBackgroundsEnabled(QString activity, QString screenName, bool enabled);
|
||||
|
@ -1657,7 +1657,7 @@ void GenericLayout::syncToLayoutFile(bool removeLayoutId)
|
||||
Layouts::Storage::self()->syncToLayoutFile(this, removeLayoutId);
|
||||
}
|
||||
|
||||
void GenericLayout::copyView(Plasma::Containment *containment)
|
||||
void GenericLayout::duplicateView(Plasma::Containment *containment)
|
||||
{
|
||||
//! Don't create LatteView when the containment is created because we must update its screen settings first
|
||||
setBlockAutomaticLatteViewCreation(true);
|
||||
|
@ -124,7 +124,7 @@ public:
|
||||
|
||||
//! this function needs the layout to have first set the corona through initToCorona() function
|
||||
virtual void addView(Plasma::Containment *containment, bool forceOnPrimary = false, int explicitScreen = -1, Layout::ViewsMap *occupied = nullptr);
|
||||
void copyView(Plasma::Containment *containment);
|
||||
void duplicateView(Plasma::Containment *containment);
|
||||
void recreateView(Plasma::Containment *containment, bool delayed = true);
|
||||
bool latteViewExists(Plasma::Containment *containment);
|
||||
|
||||
|
@ -449,9 +449,9 @@ void View::reconsiderScreen()
|
||||
m_positioner->reconsiderScreen();
|
||||
}
|
||||
|
||||
void View::copyView()
|
||||
void View::duplicateView()
|
||||
{
|
||||
m_layout->copyView(containment());
|
||||
m_layout->duplicateView(containment());
|
||||
}
|
||||
|
||||
void View::exportTemplate()
|
||||
|
@ -268,7 +268,7 @@ public:
|
||||
void releaseConfigView();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void copyView();
|
||||
Q_INVOKABLE void duplicateView();
|
||||
Q_INVOKABLE void exportTemplate();
|
||||
Q_INVOKABLE void removeView();
|
||||
|
||||
|
@ -41,6 +41,7 @@ const char LAYOUTSNAME[] = "layouts";
|
||||
const char PREFERENCESNAME[] = "preferences";
|
||||
const char QUITLATTENAME[] = "quit latte";
|
||||
const char ADDWIDGETSNAME[] = "add latte widgets";
|
||||
const char DUPLICATEVIEWNAME[] = "duplicate view";
|
||||
const char EDITVIEWNAME[] = "edit view";
|
||||
const char REMOVEVIEWNAME[] = "remove view";
|
||||
|
||||
@ -142,6 +143,18 @@ void Menu::makeActions()
|
||||
}
|
||||
});
|
||||
|
||||
//! Duplicate Action
|
||||
m_duplicateAction = new QAction(QIcon::fromTheme("edit-copy"), "Duplicate Dock", this);
|
||||
m_duplicateAction->setVisible(containment()->isUserConfiguring());
|
||||
connect(m_duplicateAction, &QAction::triggered, [=](){
|
||||
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
|
||||
|
||||
if (iface.isValid()) {
|
||||
iface.call("duplicateView", containment()->id());
|
||||
}
|
||||
});
|
||||
this->containment()->actions()->addAction(DUPLICATEVIEWNAME, m_duplicateAction);
|
||||
|
||||
//! Remove Action
|
||||
m_removeAction = new QAction(QIcon::fromTheme("delete"), "Remove Dock", this);
|
||||
m_removeAction->setVisible(containment()->isUserConfiguring());
|
||||
@ -184,6 +197,7 @@ QList<QAction *> Menu::contextualActions()
|
||||
|
||||
actions << m_separator2;
|
||||
actions << m_addWidgetsAction;
|
||||
actions << m_duplicateAction;
|
||||
actions << m_configureAction;
|
||||
actions << m_removeAction;
|
||||
|
||||
@ -206,6 +220,9 @@ QList<QAction *> Menu::contextualActions()
|
||||
const QString configureActionText = (viewType == DockView) ? i18nc("dock settings window", "&Edit Dock...") : i18nc("panel settings window", "&Edit Panel...");
|
||||
m_configureAction->setText(configureActionText);
|
||||
|
||||
const QString duplicateActionText = (viewType == DockView) ? i18n("&Duplicate Dock") : i18n("&Duplicate Panel");
|
||||
m_duplicateAction->setText(duplicateActionText);
|
||||
|
||||
const QString removeActionText = (viewType == DockView) ? i18n("&Remove Dock") : i18n("&Remove Panel");
|
||||
m_removeAction->setText(removeActionText);
|
||||
|
||||
@ -216,6 +233,8 @@ QAction *Menu::action(const QString &name)
|
||||
{
|
||||
if (name == ADDWIDGETSNAME) {
|
||||
return m_addWidgetsAction;
|
||||
} else if (name == DUPLICATEVIEWNAME) {
|
||||
return m_duplicateAction;
|
||||
} else if (name == EDITVIEWNAME) {
|
||||
return m_configureAction;
|
||||
} else if (name == LAYOUTSNAME) {
|
||||
@ -238,10 +257,12 @@ void Menu::onUserConfiguringChanged(const bool &configuring)
|
||||
}
|
||||
|
||||
m_configureAction->setVisible(!configuring);
|
||||
m_duplicateAction->setVisible(configuring);
|
||||
m_removeAction->setVisible(configuring);
|
||||
|
||||
// because sometimes they are disabled unexpectedly, we should reenable them
|
||||
m_configureAction->setEnabled(true);
|
||||
m_duplicateAction->setEnabled(true);
|
||||
m_removeAction->setEnabled(true);
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ private:
|
||||
|
||||
QAction *m_addWidgetsAction{nullptr};
|
||||
QAction *m_configureAction{nullptr};
|
||||
QAction *m_duplicateAction{nullptr};
|
||||
QAction *m_printAction{nullptr};
|
||||
QAction *m_layoutsAction{nullptr};
|
||||
QAction *m_preferenceAction{nullptr};
|
||||
|
@ -915,17 +915,25 @@ PlasmaComponents.ContextMenu {
|
||||
PlasmaComponents.MenuItem {
|
||||
id: addWidgets
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("add latte widgets") : plasmoid.action("configure");
|
||||
visible: appletAbilities.myView.isReady
|
||||
visible: appletAbilities.myView.isReady && action.visible
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: duplicateItem
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("duplicate view") : plasmoid.action("configure")
|
||||
visible: appletAbilities.myView.isReady && action.visible
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: configureItem
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("edit view") : plasmoid.action("configure")
|
||||
visible: appletAbilities.myView.isReady && action.visible
|
||||
}
|
||||
|
||||
PlasmaComponents.MenuItem {
|
||||
id: removeItem
|
||||
action: appletAbilities.myView.isReady ? appletAbilities.myView.action("remove view") : plasmoid.action("remove")
|
||||
visible: appletAbilities.myView.isReady && action.visible
|
||||
}
|
||||
|
||||
//! BEGIN: Plasmoid actions when it isnt inside a Latte dock
|
||||
|
Loading…
x
Reference in New Issue
Block a user