From 06a0c72422f28c04ea7341a010c0b3f649d30ac2 Mon Sep 17 00:00:00 2001 From: sbh Date: Wed, 28 May 2014 17:05:49 +0400 Subject: [PATCH] Issue #20 Better look&feel for workbench's buttons. --- src/XGUI/XGUI_Command.cpp | 15 +++++++++------ src/XGUI/XGUI_Command.h | 4 ++-- src/XGUI/XGUI_MainMenu.cpp | 3 +++ src/XGUI/XGUI_MenuGroupPanel.cpp | 4 +++- src/XGUI/XGUI_Workbench.cpp | 6 ++++-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 0ddb0ecfc..b289f8014 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -1,6 +1,6 @@ #include "XGUI_Command.h" -#include +#include 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; } diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h index 6c01e6136..4247a7ca4 100644 --- a/src/XGUI/XGUI_Command.h +++ b/src/XGUI/XGUI_Command.h @@ -4,8 +4,8 @@ #include "XGUI.h" #include -#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 diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp index 4c8e7dc3c..88d68492e 100644 --- a/src/XGUI/XGUI_MainMenu.cpp +++ b/src/XGUI/XGUI_MainMenu.cpp @@ -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) diff --git a/src/XGUI/XGUI_MenuGroupPanel.cpp b/src/XGUI/XGUI_MenuGroupPanel.cpp index 48a9ce1a8..8d5d24b21 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.cpp +++ b/src/XGUI/XGUI_MenuGroupPanel.cpp @@ -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, diff --git a/src/XGUI/XGUI_Workbench.cpp b/src/XGUI/XGUI_Workbench.cpp index 468d8d0ce..f92380374 100644 --- a/src/XGUI/XGUI_Workbench.cpp +++ b/src/XGUI/XGUI_Workbench.cpp @@ -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_Workbench::features() const for (aIt = myGroups.constBegin(); aIt != myGroups.constEnd(); ++aIt) aList.append((*aIt)->features()); return aList; -} \ No newline at end of file +} -- 2.39.2