[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets
From: Tiger Dong <idlecat511 () gmail ! com>
Date: 2009-12-28 15:37:47
Message-ID: 1262014667.317531.30921.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1066985 by tdong:
[GGL] Makes popouted main view resizable.
[GGL] Make applet resizing work. TODO: doesn't work right on panel.
M +2 -4 floating_decorator.cpp
M +3 -0 ggl_applet_script.h
M +1 -4 panel_decorator.cpp
M +9 -5 plasma_host.cpp
M +2 -1 plasma_view_host.h
M +19 -29 plasma_view_host_internal.h
M +5 -10 popout_decorator.cpp
M +2 -2 popout_decorator.h
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/floating_decorator.cpp \
#1066984:1066985 @@ -52,9 +52,7 @@
bool FloatingDecorator::ShowDecoratedView(bool modal, int flags,
Slot1<bool, int> *feedback_handler) {
info->applet->setMaximumSize(QSizeF());
- MainViewDecoratorBase::ShowDecoratedView(modal, flags, feedback_handler);
-
- // return something in non-void function
- return true;
+ return MainViewDecoratorBase::ShowDecoratedView(modal, flags, feedback_handler);
}
+
} // namespace ggadget
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/ggl_applet_script.h \
#1066984:1066985 @@ -32,6 +32,7 @@
namespace Plasma {
class Applet;
}
+class QGraphicsProxyWidget;
class GadgetInfo {
public:
@@ -40,6 +41,7 @@
gadget(NULL),
applet(NULL),
script(NULL),
+ proxy(NULL),
widget(NULL),
main_view_host(NULL),
expanded_main_view_host(NULL),
@@ -52,6 +54,7 @@
ggadget::Gadget *gadget;
Plasma::Applet *applet;
Plasma::AppletScript *script;
+ QGraphicsProxyWidget *proxy;
ggadget::qt::QtViewWidget *widget;
ggadget::DecoratedViewHost *main_view_host;
ggadget::ViewHostInterface *expanded_main_view_host;
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/panel_decorator.cpp \
#1066984:1066985 @@ -94,10 +94,8 @@
if (!owner_->IsMinimizedCaptionVisible()) {
minimized_width_ = owner_->GetWidth();
owner_->SetWidth(38);
- owner_->SetResizeBorderVisible(0);
} else {
owner_->SetWidth(minimized_width_);
- owner_->SetResizeBorderVisible(BORDER_RIGHT);
}
}
@@ -205,8 +203,7 @@
SetMinimized(false);
}
- SetResizeBorderVisible((!IsMinimized() || IsMinimizedCaptionVisible()) ?
- 0 : BORDER_RIGHT);
+ SetResizeBorderVisible(0);
d->vertical_ = false;
}
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/plasma_host.cpp \
#1066984:1066985 @@ -16,7 +16,8 @@
#include "plasma_host.h"
#include <string>
-#include <QtGui/QGraphicsWidget>
+#include <QGraphicsWidget>
+#include <QGraphicsProxyWidget>
#include <QtGui/QFontDatabase>
#include <ggadget/common.h>
#include <ggadget/logger.h>
@@ -281,19 +282,22 @@
if (constraints & Plasma::SizeConstraint) {
ViewInterface *view = d->info->main_view_host->GetViewDecorator();
- if (!view) return;
+ if (!view || !d->info->widget || !d->info->proxy) return;
+
QSizeF s = d->info->applet->size();
kDebug() << "size requested:" << s;
double w = s.width();
double h = s.height();
double old_w = view->GetWidth();
double old_h = view->GetHeight();
+ if (w == old_w && h == old_h) {
+ d->info->widget->resize(w, h);
+ d->info->proxy->resize(s);
+ return;
+ }
if (view->OnSizing(&w, &h)) {
- kDebug() << "Original view size:"
- << old_w << " " << old_h;
view->SetSize(w, h);
- kDebug() << "Change to:" << w << " " << h;
}
}
}
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/plasma_view_host.h \
#1066984:1066985 @@ -76,7 +76,8 @@
virtual void BeginMoveDrag(int) {}
virtual void Alert(const ViewInterface *view, const char *message);
- virtual ggadget::ViewHostInterface::ConfirmResponse Confirm(const ViewInterface \
*view, const char *message, bool); + virtual ConfirmResponse Confirm(const \
ViewInterface *view, + const char *message, bool);
virtual std::string Prompt(const ViewInterface *view,
const char *message,
const char *default_value);
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/plasma_view_host_internal.h \
#1066984:1066985 @@ -35,27 +35,12 @@
type_(type),
info(i),
is_popout_(popout),
- gadget_w_(0),
- gadget_h_(0),
feedback_handler_(NULL) {}
~Private() {
closeView();
}
- static void embedWidget(QGraphicsWidget *parent, QWidget *widget) {
- widget->setAttribute(Qt::WA_NoSystemBackground);
- QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(parent);
- layout->setSpacing(0);
- layout->setContentsMargins(0, 0, 0, 0);
- QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(parent);
- proxy->setWidget(widget);
- layout->addItem(proxy);
- parent->setLayout(layout);
- DLOG("EmbededWidget: widget:%p, applet:%p, layout:%p, proxy:%p",
- widget, parent, layout, proxy);
- }
-
/* Show the view in right place
* - floating main view: Shown within the applet
* - popouted main view and details view: Shown in QtViewWidget
@@ -74,7 +59,10 @@
// normal main view
if (info->widget == NULL) {
widget_ = new QtViewWidget(view_, 0);
- embedWidget(info->applet, widget_);
+ widget_->setAttribute(Qt::WA_NoSystemBackground);
+ info->proxy = new QGraphicsProxyWidget(info->applet);
+ info->proxy->setWidget(widget_);
+ widget_->show();
info->widget = widget_;
} else {
widget_ = info->widget;
@@ -140,20 +128,23 @@
// This is called when view size has changed, caused by constraintsEvent or
// user manually resizes gadget. Applet and widget size will be adjusted
// according to view size.
+ // size changing has two sequences:
+ // view->applet, widget, proxy
+ // applet->view->widget, proxy
void adjustAppletSize() {
- if (!info->main_view_host || !info->applet) return;
+ if (!info->main_view_host || !info->applet || !info->proxy || !widget_) {
+ return;
+ }
ViewInterface *view = info->main_view_host->GetViewDecorator();
double w = view->GetWidth();
double h = view->GetHeight();
if (w <= 0 || h <= 0) return;
- if (gadget_w_ == w && gadget_h_ == h) return;
- gadget_w_ = w;
- gadget_h_ = h;
-#if 0
kDebug() << "view size:" << w << " " << h;
kDebug() << "applet old size:" << info->applet->size();
-
+ kDebug() << "widget old size:" << widget_->size();
+ kDebug() << "proxy old size:" << info->proxy->size();
+#if 0
if (info->applet->location() == Plasma::Floating) {
info->applet->resize(w, h);
} else {
@@ -165,11 +156,12 @@
kDebug() << "applet new size:" << info->applet->size();
#endif
- if (widget_) {
- kDebug() << "widget old size:" << widget_->size();
- widget_->resize(w, h);
- kDebug() << "widget new size:" << widget_->size();
- }
+ info->applet->resize(w, h);
+ info->proxy->resize(w, h);
+ widget_->resize(w, h);
+ kDebug() << "applet new size:" << info->applet->size();
+ kDebug() << "widget new size:" << widget_->size();
+ kDebug() << "proxy new size:" << info->proxy->size();
}
void queueResize() {
@@ -200,8 +192,6 @@
ViewHostInterface::Type type_;
GadgetInfo *info;
bool is_popout_;
- double gadget_w_;
- double gadget_h_;
Slot1<bool, int> *feedback_handler_;
QString caption_;
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/popout_decorator.cpp \
#1066984:1066985 @@ -29,12 +29,9 @@
namespace ggadget {
PopOutDecorator::PopOutDecorator(PlasmaViewHost *host)
- : MainViewDecoratorBase(host,
- "plasma_popout_main_view",
- false,
- false,
- true),
+ : FloatingMainViewDecorator(host, true),
info(host->getInfo()) {
+ SetOptionPrefix("plasma_popout_main_view");
SetButtonVisible(MainViewDecoratorBase::POP_IN_OUT_BUTTON, false);
SetButtonVisible(MainViewDecoratorBase::MENU_BUTTON, false);
SetButtonVisible(MainViewDecoratorBase::CLOSE_BUTTON, false);
@@ -47,11 +44,9 @@
}
bool PopOutDecorator::ShowDecoratedView(bool modal, int flags,
- Slot1<bool, int> *feedback_handler) {
+ Slot1<bool, int> *feedback_handler) {
info->applet->setMaximumSize(QSizeF());
- MainViewDecoratorBase::ShowDecoratedView(modal, flags, feedback_handler);
-
- // return something in non-void function
- return true;
+ return FloatingMainViewDecorator::ShowDecoratedView(modal, flags, \
feedback_handler); }
+
} // namespace ggadget
--- trunk/KDE/kdebase/workspace/plasma/generic/scriptengines/google_gadgets/popout_decorator.h \
#1066984:1066985 @@ -17,12 +17,12 @@
#ifndef GGADGET_POPOUT_DECORATOR_H__
#define GGADGET_POPOUT_DECORATOR_H__
-#include <ggadget/main_view_decorator_base.h>
+#include <ggadget/floating_main_view_decorator.h>
#include "plasma_view_host.h"
namespace ggadget {
-class PopOutDecorator : public MainViewDecoratorBase {
+class PopOutDecorator : public FloatingMainViewDecorator {
public:
PopOutDecorator(PlasmaViewHost *host);
virtual ~PopOutDecorator();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic