Author: mir3x
Date: Wed Mar  9 18:21:20 2016
New Revision: 32218

URL: http://svn.gna.org/viewcvs/freeciv?rev=32218&view=rev
Log:
Added option to hide titlebar to qt-client.

See patch #6968


Modified:
    trunk/client/gui-qt/fc_client.cpp
    trunk/client/gui-qt/fc_client.h
    trunk/client/gui-qt/gui_main.cpp
    trunk/client/options.c
    trunk/client/options.h

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=32218&r1=32217&r2=32218&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Wed Mar  9 18:21:20 2016
@@ -120,6 +120,10 @@
   fc_fonts.init_fonts();
   history_pos = -1;
   menu_bar = new mr_menu();
+  corner_wid = new fc_corner(this);
+  if (gui_options.gui_qt_show_titlebar == false) {
+    menu_bar->setCornerWidget(corner_wid);
+  }
   setMenuBar(menu_bar);
   status_bar = statusBar();
   status_bar_label = new QLabel;
@@ -300,6 +304,10 @@
     update_load_page();
     break;
   case PAGE_GAME:
+    if (gui_options.gui_qt_show_titlebar == false) {
+      setWindowFlags(Qt::Window | Qt::CustomizeWindowHint);
+      showMaximized();
+    }
     gui()->infotab->chtwdg->update_widgets();
     status_bar->setVisible(false);
     gui()->infotab->chtwdg->update_font();
@@ -711,6 +719,58 @@
 }
 
 /****************************************************************************
+  Contructor for corner widget (used for menubar)
+****************************************************************************/
+fc_corner::fc_corner(QMainWindow *qmw): QWidget()
+{
+  QHBoxLayout *hb;
+  QPushButton *qpb;
+  mw = qmw;
+  hb = new QHBoxLayout();
+  qpb = new QPushButton(style()->standardIcon(
+                                 QStyle::SP_TitleBarMinButton), "");
+  connect(qpb, SIGNAL(clicked()), SLOT(minimize()));
+  hb->addWidget(qpb);
+  qpb = new QPushButton(style()->standardIcon(
+                                 QStyle::SP_TitleBarMaxButton), "");
+  connect(qpb, SIGNAL(clicked()), SLOT(maximize()));
+  hb->addWidget(qpb);
+  qpb = new QPushButton(style()->standardIcon(
+                                 QStyle::SP_TitleBarCloseButton), "");
+  connect(qpb, SIGNAL(clicked()), SLOT(close_fc()));
+  hb->addWidget(qpb);
+  setLayout(hb);
+}
+
+/****************************************************************************
+  Slot for closing freeciv via corner widget
+****************************************************************************/
+void fc_corner::close_fc()
+{
+  mw->close();
+}
+
+/****************************************************************************
+  Slot for maximizing freeciv window via corner widget
+****************************************************************************/
+void fc_corner::maximize()
+{
+  if (mw->isMaximized() == false) {
+    mw->showMaximized();
+  } else {
+    mw->showNormal();
+  }
+}
+
+/****************************************************************************
+  Slot for minimizing freeciv window via corner widget
+****************************************************************************/
+void fc_corner::minimize()
+{
+  mw->showMinimized();
+}
+
+/****************************************************************************
   Returns desired font
 ****************************************************************************/
 QFont *fc_font::get_font(QString name)

Modified: trunk/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.h?rev=32218&r1=32217&r2=32218&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.h     (original)
+++ trunk/client/gui-qt/fc_client.h     Wed Mar  9 18:21:20 2016
@@ -133,6 +133,22 @@
   Qt::SortOrder city_report_sort;
 };
 
