Skip to content

Commit

Permalink
feat: add tray menu action to show() for legacy support
Browse files Browse the repository at this point in the history
  • Loading branch information
kamui-fin committed Oct 8, 2023
1 parent 647ed86 commit 26c1c80
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/configwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ ConfigWindow::ConfigWindow(std::map<std::string, QHotkey *> hotkeys,
widget = new QWidget(this);
this->setCentralWidget(widget);


std::unordered_map<std::string, int> map = {{"jpn", 0}, {"chi_sim", 1}, {"chi_trad", 2}};
std::unordered_map<std::string, int> map = {
{"jpn", 0}, {"chi_sim", 1}, {"chi_trad", 2}};

langChoice = new QComboBox(widget);
langChoice->addItem("jpn");
langChoice->addItem("chi_sim");
langChoice->addItem("chi_trad");

std::string configLang = settings->value("language", "jpn").toString().toStdString();
std::string configLang =
settings->value("language", "jpn").toString().toStdString();
langChoice->setCurrentIndex(map[configLang]);

verticalKeybindButton = new QPushButton(
Expand Down Expand Up @@ -74,8 +75,8 @@ ConfigWindow::ConfigWindow(std::map<std::string, QHotkey *> hotkeys,

this->trayIcon->show();

connect(langChoice, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(onLanguageChange(const QString&)));
connect(langChoice, SIGNAL(currentIndexChanged(const QString &)), this,
SLOT(onLanguageChange(const QString &)));
connect(trayIcon, &QSystemTrayIcon::activated, this,
&ConfigWindow::iconActivated);
connect(verticalKeybindButton, &QPushButton::clicked, this,
Expand All @@ -86,7 +87,7 @@ ConfigWindow::ConfigWindow(std::map<std::string, QHotkey *> hotkeys,
&ConfigWindow::handleHotkeyButton);
}

void ConfigWindow::onLanguageChange(const QString& lang) {
void ConfigWindow::onLanguageChange(const QString &lang) {
QString key = "language";
settings->setValue("language", lang);
settings->sync();
Expand All @@ -96,8 +97,13 @@ QMenu *ConfigWindow::createMenu() {
QAction *quitAction = new QAction("&Quit", this);
connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);

QAction *configureAction = new QAction("&Configure", this);
connect(configureAction, &QAction::triggered, qApp,
[this]() { this->show(); });

QMenu *menu = new QMenu(this);
menu->addAction(quitAction);
menu->addAction(configureAction);

return menu;
}
Expand Down

0 comments on commit 26c1c80

Please sign in to comment.