Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn settings menu to a dialog window #605

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ set(quaternion_SRCS
client/activitydetector.cpp
client/dialog.cpp
client/logindialog.cpp
client/settingsdialog.cpp
client/networkconfigdialog.cpp
client/roomdialogs.cpp
client/mainwindow.cpp
Expand All @@ -173,6 +174,10 @@ set(quaternion_QRC
client/resources.qrc
)

set(quaternion_UI
client/settingsgeneralpage.ui
)

# quaternion_en.ts is updated explicitly by building trbase target,
# while all other translation files are created and updated externally at
# Lokalise.co
Expand All @@ -188,6 +193,8 @@ set(quaternion_TS
)
QT5_ADD_TRANSLATION(quaternion_QM ${quaternion_TS})

qt5_wrap_ui(quaternion_UI_OUT ${quaternion_UI})

QT5_ADD_RESOURCES(quaternion_QRC_SRC ${quaternion_QRC})
set_property(SOURCE qrc_resources.cpp PROPERTY SKIP_AUTOMOC ON)

Expand Down Expand Up @@ -216,7 +223,7 @@ endif(APPLE)

# Windows, this is a GUI executable; OSX, make a bundle
add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE
${quaternion_SRCS} ${quaternion_QRC_SRC} ${quaternion_QM}
${quaternion_SRCS} ${quaternion_UI_OUT} ${quaternion_QRC_SRC} ${quaternion_QM}
${quaternion_WINRC} ${${PROJECT_NAME}_MAC_ICON})

target_link_libraries(${PROJECT_NAME}
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,15 @@ Some settings exposed in UI (Settings and View menus):
If a tag is not mentioned and does not fit any namespace, it will be put at
the end in lexicographic order. Tags within the same namespace are also
ordered lexicographically.
- `UI/Fonts/family` - override the font family for the whole application.
If not specified, the default font for your environment is used.
- `UI/Fonts/pointSize` - override the font size (in points) for the whole
application. If not specified, the default size for your environment is used.
- `UI/Fonts/timeline_family` - font family (for example `Monospace`) to
display messages in the timeline. If not specified, the application-wide font
family is used.
- `UI/Fonts/timeline_pointSize` - font size (in points) to display messages
in the timeline. If not specified, the application-wide point size is used.

Settings not exposed in UI:

Expand Down Expand Up @@ -194,15 +203,6 @@ Settings not exposed in UI:
the beginning and end of the quote. By default it's `(.+)(?:\n|$)`.
- `UI/Fonts/render_type` - select how to render fonts in Quaternion timeline;
possible values are "NativeRendering" (default) and "QtRendering".
- `UI/Fonts/family` - override the font family for the whole application.
If not specified, the default font for your environment is used.
- `UI/Fonts/pointSize` - override the font size (in points) for the whole
application. If not specified, the default size for your environment is used.
- `UI/Fonts/timeline_family` - font family (for example `Monospace`) to
display messages in the timeline. If not specified, the application-wide font
family is used.
- `UI/Fonts/timeline_pointSize` - font size (in points) to display messages
in the timeline. If not specified, the application-wide point size is used.

Since version 0.0.9.4, AppImage binaries for Linux and .dmg files for macOS
are compiled with Qt Keychain support. It means that Quaternion will try
Expand Down
139 changes: 29 additions & 110 deletions client/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "userlistdock.h"
#include "chatroomwidget.h"
#include "logindialog.h"
#include "settingsdialog.h"
#include "networkconfigdialog.h"
#include "roomdialogs.h"
#include "systemtrayicon.h"
Expand Down Expand Up @@ -168,6 +169,24 @@ void MainWindow::createMenu()
{
using Quotient::Settings;

// Application menu
auto applicationMenu = menuBar()->addMenu(tr("A&pplication"));
applicationMenu->addAction(QIcon::fromTheme("preferences"), tr("&Preferences..."),
this, [=]{ showSettingsWindow(); } );

applicationMenu->addAction(QIcon::fromTheme("preferences-system-network"),
tr("Configure &network proxy..."), [this]
{
static QPointer<NetworkConfigDialog> dlg;
summon(dlg, this);
});

// Augment poor Windows users with a handy Ctrl-Q shortcut.
static const auto quitShortcut = QSysInfo::productType() == "windows"
? QKeySequence(Qt::CTRL + Qt::Key_Q) : QKeySequence::Quit;
applicationMenu->addAction(QIcon::fromTheme("application-exit"),
tr("&Quit"), qApp, &QApplication::quit, quitShortcut);

// Connection menu
connectionMenu = menuBar()->addMenu(tr("&Accounts"));

Expand All @@ -178,12 +197,6 @@ void MainWindow::createMenu()
// Account submenus will be added in this place - see addConnection()
accountListGrowthPoint = connectionMenu->addSeparator();

// Augment poor Windows users with a handy Ctrl-Q shortcut.
static const auto quitShortcut = QSysInfo::productType() == "windows"
? QKeySequence(Qt::CTRL + Qt::Key_Q) : QKeySequence::Quit;
connectionMenu->addAction(QIcon::fromTheme("application-exit"),
tr("&Quit"), qApp, &QApplication::quit, quitShortcut);

// View menu
auto viewMenu = menuBar()->addMenu(tr("&View"));

Expand Down Expand Up @@ -307,114 +320,10 @@ void MainWindow::createMenu()
tr("&Close current room"), [this] { selectRoom(nullptr); },
QKeySequence::Close);

// Settings menu
auto settingsMenu = menuBar()->addMenu(tr("&Settings"));

// Help menu
auto helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(QIcon::fromTheme("help-about"), tr("&About"),
[=]{ showAboutWindow(); });

{
auto notifGroup = new QActionGroup(this);
connect(notifGroup, &QActionGroup::triggered, this,
[] (QAction* notifAction)
{
notifAction->setChecked(true);
Settings().setValue("UI/notifications",
notifAction->data().toString());
});

auto noNotif = notifGroup->addAction(tr("&Highlight only"));
noNotif->setData(QStringLiteral("none"));
noNotif->setStatusTip(tr("Notifications are entirely suppressed"));
auto gentleNotif = notifGroup->addAction(tr("&Non-intrusive"));
gentleNotif->setData(QStringLiteral("non-intrusive"));
gentleNotif->setStatusTip(
tr("Show notifications but do not activate the window"));
auto fullNotif = notifGroup->addAction(tr("&Full"));
fullNotif->setData(QStringLiteral("intrusive"));
fullNotif->setStatusTip(
tr("Show notifications and activate the window"));

auto notifMenu = settingsMenu->addMenu(
QIcon::fromTheme("preferences-desktop-notification"),
tr("Notifications"));
for (auto a: {noNotif, gentleNotif, fullNotif})
{
a->setCheckable(true);
notifMenu->addAction(a);
}

const auto curSetting = Settings().value("UI/notifications",
fullNotif->data().toString());
if (curSetting == noNotif->data().toString())
noNotif->setChecked(true);
else if (curSetting == gentleNotif->data().toString())
gentleNotif->setChecked(true);
else
fullNotif->setChecked(true);
}
{
auto layoutGroup = new QActionGroup(this);
connect(layoutGroup, &QActionGroup::triggered, this,
[this] (QAction* action)
{
action->setChecked(true);
Settings().setValue("UI/timeline_style", action->data().toString());
chatRoomWidget->setRoom(nullptr);
chatRoomWidget->setRoom(currentRoom);
});

auto defaultLayout = layoutGroup->addAction(tr("Default"));
defaultLayout->setStatusTip(
tr("The layout with author labels above blocks of messages"));
auto xchatLayout = layoutGroup->addAction("XChat");
xchatLayout->setData(QStringLiteral("xchat"));
xchatLayout->setStatusTip(
tr("The layout with author labels to the left from each message"));

auto layoutMenu = settingsMenu->addMenu(QIcon::fromTheme("table"),
tr("Timeline layout"));
for (auto a: {defaultLayout, xchatLayout})
{
a->setCheckable(true);
layoutMenu->addAction(a);
}

const auto curSetting = Settings().value("UI/timeline_style",
defaultLayout->data().toString());
if (curSetting == xchatLayout->data().toString())
xchatLayout->setChecked(true);
else
defaultLayout->setChecked(true);
}
addTimelineOptionCheckbox(
settingsMenu,
tr("Use shuttle scrollbar (requires restart)"),
tr("Control scroll velocity instead of position with the timeline scrollbar"),
QStringLiteral("use_shuttle_dial"), true
);
addTimelineOptionCheckbox(
settingsMenu,
tr("Load full-size images at once"),
tr("Automatically download a full-size image instead of a thumbnail"),
QStringLiteral("autoload_images"), true
);
addTimelineOptionCheckbox(
settingsMenu,
tr("Close to tray"),
tr("Make close button [X] minimize to tray instead of closing main window"),
QStringLiteral("close_to_tray"), false
);

settingsMenu->addSeparator();
settingsMenu->addAction(QIcon::fromTheme("preferences-system-network"),
tr("Configure &network proxy..."), [this]
{
static QPointer<NetworkConfigDialog> dlg;
summon(dlg, this);
});
}

void MainWindow::loadSettings()
Expand Down Expand Up @@ -875,6 +784,16 @@ void MainWindow::processLogin(LoginDialog& dialog)
addConnection(connection, deviceName);
}

void MainWindow::showSettingsWindow()
{
SettingsDialog settingsDialog(this);
connect(&settingsDialog, &SettingsDialog::timelineChanged, this, [=]() {
chatRoomWidget->setRoom(nullptr);
chatRoomWidget->setRoom(currentRoom);
});
settingsDialog.exec();
}

void MainWindow::showAboutWindow()
{
Dialog aboutDialog(tr("About Quaternion"), QDialogButtonBox::Close,
Expand Down
1 change: 1 addition & 0 deletions client/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MainWindow: public QMainWindow
void showLoginWindow(const QString& statusMessage = {});
void showLoginWindow(const QString& statusMessage,
Quotient::AccountSettings& reloginAccount);
void showSettingsWindow();
void showAboutWindow();
void logout(Connection* c);

Expand Down
Loading