From 24aa5ba90c80ddeab33aba99e4d14c4f46ff4522 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 17 Mar 2013 10:46:09 +0100 Subject: [PATCH 01/13] Initial CustomCommands module --- CMakeLists.txt | 1 + CustomCommands/CMakeLists.txt | 44 ++++ CustomCommands/CustomCommandListCfgPage.cpp | 57 +++++ CustomCommands/CustomCommandListCfgPage.hpp | 43 ++++ CustomCommands/CustomCommandListCfgPage.ui | 62 +++++ CustomCommands/CustomCommandsModule.cpp | 51 ++++ CustomCommands/CustomCommandsModule.hpp | 42 ++++ CustomCommands/CustomCommandsView.cpp | 41 ++++ CustomCommands/CustomCommandsView.hpp | 38 +++ CustomCommands/EditCustomCommandDlg.ui | 258 ++++++++++++++++++++ CustomCommands/Module.json | 3 + 11 files changed, 640 insertions(+) create mode 100644 CustomCommands/CMakeLists.txt create mode 100644 CustomCommands/CustomCommandListCfgPage.cpp create mode 100644 CustomCommands/CustomCommandListCfgPage.hpp create mode 100644 CustomCommands/CustomCommandListCfgPage.ui create mode 100644 CustomCommands/CustomCommandsModule.cpp create mode 100644 CustomCommands/CustomCommandsModule.hpp create mode 100644 CustomCommands/CustomCommandsView.cpp create mode 100644 CustomCommands/CustomCommandsView.hpp create mode 100644 CustomCommands/EditCustomCommandDlg.ui create mode 100644 CustomCommands/Module.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6905eb7..2508cbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ INCLUDE_DIRECTORIES( ${libMacGitverCore_includes} ) +ADD_SUBDIRECTORY( CustomCommands ) ADD_SUBDIRECTORY( History ) ADD_SUBDIRECTORY( GitConfig ) ADD_SUBDIRECTORY( RefsViews ) diff --git a/CustomCommands/CMakeLists.txt b/CustomCommands/CMakeLists.txt new file mode 100644 index 0000000..c1f74fb --- /dev/null +++ b/CustomCommands/CMakeLists.txt @@ -0,0 +1,44 @@ + +PROJECT( MGV_MOD_CUSTOM_COMMANDS ) + +QT_PREPARE( Core Gui Widgets ) + +INCLUDE_DIRECTORIES( + ${MGV_MOD_CUSTOM_COMMANDS_SOURCE_DIR} + ${MGV_MOD_CUSTOM_COMMANDS_BINARY_DIR} +) + +SET( SRC_FILES + + CustomCommandsView.cpp + CustomCommandsModule.cpp + CustomCommandListCfgPage.cpp +) + +SET( HDR_FILES + + CustomCommandsView.hpp + CustomCommandsModule.hpp + CustomCommandListCfgPage.hpp +) + +SET( UI_FILES + + EditCustomCommandDlg.ui + CustomCommandListCfgPage.ui +) + +QT_UIC( UIC_FILES ${UI_FILES} ) +QT_MOC( MOC_FILES ${HDR_FILES} ) + +ADD_MGV_MODULE( + CustomCommands + + ${SRC_FILES} + ${HDR_FILES} + ${MOC_FILES} + ${UIC_FILES} ${UI_FILES} +) + +MSVC_SPLIT_SOURCES( ModCustomCommands ) + diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp new file mode 100644 index 0000000..44a5b50 --- /dev/null +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -0,0 +1,57 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#include "CustomCommandListCfgPage.hpp" + +CustomCommandListCfgPage::CustomCommandListCfgPage( ConfigDialog* dlg ) + : ConfigPage( dlg ) +{ + setupUi( this ); + init(); +} + +CustomCommandListCfgPage::~CustomCommandListCfgPage() +{ +} + +void CustomCommandListCfgPage::apply() +{ +} + +void CustomCommandListCfgPage::init() +{ +} + +QByteArray CustomCommandListCfgPage::pageId() const +{ + return "Commands"; +} + +QByteArray CustomCommandListCfgPage::groupId() const +{ + return "General"; +} + +QString CustomCommandListCfgPage::pageName() const +{ + return trUtf8( "Commands" ); +} + +QString CustomCommandListCfgPage::groupName() const +{ + return trUtf8( "Gerneral" ); +} + diff --git a/CustomCommands/CustomCommandListCfgPage.hpp b/CustomCommands/CustomCommandListCfgPage.hpp new file mode 100644 index 0000000..2c3e306 --- /dev/null +++ b/CustomCommands/CustomCommandListCfgPage.hpp @@ -0,0 +1,43 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#ifndef MGV_CUSCOM_CONFIG_PAGE_H +#define MGV_CUSCOM_CONFIG_PAGE_H + +#include "libMacGitverCore/Config/Ui/ConfigDialog.hpp" + +#include "ui_CustomCommandListCfgPage.h" + +class CustomCommandListCfgPage : public ConfigPage, Ui::CustomCommandListCfgPage +{ + Q_OBJECT + +public: + CustomCommandListCfgPage( ConfigDialog* dlg ); + ~CustomCommandListCfgPage(); + +public: + void apply(); + void init(); + + QByteArray pageId() const; + QByteArray groupId() const; + + QString pageName() const; + QString groupName() const; +}; + +#endif diff --git a/CustomCommands/CustomCommandListCfgPage.ui b/CustomCommands/CustomCommandListCfgPage.ui new file mode 100644 index 0000000..ebb4797 --- /dev/null +++ b/CustomCommands/CustomCommandListCfgPage.ui @@ -0,0 +1,62 @@ + + + CustomCommandListCfgPage + + + + 0 + 0 + 549 + 300 + + + + + + + &Add + + + + + + + &Edit + + + + + + + &Copy + + + + + + + &Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp new file mode 100644 index 0000000..944f2a1 --- /dev/null +++ b/CustomCommands/CustomCommandsModule.cpp @@ -0,0 +1,51 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#include + +#include "CustomCommandsModule.hpp" +#include "CustomCommandsView.hpp" +#include "CustomCommandListCfgPage.hpp" + +CustomCommandsModule::CustomCommandsModule() +{ +} + +Heaven::View* CustomCommandsModule::createCustomCommandsView() +{ + return new CustomCommandsView(); +} + +void CustomCommandsModule::initialize() +{ + registerView( QLatin1String( "Custom_Commands" ), + Heaven::GlobalViewType, + &CustomCommandsModule::createCustomCommandsView ); +} + +void CustomCommandsModule::deinitialize() +{ + unregisterView( QLatin1String( "Custom_Commands" ) ); +} + +void CustomCommandsModule::setupConfigPages( ConfigDialog* dialog ) +{ + dialog->addPage( new CustomCommandListCfgPage( dialog ) ); +} + +#if QT_VERSION < 0x050000 +Q_EXPORT_PLUGIN2( CustomCommands, CustomCommandsModule ) +#endif diff --git a/CustomCommands/CustomCommandsModule.hpp b/CustomCommands/CustomCommandsModule.hpp new file mode 100644 index 0000000..4f723f4 --- /dev/null +++ b/CustomCommands/CustomCommandsModule.hpp @@ -0,0 +1,42 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#ifndef MGV_MODULE_CUSTOM_COMMANDS_HPP +#define MGV_MODULE_CUSTOM_COMMANDS_HPP + +#include "libMacGitverCore/MacGitver/Module.h" + +class CustomCommandsView; + +class CustomCommandsModule : public Module +{ + Q_OBJECT + Q_PLUGIN_METADATA( IID "org.macgitver.Module/0.1" FILE "Module.json" ) + Q_INTERFACES( Module ) + +public: + CustomCommandsModule(); + +public: + void initialize(); + void deinitialize(); + void setupConfigPages( ConfigDialog* dialog ); + +private: + static Heaven::View* createCustomCommandsView(); +}; + +#endif diff --git a/CustomCommands/CustomCommandsView.cpp b/CustomCommands/CustomCommandsView.cpp new file mode 100644 index 0000000..ef777d7 --- /dev/null +++ b/CustomCommands/CustomCommandsView.cpp @@ -0,0 +1,41 @@ +/* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#include +#include + +#include "CustomCommandsView.hpp" + +CustomCommandsView::CustomCommandsView() + : View( QLatin1String( "Log" ) ) +{ + setViewName( trUtf8( "Log" ) ); + + QVBoxLayout* l = new QVBoxLayout; + l->setSpacing( 0 ); + l->setMargin( 0 ); + setLayout( l ); + + mBrowser = new QTextBrowser; + mBrowser->setFrameShape( QFrame::NoFrame ); + + l->addWidget( mBrowser ); +} + +QSize CustomCommandsView::sizeHint() const +{ + return QSize( 300, 110 ); +} diff --git a/CustomCommands/CustomCommandsView.hpp b/CustomCommands/CustomCommandsView.hpp new file mode 100644 index 0000000..ab7d061 --- /dev/null +++ b/CustomCommands/CustomCommandsView.hpp @@ -0,0 +1,38 @@ + /* + * MacGitver + * Copyright (C) 2012 Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#ifndef MGV_CUSTOM_COMMANDS_VIEW_HPP +#define MGV_CUSTOM_COMMANDS_VIEW_HPP + +#include "libHeaven/Views/View.h" + +class QTextBrowser; + +class CustomCommandsView : public Heaven::View +{ + Q_OBJECT +public: + CustomCommandsView(); + +public: + QSize sizeHint() const; + +private: + QTextBrowser* mBrowser; +}; + +#endif + diff --git a/CustomCommands/EditCustomCommandDlg.ui b/CustomCommands/EditCustomCommandDlg.ui new file mode 100644 index 0000000..11b9965 --- /dev/null +++ b/CustomCommands/EditCustomCommandDlg.ui @@ -0,0 +1,258 @@ + + + EditCustomCommandDlg + + + + 0 + 0 + 548 + 484 + + + + + + + Custom Command + + + + + + + 0 + 0 + + + + Name: + + + txtCommandName + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + Context: + + + cboContext + + + + + + + + 0 + 0 + + + + Refresh: + + + + + + + + + Never + + + + + + + On Failure + + + + + + + On Success + + + + + + + Always + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 0 + + + + Run: + + + + + + + + + modal + + + + + + + in background + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Custom working dir: + + + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + txtCommandName + cboContext + chkRefreshNever + chkRefreshFailure + chkRefreshSuccess + chkRefreshAlways + chkRunModal + chkRunBackground + chkCustomWD + txtWorkingDirectory + txtCommands + buttonBox + + + + + buttonBox + accepted() + EditCustomCommandDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + EditCustomCommandDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/CustomCommands/Module.json b/CustomCommands/Module.json new file mode 100644 index 0000000..64ecfce --- /dev/null +++ b/CustomCommands/Module.json @@ -0,0 +1,3 @@ +{ + "Keys": [ "CustomCommands" ] +} From 72c2690ef8059e73625f79c366d4f7d11b2d9647 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 17 Mar 2013 11:02:23 +0100 Subject: [PATCH 02/13] Adjust to CentralUI changes --- CustomCommands/CustomCommandsModule.cpp | 6 +++--- CustomCommands/CustomCommandsView.cpp | 2 +- CustomCommands/CustomCommandsView.hpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp index 944f2a1..7561a6f 100644 --- a/CustomCommands/CustomCommandsModule.cpp +++ b/CustomCommands/CustomCommandsModule.cpp @@ -31,14 +31,14 @@ Heaven::View* CustomCommandsModule::createCustomCommandsView() void CustomCommandsModule::initialize() { - registerView( QLatin1String( "Custom_Commands" ), - Heaven::GlobalViewType, + registerView( "Custom_Commands", + trUtf8( "Custom Commands" ), &CustomCommandsModule::createCustomCommandsView ); } void CustomCommandsModule::deinitialize() { - unregisterView( QLatin1String( "Custom_Commands" ) ); + unregisterView( "Custom_Commands" ); } void CustomCommandsModule::setupConfigPages( ConfigDialog* dialog ) diff --git a/CustomCommands/CustomCommandsView.cpp b/CustomCommands/CustomCommandsView.cpp index ef777d7..2ac86b3 100644 --- a/CustomCommands/CustomCommandsView.cpp +++ b/CustomCommands/CustomCommandsView.cpp @@ -20,7 +20,7 @@ #include "CustomCommandsView.hpp" CustomCommandsView::CustomCommandsView() - : View( QLatin1String( "Log" ) ) + : View( "Log" ) { setViewName( trUtf8( "Log" ) ); diff --git a/CustomCommands/CustomCommandsView.hpp b/CustomCommands/CustomCommandsView.hpp index ab7d061..baa7506 100644 --- a/CustomCommands/CustomCommandsView.hpp +++ b/CustomCommands/CustomCommandsView.hpp @@ -17,7 +17,7 @@ #ifndef MGV_CUSTOM_COMMANDS_VIEW_HPP #define MGV_CUSTOM_COMMANDS_VIEW_HPP -#include "libHeaven/Views/View.h" +#include "libHeaven/CentralUI/Views/View.hpp" class QTextBrowser; From 1c6b21b1e779b19c6f87d69d903558bed40f9ae0 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 18 Mar 2013 13:52:03 +0100 Subject: [PATCH 03/13] Initial Edit-Dialog --- CustomCommands/CMakeLists.txt | 11 ++ CustomCommands/CustomCommandActions.hid | 31 ++++++ CustomCommands/CustomCommandDef.cpp | 108 ++++++++++++++++++++ CustomCommands/CustomCommandDef.hpp | 83 +++++++++++++++ CustomCommands/CustomCommandListCfgPage.cpp | 29 +++++- CustomCommands/CustomCommandListCfgPage.hpp | 14 ++- CustomCommands/CustomCommandListCfgPage.ui | 2 +- CustomCommands/CustomCommandsModule.cpp | 12 ++- CustomCommands/CustomCommandsModule.hpp | 11 +- CustomCommands/CustomCommandsView.cpp | 4 +- CustomCommands/CustomCommandsView.hpp | 4 +- CustomCommands/EditCustomCommandDlg.cpp | 84 +++++++++++++++ CustomCommands/EditCustomCommandDlg.hpp | 48 +++++++++ CustomCommands/EditCustomCommandDlg.ui | 12 ++- 14 files changed, 442 insertions(+), 11 deletions(-) create mode 100644 CustomCommands/CustomCommandActions.hid create mode 100644 CustomCommands/CustomCommandDef.cpp create mode 100644 CustomCommands/CustomCommandDef.hpp create mode 100644 CustomCommands/EditCustomCommandDlg.cpp create mode 100644 CustomCommands/EditCustomCommandDlg.hpp diff --git a/CustomCommands/CMakeLists.txt b/CustomCommands/CMakeLists.txt index c1f74fb..87d7ba8 100644 --- a/CustomCommands/CMakeLists.txt +++ b/CustomCommands/CMakeLists.txt @@ -13,6 +13,8 @@ SET( SRC_FILES CustomCommandsView.cpp CustomCommandsModule.cpp CustomCommandListCfgPage.cpp + EditCustomCommandDlg.cpp + CustomCommandDef.cpp ) SET( HDR_FILES @@ -20,6 +22,8 @@ SET( HDR_FILES CustomCommandsView.hpp CustomCommandsModule.hpp CustomCommandListCfgPage.hpp + EditCustomCommandDlg.hpp + CustomCommandDef.hpp ) SET( UI_FILES @@ -28,6 +32,12 @@ SET( UI_FILES CustomCommandListCfgPage.ui ) +SET( HID_FILES + CustomCommandActions.hid +) + + +HIC( HIC_FILES ${HID_FILES} ) QT_UIC( UIC_FILES ${UI_FILES} ) QT_MOC( MOC_FILES ${HDR_FILES} ) @@ -38,6 +48,7 @@ ADD_MGV_MODULE( ${HDR_FILES} ${MOC_FILES} ${UIC_FILES} ${UI_FILES} + ${HIC_FILES} ${HID_FILES} ) MSVC_SPLIT_SOURCES( ModCustomCommands ) diff --git a/CustomCommands/CustomCommandActions.hid b/CustomCommands/CustomCommandActions.hid new file mode 100644 index 0000000..a3de2ce --- /dev/null +++ b/CustomCommands/CustomCommandActions.hid @@ -0,0 +1,31 @@ +/* + * MacGitver + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +Ui CustomCommandActions { + + Container CustComAC { + + Menu ExecuteOnRepo { + Text "R&epository"; + DynamicActionMerger ExecOnBranch { Merger onMergeExecuteOnBranch; }; + }; + Separator; + DynamicActionMerger ExecGlobally { Merger onMergeExecuteGlobally; }; + }; + +}; diff --git a/CustomCommands/CustomCommandDef.cpp b/CustomCommands/CustomCommandDef.cpp new file mode 100644 index 0000000..d412699 --- /dev/null +++ b/CustomCommands/CustomCommandDef.cpp @@ -0,0 +1,108 @@ +/* +* MacGitver +* Copyright (C) 2012-2013 The MacGitver-Developers +* +* (C) Sascha Cunz +* +* This program is free software; you can redistribute it and/or modify it under the terms of the +* GNU General Public License (Version 2) as published by the Free Software Foundation. +* +* 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, see . +* +*/ + +#include "CustomCommandDef.hpp" + +CustomCommandDef::CustomCommandDef() +{ +} + +CustomCommandDef::CustomCommandDef( const CustomCommandDef& other ) +{ + mName = other.mName; + mCommand = other.mCommand; + mExecute = other.mExecute; + mRunModal = other.mRunModal; + mRefresh = other.mRefresh; + mCustomWorkDir = other.mCustomWorkDir; + mWorkDir = other.mWorkDir; +} + +CustomCommandDef::~CustomCommandDef() +{ +} + +QString CustomCommandDef::name() const +{ + return mName; +} + +QString CustomCommandDef::command() const +{ + return mCommand; +} + +CustomCommandDef::ExecuteOn CustomCommandDef::executeOn() const +{ + return mExecute; +} + +bool CustomCommandDef::runModal() const +{ + return mRunModal; +} + +CustomCommandDef::RefreshType CustomCommandDef::refreshType() const +{ + return mRefresh; +} + +bool CustomCommandDef::useCustomWorkingDir() const +{ + return mCustomWorkDir; +} + +QString CustomCommandDef::customWorkingDir() const +{ + return mWorkDir; +} + +void CustomCommandDef::setName( const QString& name ) +{ + mName = name; +} + +void CustomCommandDef::setCommand( const QString& command ) +{ + mCommand = command; +} + +void CustomCommandDef::setExecuteOn( CustomCommandDef::ExecuteOn execOn ) +{ + mExecute = execOn; +} + +void CustomCommandDef::setRunModal( bool runModal ) +{ + mRunModal = runModal; +} + +void CustomCommandDef::setRefreshType( CustomCommandDef::RefreshType type ) +{ + mRefresh = type; +} + +void CustomCommandDef::setUseCustomWorkingDir( bool useCustomWorkingDir ) +{ + mCustomWorkDir = useCustomWorkingDir; +} + +void CustomCommandDef::setCustomWorkingDir( const QString& dir ) +{ + mWorkDir = dir; +} diff --git a/CustomCommands/CustomCommandDef.hpp b/CustomCommands/CustomCommandDef.hpp new file mode 100644 index 0000000..40917ee --- /dev/null +++ b/CustomCommands/CustomCommandDef.hpp @@ -0,0 +1,83 @@ +/* +* MacGitver +* Copyright (C) 2012-2013 The MacGitver-Developers +* +* (C) Sascha Cunz +* +* This program is free software; you can redistribute it and/or modify it under the terms of the +* GNU General Public License (Version 2) as published by the Free Software Foundation. +* +* 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, see . +* +*/ + +#ifndef MGV_CUSTOM_COMMANDS_DEF_HPP +#define MGV_CUSTOM_COMMANDS_DEF_HPP + +#include +#include + +class CustomCommandDef : public QSharedData +{ +public: + enum ExecuteOn + { + ExecRootRepo = 1, + ExecSubRepo = 2, + ExecRootOrSubRepo = 3, + ExecBranch = 4, + ExecForEachSubmodule = 5, + ExecForEachSubmoduleDeep = 6, + ExecInWorkingTree = 7, + ExecGlobally = 8 + }; + + enum RefreshType + { + RefreshNever, + RefreshSuccess, + RefreshFailure, + RefreshAlways + }; + +public: + typedef QExplicitlySharedDataPointer< CustomCommandDef > Ptr; + +public: + CustomCommandDef(); + CustomCommandDef( const CustomCommandDef& other ); + ~CustomCommandDef(); + +public: + QString name() const; + QString command() const; + ExecuteOn executeOn() const; + bool runModal() const; + RefreshType refreshType() const; + bool useCustomWorkingDir() const; + QString customWorkingDir() const; + + void setName( const QString& name ); + void setCommand( const QString& command ); + void setExecuteOn( ExecuteOn execOn ); + void setRunModal( bool runModal ); + void setRefreshType( RefreshType type ); + void setUseCustomWorkingDir( bool useCustomWorkingDir ); + void setCustomWorkingDir( const QString& dir ); + +private: + QString mName; + QString mCommand; + ExecuteOn mExecute; + bool mRunModal; + RefreshType mRefresh; + bool mCustomWorkDir; + QString mWorkDir; +}; + +#endif diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index 44a5b50..83e4cfc 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. @@ -15,6 +17,7 @@ */ #include "CustomCommandListCfgPage.hpp" +#include "EditCustomCommandDlg.hpp" CustomCommandListCfgPage::CustomCommandListCfgPage( ConfigDialog* dlg ) : ConfigPage( dlg ) @@ -33,6 +36,10 @@ void CustomCommandListCfgPage::apply() void CustomCommandListCfgPage::init() { + connect( cmdAdd, SIGNAL(clicked()), this, SLOT(onAdd()) ); + connect( cmdCopy, SIGNAL(clicked()), this, SLOT(onCopy()) ); + connect( cmdEdit, SIGNAL(clicked()), this, SLOT(onEdit()) ); + connect( cmdRemove, SIGNAL(clicked()), this, SLOT(onRemove()) ); } QByteArray CustomCommandListCfgPage::pageId() const @@ -55,3 +62,23 @@ QString CustomCommandListCfgPage::groupName() const return trUtf8( "Gerneral" ); } +void CustomCommandListCfgPage::onAdd() +{ + EditCustomCommandDlg d( this ); + if( d.exec() ) + { + /* update this */ + } +} + +void CustomCommandListCfgPage::onEdit() +{ +} + +void CustomCommandListCfgPage::onRemove() +{ +} + +void CustomCommandListCfgPage::onCopy() +{ +} diff --git a/CustomCommands/CustomCommandListCfgPage.hpp b/CustomCommands/CustomCommandListCfgPage.hpp index 2c3e306..0316d42 100644 --- a/CustomCommands/CustomCommandListCfgPage.hpp +++ b/CustomCommands/CustomCommandListCfgPage.hpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. @@ -14,8 +16,8 @@ * */ -#ifndef MGV_CUSCOM_CONFIG_PAGE_H -#define MGV_CUSCOM_CONFIG_PAGE_H +#ifndef MGV_CUSCOM_CONFIG_PAGE_HPP +#define MGV_CUSCOM_CONFIG_PAGE_HPP #include "libMacGitverCore/Config/Ui/ConfigDialog.hpp" @@ -38,6 +40,12 @@ class CustomCommandListCfgPage : public ConfigPage, Ui::CustomCommandListCfgPage QString pageName() const; QString groupName() const; + +private slots: + void onAdd(); + void onEdit(); + void onRemove(); + void onCopy(); }; #endif diff --git a/CustomCommands/CustomCommandListCfgPage.ui b/CustomCommands/CustomCommandListCfgPage.ui index ebb4797..5d6b742 100644 --- a/CustomCommands/CustomCommandListCfgPage.ui +++ b/CustomCommands/CustomCommandListCfgPage.ui @@ -19,7 +19,7 @@ - + &Edit diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp index 7561a6f..86b77b0 100644 --- a/CustomCommands/CustomCommandsModule.cpp +++ b/CustomCommands/CustomCommandsModule.cpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. @@ -31,6 +33,9 @@ Heaven::View* CustomCommandsModule::createCustomCommandsView() void CustomCommandsModule::initialize() { + setupActions( this ); + acCustComAC->mergeInto( "CustomToolsMP" ); + registerView( "Custom_Commands", trUtf8( "Custom Commands" ), &CustomCommandsModule::createCustomCommandsView ); @@ -46,6 +51,11 @@ void CustomCommandsModule::setupConfigPages( ConfigDialog* dialog ) dialog->addPage( new CustomCommandListCfgPage( dialog ) ); } +void CustomCommandsModule::onMergeExecuteOnBranch( Heaven::DynamicActionMerger* dam ) +{ + dam->addAction( new QAction( QLatin1String( "&Foo" ), this ) ); +} + #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2( CustomCommands, CustomCommandsModule ) #endif diff --git a/CustomCommands/CustomCommandsModule.hpp b/CustomCommands/CustomCommandsModule.hpp index 4f723f4..67302be 100644 --- a/CustomCommands/CustomCommandsModule.hpp +++ b/CustomCommands/CustomCommandsModule.hpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. @@ -21,7 +23,9 @@ class CustomCommandsView; -class CustomCommandsModule : public Module +#include "hic_CustomCommandActions.h" + +class CustomCommandsModule : public Module, private CustomCommandActions { Q_OBJECT Q_PLUGIN_METADATA( IID "org.macgitver.Module/0.1" FILE "Module.json" ) @@ -35,6 +39,9 @@ class CustomCommandsModule : public Module void deinitialize(); void setupConfigPages( ConfigDialog* dialog ); +private slots: + void onMergeExecuteOnBranch( Heaven::DynamicActionMerger* dam ); + private: static Heaven::View* createCustomCommandsView(); }; diff --git a/CustomCommands/CustomCommandsView.cpp b/CustomCommands/CustomCommandsView.cpp index 2ac86b3..0df086c 100644 --- a/CustomCommands/CustomCommandsView.cpp +++ b/CustomCommands/CustomCommandsView.cpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. diff --git a/CustomCommands/CustomCommandsView.hpp b/CustomCommands/CustomCommandsView.hpp index baa7506..0d4c043 100644 --- a/CustomCommands/CustomCommandsView.hpp +++ b/CustomCommands/CustomCommandsView.hpp @@ -1,6 +1,8 @@ /* * MacGitver - * Copyright (C) 2012 Sascha Cunz + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz * * This program is free software; you can redistribute it and/or modify it under the terms of the * GNU General Public License (Version 2) as published by the Free Software Foundation. diff --git a/CustomCommands/EditCustomCommandDlg.cpp b/CustomCommands/EditCustomCommandDlg.cpp new file mode 100644 index 0000000..ce9798d --- /dev/null +++ b/CustomCommands/EditCustomCommandDlg.cpp @@ -0,0 +1,84 @@ +/* + * MacGitver + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#include + +#include "EditCustomCommandDlg.hpp" + +EditCustomCommandDlg::EditCustomCommandDlg( QWidget* parent, CustomCommandDef::Ptr cmdTemplate ) + : QDialog( parent ) + , mCmdTemplate( cmdTemplate ) +{ + init(); +} + +void EditCustomCommandDlg::init() +{ + setupUi( this ); + + mRefreshGroup = new QButtonGroup( this ); + mRefreshGroup->addButton( chkRefreshAlways, CustomCommandDef::RefreshAlways ); + mRefreshGroup->addButton( chkRefreshFailure, CustomCommandDef::RefreshSuccess ); + mRefreshGroup->addButton( chkRefreshNever, CustomCommandDef::RefreshNever ); + mRefreshGroup->addButton( chkRefreshSuccess, CustomCommandDef::RefreshSuccess ); + + mRunGroup = new QButtonGroup( this ); + mRunGroup->addButton( chkRunBackground, false ); + mRunGroup->addButton( chkRunModal, true ); + + chkRefreshNever->setChecked( true ); + chkRunModal->setChecked( true ); + + txtWorkingDirectory->setEnabled( false ); + connect( chkCustomWD, SIGNAL(toggled(bool)), txtWorkingDirectory, SLOT(setEnabled(bool)) ); + + cboContext->addItem( trUtf8( "Execute on Repository (root)" ), + CustomCommandDef::ExecRootRepo ); + cboContext->addItem( trUtf8( "Execute on Repository (submodule)" ), + CustomCommandDef::ExecSubRepo ); + cboContext->addItem( trUtf8( "Execute on Repository (root or submodule)" ), + CustomCommandDef::ExecRootOrSubRepo ); + cboContext->addItem( trUtf8( "Execute for all submodules" ), + CustomCommandDef::ExecForEachSubmodule ); + cboContext->addItem( trUtf8( "Execute for all submodules (recursive)" ), + CustomCommandDef::ExecForEachSubmoduleDeep ); + cboContext->addItem( trUtf8( "Execute on Branch" ), + CustomCommandDef::ExecBranch ); + cboContext->addItem( trUtf8( "Execute in Working tree" ), + CustomCommandDef::ExecInWorkingTree ); + cboContext->addItem( trUtf8( "Execute gobally" ), + CustomCommandDef::ExecGlobally ); +} + +void EditCustomCommandDlg::loadTemplate() +{ + if( mCmdTemplate.data() ) + { + } +} + +CustomCommandDef::Ptr EditCustomCommandDlg::getData( bool overWriteTemplate ) +{ + CustomCommandDef::Ptr data = mCmdTemplate; + if( !overWriteTemplate ) + { + data = new CustomCommandDef; + } + + return data; +} diff --git a/CustomCommands/EditCustomCommandDlg.hpp b/CustomCommands/EditCustomCommandDlg.hpp new file mode 100644 index 0000000..baa739a --- /dev/null +++ b/CustomCommands/EditCustomCommandDlg.hpp @@ -0,0 +1,48 @@ +/* + * MacGitver + * Copyright (C) 2012-2013 The MacGitver-Developers + * + * (C) Sascha Cunz + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License (Version 2) as published by the Free Software Foundation. + * + * 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, see . + * + */ + +#ifndef MGV_CUSCOM_EDIT_DLG_HPP +#define MGV_CUSCOM_EDIT_DLG_HPP + +#include "ui_EditCustomCommandDlg.h" + +#include "CustomCommandDef.hpp" + +class EditCustomCommandDlg : public QDialog, private Ui::EditCustomCommandDlg +{ + Q_OBJECT +public: + EditCustomCommandDlg( QWidget* parent, + CustomCommandDef::Ptr cmdTemplate = CustomCommandDef::Ptr() ); + +private: + void init(); + void loadTemplate(); + +public: + CustomCommandDef::Ptr getData( bool overWriteTemplate = true ); + +private: + CustomCommandDef::Ptr mCmdTemplate; + QButtonGroup* mRunGroup; + QButtonGroup* mRefreshGroup; +}; + +#endif + + diff --git a/CustomCommands/EditCustomCommandDlg.ui b/CustomCommands/EditCustomCommandDlg.ui index 11b9965..864419f 100644 --- a/CustomCommands/EditCustomCommandDlg.ui +++ b/CustomCommands/EditCustomCommandDlg.ui @@ -34,13 +34,16 @@ - + 0 0 + + true + @@ -206,6 +209,13 @@ + + + LineEdit + QLineEdit +
libMacGitverCore/Widgets/LineEdit.h
+
+
txtCommandName cboContext From 5daf2d797728c6c9b4a8ac063b3af53d9dfe49f5 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 18 Mar 2013 15:40:22 +0100 Subject: [PATCH 04/13] Saving of custom commands --- CustomCommands/CMakeLists.txt | 2 +- CustomCommands/CustomCommandDef.cpp | 24 ++++++++ CustomCommands/CustomCommandDef.hpp | 8 +++ CustomCommands/CustomCommandListCfgPage.cpp | 58 ++++++++++++++++++- CustomCommands/CustomCommandListCfgPage.hpp | 12 ++++ CustomCommands/CustomCommandListCfgPage.ui | 15 ++++- CustomCommands/CustomCommandsModule.cpp | 63 +++++++++++++++++++++ CustomCommands/CustomCommandsModule.hpp | 13 ++++- CustomCommands/EditCustomCommandDlg.cpp | 9 +++ 9 files changed, 199 insertions(+), 5 deletions(-) diff --git a/CustomCommands/CMakeLists.txt b/CustomCommands/CMakeLists.txt index 87d7ba8..9ba04a9 100644 --- a/CustomCommands/CMakeLists.txt +++ b/CustomCommands/CMakeLists.txt @@ -1,7 +1,7 @@ PROJECT( MGV_MOD_CUSTOM_COMMANDS ) -QT_PREPARE( Core Gui Widgets ) +QT_PREPARE( Core Gui Widgets Xml ) INCLUDE_DIRECTORIES( ${MGV_MOD_CUSTOM_COMMANDS_SOURCE_DIR} diff --git a/CustomCommands/CustomCommandDef.cpp b/CustomCommands/CustomCommandDef.cpp index d412699..7ad3edd 100644 --- a/CustomCommands/CustomCommandDef.cpp +++ b/CustomCommands/CustomCommandDef.cpp @@ -16,12 +16,18 @@ * */ +#include + #include "CustomCommandDef.hpp" CustomCommandDef::CustomCommandDef() { } +CustomCommandDef::CustomCommandDef( const QDomElement& elSelf ) +{ +} + CustomCommandDef::CustomCommandDef( const CustomCommandDef& other ) { mName = other.mName; @@ -106,3 +112,21 @@ void CustomCommandDef::setCustomWorkingDir( const QString& dir ) { mWorkDir = dir; } + +void CustomCommandDef::saveTo( QDomElement& elParent ) +{ + QDomDocument doc = elParent.ownerDocument(); + QDomElement el = doc.createElement( QLatin1String( "Command" ) ); + + el.setAttribute( QLatin1String( "Name" ), mName ); + el.setAttribute( QLatin1String( "RunModal" ), mRunModal ? 1 : 0 ); + el.setAttribute( QLatin1String( "RefreshType" ), int( mRefresh ) ); + el.setAttribute( QLatin1String( "ExecuteOn" ), int( mExecute ) ); + el.setAttribute( QLatin1String( "UseWD" ), mCustomWorkDir ? 1 : 0 ); + el.setAttribute( QLatin1String( "WD" ), mWorkDir ); + + elParent.appendChild( el ); + + QDomCDATASection cmd = doc.createCDATASection( mCommand ); + el.appendChild( cmd ); +} diff --git a/CustomCommands/CustomCommandDef.hpp b/CustomCommands/CustomCommandDef.hpp index 40917ee..a4292f7 100644 --- a/CustomCommands/CustomCommandDef.hpp +++ b/CustomCommands/CustomCommandDef.hpp @@ -21,6 +21,9 @@ #include #include +#include + +class QDomElement; class CustomCommandDef : public QSharedData { @@ -47,9 +50,11 @@ class CustomCommandDef : public QSharedData public: typedef QExplicitlySharedDataPointer< CustomCommandDef > Ptr; + typedef QList< Ptr > List; public: CustomCommandDef(); + CustomCommandDef( const QDomElement& elSelf ); CustomCommandDef( const CustomCommandDef& other ); ~CustomCommandDef(); @@ -70,6 +75,9 @@ class CustomCommandDef : public QSharedData void setUseCustomWorkingDir( bool useCustomWorkingDir ); void setCustomWorkingDir( const QString& dir ); +public: + void saveTo( QDomElement& elParent ); + private: QString mName; QString mCommand; diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index 83e4cfc..0ae05ba 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -16,13 +16,15 @@ * */ +#include + #include "CustomCommandListCfgPage.hpp" +#include "CustomCommandsModule.hpp" #include "EditCustomCommandDlg.hpp" CustomCommandListCfgPage::CustomCommandListCfgPage( ConfigDialog* dlg ) : ConfigPage( dlg ) { - setupUi( this ); init(); } @@ -32,14 +34,28 @@ CustomCommandListCfgPage::~CustomCommandListCfgPage() void CustomCommandListCfgPage::apply() { + CustomCommandsModule::self().setCommands( mCommands ); + setModified( false ); } void CustomCommandListCfgPage::init() { + setupUi( this ); + connect( cmdAdd, SIGNAL(clicked()), this, SLOT(onAdd()) ); connect( cmdCopy, SIGNAL(clicked()), this, SLOT(onCopy()) ); connect( cmdEdit, SIGNAL(clicked()), this, SLOT(onEdit()) ); connect( cmdRemove, SIGNAL(clicked()), this, SLOT(onRemove()) ); + + mModel = new QStandardItemModel( 0, 2, this ); + + mModel->setHorizontalHeaderLabels( QStringList() + << trUtf8( "Command" ) + << trUtf8( "Scope" ) ); + treeView->setModel( mModel ); + + mCommands = CustomCommandsModule::self().commands(); + readCommands(); } QByteArray CustomCommandListCfgPage::pageId() const @@ -67,7 +83,10 @@ void CustomCommandListCfgPage::onAdd() EditCustomCommandDlg d( this ); if( d.exec() ) { - /* update this */ + CustomCommandDef::Ptr cmd = d.getData( false ); + mCommands.append( cmd ); + addCommand( cmd, true ); + setModified(); } } @@ -82,3 +101,38 @@ void CustomCommandListCfgPage::onRemove() void CustomCommandListCfgPage::onCopy() { } + +void CustomCommandListCfgPage::readCommands() +{ + foreach( CustomCommandDef::Ptr cmd, mCommands ) + { + addCommand( cmd ); + } +} + +QString CustomCommandListCfgPage::execText( CustomCommandDef::ExecuteOn exec ) +{ + switch( exec ) + { + case CustomCommandDef::ExecBranch: return trUtf8( "Branch" ); + case CustomCommandDef::ExecRootRepo: return trUtf8( "Repository (Root)" ); + case CustomCommandDef::ExecSubRepo: return trUtf8( "Repository (Submodules)" ); + case CustomCommandDef::ExecRootOrSubRepo: return trUtf8( "Repository (Root and" + " Submodules)" ); + case CustomCommandDef::ExecForEachSubmodule: return trUtf8( "For each submodule" ); + case CustomCommandDef::ExecForEachSubmoduleDeep: return trUtf8( "For each submodule" + " (Recursive)" ); + case CustomCommandDef::ExecGlobally: return trUtf8( "Global Command" ); + case CustomCommandDef::ExecInWorkingTree: return trUtf8( "In working tree" ); + default: return trUtf8( "Unknown" ); + } +} + +void CustomCommandListCfgPage::addCommand( CustomCommandDef::Ptr cmd, bool select ) +{ + QList< QStandardItem* > row; + row << new QStandardItem( cmd->name() ); + row << new QStandardItem( execText( cmd->executeOn() ) ); + mModel->appendRow( row ); +} + diff --git a/CustomCommands/CustomCommandListCfgPage.hpp b/CustomCommands/CustomCommandListCfgPage.hpp index 0316d42..759937b 100644 --- a/CustomCommands/CustomCommandListCfgPage.hpp +++ b/CustomCommands/CustomCommandListCfgPage.hpp @@ -21,8 +21,11 @@ #include "libMacGitverCore/Config/Ui/ConfigDialog.hpp" +#include "CustomCommandDef.hpp" #include "ui_CustomCommandListCfgPage.h" +class QStandardItemModel; + class CustomCommandListCfgPage : public ConfigPage, Ui::CustomCommandListCfgPage { Q_OBJECT @@ -46,6 +49,15 @@ private slots: void onEdit(); void onRemove(); void onCopy(); + +private: + void readCommands(); + void addCommand( CustomCommandDef::Ptr cmd, bool select = false ); + static QString execText( CustomCommandDef::ExecuteOn exec ); + +private: + CustomCommandDef::List mCommands; + QStandardItemModel* mModel; }; #endif diff --git a/CustomCommands/CustomCommandListCfgPage.ui b/CustomCommands/CustomCommandListCfgPage.ui index 5d6b742..b69a9c7 100644 --- a/CustomCommands/CustomCommandListCfgPage.ui +++ b/CustomCommands/CustomCommandListCfgPage.ui @@ -53,7 +53,20 @@ - + + + false + + + true + + + false + + + true + + diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp index 86b77b0..b21e09d 100644 --- a/CustomCommands/CustomCommandsModule.cpp +++ b/CustomCommands/CustomCommandsModule.cpp @@ -17,6 +17,12 @@ */ #include +#include +#include +#include +#include + +#include "libHeaven/App/Application.hpp" #include "CustomCommandsModule.hpp" #include "CustomCommandsView.hpp" @@ -31,9 +37,21 @@ Heaven::View* CustomCommandsModule::createCustomCommandsView() return new CustomCommandsView(); } +CustomCommandsModule& CustomCommandsModule::self() +{ + Q_ASSERT( sSelf ); + return *sSelf; +} + +CustomCommandsModule* CustomCommandsModule::sSelf = NULL; + void CustomCommandsModule::initialize() { + Q_ASSERT( sSelf == NULL ); + sSelf = this; setupActions( this ); + loadCommands(); + acCustComAC->mergeInto( "CustomToolsMP" ); registerView( "Custom_Commands", @@ -44,6 +62,7 @@ void CustomCommandsModule::initialize() void CustomCommandsModule::deinitialize() { unregisterView( "Custom_Commands" ); + sSelf = NULL; } void CustomCommandsModule::setupConfigPages( ConfigDialog* dialog ) @@ -56,6 +75,50 @@ void CustomCommandsModule::onMergeExecuteOnBranch( Heaven::DynamicActionMerger* dam->addAction( new QAction( QLatin1String( "&Foo" ), this ) ); } +void CustomCommandsModule::loadCommands() +{ +} + +void CustomCommandsModule::saveCommands() +{ + QString fn = commandsFileName(); + + QDomDocument doc( QLatin1String( "CustomCommands" ) ); + QDomElement elRoot = doc.createElement( QLatin1String( "CustomCommands" ) ); + doc.appendChild( elRoot ); + + foreach( CustomCommandDef::Ptr cmd, mCommands ) + { + cmd->saveTo( elRoot ); + } + + QString xml = doc.toString(); + + QFile f( fn ); + if( !f.open( QFile::WriteOnly ) ) + { + return; + } + f.write( xml.toUtf8() ); +} + +QString CustomCommandsModule::commandsFileName() const +{ + QString base = Heaven::Application::dataPath(); + return base % QLatin1Literal( "/commands.xml" ); +} + +CustomCommandDef::List CustomCommandsModule::commands() const +{ + return mCommands; +} + +void CustomCommandsModule::setCommands( const CustomCommandDef::List& commands ) +{ + mCommands = commands; + saveCommands(); +} + #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2( CustomCommands, CustomCommandsModule ) #endif diff --git a/CustomCommands/CustomCommandsModule.hpp b/CustomCommands/CustomCommandsModule.hpp index 67302be..6f913d0 100644 --- a/CustomCommands/CustomCommandsModule.hpp +++ b/CustomCommands/CustomCommandsModule.hpp @@ -23,6 +23,7 @@ class CustomCommandsView; +#include "CustomCommandDef.hpp" #include "hic_CustomCommandActions.h" class CustomCommandsModule : public Module, private CustomCommandActions @@ -30,20 +31,30 @@ class CustomCommandsModule : public Module, private CustomCommandActions Q_OBJECT Q_PLUGIN_METADATA( IID "org.macgitver.Module/0.1" FILE "Module.json" ) Q_INTERFACES( Module ) - public: CustomCommandsModule(); + static CustomCommandsModule& self(); public: void initialize(); void deinitialize(); void setupConfigPages( ConfigDialog* dialog ); + CustomCommandDef::List commands() const; + void setCommands( const CustomCommandDef::List& commands ); + private slots: void onMergeExecuteOnBranch( Heaven::DynamicActionMerger* dam ); private: static Heaven::View* createCustomCommandsView(); + void loadCommands(); + void saveCommands(); + QString commandsFileName() const; + +private: + static CustomCommandsModule* sSelf; + CustomCommandDef::List mCommands; }; #endif diff --git a/CustomCommands/EditCustomCommandDlg.cpp b/CustomCommands/EditCustomCommandDlg.cpp index ce9798d..f1370b4 100644 --- a/CustomCommands/EditCustomCommandDlg.cpp +++ b/CustomCommands/EditCustomCommandDlg.cpp @@ -80,5 +80,14 @@ CustomCommandDef::Ptr EditCustomCommandDlg::getData( bool overWriteTemplate ) data = new CustomCommandDef; } + data->setName( txtCommandName->text() ); + data->setCommand( txtCommands->toPlainText() ); + data->setRunModal( chkRunModal->isChecked() ); + data->setRefreshType( CustomCommandDef::RefreshType( mRefreshGroup->checkedId() ) ); + data->setExecuteOn( CustomCommandDef::ExecuteOn( cboContext->itemData( + cboContext->currentIndex() ).toInt() ) ); + data->setUseCustomWorkingDir( chkCustomWD->isChecked() ); + data->setCustomWorkingDir( txtWorkingDirectory->text() ); + return data; } From d832cd7b8f6addf456adaf1914c266350984e32f Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 18 Mar 2013 21:59:33 +0100 Subject: [PATCH 05/13] Loading of commands --- CustomCommands/CustomCommandDef.cpp | 25 +++++++++++++++++++++++++ CustomCommands/CustomCommandsModule.cpp | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/CustomCommands/CustomCommandDef.cpp b/CustomCommands/CustomCommandDef.cpp index 7ad3edd..16d2374 100644 --- a/CustomCommands/CustomCommandDef.cpp +++ b/CustomCommands/CustomCommandDef.cpp @@ -26,6 +26,31 @@ CustomCommandDef::CustomCommandDef() CustomCommandDef::CustomCommandDef( const QDomElement& elSelf ) { + mName = elSelf.attribute( QLatin1String( "Name" ) ); + mRunModal = elSelf.attribute( QLatin1String( "RunModal" ), QLatin1String( "0" ) ) + == QLatin1String( "1" ); + + mRefresh = RefreshType( elSelf.attribute( QLatin1String( "RefreshType" ), + QLatin1String( "0" ) ).toInt() ); + + mExecute = ExecuteOn( elSelf.attribute( QLatin1String( "ExecuteOn" ), + QLatin1String( "0" ) ).toInt() ); + + mWorkDir = elSelf.attribute( QLatin1String( "WD" ) ); + mCustomWorkDir = elSelf.attribute( QLatin1String( "UseWD" ), QLatin1String( "0" ) ) + == QLatin1String( "1" ); + + QDomNode child = elSelf.firstChild(); + if( child.isCDATASection() ) + { + QDomCDATASection cds = child.toCDATASection(); + mCommand = cds.data(); + } + else if( child.isText() ) + { + QDomText txt = child.toText(); + mCommand = txt.data(); + } } CustomCommandDef::CustomCommandDef( const CustomCommandDef& other ) diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp index b21e09d..a70d780 100644 --- a/CustomCommands/CustomCommandsModule.cpp +++ b/CustomCommands/CustomCommandsModule.cpp @@ -77,6 +77,23 @@ void CustomCommandsModule::onMergeExecuteOnBranch( Heaven::DynamicActionMerger* void CustomCommandsModule::loadCommands() { + QString fn = commandsFileName(); + QFile f( fn ); + if( !f.open( QFile::ReadOnly ) ) + { + return; + } + + QDomDocument doc; + doc.setContent( &f ); + QDomElement el = doc.documentElement().firstChildElement(); + while( el.isElement() ) + { + CustomCommandDef::Ptr cmd = CustomCommandDef::Ptr( new CustomCommandDef( el ) ); + mCommands.append( cmd ); + + el = el.nextSiblingElement(); + } } void CustomCommandsModule::saveCommands() From a56442e1aecbb0e551be3c5730176ec7957fe2d6 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Mon, 18 Mar 2013 22:26:30 +0100 Subject: [PATCH 06/13] Edit custom commands --- CustomCommands/CustomCommandDef.cpp | 21 +++++++ CustomCommands/CustomCommandDef.hpp | 4 ++ CustomCommands/CustomCommandListCfgPage.cpp | 61 ++++++++++++++++++++- CustomCommands/CustomCommandListCfgPage.hpp | 2 + CustomCommands/CustomCommandListCfgPage.ui | 6 ++ CustomCommands/EditCustomCommandDlg.cpp | 14 ++++- CustomCommands/EditCustomCommandDlg.hpp | 1 + 7 files changed, 107 insertions(+), 2 deletions(-) diff --git a/CustomCommands/CustomCommandDef.cpp b/CustomCommands/CustomCommandDef.cpp index 16d2374..0102f5b 100644 --- a/CustomCommands/CustomCommandDef.cpp +++ b/CustomCommands/CustomCommandDef.cpp @@ -16,16 +16,20 @@ * */ +#include #include #include "CustomCommandDef.hpp" CustomCommandDef::CustomCommandDef() { + newId(); } CustomCommandDef::CustomCommandDef( const QDomElement& elSelf ) { + mId = elSelf.attribute( QLatin1String( "Id" ), QUuid::createUuid().toString() ); + mName = elSelf.attribute( QLatin1String( "Name" ) ); mRunModal = elSelf.attribute( QLatin1String( "RunModal" ), QLatin1String( "0" ) ) == QLatin1String( "1" ); @@ -55,6 +59,7 @@ CustomCommandDef::CustomCommandDef( const QDomElement& elSelf ) CustomCommandDef::CustomCommandDef( const CustomCommandDef& other ) { + mId = other.mId; mName = other.mName; mCommand = other.mCommand; mExecute = other.mExecute; @@ -68,6 +73,16 @@ CustomCommandDef::~CustomCommandDef() { } +void CustomCommandDef::newId() +{ + mId = QUuid::createUuid().toString(); +} + +QString CustomCommandDef::id() const +{ + return mId; +} + QString CustomCommandDef::name() const { return mName; @@ -103,6 +118,11 @@ QString CustomCommandDef::customWorkingDir() const return mWorkDir; } +void CustomCommandDef::setId( const QString& id ) +{ + mId = id; +} + void CustomCommandDef::setName( const QString& name ) { mName = name; @@ -149,6 +169,7 @@ void CustomCommandDef::saveTo( QDomElement& elParent ) el.setAttribute( QLatin1String( "ExecuteOn" ), int( mExecute ) ); el.setAttribute( QLatin1String( "UseWD" ), mCustomWorkDir ? 1 : 0 ); el.setAttribute( QLatin1String( "WD" ), mWorkDir ); + el.setAttribute( QLatin1String( "Id" ), mId ); elParent.appendChild( el ); diff --git a/CustomCommands/CustomCommandDef.hpp b/CustomCommands/CustomCommandDef.hpp index a4292f7..1949ad1 100644 --- a/CustomCommands/CustomCommandDef.hpp +++ b/CustomCommands/CustomCommandDef.hpp @@ -59,6 +59,7 @@ class CustomCommandDef : public QSharedData ~CustomCommandDef(); public: + QString id() const; QString name() const; QString command() const; ExecuteOn executeOn() const; @@ -67,6 +68,8 @@ class CustomCommandDef : public QSharedData bool useCustomWorkingDir() const; QString customWorkingDir() const; + void newId(); + void setId( const QString& id ); void setName( const QString& name ); void setCommand( const QString& command ); void setExecuteOn( ExecuteOn execOn ); @@ -79,6 +82,7 @@ class CustomCommandDef : public QSharedData void saveTo( QDomElement& elParent ); private: + QString mId; QString mName; QString mCommand; ExecuteOn mExecute; diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index 0ae05ba..2e83033 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -16,6 +16,7 @@ * */ +#include #include #include "CustomCommandListCfgPage.hpp" @@ -80,7 +81,7 @@ QString CustomCommandListCfgPage::groupName() const void CustomCommandListCfgPage::onAdd() { - EditCustomCommandDlg d( this ); + EditCustomCommandDlg d( this, trUtf8( "Create custom command" ) ); if( d.exec() ) { CustomCommandDef::Ptr cmd = d.getData( false ); @@ -92,6 +93,27 @@ void CustomCommandListCfgPage::onAdd() void CustomCommandListCfgPage::onEdit() { + QModelIndex idx = treeView->selectionModel()->currentIndex(); + if( !idx.isValid() ) + { + return; + } + + QStandardItem* parent = mModel->invisibleRootItem(); + QStandardItem* it = parent->child( idx.row() ); + Q_ASSERT( it ); + + QString id = it->data().toString(); + CustomCommandDef::Ptr cmd = findCommand( id ); + Q_ASSERT( cmd ); + + EditCustomCommandDlg d( this, trUtf8( "Edit custom command" ), cmd ); + if( d.exec() ) + { + d.getData( true ); + updateCommand( cmd ); + setModified(); + } } void CustomCommandListCfgPage::onRemove() @@ -133,6 +155,43 @@ void CustomCommandListCfgPage::addCommand( CustomCommandDef::Ptr cmd, bool selec QList< QStandardItem* > row; row << new QStandardItem( cmd->name() ); row << new QStandardItem( execText( cmd->executeOn() ) ); + row[ 0 ]->setData( cmd->id() ); mModel->appendRow( row ); } +void CustomCommandListCfgPage::updateCommand( CustomCommandDef::Ptr cmd ) +{ + if( !cmd ) + { + return; + } + + QString id = cmd->id(); + QStandardItem* parent = mModel->invisibleRootItem(); + for( int i = 0; i < parent->rowCount(); ++i ) + { + QStandardItem* it = parent->child( i ); + if( it->data().toString() == id ) + { + it->setText( cmd->name() ); + it = parent->child( i, 1 ); + it->setText( execText( cmd->executeOn() ) ); + return; + } + } + + addCommand( cmd ); +} + +CustomCommandDef::Ptr CustomCommandListCfgPage::findCommand( const QString& id ) const +{ + for( int i = 0; i < mCommands.count(); ++i ) + { + if( mCommands[ i ]->id() == id ) + { + return mCommands[ i ]; + } + } + + return CustomCommandDef::Ptr(); +} diff --git a/CustomCommands/CustomCommandListCfgPage.hpp b/CustomCommands/CustomCommandListCfgPage.hpp index 759937b..13a688d 100644 --- a/CustomCommands/CustomCommandListCfgPage.hpp +++ b/CustomCommands/CustomCommandListCfgPage.hpp @@ -52,7 +52,9 @@ private slots: private: void readCommands(); + CustomCommandDef::Ptr findCommand( const QString& id ) const; void addCommand( CustomCommandDef::Ptr cmd, bool select = false ); + void updateCommand( CustomCommandDef::Ptr cmd ); static QString execText( CustomCommandDef::ExecuteOn exec ); private: diff --git a/CustomCommands/CustomCommandListCfgPage.ui b/CustomCommands/CustomCommandListCfgPage.ui index b69a9c7..789f5f6 100644 --- a/CustomCommands/CustomCommandListCfgPage.ui +++ b/CustomCommands/CustomCommandListCfgPage.ui @@ -54,6 +54,12 @@ + + QAbstractItemView::NoEditTriggers + + + false + false diff --git a/CustomCommands/EditCustomCommandDlg.cpp b/CustomCommands/EditCustomCommandDlg.cpp index f1370b4..10b9590 100644 --- a/CustomCommands/EditCustomCommandDlg.cpp +++ b/CustomCommands/EditCustomCommandDlg.cpp @@ -20,11 +20,14 @@ #include "EditCustomCommandDlg.hpp" -EditCustomCommandDlg::EditCustomCommandDlg( QWidget* parent, CustomCommandDef::Ptr cmdTemplate ) +EditCustomCommandDlg::EditCustomCommandDlg( QWidget* parent, + const QString& title, + CustomCommandDef::Ptr cmdTemplate ) : QDialog( parent ) , mCmdTemplate( cmdTemplate ) { init(); + setWindowTitle( title ); } void EditCustomCommandDlg::init() @@ -63,12 +66,21 @@ void EditCustomCommandDlg::init() CustomCommandDef::ExecInWorkingTree ); cboContext->addItem( trUtf8( "Execute gobally" ), CustomCommandDef::ExecGlobally ); + + loadTemplate(); } void EditCustomCommandDlg::loadTemplate() { if( mCmdTemplate.data() ) { + txtCommandName->setText( mCmdTemplate->name() ); + txtCommands->setPlainText( mCmdTemplate->command() ); + cboContext->setCurrentIndex( cboContext->findData( mCmdTemplate->executeOn() ) ); + mRefreshGroup->button( mCmdTemplate->refreshType() )->setChecked( true ); + mRunGroup->button( mCmdTemplate->runModal() )->setChecked( true ); + chkCustomWD->setChecked( mCmdTemplate->useCustomWorkingDir() ); + txtWorkingDirectory->setText( mCmdTemplate->customWorkingDir() ); } } diff --git a/CustomCommands/EditCustomCommandDlg.hpp b/CustomCommands/EditCustomCommandDlg.hpp index baa739a..58b196d 100644 --- a/CustomCommands/EditCustomCommandDlg.hpp +++ b/CustomCommands/EditCustomCommandDlg.hpp @@ -28,6 +28,7 @@ class EditCustomCommandDlg : public QDialog, private Ui::EditCustomCommandDlg Q_OBJECT public: EditCustomCommandDlg( QWidget* parent, + const QString& title, CustomCommandDef::Ptr cmdTemplate = CustomCommandDef::Ptr() ); private: From 25e85d6a056afab4841acd3e1691bc5b02817e08 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Tue, 19 Mar 2013 22:57:01 +0100 Subject: [PATCH 07/13] RepoTreeView: Add merge points to ctx menus --- Repository/RepoTreeViewCtxMenu.hid | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Repository/RepoTreeViewCtxMenu.hid b/Repository/RepoTreeViewCtxMenu.hid index cbedc14..d0ff0ef 100644 --- a/Repository/RepoTreeViewCtxMenu.hid +++ b/Repository/RepoTreeViewCtxMenu.hid @@ -34,6 +34,8 @@ Ui RepoTreeViewCtxMenu { Action Activate; Separator; + MergePlace RepoRootCtx; + Separator; Action Close; }; @@ -41,6 +43,8 @@ Ui RepoTreeViewCtxMenu { Menu CtxMenuSMRepo { Action Activate; + Separator; + MergePlace RepoSubCtx; }; From 373c4c6c300251da75e9b969cebc513a518a5df5 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 24 Mar 2013 18:23:06 +0100 Subject: [PATCH 08/13] Copy Custom-Commands --- CustomCommands/CustomCommandListCfgPage.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index 2e83033..4907925 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -122,6 +122,28 @@ void CustomCommandListCfgPage::onRemove() void CustomCommandListCfgPage::onCopy() { + QModelIndex idx = treeView->selectionModel()->currentIndex(); + if( !idx.isValid() ) + { + return; + } + + QStandardItem* parent = mModel->invisibleRootItem(); + QStandardItem* it = parent->child( idx.row() ); + Q_ASSERT( it ); + + QString id = it->data().toString(); + CustomCommandDef::Ptr cmd = findCommand( id ); + Q_ASSERT( cmd ); + + EditCustomCommandDlg d( this, trUtf8( "Copy custom command" ), cmd ); + if( d.exec() ) + { + cmd = d.getData( false ); + mCommands.append( cmd ); + addCommand( cmd, true ); + setModified(); + } } void CustomCommandListCfgPage::readCommands() From 57b729c90227408092746f64d7a2c61f183c77dc Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 24 Mar 2013 18:40:44 +0100 Subject: [PATCH 09/13] Remove CustomCommand --- CustomCommands/CustomCommandListCfgPage.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index 4907925..fff2809 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -118,6 +118,28 @@ void CustomCommandListCfgPage::onEdit() void CustomCommandListCfgPage::onRemove() { + QModelIndex idx = treeView->selectionModel()->currentIndex(); + if( !idx.isValid() ) + { + return; + } + + QStandardItem* parent = mModel->invisibleRootItem(); + QStandardItem* it = parent->child( idx.row() ); + Q_ASSERT( it ); + + QString id = it->data().toString(); + for( int i = 0; i < mCommands.count(); ++i ) + { + if( mCommands[ i ]->id() == id ) + { + mCommands.removeAt( i ); + setModified(); + + parent->removeRow( idx.row() ); + return; + } + } } void CustomCommandListCfgPage::onCopy() From 72d411897725471a14791c3a3a565d5ff2392298 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 24 Mar 2013 18:40:52 +0100 Subject: [PATCH 10/13] Update buttons on selection change --- CustomCommands/CustomCommandListCfgPage.cpp | 13 +++++++++++++ CustomCommands/CustomCommandListCfgPage.hpp | 1 + 2 files changed, 14 insertions(+) diff --git a/CustomCommands/CustomCommandListCfgPage.cpp b/CustomCommands/CustomCommandListCfgPage.cpp index fff2809..1b08b74 100644 --- a/CustomCommands/CustomCommandListCfgPage.cpp +++ b/CustomCommands/CustomCommandListCfgPage.cpp @@ -57,6 +57,10 @@ void CustomCommandListCfgPage::init() mCommands = CustomCommandsModule::self().commands(); readCommands(); + + connect( treeView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), + this, SLOT(onSelectionChanged()) ); + onSelectionChanged(); } QByteArray CustomCommandListCfgPage::pageId() const @@ -79,6 +83,15 @@ QString CustomCommandListCfgPage::groupName() const return trUtf8( "Gerneral" ); } +void CustomCommandListCfgPage::onSelectionChanged() +{ + QModelIndex idx = treeView->selectionModel()->currentIndex(); + + cmdEdit->setEnabled( idx.isValid() ); + cmdCopy->setEnabled( idx.isValid() ); + cmdRemove->setEnabled( idx.isValid() ); +} + void CustomCommandListCfgPage::onAdd() { EditCustomCommandDlg d( this, trUtf8( "Create custom command" ) ); diff --git a/CustomCommands/CustomCommandListCfgPage.hpp b/CustomCommands/CustomCommandListCfgPage.hpp index 13a688d..2bbb3fc 100644 --- a/CustomCommands/CustomCommandListCfgPage.hpp +++ b/CustomCommands/CustomCommandListCfgPage.hpp @@ -49,6 +49,7 @@ private slots: void onEdit(); void onRemove(); void onCopy(); + void onSelectionChanged(); private: void readCommands(); From 1d8206a0b1863c20b581d66fa8f467be205019e0 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sun, 24 Mar 2013 19:30:43 +0100 Subject: [PATCH 11/13] Remove unused view --- CustomCommands/CMakeLists.txt | 2 -- CustomCommands/CustomCommandsModule.cpp | 11 ------- CustomCommands/CustomCommandsModule.hpp | 3 -- CustomCommands/CustomCommandsView.cpp | 43 ------------------------- CustomCommands/CustomCommandsView.hpp | 40 ----------------------- 5 files changed, 99 deletions(-) delete mode 100644 CustomCommands/CustomCommandsView.cpp delete mode 100644 CustomCommands/CustomCommandsView.hpp diff --git a/CustomCommands/CMakeLists.txt b/CustomCommands/CMakeLists.txt index 9ba04a9..e91c3c8 100644 --- a/CustomCommands/CMakeLists.txt +++ b/CustomCommands/CMakeLists.txt @@ -10,7 +10,6 @@ INCLUDE_DIRECTORIES( SET( SRC_FILES - CustomCommandsView.cpp CustomCommandsModule.cpp CustomCommandListCfgPage.cpp EditCustomCommandDlg.cpp @@ -19,7 +18,6 @@ SET( SRC_FILES SET( HDR_FILES - CustomCommandsView.hpp CustomCommandsModule.hpp CustomCommandListCfgPage.hpp EditCustomCommandDlg.hpp diff --git a/CustomCommands/CustomCommandsModule.cpp b/CustomCommands/CustomCommandsModule.cpp index a70d780..bcbb4cf 100644 --- a/CustomCommands/CustomCommandsModule.cpp +++ b/CustomCommands/CustomCommandsModule.cpp @@ -25,18 +25,12 @@ #include "libHeaven/App/Application.hpp" #include "CustomCommandsModule.hpp" -#include "CustomCommandsView.hpp" #include "CustomCommandListCfgPage.hpp" CustomCommandsModule::CustomCommandsModule() { } -Heaven::View* CustomCommandsModule::createCustomCommandsView() -{ - return new CustomCommandsView(); -} - CustomCommandsModule& CustomCommandsModule::self() { Q_ASSERT( sSelf ); @@ -53,15 +47,10 @@ void CustomCommandsModule::initialize() loadCommands(); acCustComAC->mergeInto( "CustomToolsMP" ); - - registerView( "Custom_Commands", - trUtf8( "Custom Commands" ), - &CustomCommandsModule::createCustomCommandsView ); } void CustomCommandsModule::deinitialize() { - unregisterView( "Custom_Commands" ); sSelf = NULL; } diff --git a/CustomCommands/CustomCommandsModule.hpp b/CustomCommands/CustomCommandsModule.hpp index 6f913d0..ccc80d1 100644 --- a/CustomCommands/CustomCommandsModule.hpp +++ b/CustomCommands/CustomCommandsModule.hpp @@ -21,8 +21,6 @@ #include "libMacGitverCore/MacGitver/Module.h" -class CustomCommandsView; - #include "CustomCommandDef.hpp" #include "hic_CustomCommandActions.h" @@ -47,7 +45,6 @@ private slots: void onMergeExecuteOnBranch( Heaven::DynamicActionMerger* dam ); private: - static Heaven::View* createCustomCommandsView(); void loadCommands(); void saveCommands(); QString commandsFileName() const; diff --git a/CustomCommands/CustomCommandsView.cpp b/CustomCommands/CustomCommandsView.cpp deleted file mode 100644 index 0df086c..0000000 --- a/CustomCommands/CustomCommandsView.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#include -#include - -#include "CustomCommandsView.hpp" - -CustomCommandsView::CustomCommandsView() - : View( "Log" ) -{ - setViewName( trUtf8( "Log" ) ); - - QVBoxLayout* l = new QVBoxLayout; - l->setSpacing( 0 ); - l->setMargin( 0 ); - setLayout( l ); - - mBrowser = new QTextBrowser; - mBrowser->setFrameShape( QFrame::NoFrame ); - - l->addWidget( mBrowser ); -} - -QSize CustomCommandsView::sizeHint() const -{ - return QSize( 300, 110 ); -} diff --git a/CustomCommands/CustomCommandsView.hpp b/CustomCommands/CustomCommandsView.hpp deleted file mode 100644 index 0d4c043..0000000 --- a/CustomCommands/CustomCommandsView.hpp +++ /dev/null @@ -1,40 +0,0 @@ - /* - * MacGitver - * Copyright (C) 2012-2013 The MacGitver-Developers - * - * (C) Sascha Cunz - * - * This program is free software; you can redistribute it and/or modify it under the terms of the - * GNU General Public License (Version 2) as published by the Free Software Foundation. - * - * 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, see . - * - */ - -#ifndef MGV_CUSTOM_COMMANDS_VIEW_HPP -#define MGV_CUSTOM_COMMANDS_VIEW_HPP - -#include "libHeaven/CentralUI/Views/View.hpp" - -class QTextBrowser; - -class CustomCommandsView : public Heaven::View -{ - Q_OBJECT -public: - CustomCommandsView(); - -public: - QSize sizeHint() const; - -private: - QTextBrowser* mBrowser; -}; - -#endif - From 3981d52985ff4bec4da6bad1137000eaacb00edd Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Sat, 27 Jul 2013 03:57:29 +0200 Subject: [PATCH 12/13] Reformat stuff --- CustomCommands/CustomCommandActions.hid | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CustomCommands/CustomCommandActions.hid b/CustomCommands/CustomCommandActions.hid index a3de2ce..e01eb57 100644 --- a/CustomCommands/CustomCommandActions.hid +++ b/CustomCommands/CustomCommandActions.hid @@ -18,14 +18,23 @@ Ui CustomCommandActions { + /* This container lands at the bottom part of the 'tools' menu */ Container CustComAC { Menu ExecuteOnRepo { Text "R&epository"; - DynamicActionMerger ExecOnBranch { Merger onMergeExecuteOnBranch; }; + DynamicActionMerger ExecOnBranch + { + Merger onMergeExecuteOnBranch; + }; }; + Separator; - DynamicActionMerger ExecGlobally { Merger onMergeExecuteGlobally; }; + DynamicActionMerger ExecGlobally + { + Merger onMergeExecuteGlobally; + }; + }; }; From fe8ff85f6717c10fe5c9ac4ed4cdf9a708a13013 Mon Sep 17 00:00:00 2001 From: Sascha Cunz Date: Wed, 31 Jul 2013 01:41:13 +0200 Subject: [PATCH 13/13] Create an extra action container --- CustomCommands/CustomCommandActions.hid | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/CustomCommands/CustomCommandActions.hid b/CustomCommands/CustomCommandActions.hid index e01eb57..4a7ec92 100644 --- a/CustomCommands/CustomCommandActions.hid +++ b/CustomCommands/CustomCommandActions.hid @@ -18,15 +18,19 @@ Ui CustomCommandActions { + Container CustComRepoAC { + DynamicActionMerger ExecOnBranch + { + Merger onMergeExecuteOnBranch; + }; + }; + /* This container lands at the bottom part of the 'tools' menu */ Container CustComAC { Menu ExecuteOnRepo { Text "R&epository"; - DynamicActionMerger ExecOnBranch - { - Merger onMergeExecuteOnBranch; - }; + Container CustComRepoAC; }; Separator;