Author: mir3x
Date: Mon Oct 31 16:37:49 2016
New Revision: 34300

URL: http://svn.gna.org/viewcvs/freeciv?rev=34300&view=rev
Log:
Qt client - added menu to switch observed player

See patch #7890

Modified:
    branches/S2_6/client/gui-qt/pages.cpp
    branches/S2_6/client/gui-qt/sidebar.cpp
    branches/S2_6/client/gui-qt/sidebar.h

Modified: branches/S2_6/client/gui-qt/pages.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/pages.cpp?rev=34300&r1=34299&r2=34300&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/pages.cpp       (original)
+++ branches/S2_6/client/gui-qt/pages.cpp       Mon Oct 31 16:37:49 2016
@@ -714,7 +714,7 @@
   sw_cunit->set_right_click(side_center_unit);
   sw_cunit->set_wheel_up(key_recall_previous_focus_unit);
   sw_cunit->set_wheel_down(key_unit_wait);
-  sw_diplo->set_right_click(side_show_diplomacy_dialog);
+  sw_diplo->set_right_click(side_right_click_diplomacy);
 
   sidebar_wdg->add_widget(sw_map);
   sidebar_wdg->add_widget(sw_cunit);

Modified: branches/S2_6/client/gui-qt/sidebar.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/sidebar.cpp?rev=34300&r1=34299&r2=34300&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/sidebar.cpp     (original)
+++ branches/S2_6/client/gui-qt/sidebar.cpp     Mon Oct 31 16:37:49 2016
@@ -305,6 +305,36 @@
   update_final_pixmap();
 }
 
+/***************************************************************************
+  Miscelanous slot, helping observe players currently,
+  extra functionality might be added,
+  eg by setting properties
+***************************************************************************/
+void fc_sidewidget::some_slot()
+{
+  QVariant qvar;
+  struct player *obs_player;
+  QAction *act;
+
+  act = qobject_cast<QAction *>(sender());
+  qvar = act->data();
+
+  if (qvar.isValid() == false) {
+    return;
+  }
+
+  if (qvar.toInt() == -1) {
+    send_chat("/observe");
+    return;
+  }
+
+  obs_player = reinterpret_cast<struct player *>(qvar.value<void *>());
+  if (obs_player != nullptr) {
+    QString s;
+    s = QString("/observe \"%1\"").arg(obs_player->name);
+    send_chat(s.toLocal8Bit().data());
+  }
+}
 
 /***************************************************************************
   Updates final pixmap and draws it on screen
@@ -609,14 +639,46 @@
 }
 
 /***************************************************************************
-  Shows diplomacy dialog if there is any open
-***************************************************************************/
-void side_show_diplomacy_dialog(void)
-{
-  int i;
-  i = gui()->gimme_index_of("DDI");
-  if (i < 0) {
-    return;
-  }
-  gui()->game_tab_widget->setCurrentIndex(i);
-}
+  Right click for diplomacy 
+  Opens diplomacy meeting for player
+  For observer popups menu
+***************************************************************************/
+void side_right_click_diplomacy(void)
+{
+  if (client_is_observer()) {
+    QMenu *menu = new QMenu(gui()->central_wdg);
+    QAction *eiskalt;
+    QString erwischt;
+
+    players_iterate(pplayer) {
+      if (pplayer == client.conn.playing) {
+        continue;
+      }
+      erwischt = QString(_("Observe %1")).arg(pplayer->name);
+      erwischt = erwischt + " ("
+                 + nation_plural_translation(pplayer->nation) + ")";
+      eiskalt = new QAction(erwischt, gui()->mapview_wdg);
+      eiskalt->setData(QVariant::fromValue((void *)pplayer));
+      QObject::connect(eiskalt, SIGNAL(triggered()), gui()->sw_diplo,
+                       SLOT(some_slot()));
+      menu->addAction(eiskalt);
+    } players_iterate_end
+
+    if (client_is_global_observer() == false) {
+      eiskalt = new QAction(_("Observe globally"), gui()->mapview_wdg);
+      eiskalt->setData(-1);
+      menu->addAction(eiskalt);
+      QObject::connect(eiskalt, SIGNAL(triggered()), gui()->sw_diplo,
+                       SLOT(some_slot()));
+    }
+
+    menu->exec(QCursor::pos());
+  } else {
+    int i;
+    i = gui()->gimme_index_of("DDI");
+    if (i < 0) {
+      return;
+    }
+    gui()->game_tab_widget->setCurrentIndex(i);
+  }
+}

Modified: branches/S2_6/client/gui-qt/sidebar.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/sidebar.h?rev=34300&r1=34299&r2=34300&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/sidebar.h       (original)
+++ branches/S2_6/client/gui-qt/sidebar.h       Mon Oct 31 16:37:49 2016
@@ -32,7 +32,7 @@
 typedef void (*pfcn_bool)(bool);
 typedef void (*pfcn)(void);
 
-void side_show_diplomacy_dialog(void);
+void side_right_click_diplomacy(void);
 void side_blink_endturn(bool do_restore);
 void side_center_unit();
 void side_disable_endturn(bool do_restore);
@@ -40,7 +40,6 @@
 void side_indicators_menu();
 void side_rates_wdg(bool nothing);
 void side_show_map(bool nothing);
-
 /***************************************************************************
   Class representing single widget(icon) on sidebar
 ***************************************************************************/
@@ -72,6 +71,7 @@
   QString page;
 public slots:
   void sblink();
+  void some_slot();
 protected:
   void contextMenuEvent(QContextMenuEvent  *event);
   void enterEvent(QEvent *event);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to