NOISSUE improve toolbars
This commit is contained in:
parent
1e5b595923
commit
bf38021937
@ -213,6 +213,8 @@ SET(MULTIMC_SOURCES
|
||||
widgets/VersionSelectWidget.h
|
||||
widgets/ProgressWidget.h
|
||||
widgets/ProgressWidget.cpp
|
||||
widgets/WideBar.h
|
||||
widgets/WideBar.cpp
|
||||
|
||||
# GUI - instance group view
|
||||
groupview/GroupedProxyModel.cpp
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "ui_AccountListPage.h"
|
||||
|
||||
#include <QItemSelectionModel>
|
||||
#include <QMenu>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@ -77,6 +78,14 @@ void AccountListPage::changeEvent(QEvent* event)
|
||||
QMainWindow::changeEvent(event);
|
||||
}
|
||||
|
||||
QMenu * AccountListPage::createPopupMenu()
|
||||
{
|
||||
QMenu* filteredMenu = QMainWindow::createPopupMenu();
|
||||
filteredMenu->removeAction(ui->toolBar->toggleViewAction() );
|
||||
return filteredMenu;
|
||||
}
|
||||
|
||||
|
||||
void AccountListPage::listChanged()
|
||||
{
|
||||
updateButtonStates();
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
|
||||
private:
|
||||
void changeEvent(QEvent * event) override;
|
||||
QMenu * createPopupMenu() override;
|
||||
|
||||
public
|
||||
slots:
|
||||
|
@ -32,22 +32,10 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="WideBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="movable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>RightToolBarArea</enum>
|
||||
</attribute>
|
||||
@ -95,6 +83,11 @@
|
||||
<extends>QTreeView</extends>
|
||||
<header>widgets/VersionListView.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -38,11 +38,7 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList>
|
||||
: QMainWindow(parent), ui(new Ui::ModFolderPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// toolBar is a pointer to an existing toolbar
|
||||
ui->actionsToolbar->insertWidget(ui->actionView_configs, spacer);
|
||||
ui->actionsToolbar->insertSpacer(ui->actionView_configs);
|
||||
|
||||
m_inst = inst;
|
||||
on_RunningState_changed(m_inst && m_inst->isRunning());
|
||||
|
@ -73,19 +73,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="actionsToolbar">
|
||||
<widget class="WideBar" name="actionsToolbar">
|
||||
<property name="windowTitle">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
<property name="allowedAreas">
|
||||
<set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<property name="floatable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>RightToolBarArea</enum>
|
||||
</attribute>
|
||||
@ -145,6 +139,11 @@
|
||||
<header>widgets/MCModInfoFrame.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -223,11 +223,7 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
|
||||
m_valid = FS::ensureFolderPathExists(m_folder);
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// toolBar is a pointer to an existing toolbar
|
||||
ui->toolBar->insertWidget(ui->actionView_Folder, spacer);
|
||||
ui->toolBar->insertSpacer(ui->actionView_Folder);
|
||||
|
||||
ui->listView->setIconSize(QSize(128, 128));
|
||||
ui->listView->setGridSize(QSize(192, 160));
|
||||
|
@ -39,10 +39,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="WideBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextOnly</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>RightToolBarArea</enum>
|
||||
</attribute>
|
||||
@ -75,6 +78,13 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -128,7 +128,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="WideBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
@ -173,6 +173,13 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>serversView</tabstop>
|
||||
<tabstop>nameLine</tabstop>
|
||||
|
@ -112,10 +112,7 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// toolBar is a pointer to an existing toolbar
|
||||
ui->toolBar->insertWidget(ui->actionReload, spacer);
|
||||
ui->toolBar->insertSpacer(ui->actionReload);
|
||||
|
||||
m_profile = m_inst->getComponentList();
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="WideBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
@ -239,6 +239,11 @@
|
||||
<header>widgets/MCModInfoFrame.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
@ -37,10 +37,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// toolBar is a pointer to an existing toolbar
|
||||
ui->toolBar->insertWidget(ui->actionRefresh, spacer);
|
||||
ui->toolBar->insertSpacer(ui->actionRefresh);
|
||||
|
||||
QSortFilterProxyModel * proxy = new QSortFilterProxyModel(this);
|
||||
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
|
@ -57,7 +57,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<widget class="WideBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
@ -128,6 +128,13 @@
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>WideBar</class>
|
||||
<extends>QToolBar</extends>
|
||||
<header>widgets/WideBar.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
59
application/widgets/WideBar.cpp
Normal file
59
application/widgets/WideBar.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include "WideBar.h"
|
||||
#include <QToolButton>
|
||||
|
||||
class ActionButton : public QToolButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ActionButton(QAction * action, QWidget * parent = 0) : QToolButton(parent), m_action(action) {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
connect(action, &QAction::changed, this, &ActionButton::actionChanged);
|
||||
connect(this, &ActionButton::clicked, action, &QAction::trigger);
|
||||
actionChanged();
|
||||
};
|
||||
private slots:
|
||||
void actionChanged() {
|
||||
setEnabled(m_action->isEnabled());
|
||||
setChecked(m_action->isChecked());
|
||||
setCheckable(m_action->isCheckable());
|
||||
setText(m_action->text());
|
||||
setIcon(m_action->icon());
|
||||
setToolTip(m_action->toolTip());
|
||||
setHidden(!m_action->isVisible());
|
||||
}
|
||||
private:
|
||||
QAction * m_action;
|
||||
};
|
||||
|
||||
|
||||
WideBar::WideBar(const QString& title, QWidget* parent) : QToolBar(title, parent)
|
||||
{
|
||||
setFloatable(false);
|
||||
setMovable(false);
|
||||
}
|
||||
|
||||
WideBar::WideBar(QWidget* parent) : QToolBar(parent)
|
||||
{
|
||||
setFloatable(false);
|
||||
setMovable(false);
|
||||
}
|
||||
|
||||
void WideBar::addAction(QAction* action)
|
||||
{
|
||||
auto actionButton = new ActionButton(action, this);
|
||||
auto newAction = addWidget(actionButton);
|
||||
m_actionMap[action] = newAction;
|
||||
}
|
||||
|
||||
void WideBar::insertSpacer(QAction* action)
|
||||
{
|
||||
if(!m_actionMap.contains(action)) {
|
||||
return;
|
||||
}
|
||||
|
||||
QWidget* spacer = new QWidget();
|
||||
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
insertWidget(m_actionMap[action], spacer);
|
||||
}
|
||||
|
||||
#include "WideBar.moc"
|
18
application/widgets/WideBar.h
Normal file
18
application/widgets/WideBar.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <QToolBar>
|
||||
|
||||
class WideBar : public QToolBar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit WideBar(const QString &title, QWidget * parent = nullptr);
|
||||
explicit WideBar(QWidget * parent = nullptr);
|
||||
|
||||
void addAction(QAction *action);
|
||||
void insertSpacer(QAction *action);
|
||||
|
||||
private:
|
||||
QMap<QAction *, QAction *> m_actionMap;
|
||||
};
|
Loading…
Reference in New Issue
Block a user