Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding of features asked for in issue #397 #643

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

TSnatch72
Copy link

More than a year ago i suggested what keymaps to be used for the shortcuts asked in #397. Maintainer explained what would have to be done in the code to add these to the project, but i preferred to left that to someone else back then because i have almost no knowledge of C++ or programming in general. Since the Issue thread went silent after that, i eventually decided to give it a try and do it myself following the instruction of Shatur. I don't think i knew what i was doing and I'm not sure if i did it right, if i forgot something, if i followed the style of the project or if i broke things rather than improving them, but i hope these commits will at least be helpful in finally adding the features and closing the issue.

I'll await for your feedback and corrections.

Added shortcuts for clearing source text, switching languages and switching engine in settings
Added the requiere lines to be able to save the shortcuts
Assigned the clear text shortcut to its existing button in the main UI
Comment on lines +328 to +342
QKeySequence clearShortcut() const;
void setClearShortcut(const QKeySequence &shortcut);
static QKeySequence defaultClearShortcut();

QKeySequence switchSourceShortcut() const;
void setSwitchSourceShortcut(const QKeySequence &shortcut);
static QKeySequence defaultSwitchSourceShortcut();

QKeySequence switchTranslationShortcut() const;
void setSwitchTranslationShortcut(const QKeySequence &shortcut);
static QKeySequence defaultSwitchTranslationShortcut();

QKeySequence switchEngineShortcut() const;
void setSwitchEngineShortcut(const QKeySequence &shortcut);
static QKeySequence defaultSwitchEngineShortcut();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add definitions of these function in appsettings.cpp.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid i don't really know how this would be done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just look into similar functions and copy them with minor edits :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to start with clear button. Just only this one in this PR to learn how it's usually done.

@@ -1063,6 +1063,7 @@ void MainWindow::loadAppSettings()
ui->translateButton->setShortcut(settings.translateShortcut());
ui->swapButton->setShortcut(settings.swapShortcut());
ui->copyTranslationButton->setShortcut(settings.copyTranslationShortcut());
ui->clearButton->setShortcut(settings.clearShortcut());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but you also need to assign other buttons. Search for their names in mainwindow.ui

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there are buttons for the other actions. I don't have the knowledge to code them either, sadly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants