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

Fullscreen startup option flag #1175

Open
wants to merge 1 commit into
base: master
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
17 changes: 11 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ QTerminalApp * QTerminalApp::m_instance = nullptr;
exit(code);
}

void parse_args(int argc, char* argv[], QString& workdir, QStringList & shell_command, out bool& dropMode)
void parse_args(int argc, char* argv[], QString& workdir, QStringList & shell_command, out bool& dropMode, out bool& fullScreen)
{
int next_option = 0;
dropMode = false;
fullScreen = false;
do{
next_option = getopt_long(argc, argv, short_options, long_options, nullptr);
switch(next_option)
Expand All @@ -107,6 +108,9 @@ void parse_args(int argc, char* argv[], QString& workdir, QStringList & shell_co
case 'p':
Properties::Instance(QString::fromLocal8Bit(optarg));
break;
case 'f':
fullScreen = true;
break;
case '?':
print_usage_and_exit(1);
break;
Expand Down Expand Up @@ -146,7 +150,8 @@ int main(int argc, char *argv[])
QString workdir;
QStringList shell_command;
bool dropMode = false;
parse_args(argc, argv, workdir, shell_command, dropMode);
bool fullScreen = false;
parse_args(argc, argv, workdir, shell_command, dropMode, fullScreen);

#ifdef HAVE_QDBUS
app->registerOnDbus(dropMode);
Expand Down Expand Up @@ -214,7 +219,7 @@ int main(int argc, char *argv[])
}

TerminalConfig initConfig = TerminalConfig(workdir, shell_command);
app->newWindow(dropMode, initConfig);
app->newWindow(dropMode, fullScreen, initConfig);

int ret = app->exec();
delete Properties::Instance();
Expand All @@ -223,18 +228,18 @@ int main(int argc, char *argv[])
return ret;
}

MainWindow *QTerminalApp::newWindow(bool dropMode, TerminalConfig &cfg)
MainWindow *QTerminalApp::newWindow(bool dropMode, bool fullScreen, TerminalConfig &cfg)
{
MainWindow *window = nullptr;
if (dropMode)
{
window = new MainWindow(cfg, dropMode);
window = new MainWindow(cfg, dropMode, fullScreen);
if (Properties::Instance()->dropShowOnStart)
window->show();
}
else
{
window = new MainWindow(cfg, dropMode);
window = new MainWindow(cfg, dropMode, fullScreen);
if (Properties::Instance()->windowMaximized)
window->setWindowState(Qt::WindowMaximized);
window->show();
Expand Down
12 changes: 7 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Q_DECLARE_METATYPE(checkfn)

MainWindow::MainWindow(TerminalConfig &cfg,
bool dropMode,
bool fullScreen,
QWidget * parent,
Qt::WindowFlags f)
: QMainWindow(parent,f),
Expand All @@ -69,7 +70,8 @@ MainWindow::MainWindow(TerminalConfig &cfg,
presetsMenu(nullptr),
m_config(cfg),
m_dropLockButton(nullptr),
m_dropMode(dropMode)
m_dropMode(dropMode),
m_fullScreen(fullScreen)
{
#ifdef HAVE_QDBUS
registerAdapter<WindowAdaptor, MainWindow>(this);
Expand Down Expand Up @@ -439,10 +441,10 @@ void MainWindow::setup_ViewMenu_Actions()

QAction *toggleFullscreen = new QAction(tr("Fullscreen"), settingOwner);
toggleFullscreen->setCheckable(true);
toggleFullscreen->setChecked(false);
toggleFullscreen->setChecked(m_fullScreen);
showFullscreen(m_fullScreen);
setup_Action(FULLSCREEN, toggleFullscreen,
FULLSCREEN_SHORTCUT, this, SLOT(showFullscreen(bool)), menu_Window);

setup_Action(TOGGLE_BOOKMARKS, new QAction(tr("Toggle Bookmarks"), settingOwner),
TOGGLE_BOOKMARKS_SHORTCUT, this, SLOT(toggleBookmarks()), menu_Window);

Expand Down Expand Up @@ -888,8 +890,8 @@ void MainWindow::newTerminalWindow()
QProcess::startDetached(QStringLiteral("qterminal"), args);
}
else
{
MainWindow *w = new MainWindow(cfg, false);
{ // fullScreen arg false so additional windows are not started in fullscreen
MainWindow *w = new MainWindow(cfg, false, false);
w->show();
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class MainWindow : public QMainWindow, private Ui::mainWindow, public DBusAddres
public:
MainWindow(TerminalConfig& cfg,
bool dropMode,
bool fullScreen,
QWidget * parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~MainWindow() override;

Expand Down Expand Up @@ -86,6 +87,7 @@ class MainWindow : public QMainWindow, private Ui::mainWindow, public DBusAddres
void enableDropMode();
QToolButton *m_dropLockButton;
bool m_dropMode;
bool m_fullScreen;
QxtGlobalShortcut m_dropShortcut;
void realign();
void setDropShortcut(const QKeySequence& dropShortCut);
Expand Down
2 changes: 1 addition & 1 deletion src/qterminalapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QTerminalApp : public QApplication
Q_OBJECT

public:
MainWindow *newWindow(bool dropMode, TerminalConfig &cfg);
MainWindow *newWindow(bool dropMode, bool fullScreen, TerminalConfig &cfg);
QList<MainWindow*> getWindowList();
void addWindow(MainWindow *window);
void removeWindow(MainWindow *window);
Expand Down