|
22 | 22 | #include "QStyle" |
23 | 23 | #include "QTextCodec" |
24 | 24 | #include "QTimer" |
| 25 | +#include "QLineEdit" |
25 | 26 | #include "cmath" |
26 | 27 | #include "chardet.h" |
27 | 28 | #include "configdialog.h" |
@@ -64,6 +65,8 @@ MainWindow::MainWindow(QWidget *parent) |
64 | 65 | connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, |
65 | 66 | SLOT(sliderMoved(int))); |
66 | 67 |
|
| 68 | + connect(ui->timeLabel, SIGNAL(clicked()), this, SLOT(openSkipToTimeDialog())); |
| 69 | + |
67 | 70 | if (QSystemTrayIcon::isSystemTrayAvailable()) { |
68 | 71 | QSystemTrayIcon *trayIcon = new QSystemTrayIcon(this); |
69 | 72 | trayIcon->setIcon(QIcon(":/icon.png")); |
@@ -251,6 +254,30 @@ void MainWindow::openFileDialog() { |
251 | 254 | this->show(); |
252 | 255 | } |
253 | 256 |
|
| 257 | +void MainWindow::openSkipToTimeDialog() { |
| 258 | + if (!engine) |
| 259 | + return; |
| 260 | + |
| 261 | + this->hide(); |
| 262 | + |
| 263 | + bool ok; |
| 264 | + QString timeStr = QInputDialog::getText(0, tr("Skip to Time"), tr("Skip to Time"), |
| 265 | + QLineEdit::Normal, Engine::millisToTimeString(currentTime), &ok); |
| 266 | + if (ok) { |
| 267 | + QRegularExpression timeRegex( |
| 268 | + "^(\\d+):(\\d+):(\\d+)$"); |
| 269 | + QRegularExpressionMatchIterator it = timeRegex.globalMatch(timeStr); |
| 270 | + if (it.hasNext()) { |
| 271 | + QRegularExpressionMatch match = it.next(); |
| 272 | + QString h = match.captured(1), m = match.captured(2), s = match.captured(3); |
| 273 | + long long time = Engine::calculateTime(h, m, s, "0"); |
| 274 | + currentTime = qMin(engine->getFinishTime(), qMax(0LL, time)); |
| 275 | + update(); |
| 276 | + } |
| 277 | + } |
| 278 | + this->show(); |
| 279 | +} |
| 280 | + |
254 | 281 | /* |
255 | 282 | * Protected methods |
256 | 283 | */ |
|
0 commit comments