2323#include " userlistdock.h"
2424#include " chatroomwidget.h"
2525#include " logindialog.h"
26+ #include " settingsdialog.h"
2627#include " networkconfigdialog.h"
2728#include " roomdialogs.h"
2829#include " systemtrayicon.h"
@@ -168,6 +169,24 @@ void MainWindow::createMenu()
168169{
169170 using QMatrixClient::Settings;
170171
172+ // Application menu
173+ auto applicationMenu = menuBar ()->addMenu (tr (" A&pplication" ));
174+ applicationMenu->addAction (QIcon::fromTheme (" preferences" ), tr (" &Preferences..." ),
175+ this , [=]{ showSettingsWindow (); } );
176+
177+ applicationMenu->addAction (QIcon::fromTheme (" preferences-system-network" ),
178+ tr (" Configure &network proxy..." ), [this ]
179+ {
180+ static QPointer<NetworkConfigDialog> dlg;
181+ summon (dlg, this );
182+ });
183+
184+ // Augment poor Windows users with a handy Ctrl-Q shortcut.
185+ static const auto quitShortcut = QSysInfo::productType () == " windows"
186+ ? QKeySequence (Qt::CTRL + Qt::Key_Q) : QKeySequence::Quit;
187+ applicationMenu->addAction (QIcon::fromTheme (" application-exit" ),
188+ tr (" &Quit" ), qApp, &QApplication::quit, quitShortcut);
189+
171190 // Connection menu
172191 connectionMenu = menuBar ()->addMenu (tr (" &Accounts" ));
173192
@@ -178,12 +197,6 @@ void MainWindow::createMenu()
178197 // Account submenus will be added in this place - see addConnection()
179198 accountListGrowthPoint = connectionMenu->addSeparator ();
180199
181- // Augment poor Windows users with a handy Ctrl-Q shortcut.
182- static const auto quitShortcut = QSysInfo::productType () == " windows"
183- ? QKeySequence (Qt::CTRL + Qt::Key_Q) : QKeySequence::Quit;
184- connectionMenu->addAction (QIcon::fromTheme (" application-exit" ),
185- tr (" &Quit" ), qApp, &QApplication::quit, quitShortcut);
186-
187200 // View menu
188201 auto viewMenu = menuBar ()->addMenu (tr (" &View" ));
189202
@@ -318,114 +331,10 @@ void MainWindow::createMenu()
318331 tr (" &Close current room" ), [this ] { selectRoom (nullptr ); },
319332 QKeySequence::Close);
320333
321- // Settings menu
322- auto settingsMenu = menuBar ()->addMenu (tr (" &Settings" ));
323-
324334 // Help menu
325335 auto helpMenu = menuBar ()->addMenu (tr (" &Help" ));
326336 helpMenu->addAction (QIcon::fromTheme (" help-about" ), tr (" &About" ),
327337 [=]{ showAboutWindow (); });
328-
329- {
330- auto notifGroup = new QActionGroup (this );
331- connect (notifGroup, &QActionGroup::triggered, this ,
332- [] (QAction* notifAction)
333- {
334- notifAction->setChecked (true );
335- Settings ().setValue (" UI/notifications" ,
336- notifAction->data ().toString ());
337- });
338-
339- auto noNotif = notifGroup->addAction (tr (" &Highlight only" ));
340- noNotif->setData (QStringLiteral (" none" ));
341- noNotif->setStatusTip (tr (" Notifications are entirely suppressed" ));
342- auto gentleNotif = notifGroup->addAction (tr (" &Non-intrusive" ));
343- gentleNotif->setData (QStringLiteral (" non-intrusive" ));
344- gentleNotif->setStatusTip (
345- tr (" Show notifications but do not activate the window" ));
346- auto fullNotif = notifGroup->addAction (tr (" &Full" ));
347- fullNotif->setData (QStringLiteral (" intrusive" ));
348- fullNotif->setStatusTip (
349- tr (" Show notifications and activate the window" ));
350-
351- auto notifMenu = settingsMenu->addMenu (
352- QIcon::fromTheme (" preferences-desktop-notification" ),
353- tr (" Notifications" ));
354- for (auto a: {noNotif, gentleNotif, fullNotif})
355- {
356- a->setCheckable (true );
357- notifMenu->addAction (a);
358- }
359-
360- const auto curSetting = Settings ().value (" UI/notifications" ,
361- fullNotif->data ().toString ());
362- if (curSetting == noNotif->data ().toString ())
363- noNotif->setChecked (true );
364- else if (curSetting == gentleNotif->data ().toString ())
365- gentleNotif->setChecked (true );
366- else
367- fullNotif->setChecked (true );
368- }
369- {
370- auto layoutGroup = new QActionGroup (this );
371- connect (layoutGroup, &QActionGroup::triggered, this ,
372- [this ] (QAction* action)
373- {
374- action->setChecked (true );
375- Settings ().setValue (" UI/timeline_style" , action->data ().toString ());
376- chatRoomWidget->setRoom (nullptr );
377- chatRoomWidget->setRoom (currentRoom);
378- });
379-
380- auto defaultLayout = layoutGroup->addAction (tr (" Default" ));
381- defaultLayout->setStatusTip (
382- tr (" The layout with author labels above blocks of messages" ));
383- auto xchatLayout = layoutGroup->addAction (" XChat" );
384- xchatLayout->setData (QStringLiteral (" xchat" ));
385- xchatLayout->setStatusTip (
386- tr (" The layout with author labels to the left from each message" ));
387-
388- auto layoutMenu = settingsMenu->addMenu (QIcon::fromTheme (" table" ),
389- tr (" Timeline layout" ));
390- for (auto a: {defaultLayout, xchatLayout})
391- {
392- a->setCheckable (true );
393- layoutMenu->addAction (a);
394- }
395-
396- const auto curSetting = Settings ().value (" UI/timeline_style" ,
397- defaultLayout->data ().toString ());
398- if (curSetting == xchatLayout->data ().toString ())
399- xchatLayout->setChecked (true );
400- else
401- defaultLayout->setChecked (true );
402- }
403- addTimelineOptionCheckbox (
404- settingsMenu,
405- tr (" Use shuttle scrollbar (requires restart)" ),
406- tr (" Control scroll velocity instead of position with the timeline scrollbar" ),
407- QStringLiteral (" use_shuttle_dial" ), true
408- );
409- addTimelineOptionCheckbox (
410- settingsMenu,
411- tr (" Load full-size images at once" ),
412- tr (" Automatically download a full-size image instead of a thumbnail" ),
413- QStringLiteral (" autoload_images" ), true
414- );
415- addTimelineOptionCheckbox (
416- settingsMenu,
417- tr (" Close to tray" ),
418- tr (" Make close button [X] minimize to tray instead of closing main window" ),
419- QStringLiteral (" close_to_tray" ), false
420- );
421-
422- settingsMenu->addSeparator ();
423- settingsMenu->addAction (QIcon::fromTheme (" preferences-system-network" ),
424- tr (" Configure &network proxy..." ), [this ]
425- {
426- static QPointer<NetworkConfigDialog> dlg;
427- summon (dlg, this );
428- });
429338}
430339
431340void MainWindow::loadSettings ()
@@ -888,6 +797,16 @@ void MainWindow::processLogin(LoginDialog& dialog)
888797 addConnection (connection, deviceName);
889798}
890799
800+ void MainWindow::showSettingsWindow ()
801+ {
802+ SettingsDialog settingsDialog (this );
803+ connect (&settingsDialog, &SettingsDialog::timelineChanged, this , [=]() {
804+ chatRoomWidget->setRoom (nullptr );
805+ chatRoomWidget->setRoom (currentRoom);
806+ });
807+ settingsDialog.exec ();
808+ }
809+
891810void MainWindow::showAboutWindow ()
892811{
893812 Dialog aboutDialog (tr (" About Quaternion" ), QDialogButtonBox::Close,
0 commit comments