diff --git a/resources/css/style.css b/resources/css/style.css index 93d4150fd..9d630dee1 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -359,16 +359,16 @@ ContentTypeFilter { #readinglistbar QPushButton::menu-indicator { width: 0; height: 0; - +} /* ---------------------------------------- Text to Speech Page */ -#TextToSpeechBar { +TextToSpeechBar { border-top: 1px solid #ccc; } -TextToSpeechBar > #closeButton { +TextToSpeechBar #closeButton { outline: none; max-height: 36px; max-width: 36px; @@ -376,11 +376,42 @@ TextToSpeechBar > #closeButton { border-radius: 0; } -TextToSpeechBar > #closeButton:pressed { +TextToSpeechBar #stopButton { + outline: none; + max-height: 36px; + padding-left: 10px; + padding-right: 10px; + border: 1px solid #ccc; + background-color: white; + border-radius: 0; +} + +TextToSpeechBar #stopButton:hover { background-color: #D9E9FF; border: 1px solid #3366CC; } -TextToSpeechBar > #stopButton:disabled { +TextToSpeechBar #stopButton:disabled { color: grey; + background-color: darkgrey; +} + +TextToSpeechBar QComboBox::drop-down { + image: url(":/icons/search_forward.svg"); + background-color: white; } + +TextToSpeechBar QComboBox { + background-color: white; + border: 1px solid #ccc; +} + +TextToSpeechBar QComboBox QAbstractItemView QScrollBar { + width: 5px; + border: none; + outline: none; +} + +TextToSpeechBar QComboBox QAbstractItemView QScrollBar::handle { + background-color: grey; +} \ No newline at end of file diff --git a/src/texttospeechbar.cpp b/src/texttospeechbar.cpp index 84cf63e4e..2355664f3 100644 --- a/src/texttospeechbar.cpp +++ b/src/texttospeechbar.cpp @@ -3,15 +3,16 @@ #include "ui_texttospeechbar.h" #include +QTextToSpeech TextToSpeechBar::m_speech; TextToSpeechBar::TextToSpeechBar(QWidget *parent) - : QFrame(parent), mp_speech(new QTextToSpeech(this)), + : QFrame(parent), mp_ui(new Ui::TextToSpeechBar) { close(); mp_ui->setupUi(this); mp_ui->stopButton->setText(gt("stop")); mp_ui->voiceLabel->setText(gt("voice")); - connect(mp_speech, &QTextToSpeech::stateChanged, this, + connect(&m_speech, &QTextToSpeech::stateChanged, this, &TextToSpeechBar::onStateChanged); connect(mp_ui->stopButton, &QPushButton::released, this, &TextToSpeechBar::stop); @@ -21,7 +22,7 @@ TextToSpeechBar::TextToSpeechBar(QWidget *parent) mp_ui->langLabel->setText(gt("language")); mp_ui->langComboBox->setMaxVisibleItems(10); QLocale current = QLocale::system().language(); - for (auto locale : mp_speech->availableLocales()) + for (auto locale : m_speech.availableLocales()) { QString name(QString("%1 (%2)") .arg(QLocale::languageToString(locale.language())) @@ -44,12 +45,12 @@ TextToSpeechBar::TextToSpeechBar(QWidget *parent) void TextToSpeechBar::speak(const QString &text) { - mp_speech->say(text); + m_speech.say(text); } void TextToSpeechBar::stop() { - mp_speech->stop(); + m_speech.stop(); } void TextToSpeechBar::onStateChanged(QTextToSpeech::State state) @@ -63,8 +64,9 @@ void TextToSpeechBar::languageSelected(int index) disconnect(mp_ui->voiceComboBox, &QComboBox::currentIndexChanged, this, &TextToSpeechBar::voiceSelected); mp_ui->voiceComboBox->clear(); - m_voices = mp_speech->availableVoices(); - QVoice currentVoice = mp_speech->voice(); + m_speech.setLocale(locale); + m_voices = m_speech.availableVoices(); + QVoice currentVoice = m_speech.voice(); for (auto voice : m_voices) { mp_ui->voiceComboBox->addItem(QString("%1 - %2 - %3").arg(voice.name()) @@ -78,7 +80,7 @@ void TextToSpeechBar::languageSelected(int index) void TextToSpeechBar::voiceSelected(int index) { - mp_speech->setVoice(m_voices.at(index)); + m_speech.setVoice(m_voices.at(index)); } void TextToSpeechBar::speechBarClose() @@ -89,6 +91,6 @@ void TextToSpeechBar::speechBarClose() return; current->setFocus(); - mp_speech->stop(); + m_speech.stop(); close(); } diff --git a/src/texttospeechbar.h b/src/texttospeechbar.h index 4ebc50a07..83464b35f 100644 --- a/src/texttospeechbar.h +++ b/src/texttospeechbar.h @@ -24,7 +24,7 @@ public slots: void onStateChanged(QTextToSpeech::State state); private: - QTextToSpeech *mp_speech; + static QTextToSpeech m_speech; Ui::TextToSpeechBar *mp_ui; QVector m_voices; }; diff --git a/src/texttospeechbar.ui b/src/texttospeechbar.ui index 8339c6b4c..ca6184bc1 100644 --- a/src/texttospeechbar.ui +++ b/src/texttospeechbar.ui @@ -79,7 +79,7 @@ - <html><head/><body><p><br/></p></body></html> + diff --git a/src/zimview.cpp b/src/zimview.cpp index 4d69095f6..d3deff643 100644 --- a/src/zimview.cpp +++ b/src/zimview.cpp @@ -33,13 +33,13 @@ ZimView::ZimView(TabBar *tabBar, QWidget *parent) return; mp_ttsBar->speak(mp_webView->page()->selectedText()); }); - connect(app->getAction(KiwixApp::ReadTextAction), &QAction::triggered, [=](){ + connect(app->getAction(KiwixApp::ReadTextAction), &QAction::triggered, this, [=](){ if (mp_tabBar->currentZimView() != this) return; if (this->getWebView()->page()->hasSelection()) mp_ttsBar->show(); }); - connect(app->getAction(KiwixApp::ReadArticleAction), &QAction::triggered, [=](){ + connect(app->getAction(KiwixApp::ReadArticleAction), &QAction::triggered, this, [=](){ if (mp_tabBar->currentZimView() == this) mp_ttsBar->show(); });