Skip to content

Commit

Permalink
[ADDITIVE] Added alert sign to the Remap Mode Reference Editor. Added…
Browse files Browse the repository at this point in the history
… dedicated classes to manage the alert icon in the Group Box title.
  • Loading branch information
VasiliiFeshchenko committed Jun 5, 2024
1 parent 51b5b79 commit e225cb1
Show file tree
Hide file tree
Showing 15 changed files with 911 additions and 16 deletions.
10 changes: 8 additions & 2 deletions Kactus2.pri
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,10 @@ HEADERS += ./common/NameGenerationPolicy.h \
./PythonAPI/FileChannel.h \
./PythonAPI/PythonInterpreter.h \
./PythonAPI/StdInputListener.h \
./PythonAPI/extensions/IOCatcher.h
./PythonAPI/extensions/IOCatcher.h \
./common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h \
./common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h \
./common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h
SOURCES += ./editors/ComponentEditor/busInterfaces/general/MasterModeEditor.cpp \
./common/GenericEditProvider.cpp \
./common/NameGenerationPolicy.cpp \
Expand Down Expand Up @@ -1684,5 +1687,8 @@ SOURCES += ./editors/ComponentEditor/busInterfaces/general/MasterModeEditor.cpp
./PythonAPI/FileChannel.cpp \
./PythonAPI/PythonInterpreter.cpp \
./PythonAPI/StdInputListener.cpp \
./PythonAPI/extensions/IOCatcher.cpp
./PythonAPI/extensions/IOCatcher.cpp \
./common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.cpp \
./common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.cpp \
./common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.cpp
RESOURCES += kactus.qrc
6 changes: 6 additions & 0 deletions Kactus2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ CreateHelp
<ClCompile Include="common\widgets\EnumCollectionEditor\EnumerationEditor.cpp" />
<ClCompile Include="common\widgets\FileSelector\fileselector.cpp" />
<ClCompile Include="common\widgets\fileTypeSelector\filetypeselector.cpp" />
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\GroupBoxWithAlertSign.cpp" />
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\StyleGroupBoxWithAlertSign.cpp" />
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\StyleOptionGroupBoxWithAlertSign.cpp" />
<ClCompile Include="common\widgets\LibrarySelectorWidget\LibraryPathEditor\librarypatheditor.cpp" />
<ClCompile Include="common\widgets\LibrarySelectorWidget\LibraryPathSelector\librarypathselector.cpp" />
<ClCompile Include="common\widgets\LibrarySelectorWidget\LibrarySelectorWidget.cpp" />
Expand Down Expand Up @@ -1289,6 +1292,9 @@ CreateHelp
<QtMoc Include="common\widgets\TreeItemSelector\TreeItemEditor.h" />
<QtMoc Include="common\widgets\TreeItemSelector\TreeItemModel.h" />
<QtMoc Include="common\widgets\TreeItemSelector\FramedTreeItemEditor.h" />
<QtMoc Include="common\widgets\GroupBoxWithAlertSign\GroupBoxWithAlertSign.h" />
<QtMoc Include="common\widgets\GroupBoxWithAlertSign\StyleGroupBoxWithAlertSign.h" />
<ClInclude Include="common\widgets\GroupBoxWithAlertSign\StyleOptionGroupBoxWithAlertSign.h" />
<ClInclude Include="common\widgets\TreeItemSelector\TreeItem.h" />
<ClInclude Include="editors\AbstractionDefinitionEditor\AbstractionDefinitionPortsSortFilter.h" />
<ClInclude Include="editors\AbstractionDefinitionEditor\AbstractionDefinitionSignalRow.h" />
Expand Down
24 changes: 24 additions & 0 deletions Kactus2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,12 @@
<Filter Include="Header Files\editors\ComponentEditor\powerDomains">
<UniqueIdentifier>{45dc464a-4192-4641-8242-c0b1f055534f}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\common\widgets\GroupBoxWithAlertSign">
<UniqueIdentifier>{3c58c97d-2039-4bdd-8c31-12f7920606d2}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\common\widgets\GroupBoxWithAlertSign">
<UniqueIdentifier>{8783df90-961a-4171-916f-62da55f95112}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="common\GenericEditProvider.cpp">
Expand Down Expand Up @@ -3367,6 +3373,15 @@
<ClCompile Include="editors\ComponentEditor\ports\TypedPortsView.cpp">
<Filter>Source Files\editors\ComponentEditor\ports</Filter>
</ClCompile>
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\StyleGroupBoxWithAlertSign.cpp">
<Filter>Source Files\common\widgets\GroupBoxWithAlertSign</Filter>
</ClCompile>
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\StyleOptionGroupBoxWithAlertSign.cpp">
<Filter>Source Files\common\widgets\GroupBoxWithAlertSign</Filter>
</ClCompile>
<ClCompile Include="common\widgets\GroupBoxWithAlertSign\GroupBoxWithAlertSign.cpp">
<Filter>Source Files\common\widgets\GroupBoxWithAlertSign</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="common\layouts\HCollisionLayout.inl">
Expand Down Expand Up @@ -5806,6 +5821,9 @@
<ClInclude Include="editors\ComponentEditor\ports\PortSummaryEditorFactory.h">
<Filter>Header Files\editors\ComponentEditor\ports</Filter>
</ClInclude>
<ClInclude Include="common\widgets\GroupBoxWithAlertSign\StyleOptionGroupBoxWithAlertSign.h">
<Filter>Header Files\common\widgets\GroupBoxWithAlertSign</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="wizards\common\IPXactElementComparator.inl">
Expand Down Expand Up @@ -6083,5 +6101,11 @@
<QtMoc Include="editors\ComponentEditor\ports\TypedPortsView.h">
<Filter>Header Files\editors\ComponentEditor\ports</Filter>
</QtMoc>
<QtMoc Include="common\widgets\GroupBoxWithAlertSign\StyleGroupBoxWithAlertSign.h">
<Filter>Header Files\common\widgets\GroupBoxWithAlertSign</Filter>
</QtMoc>
<QtMoc Include="common\widgets\GroupBoxWithAlertSign\GroupBoxWithAlertSign.h">
<Filter>Header Files\common\widgets\GroupBoxWithAlertSign</Filter>
</QtMoc>
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions KactusAPI/include/ModeReferenceInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ class KACTUS2_API ModeReferenceInterface
*/
std::vector<std::pair<unsigned int, std::string> > getModeReferences() const;

