window: use EntryConfig, not EntryPushButton for slots

No point to implicitly convert them, in fact it was a mistake.
This commit is contained in:
Albert S. 2020-09-28 18:59:48 +02:00
부모 2ab0750f3a
커밋 ae7f310ab2
2개의 변경된 파일10개의 추가작업 그리고 10개의 파일을 삭제

파일 보기

@ -118,21 +118,21 @@ void Window::populateGrid(const QVector<EntryPushButton *> &list)
} }
} }
void Window::buttonClick(const EntryPushButton &button) void Window::buttonClick(const EntryConfig &config)
{ {
QProcess::startDetached(button.getCommand(), button.getArguments()); QProcess::startDetached(config.command, config.arguments);
this->closeWindow(); this->closeWindow();
} }
void Window::addToFavourites(const EntryPushButton &button) void Window::addToFavourites(const EntryConfig &config)
{ {
std::pair<int, int> cell = getNextFreeCell(); std::pair<int, int> cell = getNextFreeCell();
EntryConfig userConfig = button.getEntryConfig(); EntryConfig userConfig = config;
userConfig.userEntry = true; userConfig.userEntry = true;
userConfig.row = cell.first; userConfig.row = cell.first;
userConfig.col = cell.second; userConfig.col = cell.second;
userConfig.inherit = button.getEntryConfig().entryPath; userConfig.inherit = userConfig.entryPath;
QFileInfo fi{button.getEntryConfig().entryPath}; QFileInfo fi{userConfig.entryPath};
QString entryName = fi.completeBaseName() + ".qsrun"; QString entryName = fi.completeBaseName() + ".qsrun";
userConfig.entryPath = this->settingsProvider->userEntriesPaths()[0] + "/" + entryName; userConfig.entryPath = this->settingsProvider->userEntriesPaths()[0] + "/" + entryName;
try try
@ -369,7 +369,7 @@ void Window::keyPressEvent(QKeyEvent *event)
[&key](const EntryPushButton *y) { return y->getShortcutKey() == key; }); [&key](const EntryPushButton *y) { return y->getShortcutKey() == key; });
if(it != buttonsInGrid.end()) if(it != buttonsInGrid.end())
{ {
buttonClick(**it); buttonClick((*it)->getEntryConfig());
} }
} }
QWidget::keyPressEvent(event); QWidget::keyPressEvent(event);
@ -443,7 +443,7 @@ void Window::lineEditReturnPressed()
if(buttonsInGrid.length() > 0 && this->lineEdit->text().length() > 0) if(buttonsInGrid.length() > 0 && this->lineEdit->text().length() > 0)
{ {
buttonClick(*buttonsInGrid[0]); buttonClick(buttonsInGrid[0]->getEntryConfig());
return; return;
} }
} }

파일 보기

@ -63,8 +63,8 @@ class Window : public QWidget
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
QVector<EntryPushButton *> generateEntryButtons(const QVector<EntryConfig> &userEntryButtons); QVector<EntryPushButton *> generateEntryButtons(const QVector<EntryConfig> &userEntryButtons);
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void buttonClick(const EntryPushButton &button); void buttonClick(const EntryConfig &button);
void addToFavourites(const EntryPushButton &button); void addToFavourites(const EntryConfig &button);
void deleteEntry(EntryConfig &config); void deleteEntry(EntryConfig &config);
QLineEdit *lineEdit; QLineEdit *lineEdit;
QGridLayout *grid; QGridLayout *grid;