UI: Refactor flat tool button

This commit is contained in:
Nodir Temirkhodjaev 2022-04-02 15:17:42 +03:00
parent df92b13138
commit 72a23c7a76
11 changed files with 27 additions and 34 deletions

View File

@ -85,21 +85,11 @@ QPushButton *ControlUtil::createLinkButton(
return c;
}
QPushButton *ControlUtil::createFlatButton(
QToolButton *ControlUtil::createSplitterButton(
const QString &iconPath, const std::function<void()> &onClicked)
{
auto c = createButton(iconPath, onClicked);
c->setFlat(true);
c->setCursor(Qt::PointingHandCursor);
c->setFocusPolicy(Qt::NoFocus);
c->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
return c;
}
QPushButton *ControlUtil::createSplitterButton(
const QString &iconPath, const std::function<void()> &onClicked)
{
auto c = createFlatButton(iconPath, onClicked);
auto c = createFlatToolButton(iconPath, onClicked);
c->setCursor(Qt::ArrowCursor);
c->setFixedSize(32, 32);
return c;
}

View File

@ -32,9 +32,7 @@ public:
const QString &iconPath, const std::function<void()> &onClicked);
static QPushButton *createLinkButton(const QString &iconPath,
const QString &linkPath = QString(), const QString &toolTip = QString());
static QPushButton *createFlatButton(
const QString &iconPath, const std::function<void()> &onClicked);
static QPushButton *createSplitterButton(
static QToolButton *createSplitterButton(
const QString &iconPath, const std::function<void()> &onClicked);
static QLabel *createLabel(const QString &text = QString());
static QLineEdit *createLineLabel();

View File

@ -3,8 +3,8 @@
#include <QBoxLayout>
#include <QPainter>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QStyleOption>
#include <QToolButton>
#include <form/controls/controlutil.h>
#include <util/textareautil.h>

View File

@ -5,7 +5,7 @@
QT_FORWARD_DECLARE_CLASS(QBoxLayout)
QT_FORWARD_DECLARE_CLASS(QPlainTextEdit)
QT_FORWARD_DECLARE_CLASS(QPushButton)
QT_FORWARD_DECLARE_CLASS(QToolButton)
class TextArea2Splitter;
@ -24,11 +24,11 @@ public:
QPlainTextEdit *currentTextArea() const;
QPushButton *btMoveAllFrom1To2() const { return m_btMoveAllFrom1To2; }
QPushButton *btMoveSelectedFrom1To2() const { return m_btMoveSelectedFrom1To2; }
QPushButton *btInterchangeAll() const { return m_btInterchangeAll; }
QPushButton *btMoveSelectedFrom2To1() const { return m_btMoveSelectedFrom2To1; }
QPushButton *btMoveAllFrom2To1() const { return m_btMoveAllFrom2To1; }
QToolButton *btMoveAllFrom1To2() const { return m_btMoveAllFrom1To2; }
QToolButton *btMoveSelectedFrom1To2() const { return m_btMoveSelectedFrom1To2; }
QToolButton *btInterchangeAll() const { return m_btInterchangeAll; }
QToolButton *btMoveSelectedFrom2To1() const { return m_btMoveSelectedFrom2To1; }
QToolButton *btMoveAllFrom2To1() const { return m_btMoveAllFrom2To1; }
TextArea2Splitter *splitter() const;
@ -45,11 +45,11 @@ private:
QPlainTextEdit *m_textArea2 = nullptr;
QBoxLayout *m_buttonsLayout = nullptr;
QPushButton *m_btMoveAllFrom1To2 = nullptr;
QPushButton *m_btMoveSelectedFrom1To2 = nullptr;
QPushButton *m_btInterchangeAll = nullptr;
QPushButton *m_btMoveSelectedFrom2To1 = nullptr;
QPushButton *m_btMoveAllFrom2To1 = nullptr;
QToolButton *m_btMoveAllFrom1To2 = nullptr;
QToolButton *m_btMoveSelectedFrom1To2 = nullptr;
QToolButton *m_btInterchangeAll = nullptr;
QToolButton *m_btMoveSelectedFrom2To1 = nullptr;
QToolButton *m_btMoveAllFrom2To1 = nullptr;
};
#endif // TEXTAREA2SPLITTERHANDLE_H

View File

@ -8,6 +8,7 @@
#include <QPlainTextEdit>
#include <QPushButton>
#include <QTabBar>
#include <QToolButton>
#include <QVBoxLayout>
#include <conf/addressgroup.h>

View File

@ -63,7 +63,7 @@ private:
AddressesColumn *m_includeAddresses = nullptr;
AddressesColumn *m_excludeAddresses = nullptr;
TextArea2Splitter *m_splitter = nullptr;
QPushButton *m_btAddLocals = nullptr;
QToolButton *m_btAddLocals = nullptr;
QMenu *m_menuZones = nullptr;
};

View File

@ -9,6 +9,7 @@
#include <QPushButton>
#include <QSpinBox>
#include <QTimeEdit>
#include <QToolButton>
#include <QVBoxLayout>
#include <conf/appgroup.h>

View File

@ -89,7 +89,7 @@ private:
AppsColumn *m_blockApps = nullptr;
AppsColumn *m_allowApps = nullptr;
TextArea2Splitter *m_splitter = nullptr;
QPushButton *m_btSelectFile = nullptr;
QToolButton *m_btSelectFile = nullptr;
};
#endif // APPLICATIONSPAGE_H

View File

@ -10,6 +10,7 @@
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QToolButton>
#include <appinfo/appinfocache.h>
#include <conf/confmanager.h>
@ -239,7 +240,7 @@ QLayout *ProgramEditDialog::setupAppPathLayout()
m_editPath = new QLineEdit();
m_editPath->setMaxLength(1024);
m_btSelectFile = ControlUtil::createFlatButton(":/icons/folder.png", [&] {
m_btSelectFile = ControlUtil::createFlatToolButton(":/icons/folder.png", [&] {
const auto filePath = DialogUtil::getOpenFileName(
m_labelEditPath->text(), tr("Programs (*.exe);;All files (*.*)"));
@ -270,7 +271,8 @@ QLayout *ProgramEditDialog::setupAppNameLayout()
m_editName->setText(appName);
};
m_btGetName = ControlUtil::createFlatButton(":/icons/arrow_refresh_small.png", updateAppName);
m_btGetName =
ControlUtil::createFlatToolButton(":/icons/arrow_refresh_small.png", updateAppName);
layout->addWidget(m_editName);
layout->addWidget(m_btGetName);

View File

@ -62,10 +62,10 @@ private:
QLabel *m_labelEditPath = nullptr;
QLineEdit *m_editPath = nullptr;
QPushButton *m_btSelectFile = nullptr;
QToolButton *m_btSelectFile = nullptr;
QLabel *m_labelEditName = nullptr;
QLineEdit *m_editName = nullptr;
QPushButton *m_btGetName = nullptr;
QToolButton *m_btGetName = nullptr;
QLabel *m_labelAppGroup = nullptr;
QComboBox *m_comboAppGroup = nullptr;
QCheckBox *m_cbUseGroupPerm = nullptr;

View File

@ -360,6 +360,7 @@ void TrayIcon::setupTrayMenu()
}
m_menu->addSeparator();
m_quitAction = addAction(m_menu, QIcon(), tr("Quit"), this, SLOT(quitProgram()));
addHotKey(m_quitAction, iniUser()->hotKeyQuit());
}