GUI: various fixes in FavouriteTools
This commit is contained in:
parent
3e8af43bfe
commit
fdb2ee1abb
|
@ -6,8 +6,10 @@ BrowseDialog::BrowseDialog(QWidget* parent, const QString & title, const QString
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::BrowseDialog), mFilter(filter), mSave(save)
|
ui(new Ui::BrowseDialog), mFilter(filter), mSave(save)
|
||||||
{
|
{
|
||||||
this->setWindowTitle(title);
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::MSWindowsFixedSizeDialogHint);
|
||||||
|
setFixedSize(this->size()); //fixed size
|
||||||
|
setWindowTitle(title);
|
||||||
ui->label->setText(text);
|
ui->label->setText(text);
|
||||||
ui->lineEdit->setText(defaultPath);
|
ui->lineEdit->setText(defaultPath);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +26,7 @@ void BrowseDialog::on_browse_clicked()
|
||||||
file = QFileDialog::getSaveFileName(this, ui->label->text(), ui->lineEdit->text(), mFilter);
|
file = QFileDialog::getSaveFileName(this, ui->label->text(), ui->lineEdit->text(), mFilter);
|
||||||
else
|
else
|
||||||
file = QFileDialog::getOpenFileName(this, ui->label->text(), ui->lineEdit->text(), mFilter);
|
file = QFileDialog::getOpenFileName(this, ui->label->text(), ui->lineEdit->text(), mFilter);
|
||||||
|
file = QDir::toNativeSeparators(file);
|
||||||
if(file.size() != 0)
|
if(file.size() != 0)
|
||||||
ui->lineEdit->setText(file);
|
ui->lineEdit->setText(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,11 +127,28 @@ void FavouriteTools::on_btnAddFavouriteTool_clicked()
|
||||||
ui->listTools->setRowCount(rows + 1);
|
ui->listTools->setRowCount(rows + 1);
|
||||||
ui->listTools->setItem(rows, 0, new QTableWidgetItem(filename));
|
ui->listTools->setItem(rows, 0, new QTableWidgetItem(filename));
|
||||||
ui->listTools->setItem(rows, 1, new QTableWidgetItem(QString()));
|
ui->listTools->setItem(rows, 1, new QTableWidgetItem(QString()));
|
||||||
ui->listTools->setItem(rows, 2, new QTableWidgetItem(filename));
|
ui->listTools->setItem(rows, 2, new QTableWidgetItem(QString()));
|
||||||
if(rows == 0)
|
if(rows == 0)
|
||||||
ui->listTools->selectRow(0);
|
ui->listTools->selectRow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FavouriteTools::on_btnEditFavouriteTool_clicked()
|
||||||
|
{
|
||||||
|
QTableWidget* table = ui->listTools;
|
||||||
|
if(!table->rowCount())
|
||||||
|
return;
|
||||||
|
QString filename;
|
||||||
|
char buffer[MAX_SETTING_SIZE];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
BridgeSettingGet("Favourite", "LastToolPath", buffer);
|
||||||
|
BrowseDialog browse(this, QString("Browse tool"), QString("Enter the path of the tool."), QString("Executable Files (*.exe);;All Files (*.*)"), QString::fromUtf8(buffer), false);
|
||||||
|
if(browse.exec() != QDialog::Accepted)
|
||||||
|
return;
|
||||||
|
filename = browse.path;
|
||||||
|
BridgeSettingSet("Favourite", "LastToolPath", filename.toUtf8().constData());
|
||||||
|
table->item(table->currentRow(), 0)->setText(filename);
|
||||||
|
}
|
||||||
|
|
||||||
void FavouriteTools::upbutton(QTableWidget* table)
|
void FavouriteTools::upbutton(QTableWidget* table)
|
||||||
{
|
{
|
||||||
if(!table->rowCount())
|
if(!table->rowCount())
|
||||||
|
@ -201,16 +218,34 @@ void FavouriteTools::on_btnAddFavouriteScript_clicked()
|
||||||
filename = QFileDialog::getOpenFileName(this, tr("Select script"), QString::fromUtf8(buffer), tr("Script files (*.txt *.scr);;All files (*.*)"));
|
filename = QFileDialog::getOpenFileName(this, tr("Select script"), QString::fromUtf8(buffer), tr("Script files (*.txt *.scr);;All files (*.*)"));
|
||||||
if(filename.size() == 0)
|
if(filename.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
filename = QDir::toNativeSeparators(filename);
|
||||||
BridgeSettingSet("Favourite", "LastScriptPath", filename.toUtf8().constData());
|
BridgeSettingSet("Favourite", "LastScriptPath", filename.toUtf8().constData());
|
||||||
int rows = ui->listScript->rowCount();
|
int rows = ui->listScript->rowCount();
|
||||||
ui->listScript->setRowCount(rows + 1);
|
ui->listScript->setRowCount(rows + 1);
|
||||||
ui->listScript->setItem(rows, 0, new QTableWidgetItem(filename));
|
ui->listScript->setItem(rows, 0, new QTableWidgetItem(filename));
|
||||||
ui->listScript->setItem(rows, 1, new QTableWidgetItem(QString("NOT_SET")));
|
ui->listScript->setItem(rows, 1, new QTableWidgetItem(QString()));
|
||||||
ui->listScript->setItem(rows, 2, new QTableWidgetItem(filename));
|
ui->listScript->setItem(rows, 2, new QTableWidgetItem(QString()));
|
||||||
if(rows == 0)
|
if(rows == 0)
|
||||||
ui->listScript->selectRow(0);
|
ui->listScript->selectRow(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FavouriteTools::on_btnEditFavouriteScript_clicked()
|
||||||
|
{
|
||||||
|
QTableWidget* table = ui->listScript;
|
||||||
|
if(!table->rowCount())
|
||||||
|
return;
|
||||||
|
QString filename;
|
||||||
|
char buffer[MAX_SETTING_SIZE];
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
BridgeSettingGet("Favourite", "LastScriptPath", buffer);
|
||||||
|
filename = QFileDialog::getOpenFileName(this, tr("Select script"), QString::fromUtf8(buffer), tr("Script files (*.txt *.scr);;All files (*.*)"));
|
||||||
|
if(filename.size() == 0)
|
||||||
|
return;
|
||||||
|
filename = QDir::toNativeSeparators(filename);
|
||||||
|
BridgeSettingSet("Favourite", "LastScriptPath", filename.toUtf8().constData());
|
||||||
|
table->item(table->currentRow(), 0)->setText(filename);
|
||||||
|
}
|
||||||
|
|
||||||
void FavouriteTools::on_btnRemoveFavouriteScript_clicked()
|
void FavouriteTools::on_btnRemoveFavouriteScript_clicked()
|
||||||
{
|
{
|
||||||
QTableWidget* table = ui->listScript;
|
QTableWidget* table = ui->listScript;
|
||||||
|
@ -242,17 +277,27 @@ void FavouriteTools::on_btnDownFavouriteScript_clicked()
|
||||||
void FavouriteTools::on_btnAddFavouriteCommand_clicked()
|
void FavouriteTools::on_btnAddFavouriteCommand_clicked()
|
||||||
{
|
{
|
||||||
QString cmd;
|
QString cmd;
|
||||||
if(SimpleInputBox(this, tr("Enter the command that you want to create a shortcut for :"), "", cmd, tr("Example: bphws ESP")))
|
if(SimpleInputBox(this, tr("Enter the command you want to favourite"), "", cmd, tr("Example: bphws csp")))
|
||||||
{
|
{
|
||||||
int rows = ui->listCommand->rowCount();
|
int rows = ui->listCommand->rowCount();
|
||||||
ui->listCommand->setRowCount(rows + 1);
|
ui->listCommand->setRowCount(rows + 1);
|
||||||
ui->listCommand->setItem(rows, 0, new QTableWidgetItem(cmd));
|
ui->listCommand->setItem(rows, 0, new QTableWidgetItem(cmd));
|
||||||
ui->listCommand->setItem(rows, 1, new QTableWidgetItem(QString("NOT_SET")));
|
ui->listCommand->setItem(rows, 1, new QTableWidgetItem(QString()));
|
||||||
if(rows == 0)
|
if(rows == 0)
|
||||||
ui->listCommand->selectRow(0);
|
ui->listCommand->selectRow(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FavouriteTools::on_btnEditFavouriteCommand_clicked()
|
||||||
|
{
|
||||||
|
QTableWidget* table = ui->listCommand;
|
||||||
|
if(!table->rowCount())
|
||||||
|
return;
|
||||||
|
QString cmd;
|
||||||
|
if(SimpleInputBox(this, tr("Enter a new command"), table->item(table->currentRow(), 0)->text(), cmd, tr("Example: bphws ESP")))
|
||||||
|
table->item(table->currentRow(), 0)->setText(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
void FavouriteTools::on_btnRemoveFavouriteCommand_clicked()
|
void FavouriteTools::on_btnRemoveFavouriteCommand_clicked()
|
||||||
{
|
{
|
||||||
QTableWidget* table = ui->listCommand;
|
QTableWidget* table = ui->listCommand;
|
||||||
|
|
|
@ -19,22 +19,26 @@ public:
|
||||||
~FavouriteTools();
|
~FavouriteTools();
|
||||||
public slots:
|
public slots:
|
||||||
void on_btnAddFavouriteTool_clicked();
|
void on_btnAddFavouriteTool_clicked();
|
||||||
|
void on_btnEditFavouriteTool_clicked();
|
||||||
void on_btnRemoveFavouriteTool_clicked();
|
void on_btnRemoveFavouriteTool_clicked();
|
||||||
void on_btnDescriptionFavouriteTool_clicked();
|
void on_btnDescriptionFavouriteTool_clicked();
|
||||||
void on_btnUpFavouriteTool_clicked();
|
void on_btnUpFavouriteTool_clicked();
|
||||||
void on_btnDownFavouriteTool_clicked();
|
void on_btnDownFavouriteTool_clicked();
|
||||||
void on_btnAddFavouriteScript_clicked();
|
void on_btnAddFavouriteScript_clicked();
|
||||||
|
void on_btnEditFavouriteScript_clicked();
|
||||||
void on_btnRemoveFavouriteScript_clicked();
|
void on_btnRemoveFavouriteScript_clicked();
|
||||||
void on_btnDescriptionFavouriteScript_clicked();
|
void on_btnDescriptionFavouriteScript_clicked();
|
||||||
void on_btnUpFavouriteScript_clicked();
|
void on_btnUpFavouriteScript_clicked();
|
||||||
void on_btnDownFavouriteScript_clicked();
|
void on_btnDownFavouriteScript_clicked();
|
||||||
void on_btnAddFavouriteCommand_clicked();
|
void on_btnAddFavouriteCommand_clicked();
|
||||||
|
void on_btnEditFavouriteCommand_clicked();
|
||||||
void on_btnRemoveFavouriteCommand_clicked();
|
void on_btnRemoveFavouriteCommand_clicked();
|
||||||
void on_btnUpFavouriteCommand_clicked();
|
void on_btnUpFavouriteCommand_clicked();
|
||||||
void on_btnDownFavouriteCommand_clicked();
|
void on_btnDownFavouriteCommand_clicked();
|
||||||
void onListSelectionChanged();
|
void onListSelectionChanged();
|
||||||
void on_shortcutEdit_askForSave();
|
void on_shortcutEdit_askForSave();
|
||||||
void on_btnOK_clicked();
|
void on_btnOK_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FavouriteTools* ui;
|
Ui::FavouriteTools* ui;
|
||||||
QKeySequence currentShortcut;
|
QKeySequence currentShortcut;
|
||||||
|
|
|
@ -40,6 +40,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnEditFavouriteTool">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnRemoveFavouriteTool">
|
<widget class="QPushButton" name="btnRemoveFavouriteTool">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -89,6 +96,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnEditFavouriteScript">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnRemoveFavouriteScript">
|
<widget class="QPushButton" name="btnRemoveFavouriteScript">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -138,6 +152,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="btnEditFavouriteCommand">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Edit</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnRemoveFavouriteCommand">
|
<widget class="QPushButton" name="btnRemoveFavouriteCommand">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
Loading…
Reference in New Issue