-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3890 from ywwg/wscrollable
WScrollable: Add a scrollable widget type.
- Loading branch information
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include "widget/wscrollable.h" | ||
|
||
WScrollable::WScrollable(QWidget* pParent) | ||
: QScrollArea(pParent), | ||
WBaseWidget(this) { | ||
} | ||
|
||
void WScrollable::setup(const QDomNode& node, const SkinContext& context) { | ||
QString horizontalPolicy; | ||
// The QT default is "As Needed", so we don't need a selector for that. | ||
if (context.hasNodeSelectString(node, "HorizontalScrollBarPolicy", &horizontalPolicy)) { | ||
if (horizontalPolicy == "on") { | ||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | ||
} else if (horizontalPolicy == "off") { | ||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||
} | ||
} | ||
QString verticalPolicy; | ||
if (context.hasNodeSelectString(node, "VerticalScrollBarPolicy", &verticalPolicy)) { | ||
if (verticalPolicy == "on") { | ||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | ||
} else if (verticalPolicy == "off") { | ||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#pragma once | ||
|
||
#include <QDomNode> | ||
#include <QEvent> | ||
#include <QScrollArea> | ||
|
||
#include "preferences/usersettings.h" | ||
#include "skin/legacy/skincontext.h" | ||
#include "widget/wbasewidget.h" | ||
|
||
/// Creates a QScrollArea. The QT default is to show scrollbars if needed. | ||
class WScrollable : public QScrollArea, public WBaseWidget { | ||
Q_OBJECT | ||
public: | ||
WScrollable(QWidget* pParent); | ||
|
||
/// WScrollable supports the following attributes: HorizontalScrollBarPolicy, VerticalScrollBarPolicy | ||
void setup(const QDomNode& node, const SkinContext& context); | ||
}; |