Skip to content
This repository has been archived by the owner on Aug 26, 2020. It is now read-only.

Commit

Permalink
Added Overlay mode, menu toggle, frameless windows, always on top,
Browse files Browse the repository at this point in the history
trancparency, and fixed a couple of misc. bugs.
  • Loading branch information
3vi1 committed Apr 20, 2017
1 parent 50dcd96 commit 4eaf647
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 98 deletions.
50 changes: 25 additions & 25 deletions docs/FAQ
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@

Some miscellaneous questions and answers:

---------------------------------------------------------------------------------------------

Q: What are the controls?

A: Currently there are only a few:
A: The controls so far (make sure you have clicked app window to give it focus first:

Click+Drag: Pan/scroll map.
Mousewheel: Over map it will zoom in/out.
Ctrl+Mousewheel: Rotates map (make sure map has focus first - click it)
Alt+Ctrl+Mousewheel: Adjust transparency (click map for focus first)
Ctrl+F: Shortcut for Find System.
Left-Click: On a system to switch the message view to just messages for that
system. Click on an empty space to switch back to all messages.
Ctrl+Mousewheel: Rotates map
Alt+Ctrl+Mousewheel: Adjust transparency
Ctrl+F: Shortcut for "Find System".
Left-Click: On a system (on the map) to switch the message view to just
messages for that system. Click on an empty space to switch
back to all messages.
Double-Click: On a message in the list to find the related system.

You can also click and drag the map around.
O: Toggle on/off Overlay Mode.
W: Toggle on/off title bar
M: Toggle on/off menu bar
T: Toggle on/off Always on Top.

There's no feature to set your current system at the moment, but I haven't needed it
since Imp deduces your location on startup without needing to jump.

In the future, there will be some right-click context menus... as soon as I write
the features that need them.
In the future, there will be some right-click context menus.

---------------------------------------------------------------------------------------------

Expand All @@ -38,7 +43,9 @@ A: I seriously considered this, but I believe other features make it unnecessar
addition to the feature itself being redundant.

If you want to KOS-check someone that's linked in a line, just right-click the line
and choose copy, then right-click the line and choose copy again.
and choose copy, then right-click the line and choose copy again. The second time it
hits your clipboard, IMP will know you want to KOS check the pilots linked in that
line.

Vintel appears to have only allowed 'xxx' requests from channels in your intel list,
most likely to prevent spamming by reds trying to jam out people. This also means
Expand All @@ -47,7 +54,8 @@ A: I seriously considered this, but I believe other features make it unnecessar

Players can coordinate IMP message rules (rules tab in Options) to play any number
of sounds for certain messages in a specific (or any) channel from specific/any people,
if what your trying to accomplish is to play a sound for a subset of people.
if what your trying to accomplish is to play a sound for a subset of people. See
the RULES file for details.

In the future there will be a LUA scripting component in IMP, and I will make one
of the example scripts show how to add the 'xxx' checking back for people that
Expand All @@ -59,24 +67,16 @@ Q: What does disabling a pilot from the pilots menu do.

A: This is for people that play multiple accounts from the same computer. Disabling a pilot
(who may have been seen and added to the map if they were used within the previous 24
hours) will remove them from the map and suppress warnings for them. You will still get
the warnings other pilots should receive - even if they're in the same system.
hours) will remove them from the map and suppress warnings for their nearby systems.
You will still get the warnings other pilots should receive - even if they're in the same
system.

---------------------------------------------------------------------------------------------

Q: When I change regions, [something] doesn't work.

A: That's because I never tested other regions. I'm a madman like that. I've only just
added regions and never flown outside of Providence. I'll fix it... soon (tm).

---------------------------------------------------------------------------------------------

Q: Where are the transparency options?

A: That's a feature that should be part of your desktop compositor, rather than
re-implemented in every app's UI. On Linux, the Compiz, KWin, and other compositors
give you options to do this for each app. On Windows, I know there are some third-
party apps that allow you to do it.
A: That's because I've only recently even gone to another region. I am going to be
looking hard at this in the near future.

---------------------------------------------------------------------------------------------

Expand All @@ -88,7 +88,7 @@ A: I found that I never used the tray icon when running Vintel because the main
when you're not playing the game.

I'm not saying I *won't* add a tray icon and minimize to tray feature... but it's way
down the list of priorities until I can think of a real benefit.
down the list of priorities.

---------------------------------------------------------------------------------------------

Expand Down
36 changes: 31 additions & 5 deletions docs/RELEASES
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
0.8.3 - Fixed two more missing KOS texts.

"Overlay Mode" added. This disables drawing of (only) the map and
window background, turns on frameless window mode, hides the menu,
and enables the Always on Top flag. This allows you to put IMP on
top of the game window and obscure much less of the game (particularly
if you drag the message list to the closed position). Use 'O' to
toggle overlay mode on/off.

Added transparency support: Click the map (to make sure the app
has focus) and then use Ctrl+Alt+Mousewheel to adjust transparency
of the entire application. This is different than overlay mode in
that overlay mode makes only the map/window backgrounds
fully transparent, whereas transparency support adjusts *all* visual
elements.

