Check-in [75df4b5141]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:MainWindow: code improvements. PortalDialer: glyphs become disabled when 12-digit code entered
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | improvements-to-main-menu
Files: files | file ages | folders
SHA1:75df4b5141660c5936deff87b38139cf4ae11b6d
User & Date: tion 2019-02-15 22:33:43
Context
2019-02-15
22:50
MainWindow: remove unneeded headers. PortalDialer: cancel autofill setting check-in: c987d861d1 user: tion tags: improvements-to-main-menu
22:33
MainWindow: code improvements. PortalDialer: glyphs become disabled when 12-digit code entered check-in: 75df4b5141 user: tion tags: improvements-to-main-menu
18:23
Add status bar check-in: 8946855f9a user: tion tags: improvements-to-main-menu
Changes

Changes to src/CoordinateMain.cpp.

120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
      QTextStream outs (stdout);

      if ( coord == true && glyph == false )
      {
         // convert coordinates -> glyph
         for (int i = 0; i < args.size(); i++)
         {
            to_glyphs (args.at(i), bool(true), outs, verb);
         }
      }
      else if ( glyph == true && coord == false )
      {
         // convert glyph -> coordinates
         for (int i = 0; i < args.size(); i++)
         {
            to_coords (args.at(i), bool(false), outs, verb);
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
................................................................................
         {
            // Options are mixed so best guess the inputs
            for (int i = 0; i < args.size(); i++)
            {
               if ( args.at(i).size() == 12 )
               {
                  // Assume is glyph code
                  to_coords (args.at(i), bool(false), outs, verb);
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), bool(true), outs, verb);
               }
               else { }
            }
         }
      }

      // Exit properly rather than keep waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);
	  	setApplicationSettings();

      // Set GUI style
      QString gui_look = "Fusion", used;

      if ( argc >= 1 && argv[2] != QString() )
      {
         const QString temp_string = argv[2];

         if ( temp_string.size() < 15 )
            gui_look = QString(argv[2]);	// Get GUI-style to use







|







|







 







|




|

|




|








|







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
      QTextStream outs (stdout);

      if ( coord == true && glyph == false )
      {
         // convert coordinates -> glyph
         for (int i = 0; i < args.size(); i++)
         {
            to_glyphs (args.at(i), true, outs, verb);
         }
      }
      else if ( glyph == true && coord == false )
      {
         // convert glyph -> coordinates
         for (int i = 0; i < args.size(); i++)
         {
            to_coords (args.at(i), false, outs, verb);
         }
      }
      else
      {
         if ( args.size() == 0 )
         {
            outs << "Did you want to run the gui? ";
................................................................................
         {
            // Options are mixed so best guess the inputs
            for (int i = 0; i < args.size(); i++)
            {
               if ( args.at(i).size() == 12 )
               {
                  // Assume is glyph code
                  to_coords (args.at(i), false, outs, verb);
               }
               else if ( args.at(i).size() == 19 )
               {
                  // Assume is coordinate
                  to_glyphs (args.at(i), true, outs, verb);
               }
               else { /* Assume invalid input */ }
            }
         }
      }

      // Exit properly rather than waiting for input.
      app.quit();
   }
   else
   {
      QApplication app (argc, argv);
	  	setApplicationSettings();

      // Set GUI style
      QString gui_look = "Fusion", used = QString();

      if ( argc >= 1 && argv[2] != QString() )
      {
         const QString temp_string = argv[2];

         if ( temp_string.size() < 15 )
            gui_look = QString(argv[2]);	// Get GUI-style to use

Changes to src/MainWindow.cpp.

8
9
10
11
12
13
14

15

16
17
18
19
20

21
22
23
24
25
26
27

28
29
30
31
32
33
34
..
85
86
87
88
89
90
91

92
93
94
95
96
97
98
...
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140


141
142
143
144
145
146
147
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
///////////////////////
//------------------------------------------------------------------
/////////////////
// CONSTRUCTOR //
/////////////////
//------------------------------------------------------------------
MainWindow::MainWindow()

{

   setWindowTitle ("nmspd");
   
   conversion_screen = new Window;
   setCentralWidget (conversion_screen);


   portal_address = new Glyphs;
   QDockWidget *topWidget = new QDockWidget(tr ("Portal Address"), this);
   topWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   topWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   topWidget -> setWidget (portal_address);
   addDockWidget (Qt::TopDockWidgetArea, topWidget);


   glyph_selector = new PortalDialer;
   QDockWidget *bottomWidget = new QDockWidget (tr ("Glyph Entry"), this);
   bottomWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   bottomWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   bottomWidget -> setWidget (glyph_selector);
   addDockWidget (Qt::BottomDockWidgetArea, bottomWidget);

................................................................................
   portal_address -> reset();
   glyph_selector -> reset();
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////

void MainWindow::createToolBar()
{
   // TODO: Find (or create) some icons to use for these toolbar 
   //  actions. As it stands, these are text-only toolbar buttons
   QToolBar *mainToolBar;
   mainToolBar = addToolBar (tr ("Control"));
   mainToolBar -> setAllowedAreas (Qt::AllToolBarAreas);
................................................................................
}
//------------------------------------------------------------------
void MainWindow::createActions()
{
   exit_action = new QAction (QIcon(QIcon::fromTheme ("application-exit")), tr ("E&xit"));
   exit_action -> setShortcuts (QKeySequence::Quit);
   exit_action -> setStatusTip (tr ("Exit the application"));
   //connect (exit_action, &QAction::triggered, this, &QWidget::close);
   QObject::connect (exit_action, &QAction::triggered, this, &QApplication::quit);

   about_action = new QAction (tr ("&About"));
   about_action -> setStatusTip (tr ("Show the application's About box"));
   QObject::connect (about_action, &QAction::triggered, this, &MainWindow::about);

   about_qt_action = new QAction (tr ("About &Qt"));
   about_qt_action -> setStatusTip (tr ("Show the Qt library's About box"));
   QObject::connect (about_qt_action, &QAction::triggered, qApp, &QApplication::aboutQt);

   // TODO: Update glyph code from conversion_screen to 
   // glyph_selector because right now it syncs one way: 
   // glyph_selector --> conversion_screen.


   QObject::connect (glyph_selector, &PortalDialer::codeChange, this, &MainWindow::updateGlyphsFromInputWindow);
   QObject::connect (conversion_screen, &Window::validCoordinate, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (conversion_screen, &Window::validGlyphCode, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (glyph_selector, &PortalDialer::codeReady, this, &MainWindow::conversion);
   QObject::connect (conversion_screen, &Window::glyphChange, this, &MainWindow::updateGlyphsToInputWindow);
}
//------------------------------------------------------------------
................................................................................
   helpMenu = menuBar() -> addMenu (tr ("&Help"));
   helpMenu -> addAction (about_action);
   helpMenu -> addAction (about_qt_action);
}
//------------------------------------------------------------------
void MainWindow::createStatusBar()
{
	statusBar() -> showMessage (tr ("Ready!"));
}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void MainWindow::about()







>

>

|
<
<
<
>







>







 







>







 







<













>
>







 







|







8
9
10
11
12
13
14
15
16
17
18
19



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
...
122
123
124
125
126
127
128

129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
///////////////////////
//------------------------------------------------------------------
/////////////////
// CONSTRUCTOR //
/////////////////
//------------------------------------------------------------------
MainWindow::MainWindow()
	: conversion_screen (new Window)
{
   setCentralWidget (conversion_screen);
   setWindowTitle ("nmspd");




	// Create dock widget: Top
   portal_address = new Glyphs;
   QDockWidget *topWidget = new QDockWidget(tr ("Portal Address"), this);
   topWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   topWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   topWidget -> setWidget (portal_address);
   addDockWidget (Qt::TopDockWidgetArea, topWidget);

	// Create dock widget: Bottom
   glyph_selector = new PortalDialer;
   QDockWidget *bottomWidget = new QDockWidget (tr ("Glyph Entry"), this);
   bottomWidget -> setAllowedAreas (Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
   bottomWidget -> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable);
   bottomWidget -> setWidget (glyph_selector);
   addDockWidget (Qt::BottomDockWidgetArea, bottomWidget);

................................................................................
   portal_address -> reset();
   glyph_selector -> reset();
}
//------------------------------------------------------------------
///////////////////////
// PRIVATE FUNCTIONS //
///////////////////////
//------------------------------------------------------------------
void MainWindow::createToolBar()
{
   // TODO: Find (or create) some icons to use for these toolbar 
   //  actions. As it stands, these are text-only toolbar buttons
   QToolBar *mainToolBar;
   mainToolBar = addToolBar (tr ("Control"));
   mainToolBar -> setAllowedAreas (Qt::AllToolBarAreas);
................................................................................
}
//------------------------------------------------------------------
void MainWindow::createActions()
{
   exit_action = new QAction (QIcon(QIcon::fromTheme ("application-exit")), tr ("E&xit"));
   exit_action -> setShortcuts (QKeySequence::Quit);
   exit_action -> setStatusTip (tr ("Exit the application"));

   QObject::connect (exit_action, &QAction::triggered, this, &QApplication::quit);

   about_action = new QAction (tr ("&About"));
   about_action -> setStatusTip (tr ("Show the application's About box"));
   QObject::connect (about_action, &QAction::triggered, this, &MainWindow::about);

   about_qt_action = new QAction (tr ("About &Qt"));
   about_qt_action -> setStatusTip (tr ("Show the Qt library's About box"));
   QObject::connect (about_qt_action, &QAction::triggered, qApp, &QApplication::aboutQt);

   // TODO: Update glyph code from conversion_screen to 
   // glyph_selector because right now it syncs one way: 
   // glyph_selector --> conversion_screen.
   //
   // Edit: Let's not.
   QObject::connect (glyph_selector, &PortalDialer::codeChange, this, &MainWindow::updateGlyphsFromInputWindow);
   QObject::connect (conversion_screen, &Window::validCoordinate, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (conversion_screen, &Window::validGlyphCode, this, &MainWindow::updatePortalAddressFromMainWindow);
   QObject::connect (glyph_selector, &PortalDialer::codeReady, this, &MainWindow::conversion);
   QObject::connect (conversion_screen, &Window::glyphChange, this, &MainWindow::updateGlyphsToInputWindow);
}
//------------------------------------------------------------------
................................................................................
   helpMenu = menuBar() -> addMenu (tr ("&Help"));
   helpMenu -> addAction (about_action);
   helpMenu -> addAction (about_qt_action);
}
//------------------------------------------------------------------
void MainWindow::createStatusBar()
{
	statusBar() -> showMessage (tr ("Ready!"), 5000);
}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void MainWindow::about()

Changes to src/PortalAddressPickerWindow.cpp.

2
3
4
5
6
7
8
9

10
11

12
13
14
15
16
17
18

19
20
21
22
23
24
25
26
27
28
29

30

31
32
33
34
35
36
37
38
39
40
...
158
159
160
161
162
163
164
165















166
167
168
169
170
171
172
...
234
235
236
237
238
239
240
241
242








243
244
245

246
247
248








#include "PortalAddressPickerWindow.h"
#include "HelperFunctions.h"
//==================================================================
/////////////////////////
// CLASS: PortalDialer //
/////////////////////////
//------------------------------------------------------------------
PortalDialer::PortalDialer (QWidget *parent) : QWidget (parent)

{
   initGlyphs();

   initLayout();
}
//------------------------------------------------------------------
PortalDialer::PortalDialer (const QString &_code)
{
   initGlyphs();
   setGlyphs(_code);

   initLayout();
}
//------------------------------------------------------------------
void PortalDialer::initGlyphs()
{
   code = new QStack<QChar>;
   code -> clear();

   for (int i = 0; i < 16; i++)
   {
      glyph_input[i] = new QPushButton;

      glyph_input[i] -> setIconSize (QSize(40, 40));

      glyph_input[i] -> setAutoFillBackground (false);
      glyph_input[i] -> setCheckable (false);
      glyph_input[i] -> setFlat (false);
      glyph_input[i] -> setIcon (QIcon (QString (":" + QString(
                                           convert_integer_to_hex(i)).toUpper() + QString(".jpg"))));
   /*
      if ( i < 12 ) {
         glyph_select[i] = new QPushButton;
         glyph_select[i] -> setFlat (false);
         glyph_select[i] -> setCheckable (false);
................................................................................
      glyph_code -> setText (getCode());
      emit codeIncomplete();
   }

   emit codeChange();
}
//------------------------------------------------------------------
void PortalDialer::initLayout()















{
   glyph_code = new QLineEdit;
   glyph_code -> setMaxLength (12);
   glyph_code -> setReadOnly (true);

   QPushButton *back_button = new QPushButton;
   back_button -> setText (tr ("Delete"));
................................................................................

   /*
     Handle pushing the buttons
   */
   // Delete glyph(s) previously selected
   QObject::connect (back_button, &QPushButton::clicked, this, &PortalDialer::clearOne);
   QObject::connect (reset_button, &QPushButton::clicked,this, &PortalDialer::reset);

   // Glyph buttons








   for (int i = 0; i < 16; i++)
   {
   	QObject::connect (glyph_input[i], &QPushButton::clicked, this, [=] { getGlyph (i); });

   }
}
//------------------------------------------------------------------















|
>

|
>
|




|

>
|


|







>

>
|

|







 







|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|
|
>
>
>
>
>
>
>
>
|
|
<
>
|


>
>
>
>
>
>
>
>
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
...
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272

273
274
275
276
277
278
279
280
281
282
283
284
#include "PortalAddressPickerWindow.h"
#include "HelperFunctions.h"
//==================================================================
/////////////////////////
// CLASS: PortalDialer //
/////////////////////////
//------------------------------------------------------------------
PortalDialer::PortalDialer (QWidget *parent)
	: QWidget (parent)
{
   createGlyphs();
   createActions();
   createLayout();
}
//------------------------------------------------------------------
PortalDialer::PortalDialer (const QString &_code)
{
   createGlyphs();
   setGlyphs(_code);
   createActions();
   createLayout();
}
//------------------------------------------------------------------
void PortalDialer::createGlyphs()
{
   code = new QStack<QChar>;
   code -> clear();

   for (int i = 0; i < 16; i++)
   {
      glyph_input[i] = new QPushButton;
      glyph_input[i] -> setDisabled (false);
      glyph_input[i] -> setIconSize (QSize(40, 40));
      glyph_input[i] -> setMaximumSize (QSize (60,60));
      glyph_input[i] -> setAutoFillBackground (true);
      glyph_input[i] -> setCheckable (false);
      glyph_input[i] -> setFlat (true);
      glyph_input[i] -> setIcon (QIcon (QString (":" + QString(
                                           convert_integer_to_hex(i)).toUpper() + QString(".jpg"))));
   /*
      if ( i < 12 ) {
         glyph_select[i] = new QPushButton;
         glyph_select[i] -> setFlat (false);
         glyph_select[i] -> setCheckable (false);
................................................................................
      glyph_code -> setText (getCode());
      emit codeIncomplete();
   }

   emit codeChange();
}
//------------------------------------------------------------------
void PortalDialer::createActions()
{
   // Glyph buttons
   for (int i = 0; i < 16; i++)
   {
   	QObject::connect (glyph_input[i], &QPushButton::clicked, this, [=] { getGlyph (i); });
   }

	// Block further input once full code has been entered
	QObject::connect (this, &PortalDialer::codeReady, this, &PortalDialer::disableGlyphInput);

	// Re-enable input for less than full code
	QObject::connect (this, &PortalDialer::codeIncomplete, this, &PortalDialer::enableGlyphInput);
}
//------------------------------------------------------------------
void PortalDialer::createLayout()
{
   glyph_code = new QLineEdit;
   glyph_code -> setMaxLength (12);
   glyph_code -> setReadOnly (true);

   QPushButton *back_button = new QPushButton;
   back_button -> setText (tr ("Delete"));
................................................................................

   /*
     Handle pushing the buttons
   */
   // Delete glyph(s) previously selected
   QObject::connect (back_button, &QPushButton::clicked, this, &PortalDialer::clearOne);
   QObject::connect (reset_button, &QPushButton::clicked,this, &PortalDialer::reset);
}
//------------------------------------------------------------------
///////////////////
// PRIVATE SLOTS //
///////////////////
//------------------------------------------------------------------
void PortalDialer::disableGlyphInput()
{
	// TODO: Check that this wasn't called before codeReady(), or 
	// less than 12-digit code entered.
	for (int i = 0; i < 16; i++)
	{

		glyph_input[i] -> setDisabled (true);
	}
}
//------------------------------------------------------------------
void PortalDialer::enableGlyphInput()
{
	for (int i = 0; i < 16; i++)
	{
		glyph_input[i] -> setDisabled (false);
	}
}
//------------------------------------------------------------------

Changes to src/PortalAddressPickerWindow.h.

70
71
72
73
74
75
76
77
78
79


80
81
82
83
84
85
86
..
90
91
92
93
94
95
96












97
98
99
100
       *
       *  \param[in] index An integer between 0 - 15.
      */
		void getGlyph(const int index);

	private:
		/** Initializes glyph_input to empty QPushButtons. */
      void initGlyphs();
      /** Initializes the layout. */
      void initLayout();



      /** \var QPushButton *glyph_input[16]
       *
       *  Holds the glyph image for each possible glyph.
      */
     	QPushButton *glyph_input[16];
     	/** \var QStack<QChar> *code
................................................................................
     	QStack<QChar> *code;
     	/** \var QLineEdit *glyph_code
     	 *
     	 *  Displays the current glyph code.
     	*/
     	QLineEdit *glyph_code;
     	//QPushButton *glyph_select[12];












};
//==================================================================
#endif	// __NMS_PORTAL_DIAL_H__
//==================================================================







|

|
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>




70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
       *
       *  \param[in] index An integer between 0 - 15.
      */
		void getGlyph(const int index);

	private:
		/** Initializes glyph_input to empty QPushButtons. */
      void createGlyphs();
      /** Initializes the layout. */
      void createLayout();
      /** Initializes actions for the private variables. */
      void createActions();

      /** \var QPushButton *glyph_input[16]
       *
       *  Holds the glyph image for each possible glyph.
      */
     	QPushButton *glyph_input[16];
     	/** \var QStack<QChar> *code
................................................................................
     	QStack<QChar> *code;
     	/** \var QLineEdit *glyph_code
     	 *
     	 *  Displays the current glyph code.
     	*/
     	QLineEdit *glyph_code;
     	//QPushButton *glyph_select[12];

	private slots:
		/** Disables all glyph input. Useful when 12 codes have been 
		 *  entered.
		 *
		 *  Should only be called when codeReady is emitted.
		*/
		void disableGlyphInput();
		/** Enables all glyph input. This is the default state of the
		 *  object.
		*/
		void enableGlyphInput();
};
//==================================================================
#endif	// __NMS_PORTAL_DIAL_H__
//==================================================================

Changes to src/PortalAddressWindow.cpp.

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
      else
         glyph[i] -> setIcon (QIcon (QString(":empty.png")));

      glyph[i] -> setIconSize (QSize(40, 40));		// (60,60) is nice, too
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (false);
   }
}
//------------------------------------------------------------------
void Glyphs::showGlyphs()
{
	setGlyphs (glyph_code);
}







|







46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
      else
         glyph[i] -> setIcon (QIcon (QString(":empty.png")));

      glyph[i] -> setIconSize (QSize(40, 40));		// (60,60) is nice, too
      glyph[i] -> setAutoFillBackground (true);
      glyph[i] -> setText (QString());
      glyph[i] -> setCheckable (false);
      glyph[i] -> setFlat (true);
   }
}
//------------------------------------------------------------------
void Glyphs::showGlyphs()
{
	setGlyphs (glyph_code);
}