1
0
Fork 0

Fix enable of buttons in favourite tools dialog (#1106)

This commit is contained in:
Torusrxxx 2016-09-20 15:44:09 +00:00 committed by Duncan Ogilvie
parent 5775dbd2b0
commit 8e0f6ed4cf
5 changed files with 55 additions and 0 deletions

View File

@ -66,6 +66,7 @@ FavouriteTools::FavouriteTools(QWidget* parent) :
connect(ui->listCommand, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged()));
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
emit ui->listTools->itemSelectionChanged();
updateToolsBtnEnabled();
}
void FavouriteTools::setupTools(QString name, QTableWidget* list)
@ -132,6 +133,7 @@ void FavouriteTools::on_btnAddFavouriteTool_clicked()
ui->listTools->setItem(rows, 2, new QTableWidgetItem(QString()));
if(rows == 0)
ui->listTools->selectRow(0);
updateToolsBtnEnabled();
}
void FavouriteTools::on_btnEditFavouriteTool_clicked()
@ -189,6 +191,7 @@ void FavouriteTools::on_btnRemoveFavouriteTool_clicked()
if(!table->rowCount())
return;
table->removeRow(table->currentRow());
updateToolsBtnEnabled();
}
void FavouriteTools::on_btnDescriptionFavouriteTool_clicked()
@ -229,6 +232,7 @@ void FavouriteTools::on_btnAddFavouriteScript_clicked()
ui->listScript->setItem(rows, 2, new QTableWidgetItem(QString()));
if(rows == 0)
ui->listScript->selectRow(0);
updateScriptsBtnEnabled();
}
void FavouriteTools::on_btnEditFavouriteScript_clicked()
@ -254,6 +258,7 @@ void FavouriteTools::on_btnRemoveFavouriteScript_clicked()
if(!table->rowCount())
return;
table->removeRow(table->currentRow());
updateScriptsBtnEnabled();
}
void FavouriteTools::on_btnDescriptionFavouriteScript_clicked()
@ -287,6 +292,7 @@ void FavouriteTools::on_btnAddFavouriteCommand_clicked()
ui->listCommand->setItem(rows, 1, new QTableWidgetItem(QString()));
if(rows == 0)
ui->listCommand->selectRow(0);
updateCommandsBtnEnabled();
}
}
@ -306,6 +312,7 @@ void FavouriteTools::on_btnRemoveFavouriteCommand_clicked()
if(!table->rowCount())
return;
table->removeRow(table->currentRow());
updateCommandsBtnEnabled();
}
void FavouriteTools::on_btnUpFavouriteCommand_clicked()
@ -468,12 +475,15 @@ void FavouriteTools::tabChanged(int i)
{
case 0:
emit ui->listTools->itemSelectionChanged();
updateToolsBtnEnabled();
break;
case 1:
emit ui->listScript->itemSelectionChanged();
updateScriptsBtnEnabled();
break;
case 2:
emit ui->listCommand->itemSelectionChanged();
updateCommandsBtnEnabled();
break;
}
}
@ -482,3 +492,39 @@ FavouriteTools::~FavouriteTools()
{
delete ui;
}
void FavouriteTools::updateToolsBtnEnabled()
{
int rows = ui->listTools->rowCount();
bool enabled = rows != 0;
bool updownEnabled = enabled && rows != 1;
ui->btnRemoveFavouriteTool->setEnabled(enabled);
ui->btnEditFavouriteTool->setEnabled(enabled);
ui->btnUpFavouriteTool->setEnabled(updownEnabled);
ui->btnDownFavouriteTool->setEnabled(updownEnabled);
ui->btnDescriptionFavouriteTool->setEnabled(enabled);
}
void FavouriteTools::updateScriptsBtnEnabled()
{
int rows = ui->listScript->rowCount();
bool enabled = rows != 0;
bool updownEnabled = enabled && rows != 1;
ui->btnRemoveFavouriteScript->setEnabled(enabled);
ui->btnEditFavouriteScript->setEnabled(enabled);
ui->btnUpFavouriteScript->setEnabled(updownEnabled);
ui->btnDownFavouriteScript->setEnabled(updownEnabled);
ui->btnDescriptionFavouriteScript->setEnabled(enabled);
}
void FavouriteTools::updateCommandsBtnEnabled()
{
int rows = ui->listCommand->rowCount();
bool enabled = rows != 0;
bool updownEnabled = enabled && rows != 1;
ui->btnRemoveFavouriteCommand->setEnabled(enabled);
ui->btnEditFavouriteCommand->setEnabled(enabled);
ui->btnUpFavouriteCommand->setEnabled(updownEnabled);
ui->btnDownFavouriteCommand->setEnabled(updownEnabled);
}

View File

@ -52,6 +52,9 @@ private:
void downbutton(QTableWidget* table);
void setupTools(QString name, QTableWidget* list);
void updateToolsBtnEnabled();
void updateScriptsBtnEnabled();
void updateCommandsBtnEnabled();
};
#endif // FAVOURITETOOLS_H

View File

@ -139,6 +139,10 @@ static void linkify(QString & msg)
#endif //_WIN64
}
/**
* @brief LogView::addMsgToLogSlot Adds a message to the log view. This function is a slot for Bridge::addMsgToLog.
* @param msg The log message
*/
void LogView::addMsgToLogSlot(QString msg)
{
// fix Unix-style line endings.

View File

@ -608,6 +608,7 @@ void MainWindow::refreshShortcuts()
setGlobalShortcut(ui->actionReloadStylesheet, ConfigShortcut("OptionsReloadStylesheet"));
setGlobalShortcut(ui->actionAbout, ConfigShortcut("HelpAbout"));
setGlobalShortcut(ui->actionBlog, ConfigShortcut("HelpBlog"));
setGlobalShortcut(ui->actionDonate, ConfigShortcut("HelpDonate"));
setGlobalShortcut(ui->actionCheckUpdates, ConfigShortcut("HelpCheckForUpdates"));
setGlobalShortcut(ui->actionCalculator, ConfigShortcut("HelpCalculator"));

View File

@ -338,6 +338,7 @@ Configuration::Configuration() : QObject(), noMoreMsgbox(false)
defaultShortcuts.insert("OptionsReloadStylesheet", Shortcut(tr("Options -> Reload style.css") , "", true));
defaultShortcuts.insert("HelpAbout", Shortcut(tr("Help -> About"), "", true));
defaultShortcuts.insert("HelpBlog", Shortcut(tr("Help -> Blog"), "", true));
defaultShortcuts.insert("HelpDonate", Shortcut(tr("Help -> Donate"), "", true));
defaultShortcuts.insert("HelpCheckForUpdates", Shortcut(tr("Help -> Check for Updates"), "", true));
defaultShortcuts.insert("HelpCalculator", Shortcut(tr("Help -> Calculator"), "?"));