"Frameless Window" option added. Use 'W' to toggle the window
title bar on/off. This can also be used from Overlay mode to
re-enable the title-bar for easy re-positioning and then to
re-disable it.

Added an Always on Top hotkey: 'T'. Note: When using the Unity
desktop on Ubuntu, Compiz doesn't seem to honor toggling the flag
off correctly. You will have to disable it by right-clicking the
title-bar if you're using that desktop. KDE, and the Windows desktops
toggle the always-on-top state as expected.

Added Menu hide/unhide hotkey: 'M' You can use this in desktops
like KDE and Windows to toggle the menubar on/off while in overlay
mode.

Added "--debuglogging" flag. Log writing is now disabled by default
unless this flag is set.

"Toggle Frameless" option added. Use 'T' to toggle the frame back
on.

Added transparency: Click the map and use ctrl+alt+mousewheel to
adjust transparency.
Fixed a bug where some Linux desktops would not load themes due to
auto-shortcuts.

0.8.2 - Now support's "Pocket Status" queries. I.E. "b-w pocket status?"

Expand Down
147 changes: 120 additions & 27 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,22 @@ MainWindow::MainWindow(QWidget *parent) :
qDebug() << "* Imp Started *";
qDebug() << "---------------";

ui->setupUi(this);

#ifndef Q_OS_WIN32
ui->menu_Window->menuAction()->setVisible(false);
#endif
// On Linux with the Compiz compositor, I discovered that if you don't
// set the translucent background flag before you setup the window, the
// window appears to get optimized such that it will not support
// transparency (it gets drawn as black). This might be because it
// uses some separate OpenGL surface directly. Making this note to
// report it as a bug down the road.
//
// After some amount of time, we *could* toggle the translucent
// background flag off to draw things solid, but since the time is
// indeterminate, we'll just set the autofillBackground flag on all
// our visual elements instead. and unset the flag when we want
// transparency.

setAttribute(Qt::WA_TranslucentBackground);

ui->setupUi(this);

// Initialize lastAlertTime
lastAlertTime = QDateTime::currentDateTimeUtc().addDays(-1);
Expand Down Expand Up @@ -104,9 +114,18 @@ MainWindow::MainWindow(QWidget *parent) :
// If we do a macOS port later, we will need to set up a timer and another
// function to compare the previous/current clipboard value, because
// they cannot detect the clipboard is changed until the app is activated.

connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(clipboardUpdated()));

// Normally, you could just set these shortcuts in the UI, but since we hide the menus they may become
// disabled on some Desktop Environments (like KDE) if we did it that way.
findShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F), this, SLOT(on_actionSystem_triggered()));
framelessShortcut = new QShortcut(QKeySequence(Qt::Key_W), this, SLOT(on_action_Frameless_Window_triggered()));
menuShortcut = new QShortcut(QKeySequence(Qt::Key_M), this, SLOT(on_action_Menu_Toggle_triggered()));
overlayShortcut = new QShortcut(QKeySequence(Qt::Key_O), this, SLOT(on_action_Overlay_Mode_triggered()));
alwaysOnTopShortcut = new QShortcut(QKeySequence(Qt::Key_T), this, SLOT(on_action_Always_on_Top_triggered()));

#ifndef QT_DEBUG
ui->menuDebug->menuAction()->setVisible(false);
#endif
Expand All @@ -125,14 +144,29 @@ MainWindow::~MainWindow()
delete ui;
}

QString MainWindow::withoutShortcutAmpersands(const QString input)
{
QString output;
for(int i = 0; i < input.length()-1; i++)
{
if(input[i] != '&' || (input[i] == '&' && input[i+1] == '&'))
{
output.append(input[i]);
}
}
output.append(input[input.length()-1]);

return output;
}

void MainWindow::themeSelected()
{
QAction *s = qobject_cast<QAction *> (sender());

qDebug() << "MainWindow::themeSelected - loading " + s->text();
changeTheme(s->text(), qvariant_cast<ThemeType>(s->data()) );
options.setTheme(s->text(), qvariant_cast<ThemeType>(s->data()));
QString themeName = withoutShortcutAmpersands(s->text());
qDebug() << "MainWindow::themeSelected - loading " + themeName;
changeTheme(themeName, qvariant_cast<ThemeType>(s->data()) );
options.setTheme(themeName, qvariant_cast<ThemeType>(s->data()));
}

void MainWindow::changeTheme(const QString& themeName, ThemeType themeType)
Expand Down Expand Up @@ -211,7 +245,7 @@ void MainWindow::addThemeToMenu(QString name, ThemeType themeType)
void MainWindow::addThemesFromSubdirectories(QDir dir, ThemeType themeType)
{
foreach (QFileInfo fileInfo, dir.entryInfoList()) {
if (fileInfo.isDir() )
if (fileInfo.isDir() && fileInfo.fileName()[0] != '.')
{
QString absoluteFilePath = dir.absoluteFilePath(fileInfo.fileName() + "/theme.ini");
QFile file(absoluteFilePath);
Expand All @@ -222,7 +256,6 @@ void MainWindow::addThemesFromSubdirectories(QDir dir, ThemeType themeType)
addThemeToMenu(fileInfo.fileName(), themeType);
}
}

}
void MainWindow::initThemes()
{
Expand Down Expand Up @@ -255,6 +288,7 @@ void MainWindow::initThemes()
addThemesFromSubdirectories(userThemeDir, ThemeType::THEME_USER);
}


}

