[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/scriptengines/google_gadgets
From:       Tiger Dong <idlecat511 () gmail ! com>
Date:       2008-09-27 10:21:13
Message-ID: 1222510873.805525.16646.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 865269 by tdong:

[GGL] Make GG work with horizontal panel


 M  +7 -0      ggl_applet_script.cpp  
 M  +49 -19    panel_decorator.cpp  
 M  +2 -2      panel_decorator.h  
 M  +8 -2      plasma_host.cpp  


--- trunk/KDE/kdebase/workspace/plasma/scriptengines/google_gadgets/ggl_applet_script.cpp #865268:865269
@@ -174,6 +174,13 @@
 void GglAppletScript::paintInterface(QPainter *p,
                                      const QStyleOptionGraphicsItem *option,
                                      const QRect &contentsRect) {
+#if 0
+  QRect r = contentsRect;
+  p->setPen(QColor(0, 0, 255));
+  p->drawLine(r.left(), r.top(), r.right(), r.bottom());
+  p->drawLine(r.left(), r.bottom(), r.right(), r.top());
+  p->drawRect(r);
+#endif
 }
 
 void GglAppletScript::mousePressEvent(QGraphicsSceneMouseEvent *event) {
--- trunk/KDE/kdebase/workspace/plasma/scriptengines/google_gadgets/panel_decorator.cpp #865268:865269
@@ -28,34 +28,64 @@
 
 namespace ggadget {
 
+class PanelDecorator::Private {
+ public:
+  Private(GadgetInfo *info) : owner_(NULL), info_(info){}
+
+  void ShowDebugInfo(const char*) {
+    QString msg = "Applet size:(%1, %2)\nWidget size:(%3, %4)\nView size:(%5, %6)\n";
+    qt::QtViewWidget *widget = static_cast<qt::QtViewWidget*>(info_->main_view_host->GetNativeWidget());
+    ViewInterface *view = info_->main_view_host->GetViewDecorator();
+    QMessageBox::information(NULL,
+                             "Debug",
+                             msg.arg(info_->applet->size().width())
+                             .arg(info_->applet->size().height())
+                             .arg(widget->size().width())
+                             .arg(widget->size().height())
+                             .arg(view->GetWidth())
+                             .arg(view->GetHeight()));
+  }
+  void ShowIcon(const char*) {
+    owner_->SetMinimizedIconVisible(!owner_->IsMinimizedIconVisible());
+  }
+  void ShowCaption(const char*) {
+    owner_->SetMinimizedCaptionVisible(!owner_->IsMinimizedCaptionVisible());
+  }
+  void OnAddDecoratorMenuItems(MenuInterface *menu) {
+    int priority = MenuInterface::MENU_ITEM_PRI_DECORATOR;
+    owner_->AddCollapseExpandMenuItem(menu);
+    if (owner_->IsMinimized()) {
+      menu->AddItem("Show Icon", 
+                    owner_->IsMinimizedIconVisible()?MenuInterface::MENU_ITEM_FLAG_CHECKED:0,
+                    0,
+                    NewSlot(this, &Private::ShowIcon), priority);
+      menu->AddItem("Show Caption", 
+                    owner_->IsMinimizedCaptionVisible()?MenuInterface::MENU_ITEM_FLAG_CHECKED:0,
+                    0,
+                    NewSlot(this, &Private::ShowCaption), priority);
+    }
+
+    menu->AddItem(
+        "Debug", 0, 0,
+        NewSlot(this, &Private::ShowDebugInfo), priority);
+  }
+  PanelDecorator *owner_;
+  GadgetInfo *info_;
+};
+
 PanelDecorator::PanelDecorator(ViewHostInterface *host, GadgetInfo *info)
-    : DockedMainViewDecorator(host), info_(info) {
+    : DockedMainViewDecorator(host), d(new Private(info)) {
   SetButtonVisible(MainViewDecoratorBase::POP_IN_OUT_BUTTON, false);
   SetButtonVisible(MainViewDecoratorBase::MENU_BUTTON, false);
   SetButtonVisible(MainViewDecoratorBase::CLOSE_BUTTON, false);
+  d->owner_ = this;
 }
 
 PanelDecorator::~PanelDecorator() {}
 
 void PanelDecorator::OnAddDecoratorMenuItems(MenuInterface *menu) {
-  int priority = MenuInterface::MENU_ITEM_PRI_DECORATOR;
-  AddCollapseExpandMenuItem(menu);
-  menu->AddItem(
-      "Debug", 0, 0,
-      NewSlot(this, &PanelDecorator::ShowDebugInfo), priority);
+  d->OnAddDecoratorMenuItems(menu);
 }
 
-void PanelDecorator::ShowDebugInfo(const char*) {
-  QString msg = "Applet size:(%1, %2)\nWidget size:(%3, %4)\nView size:(%5, %6)\n";
-  qt::QtViewWidget *widget = static_cast<qt::QtViewWidget*>(info_->main_view_host->GetNativeWidget());
-  ViewInterface *view = info_->main_view_host->GetViewDecorator();
-  QMessageBox::information(NULL,
-    "Debug",
-    msg.arg(info_->applet->size().width())
-       .arg(info_->applet->size().height())
-       .arg(widget->size().width())
-       .arg(widget->size().height())
-       .arg(view->GetWidth())
-       .arg(view->GetHeight()));
-}
+
 } // namespace ggadget
--- trunk/KDE/kdebase/workspace/plasma/scriptengines/google_gadgets/panel_decorator.h #865268:865269
@@ -30,8 +30,8 @@
   virtual void OnAddDecoratorMenuItems(MenuInterface *menu);
 
  private:
-  void ShowDebugInfo(const char*);
-  GadgetInfo *info_;
+  class Private;
+  Private *d;
   DISALLOW_EVIL_CONSTRUCTORS(PanelDecorator);
 };
 
--- trunk/KDE/kdebase/workspace/plasma/scriptengines/google_gadgets/plasma_host.cpp #865268:865269
@@ -94,6 +94,7 @@
 
   void OnPopInHandler() {
     kDebug() << "OnPopInHandler";
+    if (!info->expanded_main_view_host) return;
     ViewInterface *child = info->expanded_main_view_host->GetView();
     ASSERT(child);
     if (child) {
@@ -136,6 +137,12 @@
       decorator->ConnectOnPopIn(NewSlot(d, &Private::OnPopInHandler));
     } else {
       PanelDecorator *decorator = new PanelDecorator(vh, d->info);
+      if (d->info->applet->location() == Plasma::TopEdge
+          || d->info->applet->location() == Plasma::BottomEdge) {
+        decorator->SetAllowYMargin(true);
+        decorator->SetAllowXMargin(false);
+        decorator->SetResizeBorderVisible(false, false, false, true);
+      }
       decorator->ConnectOnPopOut(NewSlot(d, &Private::OnPopOutHandler));
       decorator->ConnectOnPopIn(NewSlot(d, &Private::OnPopInHandler));
       dvh = new DecoratedViewHost(decorator);
@@ -221,8 +228,7 @@
   if (d->info->is_floating) {
     d->info->applet->resize(w, h);
   } else {
-    d->info->applet->setMinimumSize(w, h);
-    d->info->applet->setMaximumSize(w, h);
+    d->info->applet->setPreferredSize(w, h);
   }
   if (widget) {
     widget->AdjustToViewSize();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic