Salome HOME
Issue #20 Better look&feel for workbench's buttons.
authorsbh <sergey.belash@opencascade.com>
Wed, 28 May 2014 13:05:49 +0000 (17:05 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 28 May 2014 13:05:49 +0000 (17:05 +0400)
src/XGUI/XGUI_Command.cpp
src/XGUI/XGUI_Command.h
src/XGUI/XGUI_MainMenu.cpp
src/XGUI/XGUI_MenuGroupPanel.cpp
src/XGUI/XGUI_Workbench.cpp

index 0ddb0ecfcd8dafc2aa6bd851b42d4094ade036cb..b289f8014ec6b65c6efe2084978bebd0fe0a6068 100644 (file)
@@ -1,6 +1,6 @@
 #include "XGUI_Command.h"
 
-#include <QPushButton>
+#include <QToolButton>
 
 XGUI_Command::XGUI_Command(const QString& theId, QObject * parent, bool isCheckable)
     : QWidgetAction(parent), myCheckable(isCheckable)
@@ -24,10 +24,16 @@ XGUI_Command::~XGUI_Command()
 QWidget* XGUI_Command::createWidget(QWidget* theParent)
 {
   if (theParent->inherits("XGUI_MenuGroupPanel")) {
-    QPushButton* aButton = new QPushButton(theParent);
+    QToolButton* aButton = new QToolButton(theParent);
     aButton->setIcon(icon());
     aButton->setText(text());
-    aButton->setStyleSheet("text-align: left");
+    aButton->setStyleSheet("QToolButton::menu-indicator { image: none; }");
+    aButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+    aButton->setAutoRaise(true);
+    aButton->setArrowType(Qt::NoArrow);
+    aButton->setCheckable(myCheckable);
+    aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
+    aButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
     QKeySequence aKeys = shortcut();
     QString aToolTip = toolTip();
     if (!aKeys.isEmpty())
@@ -39,10 +45,7 @@ QWidget* XGUI_Command::createWidget(QWidget* theParent)
     connect(aButton, SIGNAL(clicked()), this, SLOT(trigger()));
     connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
     connect(this, SIGNAL(toggled(bool)), aButton, SLOT(setChecked(bool)));
-    aButton->setFlat(true);
-    aButton->setCheckable(myCheckable);
     this->setCheckable(myCheckable);
-    aButton->setMinimumSize(MIN_BUTTON_WIDTH, MIN_BUTTON_HEIGHT);
 
     return aButton;
   }
index 6c01e6136342d2592a8734466974cda0b303bbf3..4247a7ca4b8be681ee54c0649bd5aea6f4cbdadd 100644 (file)
@@ -4,8 +4,8 @@
 #include "XGUI.h"
 #include <QWidgetAction>
 
-#define MIN_BUTTON_HEIGHT 18
-#define MIN_BUTTON_WIDTH 40
+#define MIN_BUTTON_HEIGHT 25
+#define MIN_BUTTON_WIDTH 60
 
 /**\class XGUI_Command
  * \ingroup GUI
index 4c8e7dc3c6ce612b6530213ce6c974f56ae5cdda..88d68492e584bae12021f350f33043c2412b31f7 100644 (file)
@@ -13,9 +13,12 @@ XGUI_MainMenu::XGUI_MainMenu(XGUI_MainWindow *parent)
     : QObject(parent), myDesktop(parent)
 {
   parent->setTabPosition(Qt::TopDockWidgetArea, QTabWidget::North);
+  myDesktop->setStyleSheet("QTabBar::tab {height: 24px;}");
   myGeneralPage = addWorkbench(tr("General"));
   myGeneralPage->parentWidget()->setMaximumWidth(200);
   myGeneralPage->installEventFilter(this);
+//  QString aStyle = myDesktop->styleSheet();
+//  aStyle += " QTabBar::tab {min-height: 24px;}";
 }
 
 XGUI_MainMenu::~XGUI_MainMenu(void)
index 48a9ce1a87bc81f01734676f6e174917c193a3df..8d5d24b2146206e706922eff835521861c478797 100644 (file)
@@ -32,7 +32,8 @@ void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
     myNewRow = 0;
     myNewCol++;
   }
-  myLayout->addWidget(theWgt, myNewRow, myNewCol, Qt::AlignLeft);
+  myLayout->addWidget(theWgt, myNewRow, myNewCol);
+  myLayout->setRowStretch(myNewRow, 0);
   myNewRow++;
 }
 
@@ -58,6 +59,7 @@ void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
   foreach(QWidget* eachWidget, myActionWidget) {
     placeWidget(eachWidget);
   }
+  myLayout->setRowStretch(myMaxRow + 1,  1);
 }
 
 XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle,
index 468d8d0ce1f1fdfa4732aedf1243355e605bcca2..f92380374eb88c32b2494d572f29bd49b276da50 100644 (file)
@@ -84,7 +84,9 @@ XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId)
   XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
   aGroup->setObjectName(theId);
   myLayout->addWidget(aGroup);
-  addSeparator();
+  if(theId != "Default") {
+    addSeparator();
+  }
   myLayout->addStretch();
   myGroups.append(aGroup);
   return aGroup;
@@ -190,4 +192,4 @@ QList<XGUI_Command*> XGUI_Workbench::features() const
   for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) 
     aList.append((*aIt)->features());
   return aList;
-}
\ No newline at end of file
+}