/*!
* Checks if all mode references are errorless.
*
* @return Boolean true if componentModes_ is not empty and every item is errorless, overwise false
*/
bool areAllModeReferencesValid();

private:

/*!
Expand Down
23 changes: 23 additions & 0 deletions KactusAPI/interfaces/component/ModeReferenceInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,29 @@ std::vector<std::pair<unsigned int, std::string> > ModeReferenceInterface::getMo
return modeReferences_;
}

//-----------------------------------------------------------------------------
// Function: ModeReferenceInterface::areAllModeReferencesValid()
//-----------------------------------------------------------------------------
bool ModeReferenceInterface::areAllModeReferencesValid()
{
if (modeReferences_.empty())
{
return false;
}
for ( int i = 0; i < modeReferences_.size(); i++)
{
if (!modeReferenceValueIsValid(i))
{
return false;
}
if(!modeReferencePriorityIsValid(i))
{
return false;
}
}
return true;
}

//-----------------------------------------------------------------------------
// Function: ModeReferenceInterface::getModeReferencesInUse()
//-----------------------------------------------------------------------------
Expand Down
186 changes: 186 additions & 0 deletions common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
//-----------------------------------------------------------------------------
// File: GroupBoxWithAlertSign.h
//-----------------------------------------------------------------------------
// Project: Kactus 2
// Author: Vasilii Feshchenko
// Date: 05.06.2024
//
// Description:
// Group box with an alert sign in the title.
// The main parts of the code have been created by Michael Scopchanov
// Git hub: https://github.com/scopchanov/SO-DecoratedGroupBox.git ,
// stackoverflow answer by Michael Scopchanov: https://stackoverflow.com/a/52630998 .
// Read copyright below.
//-----------------------------------------------------------------------------

/**
MIT License
Copyright (c) 2018 Michael Scopchanov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#include<common/widgets/GroupBoxWithAlertSign/GroupBoxWithAlertSign.h>
#include<common/widgets/GroupBoxWithAlertSign/StyleGroupBoxWithAlertSign.h>
#include<common/widgets/GroupBoxWithAlertSign/StyleOptionGroupBoxWithAlertSign.h>
#include <QVBoxLayout>
#include <QIcon>
#include <QPixmap>
#include <QPainter>


//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::GroupBoxWithAlertSign()
//-----------------------------------------------------------------------------
GroupBoxWithAlertSign::GroupBoxWithAlertSign(QString title, QWidget* parent) :
QGroupBox(title, parent),
offset_(5),
leftSpace_(3),
rightSpace_(3),
verticalIconOffset_(-5)
{

}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::getPixmap()
//-----------------------------------------------------------------------------
QPixmap GroupBoxWithAlertSign::getPixmap() const
{
return pixmap_;
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setPixmap()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setPixmap(const QPixmap& pixmap)
{
pixmap_ = pixmap;
update();
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::getOffset()
//-----------------------------------------------------------------------------
int GroupBoxWithAlertSign::getOffset() const
{
return offset_;
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setOffset()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setOffset(int offset)
{
offset_ = offset;
update();
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::getLeftSpace()
//-----------------------------------------------------------------------------
int GroupBoxWithAlertSign::getLeftSpace() const
{
return leftSpace_;
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setLeftSpace()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setLeftSpace(int leftSpace)
{
leftSpace_ = leftSpace;
update();
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::getRightSpace()
//-----------------------------------------------------------------------------
int GroupBoxWithAlertSign::getRightSpace() const
{
return rightSpace_;
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setRightSpace()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setRightSpace(int rightSpace)
{
rightSpace_ = rightSpace;
update();
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setSpaces()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setSpaces(int leftSpace, int rightSpace)
{
setLeftSpace(leftSpace);
setRightSpace(rightSpace);
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::paintEvent()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::paintEvent(QPaintEvent* /*event*/)
{
StyleGroupBoxWithAlertSign style;
QPainter painter(this);
StyleOptionGroupBoxWithAlertSign option;

initStyleOption(&option);
option.setPixmap(pixmap_);
option.setOffset(offset_);
option.setLeftSpace(leftSpace_);
option.setRightSpace(rightSpace_);

style.drawComplexControl(QStyle::CC_GroupBox, &option, &painter, this);
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setAlertIcon()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setAlertIcon()
{
setPixmap(QIcon(":/icons/common/graphics/exclamation--frame.png").pixmap(QSize(22, 22)));
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::removeAlertIcon()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::removeAlertIcon()
{
setPixmap(QPixmap());
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::getVerticalIconOffset()
//-----------------------------------------------------------------------------
int GroupBoxWithAlertSign::getVerticalIconOffset() const {
return verticalIconOffset_;
}

//-----------------------------------------------------------------------------
// Function: GroupBoxWithAlertSign::setVerticalIconOffset()
//-----------------------------------------------------------------------------
void GroupBoxWithAlertSign::setVerticalIconOffset(int verticalOffset) {
verticalIconOffset_ = verticalOffset;
update();
}
Loading

0 comments on commit e225cb1

Please sign in to comment.