2015-09-06 13:44:10 +02:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2010 by Petr Vanek *
|
|
|
|
* petr@scribus.info *
|
|
|
|
* *
|
|
|
|
* 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 2 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/>. *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
#include <qtermwidget.h>
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
|
|
#include "propertiesdialog.h"
|
|
|
|
#include "properties.h"
|
|
|
|
#include "fontdialog.h"
|
|
|
|
#include "config.h"
|
2017-12-05 17:30:58 +01:00
|
|
|
#include "qterminalapp.h"
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
PropertiesDialog::PropertiesDialog(QWidget *parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
connect(buttonBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()),
|
|
|
|
this, SLOT(apply()));
|
|
|
|
connect(changeFontButton, SIGNAL(clicked()),
|
|
|
|
this, SLOT(changeFontButton_clicked()));
|
2016-12-22 00:36:10 +01:00
|
|
|
connect(chooseBackgroundImageButton, &QPushButton::clicked,
|
|
|
|
this, &PropertiesDialog::chooseBackgroundImageButton_clicked);
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
QStringList emulations = QTermWidget::availableKeyBindings();
|
|
|
|
QStringList colorSchemes = QTermWidget::availableColorSchemes();
|
|
|
|
|
|
|
|
listWidget->setCurrentRow(0);
|
2015-09-06 13:44:10 +02:00
|
|
|
listWidget->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow);
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
colorSchemaCombo->addItems(colorSchemes);
|
|
|
|
int csix = colorSchemaCombo->findText(Properties::Instance()->colorScheme);
|
|
|
|
if (csix != -1)
|
|
|
|
colorSchemaCombo->setCurrentIndex(csix);
|
|
|
|
|
2016-12-22 00:36:10 +01:00
|
|
|
backgroundImageLineEdit->setText(Properties::Instance()->backgroundImage);
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
emulationComboBox->addItems(emulations);
|
|
|
|
int eix = emulationComboBox->findText(Properties::Instance()->emulation);
|
|
|
|
emulationComboBox->setCurrentIndex(eix != -1 ? eix : 0 );
|
2015-09-06 13:44:10 +02:00
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
/* shortcuts */
|
|
|
|
setupShortcuts();
|
|
|
|
|
|
|
|
/* scrollbar position */
|
|
|
|
QStringList scrollBarPosList;
|
2015-09-06 13:44:10 +02:00
|
|
|
scrollBarPosList << tr("No scrollbar") << tr("Left") << tr("Right");
|
2015-08-16 00:43:27 +08:00
|
|
|
scrollBarPos_comboBox->addItems(scrollBarPosList);
|
|
|
|
scrollBarPos_comboBox->setCurrentIndex(Properties::Instance()->scrollBarPos);
|
|
|
|
|
|
|
|
/* tabs position */
|
|
|
|
QStringList tabsPosList;
|
2015-09-06 13:44:10 +02:00
|
|
|
tabsPosList << tr("Top") << tr("Bottom") << tr("Left") << tr("Right");
|
2015-08-16 00:43:27 +08:00
|
|
|
tabsPos_comboBox->addItems(tabsPosList);
|
|
|
|
tabsPos_comboBox->setCurrentIndex(Properties::Instance()->tabsPos);
|
|
|
|
|
2016-10-18 20:59:44 +02:00
|
|
|
/* keyboard cursor shape */
|
|
|
|
QStringList keyboardCursorShapeList;
|
|
|
|
keyboardCursorShapeList << tr("BlockCursor") << tr("UnderlineCursor") << tr("IBeamCursor");
|
|
|
|
keybCursorShape_comboBox->addItems(keyboardCursorShapeList);
|
|
|
|
keybCursorShape_comboBox->setCurrentIndex(Properties::Instance()->keyboardCursorShape);
|
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
hideTabBarCheckBox->setChecked(Properties::Instance()->hideTabBarWithOneTab);
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
// show main menu bar
|
|
|
|
showMenuCheckBox->setChecked(Properties::Instance()->menuVisible);
|
|
|
|
|
|
|
|
/* actions by motion after paste */
|
2015-09-06 13:44:10 +02:00
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
QStringList motionAfter;
|
2015-09-06 13:44:10 +02:00
|
|
|
motionAfter << tr("No move") << tr("Move start") << tr("Move end");
|
2015-08-16 00:43:27 +08:00
|
|
|
motionAfterPasting_comboBox->addItems(motionAfter);
|
|
|
|
motionAfterPasting_comboBox->setCurrentIndex(Properties::Instance()->m_motionAfterPaste);
|
2015-09-06 13:44:10 +02:00
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
// Setting windows style actions
|
|
|
|
styleComboBox->addItem(tr("System Default"));
|
|
|
|
styleComboBox->addItems(QStyleFactory::keys());
|
|
|
|
|
|
|
|
int ix = styleComboBox->findText(Properties::Instance()->guiStyle);
|
|
|
|
if (ix != -1)
|
|
|
|
styleComboBox->setCurrentIndex(ix);
|
2015-09-06 13:44:10 +02:00
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
setFontSample(Properties::Instance()->font);
|
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
appTransparencyBox->setValue(Properties::Instance()->appTransparency);
|
2015-08-16 00:43:27 +08:00
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
termTransparencyBox->setValue(Properties::Instance()->termTransparency);
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
highlightCurrentCheckBox->setChecked(Properties::Instance()->highlightCurrentTerminal);
|
|
|
|
|
|
|
|
askOnExitCheckBox->setChecked(Properties::Instance()->askOnExit);
|
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
savePosOnExitCheckBox->setChecked(Properties::Instance()->savePosOnExit);
|
|
|
|
saveSizeOnExitCheckBox->setChecked(Properties::Instance()->saveSizeOnExit);
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
useCwdCheckBox->setChecked(Properties::Instance()->useCWD);
|
|
|
|
|
|
|
|
historyLimited->setChecked(Properties::Instance()->historyLimited);
|
|
|
|
historyUnlimited->setChecked(!Properties::Instance()->historyLimited);
|
|
|
|
historyLimitedTo->setValue(Properties::Instance()->historyLimitedTo);
|
|
|
|
|
|
|
|
dropShowOnStartCheckBox->setChecked(Properties::Instance()->dropShowOnStart);
|
2016-12-22 00:36:10 +01:00
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
dropHeightSpinBox->setValue(Properties::Instance()->dropHeight);
|
2016-12-22 00:36:10 +01:00
|
|
|
dropHeightSpinBox->setMaximum(100);
|
2015-08-16 00:43:27 +08:00
|
|
|
dropWidthSpinBox->setValue(Properties::Instance()->dropWidht);
|
2016-12-22 00:36:10 +01:00
|
|
|
dropWidthSpinBox->setMaximum(100);
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
dropShortCutEdit->setText(Properties::Instance()->dropShortCut.toString());
|
|
|
|
|
|
|
|
useBookmarksCheckBox->setChecked(Properties::Instance()->useBookmarks);
|
|
|
|
bookmarksLineEdit->setText(Properties::Instance()->bookmarksFile);
|
|
|
|
openBookmarksFile(Properties::Instance()->bookmarksFile);
|
|
|
|
connect(bookmarksButton, SIGNAL(clicked()),
|
|
|
|
this, SLOT(bookmarksButton_clicked()));
|
2015-09-06 13:44:10 +02:00
|
|
|
|
|
|
|
terminalPresetComboBox->setCurrentIndex(Properties::Instance()->terminalsPreset);
|
2016-10-18 20:59:44 +02:00
|
|
|
|
|
|
|
changeWindowTitleCheckBox->setChecked(Properties::Instance()->changeWindowTitle);
|
|
|
|
changeWindowIconCheckBox->setChecked(Properties::Instance()->changeWindowIcon);
|
2017-12-05 17:30:58 +01:00
|
|
|
|
|
|
|
trimPastedTrailingNewlinesCheckBox->setChecked(Properties::Instance()->trimPastedTrailingNewlines);
|
|
|
|
confirmMultilinePasteCheckBox->setChecked(Properties::Instance()->confirmMultilinePaste);
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PropertiesDialog::~PropertiesDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::accept()
|
|
|
|
{
|
|
|
|
apply();
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::apply()
|
|
|
|
{
|
|
|
|
Properties::Instance()->colorScheme = colorSchemaCombo->currentText();
|
|
|
|
Properties::Instance()->font = fontSampleLabel->font();//fontComboBox->currentFont();
|
|
|
|
Properties::Instance()->guiStyle = (styleComboBox->currentText() == tr("System Default")) ?
|
|
|
|
QString() : styleComboBox->currentText();
|
|
|
|
|
|
|
|
Properties::Instance()->emulation = emulationComboBox->currentText();
|
|
|
|
|
|
|
|
/* do not allow to go above 99 or we lose transparency option */
|
2015-09-06 13:44:10 +02:00
|
|
|
(appTransparencyBox->value() >= 100) ?
|
|
|
|
Properties::Instance()->appTransparency = 99
|
2015-08-16 00:43:27 +08:00
|
|
|
:
|
2015-09-06 13:44:10 +02:00
|
|
|
Properties::Instance()->appTransparency = appTransparencyBox->value();
|
2015-08-16 00:43:27 +08:00
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
Properties::Instance()->termTransparency = termTransparencyBox->value();
|
2015-08-16 00:43:27 +08:00
|
|
|
Properties::Instance()->highlightCurrentTerminal = highlightCurrentCheckBox->isChecked();
|
2016-12-22 00:36:10 +01:00
|
|
|
Properties::Instance()->backgroundImage = backgroundImageLineEdit->text();
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
Properties::Instance()->askOnExit = askOnExitCheckBox->isChecked();
|
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
Properties::Instance()->savePosOnExit = savePosOnExitCheckBox->isChecked();
|
|
|
|
Properties::Instance()->saveSizeOnExit = saveSizeOnExitCheckBox->isChecked();
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
Properties::Instance()->useCWD = useCwdCheckBox->isChecked();
|
|
|
|
|
|
|
|
Properties::Instance()->scrollBarPos = scrollBarPos_comboBox->currentIndex();
|
|
|
|
Properties::Instance()->tabsPos = tabsPos_comboBox->currentIndex();
|
2016-10-18 20:59:44 +02:00
|
|
|
Properties::Instance()->keyboardCursorShape = keybCursorShape_comboBox->currentIndex();
|
2015-09-06 13:44:10 +02:00
|
|
|
Properties::Instance()->hideTabBarWithOneTab = hideTabBarCheckBox->isChecked();
|
2015-08-16 00:43:27 +08:00
|
|
|
Properties::Instance()->menuVisible = showMenuCheckBox->isChecked();
|
|
|
|
Properties::Instance()->m_motionAfterPaste = motionAfterPasting_comboBox->currentIndex();
|
|
|
|
|
|
|
|
Properties::Instance()->historyLimited = historyLimited->isChecked();
|
|
|
|
Properties::Instance()->historyLimitedTo = historyLimitedTo->value();
|
|
|
|
|
|
|
|
saveShortcuts();
|
|
|
|
|
|
|
|
Properties::Instance()->saveSettings();
|
|
|
|
|
|
|
|
Properties::Instance()->dropShowOnStart = dropShowOnStartCheckBox->isChecked();
|
|
|
|
Properties::Instance()->dropHeight = dropHeightSpinBox->value();
|
|
|
|
Properties::Instance()->dropWidht = dropWidthSpinBox->value();
|
|
|
|
Properties::Instance()->dropShortCut = QKeySequence(dropShortCutEdit->text());
|
|
|
|
|
|
|
|
Properties::Instance()->useBookmarks = useBookmarksCheckBox->isChecked();
|
|
|
|
Properties::Instance()->bookmarksFile = bookmarksLineEdit->text();
|
|
|
|
saveBookmarksFile(Properties::Instance()->bookmarksFile);
|
|
|
|
|
2015-09-06 13:44:10 +02:00
|
|
|
Properties::Instance()->terminalsPreset = terminalPresetComboBox->currentIndex();
|
|
|
|
|
2016-10-18 20:59:44 +02:00
|
|
|
Properties::Instance()->changeWindowTitle = changeWindowTitleCheckBox->isChecked();
|
|
|
|
Properties::Instance()->changeWindowIcon = changeWindowIconCheckBox->isChecked();
|
|
|
|
|
2017-12-05 17:30:58 +01:00
|
|
|
Properties::Instance()->trimPastedTrailingNewlines = trimPastedTrailingNewlinesCheckBox->isChecked();
|
|
|
|
Properties::Instance()->confirmMultilinePaste = confirmMultilinePasteCheckBox->isChecked();
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
emit propertiesChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::setFontSample(const QFont & f)
|
|
|
|
{
|
|
|
|
fontSampleLabel->setFont(f);
|
|
|
|
QString sample("%1 %2 pt");
|
|
|
|
fontSampleLabel->setText(sample.arg(f.family()).arg(f.pointSize()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::changeFontButton_clicked()
|
|
|
|
{
|
|
|
|
FontDialog dia(fontSampleLabel->font());
|
|
|
|
if (!dia.exec())
|
|
|
|
return;
|
|
|
|
QFont f = dia.getFont();
|
|
|
|
if (QFontInfo(f).fixedPitch())
|
|
|
|
setFontSample(f);
|
|
|
|
}
|
|
|
|
|
2016-12-22 00:36:10 +01:00
|
|
|
void PropertiesDialog::chooseBackgroundImageButton_clicked()
|
|
|
|
{
|
|
|
|
QString filename = QFileDialog::getOpenFileName(
|
2017-12-05 17:30:58 +01:00
|
|
|
this, tr("Choose a background image"),
|
2016-12-22 00:36:10 +01:00
|
|
|
QString(), tr("Images (*.bmp *.png *.xpm *.jpg)"));
|
|
|
|
if (!filename.isNull())
|
|
|
|
backgroundImageLineEdit->setText(filename);
|
|
|
|
}
|
|
|
|
|
2015-08-16 00:43:27 +08:00
|
|
|
void PropertiesDialog::saveShortcuts()
|
|
|
|
{
|
2017-12-05 17:30:58 +01:00
|
|
|
QMap<QString, QAction*> actions = QTerminalApp::Instance()->getWindowList()[0]->leaseActions();
|
|
|
|
QList< QString > shortcutKeys = actions.keys();
|
2015-08-16 00:43:27 +08:00
|
|
|
int shortcutCount = shortcutKeys.count();
|
|
|
|
|
|
|
|
shortcutsWidget->setRowCount( shortcutCount );
|
|
|
|
|
|
|
|
for( int x=0; x < shortcutCount; x++ )
|
|
|
|
{
|
|
|
|
QString keyValue = shortcutKeys.at(x);
|
2017-12-05 17:30:58 +01:00
|
|
|
QAction *keyAction = actions[keyValue];
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
QTableWidgetItem *item = shortcutsWidget->item(x, 1);
|
|
|
|
QKeySequence sequence = QKeySequence(item->text());
|
|
|
|
QString sequenceString = sequence.toString();
|
|
|
|
|
2016-12-22 00:36:10 +01:00
|
|
|
QList<QKeySequence> shortcuts;
|
|
|
|
foreach (sequenceString, item->text().split('|'))
|
|
|
|
shortcuts.append(QKeySequence(sequenceString));
|
|
|
|
keyAction->setShortcuts(shortcuts);
|
2015-08-16 00:43:27 +08:00
|
|
|
}
|
2017-12-05 17:30:58 +01:00
|
|
|
Properties::Instance()->saveSettings();
|
2015-08-16 00:43:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::setupShortcuts()
|
|
|
|
{
|
2017-12-05 17:30:58 +01:00
|
|
|
QMap<QString, QAction*> actions = QTerminalApp::Instance()->getWindowList()[0]->leaseActions();
|
|
|
|
QList< QString > shortcutKeys = actions.keys();
|
2015-08-16 00:43:27 +08:00
|
|
|
int shortcutCount = shortcutKeys.count();
|
|
|
|
|
|
|
|
shortcutsWidget->setRowCount( shortcutCount );
|
|
|
|
|
|
|
|
for( int x=0; x < shortcutCount; x++ )
|
|
|
|
{
|
|
|
|
QString keyValue = shortcutKeys.at(x);
|
2017-12-05 17:30:58 +01:00
|
|
|
QAction *keyAction = actions[keyValue];
|
2016-12-22 00:36:10 +01:00
|
|
|
QStringList sequenceStrings;
|
|
|
|
|
2017-12-05 17:30:58 +01:00
|
|
|
foreach (const QKeySequence &shortcut, keyAction->shortcuts())
|
2016-12-22 00:36:10 +01:00
|
|
|
sequenceStrings.append(shortcut.toString());
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
QTableWidgetItem *itemName = new QTableWidgetItem( tr(keyValue.toStdString().c_str()) );
|
2016-12-22 00:36:10 +01:00
|
|
|
QTableWidgetItem *itemShortcut = new QTableWidgetItem( sequenceStrings.join('|') );
|
2015-08-16 00:43:27 +08:00
|
|
|
|
|
|
|
itemName->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
|
|
|
|
|
|
|
|
shortcutsWidget->setItem(x, 0, itemName);
|
|
|
|
shortcutsWidget->setItem(x, 1, itemShortcut);
|
|
|
|
}
|
|
|
|
|
|
|
|
shortcutsWidget->resizeColumnsToContents();
|
|
|
|
/*
|
|
|
|
connect(shortcutsWidget, SIGNAL(currentChanged(int, int)),
|
|
|
|
this, SLOT(recordAction(int, int)));
|
|
|
|
connect(shortcutsWidget, SIGNAL(valueChanged(int, int)),
|
|
|
|
this, SLOT(validateAction(int, int)));
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::recordAction(int row, int column)
|
|
|
|
{
|
|
|
|
oldAccelText = shortcutsWidget->item(row, column)->text();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::validateAction(int row, int column)
|
|
|
|
{
|
|
|
|
QTableWidgetItem *item = shortcutsWidget->item(row, column);
|
|
|
|
QString accelText = QKeySequence(item->text()).toString();
|
|
|
|
|
|
|
|
if (accelText.isEmpty() && !item->text().isEmpty())
|
|
|
|
item->setText(oldAccelText);
|
|
|
|
else
|
|
|
|
item->setText(accelText);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::bookmarksButton_clicked()
|
|
|
|
{
|
|
|
|
QFileDialog dia(this, tr("Open or create bookmarks file"));
|
|
|
|
dia.setConfirmOverwrite(false);
|
|
|
|
dia.setFileMode(QFileDialog::AnyFile);
|
|
|
|
if (!dia.exec())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString fname = dia.selectedFiles().count() ? dia.selectedFiles().at(0) : QString();
|
|
|
|
if (fname.isNull())
|
|
|
|
return;
|
|
|
|
|
|
|
|
bookmarksLineEdit->setText(fname);
|
|
|
|
openBookmarksFile(bookmarksLineEdit->text());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::openBookmarksFile(const QString &fname)
|
|
|
|
{
|
|
|
|
QFile f(fname);
|
|
|
|
QString content;
|
|
|
|
if (!f.open(QFile::ReadOnly))
|
2016-01-11 21:24:47 +01:00
|
|
|
content = "<qterminal>\n <group name=\"group1\">\n <command name=\"cmd1\" value=\"cd $HOME\"/>\n </group>\n</qterminal>";
|
2015-08-16 00:43:27 +08:00
|
|
|
else
|
|
|
|
content = f.readAll();
|
|
|
|
|
|
|
|
bookmarkPlainEdit->setPlainText(content);
|
|
|
|
bookmarkPlainEdit->document()->setModified(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::saveBookmarksFile(const QString &fname)
|
|
|
|
{
|
|
|
|
if (!bookmarkPlainEdit->document()->isModified())
|
|
|
|
return;
|
|
|
|
|
|
|
|
QFile f(fname);
|
|
|
|
if (!f.open(QFile::WriteOnly|QFile::Truncate))
|
|
|
|
qDebug() << "Cannot write to file" << f.fileName();
|
|
|
|
else
|
|
|
|
f.write(bookmarkPlainEdit->toPlainText().toUtf8());
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
void PropertiesDialog::setupShortcuts()
|
|
|
|
{
|
|
|
|
QList< QString > shortcutKeys = Properties::Instance()->shortcuts.keys();
|
|
|
|
int shortcutCount = shortcutKeys.count();
|
|
|
|
|
|
|
|
shortcutsWidget->setRowCount( shortcutCount );
|
|
|
|
|
|
|
|
for( int x=0; x < shortcutCount; x++ )
|
|
|
|
{
|
|
|
|
QString keyValue = shortcutKeys.at(x);
|
|
|
|
|
|
|
|
QLabel *lblShortcut = new QLabel( keyValue, this );
|
|
|
|
QPushButton *btnLaunch = new QPushButton( Properties::Instance()->shortcuts.value( keyValue ), this );
|
|
|
|
|
|
|
|
btnLaunch->setObjectName(keyValue);
|
|
|
|
connect( btnLaunch, SIGNAL(clicked()), this, SLOT(shortcutPrompt()) );
|
|
|
|
|
|
|
|
shortcutsWidget->setCellWidget( x, 0, lblShortcut );
|
|
|
|
shortcutsWidget->setCellWidget( x, 1, btnLaunch );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PropertiesDialog::shortcutPrompt()
|
|
|
|
{
|
|
|
|
QObject *objectSender = sender();
|
|
|
|
|
|
|
|
if( !objectSender )
|
|
|
|
return;
|
|
|
|
|
|
|
|
QString name = objectSender->objectName();
|
|
|
|
qDebug() << "shortcutPrompt(" << name << ")";
|
|
|
|
|
|
|
|
DialogShortcut *dlgShortcut = new DialogShortcut(this);
|
|
|
|
dlgShortcut->setTitle( tr("Select a key sequence for %1").arg(name) );
|
|
|
|
|
|
|
|
QString sequenceString = Properties::Instance()->shortcuts[name];
|
|
|
|
dlgShortcut->setKey(sequenceString);
|
|
|
|
|
|
|
|
int result = dlgShortcut->exec();
|
|
|
|
if( result == QDialog::Accepted )
|
|
|
|
{
|
|
|
|
sequenceString = dlgShortcut->getKey();
|
|
|
|
Properties::Instance()->shortcuts[name] = sequenceString;
|
|
|
|
Properties::Instance()->saveSettings();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|