Changeset View
Changeset View
Standalone View
Standalone View
mainwindow.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
58 | 58 | | |||
59 | #include <QAction> | 59 | #include <QAction> | ||
60 | #include <KActionCollection> | 60 | #include <KActionCollection> | ||
61 | #include <KConfigDialog> | 61 | #include <KConfigDialog> | ||
62 | #include <QFileDialog> | 62 | #include <QFileDialog> | ||
63 | #include <QIcon> | 63 | #include <QIcon> | ||
64 | #include <KLocalizedString> | 64 | #include <KLocalizedString> | ||
65 | #include <KMessageBox> | 65 | #include <KMessageBox> | ||
66 | #include <KRandom> | 66 | #include <QRandomGenerator> | ||
67 | #include <QStatusBar> | 67 | #include <QStatusBar> | ||
68 | #include <QMenuBar> | 68 | #include <QMenuBar> | ||
69 | #include <QTemporaryFile> | 69 | #include <QTemporaryFile> | ||
70 | #include <KToggleAction> | 70 | #include <KToggleAction> | ||
71 | #include <KIOCore/KIO/StoredTransferJob> | 71 | #include <KIOCore/KIO/StoredTransferJob> | ||
72 | #include <KXMLGUIFactory> | 72 | #include <KXMLGUIFactory> | ||
73 | 73 | | |||
74 | #include <QScreen> | 74 | #include <QScreen> | ||
▲ Show 20 Lines • Show All 327 Lines • ▼ Show 20 Line(s) | |||||
402 | 402 | | |||
403 | void MainWindow::restart() | 403 | void MainWindow::restart() | ||
404 | { | 404 | { | ||
405 | startNew(-1); | 405 | startNew(-1); | ||
406 | } | 406 | } | ||
407 | 407 | | |||
408 | void MainWindow::startRandom() | 408 | void MainWindow::startRandom() | ||
409 | { | 409 | { | ||
410 | startNew(KRandom::random()); | 410 | startNew(QRandomGenerator::global()->generate()); | ||
411 | } | 411 | } | ||
coates: Personally, I think the following would be more readable, but at minimum a comment explaining… | |||||
412 | 412 | | |||
413 | void MainWindow::startNew(int gameNumber) | 413 | void MainWindow::startNew(int gameNumber) | ||
414 | { | 414 | { | ||
415 | m_dealer->startNew(gameNumber); | 415 | m_dealer->startNew(gameNumber); | ||
416 | setGameCaption(); | 416 | setGameCaption(); | ||
417 | } | 417 | } | ||
418 | 418 | | |||
419 | void MainWindow::slotPickRandom() | 419 | void MainWindow::slotPickRandom() | ||
420 | { | 420 | { | ||
421 | QList<KCardTheme> themes = KCardTheme::findAll(); | 421 | QList<KCardTheme> themes = KCardTheme::findAll(); | ||
422 | KCardTheme theme = themes.at( KRandom::random() % themes.size() ); | 422 | KCardTheme theme = themes.at( QRandomGenerator::global()->generate() % themes.size() ); | ||
KCardTheme theme = themes.at( QRandomGenerator::global()->bounded( themes.size() ) ); coates: ```
KCardTheme theme = themes.at( QRandomGenerator::global()->bounded( themes.size() ) );
``` | |||||
423 | Settings::setCardTheme( theme.dirName() ); | 423 | Settings::setCardTheme( theme.dirName() ); | ||
424 | 424 | | |||
425 | appearanceChanged(); | 425 | appearanceChanged(); | ||
426 | } | 426 | } | ||
427 | 427 | | |||
428 | void MainWindow::configureAppearance() | 428 | void MainWindow::configureAppearance() | ||
429 | { | 429 | { | ||
430 | const QString previewFormat = QStringLiteral("back;10_spade,jack_diamond,queen_club,king_heart;1_spade"); | 430 | const QString previewFormat = QStringLiteral("back;10_spade,jack_diamond,queen_club,king_heart;1_spade"); | ||
▲ Show 20 Lines • Show All 649 Lines • Show Last 20 Lines |
Personally, I think the following would be more readable, but at minimum a comment explaining the bit fiddling would be appropriate.