~osomon/oxide/fix-crash-popup-menu

« back to all changes in this revision

Viewing changes to qt/quick/api/oxideqquicklocationbarcontroller.cc

  • Committer: Chris Coulson
  • Date: 2015-04-16 23:11:37 UTC
  • Revision ID: chris.coulson@canonical.com-20150416231137-gu15fh6rj1xwnjh2
Tags: BRANCH_1_7
Add LocationBarController.show(), LocationBarController.hide() and LocationBarController.animated

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
qreal OxideQQuickLocationBarController::height() const {
42
42
  Q_D(const OxideQQuickLocationBarController);
43
43
 
44
 
  OxideQQuickWebViewPrivate* p = OxideQQuickWebViewPrivate::get(d->view);
45
 
  return p->locationBarHeight();
 
44
  return OxideQQuickWebViewPrivate::get(d->view)->locationBarHeight();
46
45
}
47
46
 
48
47
void OxideQQuickLocationBarController::setHeight(qreal height) {
49
48
  Q_D(OxideQQuickLocationBarController);
50
49
 
51
50
  if (height < 0.0f) {
52
 
    qWarning() << "OxideQQuickLocationBarController: height cannot be negative";
 
51
    qWarning() <<
 
52
        "OxideQQuickLocationBarController: height cannot be negative";
53
53
    return;
54
54
  }
55
55
 
86
86
    return;
87
87
  }
88
88
 
89
 
  if (height() == 0) {
90
 
    return;
91
 
  }
92
 
 
93
89
  OxideQQuickWebViewPrivate::get(d->view)->setLocationBarMode(
94
90
      static_cast<oxide::qt::LocationBarMode>(mode));
95
91
  Q_EMIT modeChanged();
96
92
}
97
93
 
 
94
bool OxideQQuickLocationBarController::animated() const {
 
95
  Q_D(const OxideQQuickLocationBarController);
 
96
 
 
97
  return OxideQQuickWebViewPrivate::get(d->view)->locationBarAnimated();
 
98
}
 
99
 
 
100
void OxideQQuickLocationBarController::setAnimated(bool animated) {
 
101
  Q_D(OxideQQuickLocationBarController);
 
102
 
 
103
  if (animated == this->animated()) {
 
104
    return;
 
105
  }
 
106
 
 
107
  OxideQQuickWebViewPrivate::get(d->view)->setLocationBarAnimated(animated);
 
108
  Q_EMIT animatedChanged();
 
109
}
 
110
 
98
111
qreal OxideQQuickLocationBarController::offset() const {
99
112
  Q_D(const OxideQQuickLocationBarController);
100
113
 
107
120
  return OxideQQuickWebViewPrivate::get(
108
121
      d->view)->locationBarContentOffsetPix();
109
122
}
 
123
 
 
124
void OxideQQuickLocationBarController::show(bool animate) {
 
125
  Q_D(OxideQQuickLocationBarController);
 
126
 
 
127
  if (mode() != ModeAuto) {
 
128
    qWarning() <<
 
129
        "OxideQQuickLocationBarController::show: mode is not ModeAuto";
 
130
    return;
 
131
  }
 
132
 
 
133
  if (height() <= 0.f) {
 
134
    qWarning() <<
 
135
        "OxideQQuickLocationBarController::show: height is not greater than "
 
136
        "zero";
 
137
    return;
 
138
  }
 
139
 
 
140
  OxideQQuickWebViewPrivate::get(d->view)->locationBarShow(animate);
 
141
}
 
142
 
 
143
void OxideQQuickLocationBarController::hide(bool animate) {
 
144
  Q_D(OxideQQuickLocationBarController);
 
145
 
 
146
  if (mode() != ModeAuto) {
 
147
    qWarning() <<
 
148
        "OxideQQuickLocationBarController::hide: mode is not ModeAuto";
 
149
    return;
 
150
  }
 
151
 
 
152
  if (height() <= 0.f) {
 
153
    qWarning() <<
 
154
        "OxideQQuickLocationBarController::hide: height is not greater than "
 
155
        "zero";
 
156
    return;
 
157
  }
 
158
 
 
159
  OxideQQuickWebViewPrivate::get(d->view)->locationBarHide(animate);
 
160
}