comparison mainwindow.cpp @ 61:bf57a16315bd

* Some experimental cutbacks to interface
author Chris Cannam
date Wed, 17 Nov 2010 11:48:58 +0000
parents f583e44d9d31
children 68aebc316898
comparison
equal deleted inserted replaced
60:73073f34a5ee 61:bf57a16315bd
24 #include <QStatusBar> 24 #include <QStatusBar>
25 #include <QMessageBox> 25 #include <QMessageBox>
26 #include <QMenuBar> 26 #include <QMenuBar>
27 #include <QApplication> 27 #include <QApplication>
28 #include <QToolBar> 28 #include <QToolBar>
29 #include <QToolButton>
29 #include <QSettings> 30 #include <QSettings>
30 31
31 #include "mainwindow.h" 32 #include "mainwindow.h"
32 #include "settingsdialog.h" 33 #include "settingsdialog.h"
33 #include "colourset.h" 34 #include "colourset.h"
45 timerId = startTimer(200); 46 timerId = startTimer(200);
46 runner = new HgRunner(this); 47 runner = new HgRunner(this);
47 runningAction = ACT_NONE; 48 runningAction = ACT_NONE;
48 statusBar()->addPermanentWidget(runner); 49 statusBar()->addPermanentWidget(runner);
49 50
50 wndTitle.sprintf("%s %s", APPNAME, APPVERSION); 51 setWindowTitle(tr("EasyMercurial"));
51 setWindowTitle(wndTitle);
52 52
53 remoteRepoPath = ""; 53 remoteRepoPath = "";
54 workFolderPath = ""; 54 workFolderPath = "";
55 55
56 readSettings(); 56 readSettings();
1281 exitAct->setShortcuts(QKeySequence::Quit); 1281 exitAct->setShortcuts(QKeySequence::Quit);
1282 exitAct->setStatusTip(tr("Exit application")); 1282 exitAct->setStatusTip(tr("Exit application"));
1283 exitAct -> setIconVisibleInMenu(true); 1283 exitAct -> setIconVisibleInMenu(true);
1284 1284
1285 //Repository actions 1285 //Repository actions
1286 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("View incoming changesets"), this); 1286 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh"), this);
1287 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
1288
1289 hgIncomingAct = new QAction(QIcon(":/images/incoming.png"), tr("Preview"), this);
1287 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)")); 1290 hgIncomingAct -> setStatusTip(tr("View info of changesets incoming to us from remote repository (on pull operation)"));
1288 1291
1289 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull from remote"), this); 1292 hgPullAct = new QAction(QIcon(":/images/pull.png"), tr("Pull"), this);
1290 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository")); 1293 hgPullAct -> setStatusTip(tr("Pull changesets from remote repository to local repository"));
1291 1294
1292 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push to remote"), this); 1295 hgPushAct = new QAction(QIcon(":/images/push.png"), tr("Push"), this);
1293 hgPushAct->setStatusTip(tr("Push local changesets to remote repository")); 1296 hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
1294 1297
1295 //Workfolder actions 1298 //Workfolder actions
1296 hgStatAct = new QAction(QIcon(":/images/status.png"), tr("Refresh status"), this); 1299 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("Diff"), this);
1297 hgStatAct->setStatusTip(tr("Refresh (info of) status of workfolder files"));
1298
1299 hgFileDiffAct = new QAction(QIcon(":/images/diff.png"), tr("View filediff"), this);
1300 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file")); 1300 hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
1301 1301
1302 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this); 1302 hgFolderDiffAct = new QAction(QIcon(":/images/folderdiff.png"), tr("View folderdiff"), this);
1303 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files")); 1303 hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
1304 1304
1305 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this); 1305 hgChgSetDiffAct = new QAction(QIcon(":/images/chgsetdiff.png"), tr("View changesetdiff"), this);
1306 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets")); 1306 hgChgSetDiffAct->setStatusTip(tr("Change set diff: View differences between all files of 2 repository changesets"));
1307 1307
1308 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Undo changes"), this); 1308 hgRevertAct = new QAction(QIcon(":/images/undo.png"), tr("Revert"), this);
1309 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)")); 1309 hgRevertAct->setStatusTip(tr("Undo selected working folder file changes (return to local repository version)"));
1310 1310
1311 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add files"), this); 1311 hgAddAct = new QAction(QIcon(":/images/add.png"), tr("Add"), this);
1312 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)")); 1312 hgAddAct -> setStatusTip(tr("Add working folder file(s) (selected or all yet untracked) to local repository (on next commit)"));
1313 1313
1314 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove file"), this); 1314 hgRemoveAct = new QAction(QIcon(":/images/remove.png"), tr("Remove"), this);
1315 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)")); 1315 hgRemoveAct -> setStatusTip(tr("Remove selected working folder file from local repository (on next commit)"));
1316 1316
1317 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update working folder"), this); 1317 hgUpdateAct = new QAction(QIcon(":/images/update.png"), tr("Update"), this);
1318 hgUpdateAct->setStatusTip(tr("Update working folder from local repository")); 1318 hgUpdateAct->setStatusTip(tr("Update working folder from local repository"));
1319 1319
1320 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit / Save change(s)"), this); 1320 hgCommitAct = new QAction(QIcon(":/images/commit.png"), tr("Commit"), this);
1321 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository")); 1321 hgCommitAct->setStatusTip(tr("Save selected file(s) or all changed files in working folder (and all subfolders) to local repository"));
1322 1322
1323 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this); 1323 hgMergeAct = new QAction(QIcon(":/images/merge.png"), tr("Merge"), this);
1324 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder")); 1324 hgMergeAct->setStatusTip(tr("Merge two local repository changesets to working folder"));
1325 1325
1391 fileToolBar = addToolBar(tr("File")); 1391 fileToolBar = addToolBar(tr("File"));
1392 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); 1392 fileToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
1393 fileToolBar -> addAction(settingsAct); 1393 fileToolBar -> addAction(settingsAct);
1394 fileToolBar -> addAction(hgStatAct); 1394 fileToolBar -> addAction(hgStatAct);
1395 fileToolBar -> addSeparator(); 1395 fileToolBar -> addSeparator();
1396 fileToolBar -> addAction(hgChgSetDiffAct); 1396 // fileToolBar -> addAction(hgChgSetDiffAct);
1397 fileToolBar -> setMovable(false); 1397 fileToolBar -> setMovable(false);
1398 1398
1399 repoToolBar = addToolBar(tr(REPOMENU_TITLE)); 1399 repoToolBar = addToolBar(tr(REPOMENU_TITLE));
1400 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); 1400 repoToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
1401 repoToolBar->addAction(hgIncomingAct); 1401 repoToolBar->addAction(hgIncomingAct);
1404 repoToolBar -> setMovable(false); 1404 repoToolBar -> setMovable(false);
1405 1405
1406 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE)); 1406 workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
1407 addToolBar(Qt::LeftToolBarArea, workFolderToolBar); 1407 addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
1408 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE)); 1408 workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
1409 workFolderToolBar->addSeparator(); 1409 // workFolderToolBar->addSeparator();
1410 workFolderToolBar->addAction(hgFileDiffAct); 1410 workFolderToolBar->addAction(hgFileDiffAct);
1411 workFolderToolBar->addAction(hgFolderDiffAct); 1411 // workFolderToolBar->addAction(hgFolderDiffAct);
1412 workFolderToolBar->addSeparator(); 1412 workFolderToolBar->addSeparator();
1413 workFolderToolBar->addAction(hgRevertAct); 1413 workFolderToolBar->addAction(hgRevertAct);
1414 workFolderToolBar->addAction(hgUpdateAct); 1414 workFolderToolBar->addAction(hgUpdateAct);
1415 workFolderToolBar->addAction(hgCommitAct); 1415 workFolderToolBar->addAction(hgCommitAct);
1416 workFolderToolBar->addAction(hgMergeAct); 1416 workFolderToolBar->addAction(hgMergeAct);
1417 workFolderToolBar->addSeparator(); 1417 workFolderToolBar->addSeparator();
1418 workFolderToolBar->addAction(hgAddAct); 1418 workFolderToolBar->addAction(hgAddAct);
1419 workFolderToolBar->addAction(hgRemoveAct); 1419 workFolderToolBar->addAction(hgRemoveAct);
1420 workFolderToolBar -> setMovable(false); 1420 workFolderToolBar -> setMovable(false);
1421
1422 foreach (QToolButton *tb, findChildren<QToolButton *>()) {
1423 tb->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
1424 }
1421 } 1425 }
1422 1426
1423 1427
1424 void MainWindow::createStatusBar() 1428 void MainWindow::createStatusBar()
1425 { 1429 {
1428 1432
1429 void MainWindow::readSettings() 1433 void MainWindow::readSettings()
1430 { 1434 {
1431 QDir workFolder; 1435 QDir workFolder;
1432 1436
1433 QSettings settings("hgexplorer", "hgexplorer"); 1437 QSettings settings;
1434 1438
1435 remoteRepoPath = settings.value("remoterepopath", "").toString(); 1439 remoteRepoPath = settings.value("remoterepopath", "").toString();
1436 workFolderPath = settings.value("workfolderpath", "").toString(); 1440 workFolderPath = settings.value("workfolderpath", "").toString();
1437 if (!workFolder.exists(workFolderPath)) 1441 if (!workFolder.exists(workFolderPath))
1438 { 1442 {
1468 } 1472 }
1469 1473
1470 1474
1471 void MainWindow::writeSettings() 1475 void MainWindow::writeSettings()
1472 { 1476 {
1473 QSettings settings("hgexplorer", "hgexplorer"); 1477 QSettings settings;
1474 settings.setValue("pos", pos()); 1478 settings.setValue("pos", pos());
1475 settings.setValue("size", size()); 1479 settings.setValue("size", size());
1476 settings.setValue("remoterepopath", remoteRepoPath); 1480 settings.setValue("remoterepopath", remoteRepoPath);
1477 settings.setValue("workfolderpath", workFolderPath); 1481 settings.setValue("workfolderpath", workFolderPath);
1478 1482