+/****************************************************************************
+  Corner widget for menu
+****************************************************************************/
+class fc_corner : public QWidget
+{
+  Q_OBJECT
+  QMainWindow *mw;
+public:
+  fc_corner(QMainWindow *qmw);
+public slots:
+  void maximize();
+  void minimize();
+  void close_fc();
+};
+
+
 class fc_client : public QMainWindow
 {
   Q_OBJECT
@@ -222,6 +238,7 @@
   end_turn_area *end_turn_rect;
   QWidget *central_wdg;
   mr_menu *menu_bar;
+  fc_corner *corner_wid;
   fc_game_tab_widget *game_tab_widget;
   messagewdg *msgwdg;
   info_tab *infotab;

Modified: trunk/client/gui-qt/gui_main.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/gui_main.cpp?rev=32218&r1=32217&r2=32218&view=diff
==============================================================================
--- trunk/client/gui-qt/gui_main.cpp    (original)
+++ trunk/client/gui-qt/gui_main.cpp    Wed Mar  9 18:21:20 2016
@@ -66,6 +66,7 @@
 void reset_unit_table(void);
 static void populate_unit_pixmap_table(void);
 static void apply_font(struct option *poption);
+static void apply_titlebar(struct option *poption);
 static void apply_city_font(struct option *poption);
 static void apply_help_font(struct option *poption);
 
@@ -219,6 +220,8 @@
                           apply_help_font);
   option_var_set_callback(gui_qt_font_chatline,
                           apply_font);
+  option_var_set_callback(gui_qt_show_titlebar,
+                          apply_titlebar);
 #undef option_var_set_callback
 }
 
@@ -348,6 +351,35 @@
 }
 
 /****************************************************************************
+  Shows/Hides titlebar
+****************************************************************************/
+void apply_titlebar(struct option *poption)
+{
+  bool val;
+  QWidget *w;
+  Qt::WindowFlags flags = Qt::Window;
+  val = option_bool_get(poption);
+  
+  if (gui()->current_page() < PAGE_GAME) {
+    return;
+  }
+
+  if (val == true) {
+    w = new QWidget();
+    gui()->setWindowFlags(flags);
+    delete gui()->corner_wid;
+    gui()->corner_wid = nullptr;
+    gui()->menu_bar->setCornerWidget(w);
+  } else {
+    flags |= Qt::CustomizeWindowHint;
+    gui()->setWindowFlags(flags);
+    gui()->corner_wid = new fc_corner(gui());
+    gui()->menu_bar->setCornerWidget(gui()->corner_wid);
+  }
+  gui()->show();
+}
+
+/****************************************************************************
   Change the manual font
 ****************************************************************************/
 static void apply_help_font(struct option *poption)

Modified: trunk/client/options.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/options.c?rev=32218&r1=32217&r2=32218&view=diff
==============================================================================
--- trunk/client/options.c      (original)
+++ trunk/client/options.c      Wed Mar  9 18:21:20 2016
@@ -323,6 +323,7 @@
   .gui_qt_font_city_names = "Sans Serif,10,-1,5,75,0,0,0,0,0",
   .gui_qt_font_city_productions = "Sans Serif,10,-1,5,50,1,0,0,0,0",
   .gui_qt_font_reqtree_text = "Sans Serif,10,-1,5,50,1,0,0,0,0",
+  .gui_qt_show_titlebar = TRUE,
   .gui_qt_wakeup_text = "Wake up %1"
 };
 
@@ -3036,6 +3037,11 @@
                   N_("If this option is set the client will use the "
                      "whole screen area for drawing."),
                   COC_INTERFACE, GUI_QT, FALSE, NULL),
+  GEN_BOOL_OPTION(gui_qt_show_titlebar, N_("Show titlebar"),
+                  N_("If this option is set the client will show titlebar "
+                     "If disabled, then minimize/maximize/buttons will be "
+                     "placed on menubar." ),
+                  COC_INTERFACE, GUI_QT, TRUE, NULL),
   GEN_FONT_OPTION(gui_qt_font_city_label, "city_label",
                   N_("City Label"),
                   N_("This font is used to display the city labels on city "

Modified: trunk/client/options.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/options.h?rev=32218&r1=32217&r2=32218&view=diff
==============================================================================
--- trunk/client/options.h      (original)
+++ trunk/client/options.h      Wed Mar  9 18:21:20 2016
@@ -340,6 +340,7 @@
   char gui_qt_font_city_names[512];
   char gui_qt_font_city_productions[512];
   char gui_qt_font_reqtree_text[512];
+  bool gui_qt_show_titlebar;
   char gui_qt_wakeup_text[512];
 
   struct overview overview;


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

Reply via email to