File: hotkeysdialog.cpp

package info (click to toggle)
veroroute 2.38-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,044 kB
  • sloc: cpp: 21,512; xml: 89; sh: 65; lisp: 20; makefile: 5
file content (106 lines) | stat: -rw-r--r-- 3,877 bytes parent folder | download | duplicates (2)
1
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
	VeroRoute - Qt based Veroboard/Perfboard/PCB layout & routing application.

	Copyright (C) 2017  Alex Lawrow    ( dralx@users.sourceforge.net )

	This program is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "hotkeysdialog.h"
#include "ui_hotkeysdialog.h"
#include "mainwindow.h"

HotkeysDialog::HotkeysDialog(MainWindow* parent)
: QDialog(parent)
, ui(new Ui_HotkeysDialog)
, m_pMainWindow(parent)
{
	ui->setupUi(this);

	Setup();
}

HotkeysDialog::~HotkeysDialog()
{
	delete ui;
}

void HotkeysDialog::Setup()
{
	typedef std::pair<std::string, std::string> KEY_ACTION ;
	std::list<KEY_ACTION> list;
	list.push_back( KEY_ACTION("Ctrl + click-drag mouse",		"Move whole layout") );
	list.push_back( KEY_ACTION("R + click-drag mouse",			"Select parts/tracks by area") );
	list.push_back( KEY_ACTION("Ctrl+A",						"Select all parts") );
	list.push_back( KEY_ACTION("Shift + mouse button",			"Add/Remove to selected parts") );
	list.push_back( KEY_ACTION("Z",								"Rotate selected parts counter-clockwise") );
	list.push_back( KEY_ACTION("X",								"Rotate selected parts clockwise") );
	list.push_back( KEY_ACTION("V",								"Copy and paste selected parts") );
	list.push_back( KEY_ACTION("G",								"Group selected parts") );
	list.push_back( KEY_ACTION("U",								"Un-group selected parts") );
	list.push_back( KEY_ACTION("W",								"Wipe all tracks") );
	list.push_back( KEY_ACTION("L",								"Switch layer (Top/Bottom)") );
	list.push_back( KEY_ACTION("P + left mouse button",			"Paint pin") );
	list.push_back( KEY_ACTION("P + right mouse button",		"Un-paint pin") );
	list.push_back( KEY_ACTION("SPACE + left mouse button",		"Paint track (excluding pins)") );
	list.push_back( KEY_ACTION("SPACE + right mouse button",	"Un-paint track (excluding pins)") );
	list.push_back( KEY_ACTION("F + left mouse button",			"Paint with flood-fill (all connected tracks + pins)") );

	// Set up the table
	ui->tableWidget->clear();
	ui->tableWidget->setRowCount(static_cast<int>( list.size() ));
	ui->tableWidget->setColumnCount(2);
	ui->tableWidget->setColumnWidth(0,257);
	ui->tableWidget->setColumnWidth(1,400);
	m_tableHeader << "Action" << "Behaviour";
	ui->tableWidget->setHorizontalHeaderLabels(m_tableHeader);
	ui->tableWidget->verticalHeader()->setVisible(false);
	ui->tableWidget->setEditTriggers(QAbstractItemView::AllEditTriggers);
	ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
	ui->tableWidget->setSelectionMode(QAbstractItemView::NoSelection);
	ui->tableWidget->setShowGrid(true);

	// Populate the table with data
	int iRow(0);
	for (const auto& o : list)
	{
		auto pItem0 = new QTableWidgetItem(QString::fromStdString( o.first ));
		pItem0->setFlags(Qt::NoItemFlags);
		ui->tableWidget->setItem(iRow, 0, pItem0);

		auto pItem1 = new QTableWidgetItem(QString::fromStdString( o.second ));
		pItem1->setFlags(Qt::NoItemFlags);
		ui->tableWidget->setItem(iRow, 1, pItem1);

		iRow++;
	}
}

void HotkeysDialog::keyPressEvent(QKeyEvent* event)
{
#ifndef VEROROUTE_ANDROID
	m_pMainWindow->specialKeyPressEvent(event);
#endif
	QDialog::keyPressEvent(event);
	event->accept();
}

void HotkeysDialog::keyReleaseEvent(QKeyEvent* event)
{
#ifndef VEROROUTE_ANDROID
	m_pMainWindow->commonKeyReleaseEvent(event);
#endif
	QDialog::keyReleaseEvent(event);
	event->accept();
}