diff --git a/saoritootwidget.cpp b/saoritootwidget.cpp index 3224ae3..ea8ad4c 100644 --- a/saoritootwidget.cpp +++ b/saoritootwidget.cpp @@ -28,6 +28,7 @@ #include "ui_saoritootwidget.h" #include <QUrlQuery> #include <QNetworkReply> +#include <QToolBar> #include <QDebug> SaoriTootWidget::SaoriTootWidget(QWidget *parent) : @@ -35,10 +36,11 @@ ui(new Ui::SaoriTootWidget) { ui->setupUi(this); + ui->actionToot->setEnabled(false); connect(ui->textEdit_toot,&QTextEdit::textChanged,this,[=](){ int c = 500 - ui->textEdit_toot->toPlainText().count(); - if ((c >= 500) || (c < 0)) ui->pushButton_commit->setEnabled(false); - else ui->pushButton_commit->setEnabled(true); + if ((c >= 500) || (c < 0)) ui->actionToot->setEnabled(false); + else ui->actionToot->setEnabled(true); if (c < 0) ui->label_count->setText("<b style=\"color:red\">" + QString::number(c) + "</b>"); else if (c < 100) ui->label_count->setText("<b style=\"color:yellow\">" + QString::number(c) + "</b>"); else ui->label_count->setText("<b>" + QString::number(c) + "</b>"); @@ -90,7 +92,7 @@ return result; } -void SaoriTootWidget::on_pushButton_commit_clicked() +void SaoriTootWidget::on_actionToot_triggered() { emit postNewStatus(createPostData()); } diff --git a/saoritootwidget.h b/saoritootwidget.h index d661a93..90b5e7b 100644 --- a/saoritootwidget.h +++ b/saoritootwidget.h @@ -53,7 +53,7 @@ void postNewStatus(const QString data); private slots: - void on_pushButton_commit_clicked(); + void on_actionToot_triggered(); private: Ui::SaoriTootWidget *ui; diff --git a/saoritootwidget.ui b/saoritootwidget.ui index 80b56e9..66d28b3 100644 --- a/saoritootwidget.ui +++ b/saoritootwidget.ui @@ -125,53 +125,42 @@ </widget> </item> <item> - <widget class="QPushButton" name="pushButton_clear"> - <property name="focusPolicy"> - <enum>Qt::NoFocus</enum> - </property> - <property name="text"> - <string>clear</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pushButton_commit"> - <property name="enabled"> + <widget class="QToolBar" name="toolBar"> + <property name="movable"> <bool>false</bool> </property> - <property name="contextMenuPolicy"> - <enum>Qt::ActionsContextMenu</enum> + <property name="floatable"> + <bool>false</bool> </property> - <property name="text"> - <string>Toot!</string> - </property> + <addaction name="actionClear"/> + <addaction name="actionToot"/> </widget> </item> </layout> </item> </layout> + <action name="actionToot"> + <property name="text"> + <string>Toot!</string> + </property> + <property name="shortcut"> + <string>Ctrl+Return</string> + </property> + </action> + <action name="actionClear"> + <property name="text"> + <string>clear</string> + </property> + <property name="shortcut"> + <string>Ctrl+Del</string> + </property> + </action> </widget> <resources> <include location="saori.qrc"/> </resources> <connections> <connection> - <sender>pushButton_clear</sender> - <signal>clicked()</signal> - <receiver>textEdit_toot</receiver> - <slot>clear()</slot> - <hints> - <hint type="sourcelabel"> - <x>263</x> - <y>277</y> - </hint> - <hint type="destinationlabel"> - <x>199</x> - <y>158</y> - </hint> - </hints> - </connection> - <connection> <sender>checkBox_cw</sender> <signal>toggled(bool)</signal> <receiver>lineEdit_cw</receiver> @@ -187,5 +176,37 @@ </hint> </hints> </connection> + <connection> + <sender>actionClear</sender> + <signal>triggered()</signal> + <receiver>textEdit_toot</receiver> + <slot>clear()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>199</x> + <y>170</y> + </hint> + </hints> + </connection> + <connection> + <sender>actionClear</sender> + <signal>triggered()</signal> + <receiver>lineEdit_cw</receiver> + <slot>clear()</slot> + <hints> + <hint type="sourcelabel"> + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel"> + <x>227</x> + <y>82</y> + </hint> + </hints> + </connection> </connections> </ui>