void MainWindow::changeFont(const QString& fontName, int fontSize)
Expand Down Expand Up @@ -1519,19 +1553,15 @@ void MainWindow::on_actionReset_Rotation_triggered()
ui->mapView->resetRotation();
}

void MainWindow::on_action_Always_on_Top_triggered(bool checked)
void MainWindow::on_action_Always_on_Top_triggered()
{
Qt::WindowFlags flags = this->windowFlags();
if (checked)
{
this->setWindowFlags(flags | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint);
this->show();
}
else
{
this->setWindowFlags(flags ^ (Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint));
this->show();
}
alwaysOnTop = !alwaysOnTop;
Qt::WindowFlags flags = windowFlags();
flags ^= Qt::WindowStaysOnTopHint;
setWindowFlags(flags);

ui->action_Always_on_Top->setChecked(alwaysOnTop);
show();
}

void MainWindow::on_listView_doubleClicked(const QModelIndex &index)
Expand All @@ -1552,19 +1582,82 @@ void MainWindow::gotOpacity(int delta)
setWindowOpacity(factor);
}

void MainWindow::on_actionToggle_Frameless_triggered()
void MainWindow::on_action_Overlay_Mode_triggered()
{
overlayMode = !overlayMode;

ui->mapView->disableBackgroundDraw(overlayMode);
ui->action_Overlay_Mode->setChecked(overlayMode);

Qt::WindowFlags flags = this->windowFlags();
if(overlayMode)
{
ui->menuBar->setAutoFillBackground(false);
ui->centralWidget->setAutoFillBackground(false);
ui->statusBar->setAutoFillBackground(false);

if(!frameless)
{
// Enable frameless mode too.
flags |= Qt::FramelessWindowHint;
ui->menuBar->hide();
}

alwaysOnTop = true;
setWindowFlags(flags | Qt::WindowStaysOnTopHint);

}
else
{
// Disable Translucency
ui->menuBar->setAutoFillBackground(true);
ui->centralWidget->setAutoFillBackground(true);
ui->statusBar->setAutoFillBackground(true);

Qt::WindowFlags newFlags = flags;
if(alwaysOnTop == false && (flags & Qt::WindowStaysOnTopHint))
{
// Disable Always on Top
newFlags = newFlags ^ Qt::WindowStaysOnTopHint;
}

if(frameless == false && (flags & Qt::FramelessWindowHint))
{
newFlags = newFlags ^ Qt::FramelessWindowHint;
ui->menuBar->show();
}

if (flags != newFlags)
setWindowFlags(newFlags);

}

this->show();
this->repaint();
}

void MainWindow::on_action_Frameless_Window_triggered()
{
Qt::WindowFlags flags = this->windowFlags();

frameless = !frameless;
if(frameless)
{
this->setWindowFlags(flags | Qt::Widget | Qt::FramelessWindowHint);
this->show();
this->setWindowFlags(flags | Qt::FramelessWindowHint);
ui->menuBar->hide();
}
else
{
this->setWindowFlags(flags ^ (Qt::Widget | Qt::FramelessWindowHint));
this->show();
this->setWindowFlags(flags ^ Qt::FramelessWindowHint);
ui->menuBar->show();
}
this->show();
}

void MainWindow::on_action_Menu_Toggle_triggered()
{
if(ui->menuBar->isVisible())
ui->menuBar->hide();
else
ui->menuBar->show();
}
16 changes: 14 additions & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ private slots:
void on_actionFindMessages_triggered();
void on_actionCustomize_triggered();
void on_actionReset_Rotation_triggered();
void on_action_Always_on_Top_triggered(bool checked);
void on_action_Always_on_Top_triggered();
void on_listView_doubleClicked(const QModelIndex &index);
void on_actionToggle_Frameless_triggered();
void on_action_Overlay_Mode_triggered();
void on_action_Frameless_Window_triggered();
void on_action_Menu_Toggle_triggered();

private:
void initParsing();
Expand Down Expand Up @@ -132,8 +134,18 @@ private slots:
void switchToRegion(const QString& currentRegion);
void updateRegionMenu(const QString& currentRegion);

QString withoutShortcutAmpersands(const QString input);

Ui::MainWindow* ui;
bool frameless = false;
bool alwaysOnTop = false;
bool overlayMode = false;
QShortcut* alwaysOnTopShortcut = NULL;
QShortcut* framelessShortcut = NULL;
QShortcut* menuShortcut = NULL;
QShortcut* overlayShortcut = NULL;
// QStyle* savedStyle;

ChatModel* chatModel;
ChatItemDelegate m_cid;
QShortcut* findShortcut;
Expand Down
Loading

0 comments on commit 4eaf647

Please sign in to comment.