mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[ReloadStopButton] It is now only one button
Instead of hiding and showing two buttons (reload and stop), use only one ToolButton and change the object name accordingly.
This commit is contained in:
parent
927c8b2a17
commit
f21be271b2
@ -16,47 +16,27 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "reloadstopbutton.h"
|
#include "reloadstopbutton.h"
|
||||||
#include "toolbutton.h"
|
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
ReloadStopButton::ReloadStopButton(QWidget* parent)
|
ReloadStopButton::ReloadStopButton(QWidget* parent)
|
||||||
: QWidget(parent)
|
: ToolButton(parent)
|
||||||
, m_loadInProgress(false)
|
, m_loadInProgress(false)
|
||||||
{
|
{
|
||||||
QHBoxLayout* lay = new QHBoxLayout(this);
|
setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||||
setLayout(lay);
|
setToolbarButtonLook(true);
|
||||||
|
setAutoRaise(true);
|
||||||
m_buttonStop = new ToolButton(this);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
m_buttonStop->setObjectName("navigation-button-stop");
|
|
||||||
m_buttonStop->setToolTip(ToolButton::tr("Stop"));
|
|
||||||
m_buttonStop->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
||||||
m_buttonStop->setToolbarButtonLook(true);
|
|
||||||
m_buttonStop->setVisible(false);
|
|
||||||
m_buttonStop->setAutoRaise(true);
|
|
||||||
m_buttonStop->setFocusPolicy(Qt::NoFocus);
|
|
||||||
|
|
||||||
m_buttonReload = new ToolButton(this);
|
|
||||||
m_buttonReload->setObjectName("navigation-button-reload");
|
|
||||||
m_buttonReload->setToolTip(ToolButton::tr("Reload"));
|
|
||||||
m_buttonReload->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
|
||||||
m_buttonReload->setToolbarButtonLook(true);
|
|
||||||
m_buttonReload->setAutoRaise(true);
|
|
||||||
m_buttonReload->setFocusPolicy(Qt::NoFocus);
|
|
||||||
|
|
||||||
lay->addWidget(m_buttonStop);
|
|
||||||
lay->addWidget(m_buttonReload);
|
|
||||||
lay->setContentsMargins(0, 0, 0, 0);
|
|
||||||
lay->setSpacing(0);
|
|
||||||
|
|
||||||
m_updateTimer = new QTimer(this);
|
m_updateTimer = new QTimer(this);
|
||||||
m_updateTimer->setInterval(100);
|
m_updateTimer->setInterval(50);
|
||||||
m_updateTimer->setSingleShot(true);
|
m_updateTimer->setSingleShot(true);
|
||||||
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateButton()));
|
connect(m_updateTimer, SIGNAL(timeout()), this, SLOT(updateButton()));
|
||||||
|
|
||||||
connect(m_buttonStop, SIGNAL(clicked()), this, SIGNAL(stopClicked()));
|
connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked()));
|
||||||
connect(m_buttonReload, SIGNAL(clicked()), this, SIGNAL(reloadClicked()));
|
|
||||||
|
updateButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReloadStopButton::showStopButton()
|
void ReloadStopButton::showStopButton()
|
||||||
@ -73,8 +53,24 @@ void ReloadStopButton::showReloadButton()
|
|||||||
|
|
||||||
void ReloadStopButton::updateButton()
|
void ReloadStopButton::updateButton()
|
||||||
{
|
{
|
||||||
setUpdatesEnabled(false);
|
if (m_loadInProgress) {
|
||||||
m_buttonStop->setVisible(m_loadInProgress);
|
setToolTip(tr("Stop"));
|
||||||
m_buttonReload->setVisible(!m_loadInProgress);
|
setObjectName(QSL("navigation-button-stop"));
|
||||||
setUpdatesEnabled(true);
|
}
|
||||||
|
else {
|
||||||
|
setToolTip(tr("Reload"));
|
||||||
|
setObjectName(QSL("navigation-button-reload"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the stylesheet for the changed object name
|
||||||
|
style()->unpolish(this);
|
||||||
|
style()->polish(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReloadStopButton::buttonClicked()
|
||||||
|
{
|
||||||
|
if (m_loadInProgress)
|
||||||
|
emit stopClicked();
|
||||||
|
else
|
||||||
|
emit reloadClicked();
|
||||||
}
|
}
|
||||||
|
@ -18,15 +18,12 @@
|
|||||||
#ifndef RELOADSTOPBUTTON_H
|
#ifndef RELOADSTOPBUTTON_H
|
||||||
#define RELOADSTOPBUTTON_H
|
#define RELOADSTOPBUTTON_H
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
#include "qzcommon.h"
|
#include "qzcommon.h"
|
||||||
|
#include "toolbutton.h"
|
||||||
|
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
|
||||||
class ToolButton;
|
class QUPZILLA_EXPORT ReloadStopButton : public ToolButton
|
||||||
|
|
||||||
class QUPZILLA_EXPORT ReloadStopButton : public QWidget
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -42,13 +39,11 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateButton();
|
void updateButton();
|
||||||
|
void buttonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_loadInProgress;
|
bool m_loadInProgress;
|
||||||
QTimer* m_updateTimer;
|
QTimer* m_updateTimer;
|
||||||
|
|
||||||
ToolButton* m_buttonStop;
|
|
||||||
ToolButton* m_buttonReload;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // RELOADSTOPBUTTON_H
|
#endif // RELOADSTOPBUTTON_H
|
||||||
|
Loading…
Reference in New Issue
Block a user